-
Notifications
You must be signed in to change notification settings - Fork 202
[WIP] Magnetostatic solver refactor and bug fixes #5175
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
base: development
Are you sure you want to change the base?
[WIP] Magnetostatic solver refactor and bug fixes #5175
Conversation
Signed-off-by: roelof-groenewald <[email protected]>
Signed-off-by: roelof-groenewald <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: roelof-groenewald <[email protected]>
Signed-off-by: roelof-groenewald <[email protected]>
Signed-off-by: roelof-groenewald <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good @roelof-groenewald thank you for shaking this out.
if (field_boundary_hi[0] == FieldBoundaryType::PEC) { | ||
if (adim == 0) { | ||
hibc[adim][0] = LinOpBCType::Neumann; | ||
dirichlet_flag[adim][1] = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be changed to use an STL map data structure as in the ProjectionDivCleaner. Seesm like a good time to do this refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! I'll add that to my tasks for the upcoming hackathon (also changing it for the current ES solver).
@@ -249,9 +269,9 @@ void | |||
WarpX::setVectorPotentialBC ( amrex::Vector<amrex::Array<std::unique_ptr<amrex::MultiFab>,3>>& A ) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have some sort of warning about the inaccuracy of the field near an EB surface? This is now effetively going to be a staircase EB instead of cut cell correct?
@@ -326,7 +326,7 @@ WarpX::ProjectionCleanDivB() { | |||
} else if ( WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::Yee | |||
|| WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC | |||
|| ( (WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame | |||
|| WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameElectroMagnetostatic) | |||
|| WarpX::electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrameSemiImplicit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the explicit version of the solver going away completely? I.e. the LabFrameElectroMagnetostatic Algo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the magnetostatic solver is just changed to function as an add-on to an electrostatic solver. So instead of defining it as it's own solver (explicit ES + MS) the type of ES solver is set in the input and the extra flag do_magnetostatic
sets whether the MS solve will be added on to the ES solve.
#5446) …ch is currently hard coded, and adding assert to force EB being enabled in order to avoid a seg fault in AMReX when computing the gradient solution. This PR partially addresses #5444. This PR adds semi-coarsening in 3D and then adds an assert to keep the magnetostatic solver from being run without an EB. This is required since in AMReX MLMG->getGradSolution will segfault when not using an EB. It should also be noted that #5175 will use a different scheme around the embedded boundaries to compute gradients, and will likely mitigate these issues. A work around in RZ to use the outer edge is to enable the embedded boundary and set the boundary radius larger than the outer grid radius. This works like it would without an embedded boundary and can be used until either the refactor or the bugfix in AMReX for getGradSolution. --------- Signed-off-by: S. Eric Clark <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This PR introduces a major refactor of the magnetostatic solver primarily with three goals:
Example of non-zero B-field divergence introduced with the current magnetostatic solver implementation.
Same simulation as above but with the fixes from this PR included (note the colorbar range)
This PR builds on and requires first merging: