Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constant derivative boundary condition and expose GenericBC #884

Merged
merged 143 commits into from
Jun 20, 2023

Conversation

lroberts36
Copy link
Collaborator

@lroberts36 lroberts36 commented Jun 8, 2023

PR Summary

This PR adds:

  • The option of a constant derivative boundary condition (which I needed when experimenting with evolving the vector potential).
  • The option of a constant value boundary condition (which I also needed at some point)
  • Slightly refactors the internal pieces of GenericBC to use sparse packs and allow for the selection of which variables to apply boundary conditions on
  • Moves GenericBC to a header so that downstream codes can compose the generic boundary conditions for subsets of variables. This should make it easier to create user defined boundary conditions that behave differently for different variables, e.g.
 pman.app_input->boundary_conditions[parthenon::BoundaryFace::inner_x1] = 
    [](std::shared_ptr<MeshBlockData<Real>> &rc, bool coarse) { 
      using namespace parthenon; 
      using namespace parthenon::BoundaryFunction; 
      GenericBC<X1DIR, BCSide::Inner, BCType::Outflow, variable_names::any>(rc, coarse); 
      GenericBC<X1DIR, BCSide::Inner, BCType::ConstantDeriv, myvar_t>(rc, coarse); 
      GenericBC<X1DIR, BCSide::Inner, BCType::Fixed, myvar2_t>(rc, coarse, 1.0); 
    };
  • Additionally, it fixes a small bug in sparse packs, ensures that the vector components of fields in a sparse pack are correctly set, exposes MeshData level ApplyBoundaryConditions tasks, and removes some unused code.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files

@lroberts36 lroberts36 added the enhancement New feature or request label Jun 8, 2023
Copy link
Collaborator

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

This is a nice improvement. Thanks for adding it. Assuming everything works, I'm in favor. 👍

@lroberts36
Copy link
Collaborator Author

This at least partially closes #376

@lroberts36
Copy link
Collaborator Author

I used this in a downstream code that does CT using a vector potential (which requires a constant derivative boundary condition to give outflow boundary conditions for B, while the other conserved variables have an outflow boundary condtion) and everything seems to work well.

Copy link
Collaborator

@brryan brryan left a comment

Choose a reason for hiding this comment

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

LGTM, this is nice to have. I think the if constexpr change would be worthwhile performance-wise if you agree and don't mind doing that before merge.

I thought about whether we should have a bunch more functions like ConstantInnerX1 etc. but I'm not sure that's a good idea. As in your use case different variables often have different BCs. Maybe the right way to do this would be to tag variables with their boundary conditions in their metadata, and use that to construct a BC function at runtime? Not a task for this PR of course.

src/bvals/boundary_conditions_generic.hpp Show resolved Hide resolved
@Yurlungur
Copy link
Collaborator

As in your use case different variables often have different BCs. Maybe the right way to do this would be to tag variables with their boundary conditions in their metadata, and use that to construct a BC function at runtime? Not a task for this PR of course.

I have a plan for this... metadata is one option, per-package BCs would be another. I've been meaning to refactor the code to add this forever, but I keep putting it off...

Copy link
Collaborator

@pdmullen pdmullen left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@lroberts36 lroberts36 changed the base branch from lroberts36/face-boundary-communication to develop June 9, 2023 17:15
@lroberts36 lroberts36 enabled auto-merge (squash) June 9, 2023 17:18
@lroberts36 lroberts36 disabled auto-merge June 9, 2023 17:21
@lroberts36 lroberts36 enabled auto-merge (squash) June 20, 2023 16:22
@lroberts36 lroberts36 disabled auto-merge June 20, 2023 21:04
@lroberts36 lroberts36 enabled auto-merge (squash) June 20, 2023 21:04
@lroberts36 lroberts36 merged commit 40dd596 into develop Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants