-
Notifications
You must be signed in to change notification settings - Fork 256
GMRES for Poisson Equation #6367
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?
Changes from all commits
00816aa
b8656bb
18657bb
27aaf7a
c73d77a
5b70ef4
5791568
5c3b0f7
7ece418
b421fb8
73c46a7
b4ec1dc
f2c5058
65c08af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,8 @@ | |
| #ifdef AMREX_USE_EB | ||
| # include <AMReX_EBFabFactory.H> | ||
| #endif | ||
| #include <AMReX_GMRES_MLMG.H> | ||
| #include "WarpX.H" | ||
|
|
||
| #include <algorithm> | ||
| #include <array> | ||
|
|
@@ -416,8 +418,15 @@ computePhi ( | |
| rho[lev]->OverrideSync(geom[lev].periodicity()); | ||
|
|
||
| // Solve Poisson equation at lev | ||
| mlmg.solve( {phi[lev]}, {rho[lev]}, | ||
| relative_tolerance, absolute_tolerance ); | ||
| if (WarpX::poisson_solver_id == PoissonSolverAlgo::Multigrid) { | ||
| mlmg.solve( {phi[lev]}, {rho[lev]}, | ||
| relative_tolerance, absolute_tolerance ); | ||
| } else { | ||
| amrex::GMRESMLMG gmsolve(mlmg); | ||
| gmsolve.setMaxIters(max_iters); | ||
| gmsolve.solve( *phi[lev], *rho[lev], relative_tolerance, absolute_tolerance ); | ||
| linop->postSolve({phi[lev]}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the need for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MLMG calls postSolve within, which sets the value of phi in covered cells to the Dirichlet value. GMRES initially left phi in covered cells at zero; I added this call so the plotfiles would match up in the covered cells. |
||
| } | ||
|
|
||
| const amrex::IntVect& refratio = rel_ref_ratio.value()[lev]; | ||
| const int ncomp = linop->getNComp(); | ||
|
|
@@ -437,12 +446,47 @@ computePhi ( | |
| ng); | ||
| } | ||
|
|
||
| // Run additional operations, such as calculation of the E field for embedded boundaries | ||
| if constexpr (!std::is_same_v<T_PostPhiCalculationFunctor, std::nullopt_t>) { | ||
| if (post_phi_calculation.has_value()) { | ||
| post_phi_calculation.value()(mlmg, lev); | ||
| if (WarpX::poisson_solver_id == PoissonSolverAlgo::Multigrid) { | ||
| // Run additional operations, such as calculation of the E field for embedded boundaries | ||
| if constexpr (!std::is_same_v<T_PostPhiCalculationFunctor, std::nullopt_t>) { | ||
| if (post_phi_calculation.has_value()) { | ||
| post_phi_calculation.value()(mlmg, lev); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (WarpX::poisson_solver_id == PoissonSolverAlgo::GMRES && eb_enabled) { | ||
|
|
||
| // create an alieas to the WarpX Efield | ||
| auto & warpx = WarpX::GetInstance(); | ||
|
|
||
| amrex::Vector< amrex::Array<amrex::MultiFab *, AMREX_SPACEDIM> > e_field; | ||
| e_field.push_back( | ||
| #if defined(WARPX_DIM_1D_Z) | ||
| amrex::Array<amrex::MultiFab*, 1>{ | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{2}, lev) | ||
| } | ||
| #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) | ||
| amrex::Array<amrex::MultiFab*, 2>{ | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{0}, lev), | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{2}, lev) | ||
| } | ||
| #elif defined(WARPX_DIM_3D) | ||
| amrex::Array<amrex::MultiFab *, 3>{ | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{0}, lev), | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{1}, lev), | ||
| warpx.m_fields.get(warpx::fields::FieldType::Efield_fp, Direction{2}, lev) | ||
| } | ||
| #endif | ||
|
Comment on lines
+465
to
+480
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dpgrote Is electrostatic mode in WarpX not setup for RCYLINDER and RSPHERE geometries?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JustinRayAngus Those geometries are not supported in electrostatic. Also, this block of code is for EB which is also not supported. |
||
| ); | ||
|
|
||
| // compute E = grad(phi) | ||
| linop->compGrad(lev, e_field[lev], *phi[lev], amrex::MLLinOp::Location::CellCenter); | ||
| for(int dir=0; dir<AMREX_SPACEDIM; ++dir) { | ||
| e_field[lev][dir]->mult(-1.); | ||
| } | ||
| } | ||
|
|
||
| rho[lev]->mult(-ablastr::constant::SI::epsilon_0); // Multiply rho by epsilon again | ||
|
|
||
| } // loop over lev(els) | ||
|
|
||
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.
@RemiLehe commented: can we also handle
max_itershere? Otherwise it is silently ignored if user-set