-
Notifications
You must be signed in to change notification settings - Fork 230
Implicit Field Solve Preconditioner based on Curl-Curl Operator #5286
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
Changes from all commits
ef110d5
8196a85
248e21e
40d11ab
6cbebe6
0f3218a
daa8edc
ea3838b
482bc73
aff9965
5c45dc1
4801d6c
75b88f9
d2d7ea6
e601e91
79aa72c
0db699d
e9ff4f2
ff0d8d3
a698210
ac479fc
af56e98
cabcf74
d1bb01b
4228075
4a3c2ba
70c5f3f
4fe3cfb
0c4c1d7
42cc9ec
98b0363
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /* Copyright 2024 Justin Angus | ||
| /* Copyright 2024 Justin Angus, Debojyoti Ghosh | ||
| * | ||
| * This file is part of WarpX. | ||
| * | ||
|
|
@@ -9,9 +9,11 @@ | |
|
|
||
| #include "FieldSolver/ImplicitSolvers/WarpXSolverVec.H" | ||
| #include "NonlinearSolvers/NonlinearSolverLibrary.H" | ||
| #include "Utils/WarpXAlgorithmSelection.H" | ||
|
|
||
| #include <AMReX_Array.H> | ||
| #include <AMReX_REAL.H> | ||
| #include <AMReX_LO_BCTYPES.H> | ||
|
|
||
| /** | ||
| * \brief Base class for implicit time solvers. The base functions are those | ||
|
|
@@ -85,6 +87,16 @@ public: | |
| int a_nl_iter, | ||
| bool a_from_jacobian ) = 0; | ||
|
|
||
| [[nodiscard]] virtual amrex::Real theta () const { return 1.0; } | ||
|
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. Making this a member of the base class is fine for now. In a future PR, we can remove it by passing in m_theta*a_dt to the solver. This will require modifications to several files in the ImplicitSolver folder and in the NonlinearSolvers folder, but it will make the code more tidy. I can do this after this PR is merged. |
||
|
|
||
| [[nodiscard]] int numAMRLevels () const { return m_num_amr_levels; } | ||
|
|
||
| [[nodiscard]] const amrex::Geometry& GetGeometry (int) const; | ||
| [[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryLo () const; | ||
| [[nodiscard]] const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& GetFieldBoundaryHi () const; | ||
| [[nodiscard]] amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> GetLinOpBCLo () const; | ||
| [[nodiscard]] amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> GetLinOpBCHi () const; | ||
|
|
||
| protected: | ||
|
|
||
| /** | ||
|
|
@@ -94,6 +106,11 @@ protected: | |
|
|
||
| bool m_is_defined = false; | ||
|
|
||
| /** | ||
| * \brief Number of AMR levels | ||
| */ | ||
| int m_num_amr_levels = 1; | ||
|
|
||
| /** | ||
| * \brief Nonlinear solver type and object | ||
| */ | ||
|
|
@@ -140,6 +157,11 @@ protected: | |
|
|
||
| } | ||
|
|
||
| /** | ||
| * \brief Convert from WarpX FieldBoundaryType to amrex::LinOpBCType | ||
| */ | ||
| [[nodiscard]] amrex::Array<amrex::LinOpBCType,AMREX_SPACEDIM> convertFieldBCToLinOpBC ( const amrex::Array<FieldBoundaryType,AMREX_SPACEDIM>& ) const; | ||
|
|
||
| }; | ||
|
|
||
| #endif | ||
| 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"); | ||
| } | ||
debog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return lbc; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.