Skip to content

Add method to execute selected postprocessors - #7226

Draft
hangqjan wants to merge 1 commit into
geodynamics:mainfrom
hangqjan:postprocess-execute-selected
Draft

Add method to execute selected postprocessors#7226
hangqjan wants to merge 1 commit into
geodynamics:mainfrom
hangqjan:postprocess-execute-selected

Conversation

@hangqjan

@hangqjan hangqjan commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new method to Postprocess::Manager for executing a selected set of postprocessors.

The change is extracted from #7120 to keep that PR focused and to make this functionality available independently. It is needed by the adjoint framework, where specific postprocessors must be executed on demand to provide the required forward-model quantities.

Before your first pull request:

For all pull requests:

  • I have followed the instructions for indenting my code.
  • I followed the AI Policy:
    • Significant parts of this PR were written by AI (please add a sentence below).
      I have reviewed, understood, and verified the codes generated by AI.
    • AI has not been used in significant ways.

If yes, please describe your usage of AI models in the creation of this pull request

For new features/models or changes of existing features:

  • I have tested my new feature locally to ensure it is correct.
  • I have created a testcase for the new feature/benchmark in the tests/ directory.
  • I have added a changelog entry in the doc/modules/changes directory that will inform other users of my change.

@bangerth bangerth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against this PR, but can you explain where this is useful? Running postprocessors is a tricky business because it also affects the statistics table, and running only some means filling a row in the table only partially. I'm pretty sure you have a good reason, but I'd like to talk about the purpose of this function before we merge :-)

Comment thread source/postprocess/interface.cc Outdated
Comment on lines +134 to +145
auto plugin = this->plugin_objects.begin();
for (unsigned int i = 0;
i < this->plugin_names.size();
++i, ++plugin)
{
if (postprocessors_to_execute.find(this->plugin_names[i])
== postprocessors_to_execute.end())
continue;

for (const std::string &dependency : (*plugin)->required_other_postprocessors())
if (postprocessors_to_execute.insert(dependency).second)
dependency_list_changed = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit that I don't understand this loop. plugin_names are the names of the existing plugins. postprocessors_to_execute is initialized with the subset of postprocessors the caller wants called. So your loop looks like this:

  for (plugin : list of all plugins)
  {
      if (plugin is not in postprocessors_to_execute)
        continue;

      // so were are now only looking at postprocessors that are in the caller-provided list
      add all dependencies of plugin to the list
  }

I think it would have been easier to actually turn this loop and the one below around: Go through all of the requested plugin names, find the corresponding plugin (or error out if it doesn't exist), and then ask that plugin for its dependencies which you add to the end of the list.

I don't feel adamant about this. If you like your version better, keep it but at least add some commentary that helps understand what the pieces of the loop are doing along the lines of my pseudocode above.

@gassmoeller

Copy link
Copy Markdown
Member

I will let @hangqjan explain the purpose of the function, but the issue about the statistics file is solved because he keeps a separate statistics table in the adjoint manager, that is specifically used for all postprocessor evaluations during adjoint computations.

@gassmoeller gassmoeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more comments. I agree with Wolfgang that the loops in the function are very hard to understand. It would be great if they could be simplified or at least more extensively documented.

Comment thread source/postprocess/interface.cc Outdated
Comment on lines +172 to +173
// first call the update() function.
(*plugin)->update();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how the discussion in #7235 is going you may be able to remove this. Leave it in for now, it doesnt hurt.

Comment thread source/postprocess/interface.cc Outdated
dependency_list_changed = false;

auto plugin = this->plugin_objects.begin();
for (unsigned int i = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment at the beginning of this loop describing what it does. At the moment I am unsure it does exactly what is intended.

@gassmoeller

Copy link
Copy Markdown
Member

And we will probably need a test for this pull request. Can you start from the test find_postprocess in tests/ and modify it to actually execute a few selected postprocessors?

@hangqjan
hangqjan force-pushed the postprocess-execute-selected branch from 708723a to 1996b1c Compare July 30, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants