WarpX
Loading...
Searching...
No Matches
StrangImplicitSpectralEM Class Reference

#include <StrangImplicitSpectralEM.H>

Inheritance diagram for StrangImplicitSpectralEM:
ImplicitSolver

Public Member Functions

 StrangImplicitSpectralEM ()=default
 
 ~StrangImplicitSpectralEM () override=default
 
 StrangImplicitSpectralEM (const StrangImplicitSpectralEM &)=delete
 
StrangImplicitSpectralEMoperator= (const StrangImplicitSpectralEM &)=delete
 
 StrangImplicitSpectralEM (StrangImplicitSpectralEM &&)=delete
 
StrangImplicitSpectralEMoperator= (StrangImplicitSpectralEM &&)=delete
 
void Define (WarpX *a_WarpX) override
 Read user-provided parameters that control the implicit solver. Allocate internal arrays for intermediate field values needed by the solver.
 
void PrintParameters () const override
 
void OneStep (amrex::Real start_time, amrex::Real a_dt, int a_step) override
 Advance fields and particles by one time step using the specified implicit algorithm.
 
void ComputeRHS (WarpXSolverVec &a_RHS, const WarpXSolverVec &a_E, amrex::Real start_time, int a_nl_iter, bool a_from_jacobian) override
 Computes the RHS of the equation corresponding to the specified implicit algorithm. The discrete equations corresponding to numerical integration of ODEs are often written in the form U = b + RHS(U), where U is the variable to be solved for (e.g., the solution at the next time step), b is a constant (i.e., the solution from the previous time step), and RHS(U) is the right-hand-side of the equation. Iterative solvers, such as Picard and Newton, and higher-order Runge-Kutta methods, need to compute RHS(U) multiple times for different values of U. Thus, a routine that returns this value is needed. e.g., Ebar - E^n = cvac^2*0.5*dt*(curl(Bbar) - mu0*Jbar(Ebar,Bbar)) Here, U = Ebar, b = E^n, and the expression on the right is RHS(U).
 
amrex::Real GetThetaForPC () const override
 
- Public Member Functions inherited from ImplicitSolver
 ImplicitSolver ()=default
 
virtual ~ImplicitSolver ()=default
 
 ImplicitSolver (const ImplicitSolver &)=delete
 
ImplicitSolveroperator= (const ImplicitSolver &)=delete
 
 ImplicitSolver (ImplicitSolver &&)=delete
 
ImplicitSolveroperator= (ImplicitSolver &&)=delete
 
bool IsDefined () const
 
void CreateParticleAttributes () const
 
bool DoParticleSuborbits ()
 
int numAMRLevels () const
 
const amrex::GeometryGetGeometry (int) const
 
const amrex::Array< FieldBoundaryType, 3 > & GetFieldBoundaryLo () const
 
const amrex::Array< FieldBoundaryType, 3 > & GetFieldBoundaryHi () const
 
amrex::Array< amrex::LinOpBCType, 3 > GetLinOpBCLo () const
 
amrex::Array< amrex::LinOpBCType, 3 > GetLinOpBCHi () const
 
const amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > * GetMassMatricesCoeff () const
 Return pointer to MultiFab array for mass matrix.
 
void ComputeJfromMassMatrices (const bool a_J_from_MM_only)
 

Private Member Functions

void UpdateWarpXFields (WarpXSolverVec const &a_E, amrex::Real half_time)
 Update the E and B fields owned by WarpX.
 
void FinishFieldUpdate (amrex::Real a_new_time)
 Nonlinear solver is for the time-centered values of E. After the solver, need to use m_E and m_Eold to compute E^{n+1}.
 

Private Attributes

WarpXSolverVec m_E
 Solver vectors to be used in the nonlinear solver to solve for the electric field E. The main logic for determining which variables should be WarpXSolverVec type is that it must have the same size and have the same centering of the data as the variable being solved for, which is E here. For example, if using a Yee grid then a container for curlB could be a WarpXSovlerVec, but magnetic field B should not be.
 
WarpXSolverVec m_Eold
 
amrex::Vector< std::array< std::unique_ptr< amrex::MultiFab >, 3 > > m_Bold
 B is a derived variable from E. Need to save Bold to update B during the iterative nonlinear solve for E. Bold is owned here, but only used by WarpX. It is not used directly by the nonlinear solver, nor is it the same size as the solver vector (size E), and so it should not be WarpXSolverVec type.
 

Additional Inherited Members

- Protected Member Functions inherited from ImplicitSolver
void parseNonlinearSolverParams (const amrex::ParmParse &pp)
 parse nonlinear solver parameters (if one is used)
 
void InitializeMassMatrices ()
 Initialize the Mass Matrices used for plasma response in nonlinear Newton solver.
 
void PrintBaseImplicitSolverParameters () const
 
void PreRHSOp (const amrex::Real a_cur_time, const int a_nl_iter, const bool a_from_jacobian)
 Perform operations needed before computing the Right Hand Side.
 
void SyncMassMatricesPCAndApplyBCs ()
 Communicate Mass Matrices used for PC and apply boundary conditions.
 
void SetMassMatricesForPC (const amrex::Real a_theta_dt)
 Scale mass matrices used for PC by c^2*mu0*theta*dt and add 1 to diagonal terms.
 
void CumulateJ ()
 Add J from particles included in mass matrices at start of each Newton step.
 
void SaveE ()
 Save E at start of each Newton step.
 
amrex::Array< amrex::LinOpBCType, 3 > convertFieldBCToLinOpBC (const amrex::Array< FieldBoundaryType, 3 > &) const
 Convert from WarpX FieldBoundaryType to amrex::LinOpBCType.
 
- Protected Attributes inherited from ImplicitSolver
WarpXm_WarpX
 Pointer back to main WarpX class.
 
bool m_is_defined = false
 
int m_num_amr_levels = 1
 Number of AMR levels.
 
amrex::Real m_dt = 0.0
 Time step.
 
amrex::Real m_theta = 0.5
 Time-biasing parameter for fields used on RHS to advance system.
 
NonlinearSolverType m_nlsolver_type
 Nonlinear solver type and object.
 
std::unique_ptr< NonlinearSolver< WarpXSolverVec, ImplicitSolver > > m_nlsolver
 
amrex::ParticleReal m_particle_tolerance = amrex::ParticleReal(1.0e-10)
 tolerance used by the iterative method used to obtain a self-consistent update of the particle positions and velocities for given E and B on the grid
 
int m_max_particle_iterations = 21
 maximum iterations for the iterative method used to obtain a self-consistent update of the particle positions and velocities for given E and B on the grid
 
bool m_particle_suborbits = false
 whether to use suborbits for particles that fail to converge in m_max_particle_iterations iterations
 
bool m_print_unconverged_particle_details = false
 whether the details of unconverged particles are printed out during the particle evolve loops
 
bool m_skip_particle_picard_init = false
 whether to skip the full Picard update of particles on the initial newton step
 
bool m_use_mass_matrices = false
 Whether to use mass matrices for the implicit solver.
 
bool m_use_mass_matrices_jacobian = false
 Whether to use mass matrices to compute J during linear stage of JFNK.
 
bool m_use_mass_matrices_pc = false
 Whether to use mass matrices in the preconditioner.
 
amrex::IntVect m_ncomp_xx = amrex::IntVect{0}
 Direction-dependent component number of mass matrices elements.
 
amrex::IntVect m_ncomp_xy = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_xz = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_yx = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_yy = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_yz = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_zx = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_zy = amrex::IntVect{0}
 
amrex::IntVect m_ncomp_zz = amrex::IntVect{0}
 
amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > m_mmpc_mfarrvec
 Array of multifab pointers to mass matrix preconditioner.
 

Constructor & Destructor Documentation

◆ StrangImplicitSpectralEM() [1/3]

StrangImplicitSpectralEM::StrangImplicitSpectralEM ( )
default

◆ ~StrangImplicitSpectralEM()

StrangImplicitSpectralEM::~StrangImplicitSpectralEM ( )
overridedefault

◆ StrangImplicitSpectralEM() [2/3]

StrangImplicitSpectralEM::StrangImplicitSpectralEM ( const StrangImplicitSpectralEM & )
delete

◆ StrangImplicitSpectralEM() [3/3]

StrangImplicitSpectralEM::StrangImplicitSpectralEM ( StrangImplicitSpectralEM && )
delete

Member Function Documentation

◆ ComputeRHS()

void StrangImplicitSpectralEM::ComputeRHS ( WarpXSolverVec & a_RHS,
const WarpXSolverVec & a_E,
amrex::Real a_time,
int a_nl_iter,
bool a_from_jacobian )
overridevirtual

Computes the RHS of the equation corresponding to the specified implicit algorithm. The discrete equations corresponding to numerical integration of ODEs are often written in the form U = b + RHS(U), where U is the variable to be solved for (e.g., the solution at the next time step), b is a constant (i.e., the solution from the previous time step), and RHS(U) is the right-hand-side of the equation. Iterative solvers, such as Picard and Newton, and higher-order Runge-Kutta methods, need to compute RHS(U) multiple times for different values of U. Thus, a routine that returns this value is needed. e.g., Ebar - E^n = cvac^2*0.5*dt*(curl(Bbar) - mu0*Jbar(Ebar,Bbar)) Here, U = Ebar, b = E^n, and the expression on the right is RHS(U).

Implements ImplicitSolver.

◆ Define()

void StrangImplicitSpectralEM::Define ( WarpX * a_WarpX)
overridevirtual

Read user-provided parameters that control the implicit solver. Allocate internal arrays for intermediate field values needed by the solver.

Implements ImplicitSolver.

◆ FinishFieldUpdate()

void StrangImplicitSpectralEM::FinishFieldUpdate ( amrex::Real a_new_time)
private

Nonlinear solver is for the time-centered values of E. After the solver, need to use m_E and m_Eold to compute E^{n+1}.

◆ GetThetaForPC()

amrex::Real StrangImplicitSpectralEM::GetThetaForPC ( ) const
inlinenodiscardoverridevirtual

Implements ImplicitSolver.

◆ OneStep()

void StrangImplicitSpectralEM::OneStep ( amrex::Real a_time,
amrex::Real a_dt,
int a_step )
overridevirtual

Advance fields and particles by one time step using the specified implicit algorithm.

Implements ImplicitSolver.

◆ operator=() [1/2]

StrangImplicitSpectralEM & StrangImplicitSpectralEM::operator= ( const StrangImplicitSpectralEM & )
delete

◆ operator=() [2/2]

StrangImplicitSpectralEM & StrangImplicitSpectralEM::operator= ( StrangImplicitSpectralEM && )
delete

◆ PrintParameters()

void StrangImplicitSpectralEM::PrintParameters ( ) const
overridevirtual

Implements ImplicitSolver.

◆ UpdateWarpXFields()

void StrangImplicitSpectralEM::UpdateWarpXFields ( WarpXSolverVec const & a_E,
amrex::Real half_time )
private

Update the E and B fields owned by WarpX.

Member Data Documentation

◆ m_Bold

amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > StrangImplicitSpectralEM::m_Bold
private

B is a derived variable from E. Need to save Bold to update B during the iterative nonlinear solve for E. Bold is owned here, but only used by WarpX. It is not used directly by the nonlinear solver, nor is it the same size as the solver vector (size E), and so it should not be WarpXSolverVec type.

◆ m_E

WarpXSolverVec StrangImplicitSpectralEM::m_E
private

Solver vectors to be used in the nonlinear solver to solve for the electric field E. The main logic for determining which variables should be WarpXSolverVec type is that it must have the same size and have the same centering of the data as the variable being solved for, which is E here. For example, if using a Yee grid then a container for curlB could be a WarpXSovlerVec, but magnetic field B should not be.

◆ m_Eold

WarpXSolverVec StrangImplicitSpectralEM::m_Eold
private

The documentation for this class was generated from the following files: