OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
FieldSolver< T, Dim > Class Template Reference

#include <FieldSolver.hpp>

Inheritance diagram for FieldSolver< T, Dim >:
Inheritance graph
Collaboration diagram for FieldSolver< T, Dim >:
Collaboration graph

Public Member Functions

 FieldSolver (std::string solver, Field_t< Dim > *rho, VField_t< T, Dim > *E, Field_t< Dim > *phi, std::shared_ptr< BCHandler_t > bcHandler)
 
 ~FieldSolver () override=default
 
void dumpScalField (std::string what)
 
void dumpVectField (std::string what)
 
Field_t< Dim > * getRho ()
 
void setRho (Field_t< Dim > *rho)
 
VField_t< T, Dim > * getE () const
 
void setE (VField_t< T, Dim > *E)
 
Field< T, Dim > * getPhi () const
 
void setPhi (Field< T, Dim > *phi)
 
std::shared_ptr< BCHandler_tgetBCHandler () const
 
void setBCHandler (std::shared_ptr< BCHandler_t > bcHandler)
 
T getCouplingConstant () const
 Get the solver's coupling constant.
 
void initOpenSolver ()
 
void initSolver () override
 
void setPotentialBCs ()
 Set boundary conditions for the electrostatic potential field.
 
bool hasValidBCHandler () const
 
void runSolver () override
 
void resetCallCounter ()
 Reset the solver call counter to zero.
 
size_t getCallCounter ()
 
void runSolver (bool force_skip_field_dump)
 Execute the field solver for the current simulation state.
 
void runShiftedOpenSolver (const ippl::Vector< double, Dim > &shift)
 Run an Open-solver solve with a shifted free-space Green's function.
 
template<typename Solver >
void initSolverWithParams (const ippl::ParameterList &sp)
 
void initNullSolver ()
 
void initFFTSolver ()
 
void initCGSolver ()
 
void initP3MSolver ()
 
void initSolverWithParams (const ippl::ParameterList &sp)
 
void dumpVectField (std::string what)
 
void dumpScalField (std::string what)
 
void initOpenSolver ()
 
void initFFTSolver ()
 
void initCGSolver ()
 
void initNullSolver ()
 
void initSolver ()
 
void runSolver (bool force_skip_field_dump)
 
void runShiftedOpenSolver (const ippl::Vector< double, 3 > &shift)
 
double getCouplingConstant () const
 
void setPotentialBCs ()
 
void initNullSolver ()
 

Private Types

using BCHandler_t = BCHandler< Dim >
 

Private Attributes

Field_t< Dim > * rho_m
 
VField_t< T, Dim > * E_m
 
Field_t< Dim > * phi_m
 
std::shared_ptr< BCHandler_tbcHandler_m
 
size_t call_counter_m
 Counts number of times the solver has been called.
 

Detailed Description

template<typename T, unsigned Dim>
class FieldSolver< T, Dim >

Definition at line 11 of file FieldSolver.hpp.

Member Typedef Documentation

◆ BCHandler_t

template<typename T , unsigned Dim>
using FieldSolver< T, Dim >::BCHandler_t = BCHandler<Dim>
private

Definition at line 17 of file FieldSolver.hpp.

Constructor & Destructor Documentation

◆ FieldSolver()

template<typename T , unsigned Dim>
FieldSolver< T, Dim >::FieldSolver ( std::string  solver,
Field_t< Dim > *  rho,
VField_t< T, Dim > *  E,
Field_t< Dim > *  phi,
std::shared_ptr< BCHandler_t bcHandler 
)
inline

Definition at line 24 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::setPotentialBCs().

Here is the call graph for this function:

◆ ~FieldSolver()

template<typename T , unsigned Dim>
FieldSolver< T, Dim >::~FieldSolver ( )
overridedefault

Member Function Documentation

◆ dumpScalField() [1/2]

void FieldSolver< double, 3 >::dumpScalField ( std::string  what)

Definition at line 148 of file FieldSolver.cpp.

References OpalData::getInputBasename(), OpalData::getInstance(), and Util::toUpper().

Here is the call graph for this function:

◆ dumpScalField() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::dumpScalField ( std::string  what)

◆ dumpVectField() [1/2]

void FieldSolver< double, 3 >::dumpVectField ( std::string  what)

Definition at line 55 of file FieldSolver.cpp.

References OpalData::getInputBasename(), OpalData::getInstance(), and Util::toUpper().

Here is the call graph for this function:

◆ dumpVectField() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::dumpVectField ( std::string  what)

◆ getBCHandler()

template<typename T , unsigned Dim>
std::shared_ptr< BCHandler_t > FieldSolver< T, Dim >::getBCHandler ( ) const
inline

Definition at line 50 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::bcHandler_m.

◆ getCallCounter()

template<typename T , unsigned Dim>
size_t FieldSolver< T, Dim >::getCallCounter ( )
inline

Definition at line 103 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::call_counter_m.

Referenced by ParallelTracker::execute().

◆ getCouplingConstant() [1/2]

double FieldSolver< double, 3 >::getCouplingConstant ( ) const
Todo:
Verify this before activating a new solver!

Definition at line 483 of file FieldSolver.cpp.

References Physics::epsilon_0, and Physics::pi.

◆ getCouplingConstant() [2/2]

template<typename T , unsigned Dim>
T FieldSolver< T, Dim >::getCouplingConstant ( ) const

Get the solver's coupling constant.

Returns the scalar coupling constant used by the field solver to scale interactions between particles and the field. This value is applied during ParBunch::computeSpaceCharge. Its physical meaning and units potentially depend on the specific solver type used.

Returns
The coupling constant of type T (usually double).

◆ getE()

template<typename T , unsigned Dim>
VField_t< T, Dim > * FieldSolver< T, Dim >::getE ( ) const
inline

Definition at line 44 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::E_m.

◆ getPhi()

template<typename T , unsigned Dim>
Field< T, Dim > * FieldSolver< T, Dim >::getPhi ( ) const
inline

Definition at line 47 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::phi_m.

◆ getRho()

template<typename T , unsigned Dim>
Field_t< Dim > * FieldSolver< T, Dim >::getRho ( )
inline

Definition at line 41 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::rho_m.

◆ hasValidBCHandler()

template<typename T , unsigned Dim>
bool FieldSolver< T, Dim >::hasValidBCHandler ( ) const
inline

Definition at line 84 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::bcHandler_m.

◆ initCGSolver() [1/2]

void FieldSolver< double, 3 >::initCGSolver ( )
Todo:
should probably at some point be passed from the input file

Definition at line 308 of file FieldSolver.cpp.

◆ initCGSolver() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initCGSolver ( )
inline

Definition at line 153 of file FieldSolver.hpp.

◆ initFFTSolver() [1/2]

void FieldSolver< double, 3 >::initFFTSolver ( )
Todo:
don't print phi_m to file if FFT and GRAD is selected!

Definition at line 286 of file FieldSolver.cpp.

References Dim.

◆ initFFTSolver() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initFFTSolver ( )

◆ initNullSolver() [1/3]

void FieldSolver< double, 3 >::initNullSolver ( )

Definition at line 318 of file FieldSolver.cpp.

References Dim.

◆ initNullSolver() [2/3]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initNullSolver ( )

◆ initNullSolver() [3/3]

void FieldSolver< double, 3 >::initNullSolver ( )

◆ initOpenSolver() [1/2]

void FieldSolver< double, 3 >::initOpenSolver ( )

Definition at line 272 of file FieldSolver.cpp.

◆ initOpenSolver() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initOpenSolver ( )

◆ initP3MSolver()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initP3MSolver ( )
inline

Definition at line 155 of file FieldSolver.hpp.

◆ initSolver() [1/2]

void FieldSolver< double, 3 >::initSolver ( )

Definition at line 330 of file FieldSolver.cpp.

◆ initSolver() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::initSolver ( )
override

◆ initSolverWithParams() [1/2]

void FieldSolver< double, 3 >::initSolverWithParams ( const ippl::ParameterList &  sp)
Todo:
for now, don't use the CG solver!

Definition at line 17 of file FieldSolver.cpp.

◆ initSolverWithParams() [2/2]

template<typename T , unsigned Dim>
template<typename Solver >
void FieldSolver< T, Dim >::initSolverWithParams ( const ippl::ParameterList &  sp)

◆ resetCallCounter()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::resetCallCounter ( )
inline

Reset the solver call counter to zero.

Sets the internal call counter (call_counter_m) back to 0 so that subsequent calls will be counted from a clean state.

Note
This function is necessary to exclude potential solver warm-up calls from being counted towards output or logging that depends on the number of solver executions.

Definition at line 101 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::call_counter_m.

◆ runShiftedOpenSolver() [1/2]

void FieldSolver< double, 3 >::runShiftedOpenSolver ( const ippl::Vector< double, 3 > &  shift)

Definition at line 446 of file FieldSolver.cpp.

◆ runShiftedOpenSolver() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::runShiftedOpenSolver ( const ippl::Vector< double, Dim > &  shift)

Run an Open-solver solve with a shifted free-space Green's function.

Installs a translated Green's kernel \(G(r) = -1/(4\pi|r - \texttt{shift}|)\) on the underlying IPPL FFTOpenPoissonSolver via shiftedGreensFunction(shift), runs solve(), then restores the standard Green's function (greensFunction()) so subsequent solves in later bins are not affected.

The manual restore guards against two adjacent bins whose stretched mesh spacings happen to coincide: the mesh-change detector inside the IPPL solve() would then not recompute the kernel and the next primary solve would silently reuse the shifted one. With the current binning algorithm this collision is not supposed to happen, so the extra FFT per shifted pass is defensive and can be removed once the invariant is guaranteed by the binner.

Parameters
shiftPer-axis translation of the Green's function in physical units.
Exceptions
OpalExceptionif the configured solver is not "OPEN".

◆ runSolver() [1/3]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::runSolver ( )
inlineoverride

Definition at line 86 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::runSolver().

Referenced by FieldSolver< T, Dim >::runSolver().

Here is the call graph for this function:

◆ runSolver() [2/3]

void FieldSolver< double, 3 >::runSolver ( bool  force_skip_field_dump)

Definition at line 362 of file FieldSolver.cpp.

References Dim.

◆ runSolver() [3/3]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::runSolver ( bool  force_skip_field_dump)

Execute the field solver for the current simulation state.

Performs a single solve cycle using the solver's current configuration, boundary conditions and particle/mesh data. The solver updates the internal field representations.

Parameters
force_skip_field_dumpIf true, suppress any field-dump output that would otherwise be produced by this call. If false, field output behavior follows the configured/normal schedule.
Note
This second implementation is necessary since the pure runSolver() routine is defined in the base class as not taking any arguments.

◆ setBCHandler()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::setBCHandler ( std::shared_ptr< BCHandler_t bcHandler)
inline

Definition at line 51 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::bcHandler_m, and FieldSolver< T, Dim >::setPotentialBCs().

Here is the call graph for this function:

◆ setE()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::setE ( VField_t< T, Dim > *  E)
inline

Definition at line 45 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::E_m.

◆ setPhi()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::setPhi ( Field< T, Dim > *  phi)
inline

Definition at line 48 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::phi_m.

◆ setPotentialBCs() [1/2]

void FieldSolver< double, 3 >::setPotentialBCs ( )

Definition at line 509 of file FieldSolver.cpp.

References Dim.

◆ setPotentialBCs() [2/2]

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::setPotentialBCs ( )

Set boundary conditions for the electrostatic potential field.

Converts the boundary-condition specification provided by the BC handler into the IPPL boundary-condition format for Field_t<Dim> and applies the resulting conditions to the internal potential field (phi_m) by calling its setFieldBC method.

Exceptions
OpalExceptionif the BC handler is not set or invalid.

Referenced by FieldSolver< T, Dim >::FieldSolver(), and FieldSolver< T, Dim >::setBCHandler().

◆ setRho()

template<typename T , unsigned Dim>
void FieldSolver< T, Dim >::setRho ( Field_t< Dim > *  rho)
inline

Definition at line 42 of file FieldSolver.hpp.

References FieldSolver< T, Dim >::rho_m.

Member Data Documentation

◆ bcHandler_m

template<typename T , unsigned Dim>
std::shared_ptr<BCHandler_t> FieldSolver< T, Dim >::bcHandler_m
private

◆ call_counter_m

template<typename T , unsigned Dim>
size_t FieldSolver< T, Dim >::call_counter_m
private

Counts number of times the solver has been called.

Definition at line 21 of file FieldSolver.hpp.

Referenced by FieldSolver< T, Dim >::getCallCounter(), and FieldSolver< T, Dim >::resetCallCounter().

◆ E_m

template<typename T , unsigned Dim>
VField_t<T, Dim>* FieldSolver< T, Dim >::E_m
private

Definition at line 14 of file FieldSolver.hpp.

Referenced by FieldSolver< T, Dim >::getE(), and FieldSolver< T, Dim >::setE().

◆ phi_m

template<typename T , unsigned Dim>
Field_t<Dim>* FieldSolver< T, Dim >::phi_m
private

Definition at line 15 of file FieldSolver.hpp.

Referenced by FieldSolver< T, Dim >::getPhi(), and FieldSolver< T, Dim >::setPhi().

◆ rho_m

template<typename T , unsigned Dim>
Field_t<Dim>* FieldSolver< T, Dim >::rho_m
private

Definition at line 13 of file FieldSolver.hpp.

Referenced by FieldSolver< T, Dim >::getRho(), and FieldSolver< T, Dim >::setRho().


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