-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implicit Field Solve Preconditioner based on Curl-Curl Operator (#5286)
Implemented a preconditioner for the implicit E-field solve using the AMReX curl-curl operator and the MLMG solver. + Introduced a `Preconditioner` base class that defines the action of a preconditioner for the JFNK algorithm. + Implemented the `CurlCurlMLMGPC` that uses the multigrid solution for the curl-curl operator (implemented in `AMReX`) to precondition the E-field JFNK solve. Other changes needed for this: + Partially implemented a mapping between WarpX field boundary types and AMReX's linear operator boundary types. + Added some functionalities to `ImplicitSolver` class that allows preconditioners to access `WarpX` info (like `Geometry`, boundaries, etc). Some premilinary wall times for: ``` Test: inputs_vandb_2d Grid: 160 X 160 dt: 0.125/wpe = 2.22e-18 (dt_CFL = 7.84e-19 s, CFL = 2.83) Time iterations: 20 Solver parameters: newton.max_iterations = 10 newton.relative_tolerance = 1.0e-12 newton.absolute_tolerance = 0.0 gmres.max_iterations = 1000 gmres.relative_tolerance = 1.0e-8 gmres.absolute_tolerance = 0.0 Avg GMRES iterations: ~3 (wPC), ~27 (noPC) ``` with `32^2` particles per cell: ``` Lassen (MPI + CUDA) ------------------- Box GPU Walltime (s) wPC noPC 1 1 2324.7 15004.1 4 1 2306.8 14356.8 4 4 758.9 3647.3 Dane (MPI + OMP) ---------------- Box CPU Threads Walltime (s) wPC noPC 1 1 1 6709.3 43200.0* 1 1 2 3279.1 22296.1 1 1 4 1696.3 11613.2 1 1 8 1085.0 6911.4 1 1 16 724.3 4729.0 4 1 1 5525.9 33288.8 16 1 1 4419.4 28467.8 4 4 1 1324.4 9121.1 16 16 1 524.9 3658.8 * 43200.0 seconds is 12 hours (max job duration on Dane); the simulation was almost done (started the 20th step). ``` with `10^2` particles per cell: ``` Lassen (MPI + CUDA) ------------------- Box GPU Walltime (s) wPC noPC 1 1 365.0 1443.5 4 1 254.1 927.8 4 4 133.1 301.5 Dane (MPI + OMP) ---------------- Box CPU Threads Walltime (s) wPC noPC 1 1 1 440.8 2360.5 1 1 2 241.7 1175.8 1 1 4 129.3 727.0 1 1 8 94.2 407.5 1 1 16 74.3 245.6 4 1 1 393.3 1932.5 16 1 1 337.6 1618.7 4 4 1 92.2 479.1 16 16 1 58.1 192.6 ``` --------- Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> Co-authored-by: Justin Angus <angus1@llnl.gov> Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov>
- Loading branch information
1 parent
78cf034
commit c1cd7ab
Showing
13 changed files
with
615 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "ImplicitSolver.H" | ||
#include "WarpX.H" | ||
|
||
using namespace amrex; | ||
|
||
const Geometry& ImplicitSolver::GetGeometry (const int a_lvl) const | ||
{ | ||
AMREX_ASSERT((a_lvl >= 0) && (a_lvl < m_num_amr_levels)); | ||
return m_WarpX->Geom(a_lvl); | ||
} | ||
|
||
const Array<FieldBoundaryType,AMREX_SPACEDIM>& ImplicitSolver::GetFieldBoundaryLo () const | ||
{ | ||
return m_WarpX->GetFieldBoundaryLo(); | ||
} | ||
|
||
const Array<FieldBoundaryType,AMREX_SPACEDIM>& ImplicitSolver::GetFieldBoundaryHi () const | ||
{ | ||
return m_WarpX->GetFieldBoundaryHi(); | ||
} | ||
|
||
Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::GetLinOpBCLo () const | ||
{ | ||
return convertFieldBCToLinOpBC(m_WarpX->GetFieldBoundaryLo()); | ||
} | ||
|
||
Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::GetLinOpBCHi () const | ||
{ | ||
return convertFieldBCToLinOpBC(m_WarpX->GetFieldBoundaryHi()); | ||
} | ||
|
||
Array<LinOpBCType,AMREX_SPACEDIM> ImplicitSolver::convertFieldBCToLinOpBC (const Array<FieldBoundaryType,AMREX_SPACEDIM>& a_fbc) const | ||
{ | ||
Array<LinOpBCType, AMREX_SPACEDIM> lbc; | ||
for (auto& bc : lbc) { bc = LinOpBCType::interior; } | ||
for (int i = 0; i < AMREX_SPACEDIM; i++) { | ||
if (a_fbc[i] == FieldBoundaryType::PML) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::Periodic) { | ||
lbc[i] = LinOpBCType::Periodic; | ||
} else if (a_fbc[i] == FieldBoundaryType::PEC) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::PMC) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::Damped) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::Absorbing_SilverMueller) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::Neumann) { | ||
lbc[i] = LinOpBCType::Neumann; | ||
} else if (a_fbc[i] == FieldBoundaryType::None) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else if (a_fbc[i] == FieldBoundaryType::Open) { | ||
WARPX_ABORT_WITH_MESSAGE("LinOpBCType not set for this FieldBoundaryType"); | ||
} else { | ||
WARPX_ABORT_WITH_MESSAGE("Invalid value for FieldBoundaryType"); | ||
} | ||
} | ||
return lbc; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.