As it was mentioned in the other reply, the full solution to your question requires a Scriptrunner for Jira add-on. It is not free, but it is powerful and very useful extension which may be worth having. The query would be something like this:
Project = DEVP AND status = "In Progress" AND issueFunction in linkedIssuesOf("status = Done", "relates to")
Alternatively, there is not fully automated but free solution:
Starting with Jira Server 8, Jira now has the native functionality for searching by link types. It may be helpful to find all issues that are "In Progress" and that have links to other issues of the needed type (for example "relates to"). The query would be:
Project = DEVP AND issueLinkType in ("relates to") AND status = "In Progress"
You can also add "Linked issues" field that would add "Links" column to your issue navigator. It would display the linked issues. Now, if it wasn't changed in your Jira configuration, the issues that are in "Done" status should be treated by Jira as resolved (and should be indicated as stroked through). So after you run the query and start Bulk Change, you'll only have to manually pick all the issues that have stroked through issues in links column.