Skip to content

Field setBoundary and applyBoundary use options#3365

Closed
bendudson wants to merge 2 commits intonextfrom
boundaries-use-options
Closed

Field setBoundary and applyBoundary use options#3365
bendudson wants to merge 2 commits intonextfrom
boundaries-use-options

Conversation

@bendudson
Copy link
Copy Markdown
Contributor

When a boundary value uses options then these were only parsed on processors with boundaries. This uses a dummy boundary region to force all processors to parse options.

This should fix the problem that means unused options checking needs to be disabled in many transport simulations.

When a boundary value uses options then these were only
parsed on processors with boundaries. This uses a dummy
boundary region to force all processors to parse options.

This should fix the problem that means unused options checking
needs to be disabled in many transport simulations.
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread src/field/field3d.cxx
// This ensures that options are parsed/used on all processors
BoundaryRegionXIn dummy_region{"dummy_region", 0, 1, fieldmesh};
auto* bndry = bfact->create(condition, &dummy_region);
delete bndry;
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.

warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

  delete bndry;
  ^
Additional context

src/field/field3d.cxx:404: variable declared here

  auto* bndry = bfact->create(condition, &dummy_region);
  ^

Comment thread src/field/field_data.cxx
// This ensures that options are parsed/used on all processors
BoundaryRegionXIn dummy_region{"dummy_region", 0, 1, mesh};
auto* bndry = bfact->createFromOptions(name, &dummy_region);
delete bndry;
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.

warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]

  delete bndry;
  ^
Additional context

src/field/field_data.cxx:153: variable declared here

  auto* bndry = bfact->createFromOptions(name, &dummy_region);
  ^

@dschwoerer
Copy link
Copy Markdown
Contributor

Should that be handled by setting the options as conditionally used?

@bendudson
Copy link
Copy Markdown
Contributor Author

Should that be handled by setting the options as conditionally used?

Hi @dschwoerer ! The issue is that some processors have no boundaries so options are not used on those processors.
The unused options then kill the simulation. If the boundary condition depends on expressions then those expression options should be parsed and recursively marked used.

One possibility would be to have the unused options code coordinate across processors. This is nontrivial because some processors could use one set of options and another set of processors use a different set of options.

@dschwoerer
Copy link
Copy Markdown
Contributor

Should that be handled by setting the options as conditionally used?

Hi @dschwoerer ! The issue is that some processors have no boundaries so options are not used on those processors. The unused options then kill the simulation. If the boundary condition depends on expressions then those expression options should be parsed and recursively marked used.

We might want to have the conditionally used part to do that recursive anyway, but that is probably a bit more involved.

One possibility would be to have the unused options code coordinate across processors. This is nontrivial because some processors could use one set of options and another set of processors use a different set of options.

Then the right thing would be to only fail if something is not used anywhere. The current approach feels more like a workaround, then a fix. It would be much nicer to have the state synced to all procs. But that is indeed a bit more complicated, but should be doable. It is only done twice in the simulation, and it should not be a huge amount of data that we have to communicate, even if we just send the whole list that is used on one proc to all other procs.

@bendudson
Copy link
Copy Markdown
Contributor Author

Hi @dschwoerer Yes I agree that the right solution is to coordinate across processors, and only raise an exception if an option is not used on any processor. I'll close this PR and create an issue.

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.

2 participants