-
Notifications
You must be signed in to change notification settings - Fork 390
Buoyancy example on static multi-level MAC grid #4423
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
Draft
drb-tai
wants to merge
6
commits into
AMReX-Codes:development
Choose a base branch
from
drb-tai:buoyancy-example
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: Create a place to put some new code. The example will implement a simple velocity update on a multi-level MAC grid, without subcycling-in-time. It was created to explore what is necessary to convert a single-level code to multi-level, and it is being shared in an attempt to document what was learned. main.cpp * main() - Boilerplate for Initialize()/Finalize(). * MyMain() - Stub implementation. Placeholder for the example/test. CMakeLists.txt GNUmakefile Make.package * Boilerplate for adding the example/test. The initial implementation will only support 3D.
Summary: Example/test implementing a simple buoyancy calculation on a MAC grid on a multi-level mesh without subcycling-in-time. The intention in developing this code was to identify the requirements for converting a single-level code to multi-level, starting with a simple calculation. This calculation requires a) an "interpolation from coarse" step to initialize the coarse/fine ghosts on one of the input data sets (temperature), and b) an "average down" step to overwrite the covered coarse results. Tests/Amr/Buoyancy/main.cpp * Add a big comment block documenting the system that is being implemented. - Note the buoyancy calculation itself is not particularly interesting. Rather, it is a simple system which should allow for exactly reproducing an analytic solution if the composite mesh is handled correctly, and which will show a variance if ghosts are not handled correctly. * MyMain() - Allocate the multi-level MultiFabs, initialize temperature and velocity data, call the buoyancy calculation subroutine, and test that the results match the analytic expectation. Tests/Amr/Buoyancy/helpers.H Tests/Amr/Buoyancy/helpers.cpp * DefineGeometry() - Declare a 4x1x1 domain, refined twice. * DefineBoxArrays() - Declare a single box/FAB at each level, covering only half of the next-coarser level. * DefineDMs() - Default DistributionMappings should put all the FABs on the rank-zero process. * DefineFABs() - Declare a cell-centered temperature MultiFab. - Declare a set of face-centered velocity MultiFabs (i.e. a MAC grid). * CalculateBuoyancy() - Calculate the buoyant acceleration and update the velocities for the current time step. - Perform an "average down" to overwrite any covered coarse results with the solution from the fine grid. For this test case, the results should be identical in the bulk, and should vary only at the domain boundary. * CalculateVelocities() - Function meant to mock a non-subcycling-in-time velocity update calculation at the current time step. This mock just sets the velocity at all levels to {0.0,0.0,0.0}. * CalculateTemperatures() - Function meant to mock a non-subcycling-in-time temperature update calculation at the current time step. This mock sets T(x,y,z) = 300.0+100.0*x on all the valid cells, and then updates all temperature ghosts. * SetTemperatureProfile() - Helper to set the temperature field. * UpdateTemperatureGhosts() - Helper to update the internal, external, and coarse/fine temperature ghosts. * FillCoarseFineGhosts() - Helper to update the coarse/fine temperature ghosts. Tests/Amr/Buoyancy/CMakeLists.txt Tests/Amr/Buoyancy/Make.package * Add the new source file.
Tests/Amr/Buoyancy/Amr/Buoyancy/main.cpp * MyMain() - Skip the debug output printing. Tests/Amr/Buoyancy/Amr/Buoyancy/helpers.H Tests/Amr/Buoyancy/Amr/Buoyancy/helpers.cpp * Delete the debug output functions. * Remove ifdef'd out GTest assertion.
Tests/Amr/Buoyancy/Amr/Buoyancy/helpers.H Tests/Amr/Buoyancy/Amr/Buoyancy/helpers.cpp * Attempt to match project formatting standards.
Tests/Amr/Buoyancy/README.md Tests/Amr/Buoyancy/main.cpp * Move the documentation for this example from main.cpp into a new README.md, converting some formatting.
Sorry. I am not sure where this belongs to. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add minimal working example of a buoyancy calculation on a MAC grid on a static multi-level mesh without subcycling-in-time. Detailed description in README.md.
Draft PR to get feedback on the following questions:
Additional background
I built up this example while attempting to learn how to convert an existing single-level code to multi-level. It was intended to represent a single stage in a CFD code, and to expose and solve the unique requirements for a (static, non-subcycling-in-time) multi-level solve compared to a (uniform, distributed parallel) single-level solve. For this buoyancy algorithm, those unique requirements seem to be a) initialization of coarse/fine ghosts for temperature inputs, and b) an "average down" for the velocity outputs. I plan to do this again for a more complicated case (heat equation? Suggestions welcome) to tease out more of these requirements, and may be able to contribute that if it's useful.
Checklist
The proposed changes: