WarpX
Namespaces | Functions
ablastr::fields Namespace Reference

Namespaces

 details
 

Functions

void computePhiIGF (amrex::MultiFab const &rho, amrex::MultiFab &phi, std::array< amrex::Real, 3 > const &cell_size, amrex::BoxArray const &ba)
 Compute the electrostatic potential using the Integrated Green Function method as in http://dx.doi.org/10.1103/PhysRevSTAB.9.044204. More...
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real IntegratedPotential (amrex::Real x, amrex::Real y, amrex::Real z)
 Implements equation 2 in https://doi.org/10.1103/PhysRevSTAB.10.129901 with some modification to symmetrize the function. More...
 
template<typename T_BoundaryHandler , typename T_PostPhiCalculationFunctor = std::nullopt_t, typename T_FArrayBoxFactory = void>
void computePhi (amrex::Vector< amrex::MultiFab * > const &rho, amrex::Vector< amrex::MultiFab * > &phi, std::array< amrex::Real, 3 > const beta, amrex::Real const relative_tolerance, amrex::Real absolute_tolerance, int const max_iters, int const verbosity, amrex::Vector< amrex::Geometry > const &geom, amrex::Vector< amrex::DistributionMapping > const &dmap, amrex::Vector< amrex::BoxArray > const &grids, T_BoundaryHandler const boundary_handler, [[maybe_unused]] bool is_solver_multigrid, bool const do_single_precision_comms=false, std::optional< amrex::Vector< amrex::IntVect > > rel_ref_ratio=std::nullopt, [[maybe_unused]] T_PostPhiCalculationFunctor post_phi_calculation=std::nullopt, [[maybe_unused]] std::optional< amrex::Real const > current_time=std::nullopt, [[maybe_unused]] std::optional< amrex::Vector< T_FArrayBoxFactory const * > > eb_farray_box_factory=std::nullopt)
 
template<typename T_BoundaryHandler , typename T_PostACalculationFunctor = std::nullopt_t, typename T_FArrayBoxFactory = void>
void computeVectorPotential (amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > const &curr, amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > &A, amrex::Real const relative_tolerance, amrex::Real absolute_tolerance, int const max_iters, int const verbosity, amrex::Vector< amrex::Geometry > const &geom, amrex::Vector< amrex::DistributionMapping > const &dmap, amrex::Vector< amrex::BoxArray > const &grids, T_BoundaryHandler const boundary_handler, bool const do_single_precision_comms=false, std::optional< amrex::Vector< amrex::IntVect > > rel_ref_ratio=std::nullopt, [[maybe_unused]] T_PostACalculationFunctor post_A_calculation=std::nullopt, [[maybe_unused]] std::optional< amrex::Real const > current_time=std::nullopt, [[maybe_unused]] std::optional< amrex::Vector< T_FArrayBoxFactory const * > > eb_farray_box_factory=std::nullopt)
 

Function Documentation

◆ computePhi()

template<typename T_BoundaryHandler , typename T_PostPhiCalculationFunctor = std::nullopt_t, typename T_FArrayBoxFactory = void>
void ablastr::fields::computePhi ( amrex::Vector< amrex::MultiFab * > const &  rho,
amrex::Vector< amrex::MultiFab * > &  phi,
std::array< amrex::Real, 3 > const  beta,
amrex::Real const  relative_tolerance,
amrex::Real  absolute_tolerance,
int const  max_iters,
int const  verbosity,
amrex::Vector< amrex::Geometry > const &  geom,
amrex::Vector< amrex::DistributionMapping > const &  dmap,
amrex::Vector< amrex::BoxArray > const &  grids,
T_BoundaryHandler const  boundary_handler,
[[maybe_unused] ] bool  is_solver_multigrid,
bool const  do_single_precision_comms = false,
std::optional< amrex::Vector< amrex::IntVect > >  rel_ref_ratio = std::nullopt,
[[maybe_unused] ] T_PostPhiCalculationFunctor  post_phi_calculation = std::nullopt,
[[maybe_unused] ] std::optional< amrex::Real const >  current_time = std::nullopt,
[[maybe_unused] ] std::optional< amrex::Vector< T_FArrayBoxFactory const * > >  eb_farray_box_factory = std::nullopt 
)

Compute the potential phi by solving the Poisson equation

Uses rho as a source, assuming that the source moves at a constant speed $\vec{\beta}$. This uses the AMReX solver.

More specifically, this solves the equation

\[ \vec{\nabla}^2 r \phi - (\vec{\beta}\cdot\vec{\nabla})^2 r \phi = -\frac{r \rho}{\epsilon_0} \]

Template Parameters
T_BoundaryHandlerhandler for boundary conditions, for example
See also
ElectrostaticSolver::PoissonBoundaryHandler
Template Parameters
T_PostPhiCalculationFunctora calculation per level directly after phi was calculated
T_FArrayBoxFactoryusually nothing or an amrex::EBFArrayBoxFactory (EB ONLY)
Parameters
[in]rhoThe charge density a given species
[out]phiThe potential to be computed by this function
[in]betaRepresents the velocity of the source of phi
[in]relative_toleranceThe relative convergence threshold for the MLMG solver
[in]absolute_toleranceThe absolute convergence threshold for the MLMG solver
[in]max_itersThe maximum number of iterations allowed for the MLMG solver
[in]verbosityThe verbosity setting for the MLMG solver
[in]geomthe geometry per level (e.g., from AmrMesh)
[in]dmapthe distribution mapping per level (e.g., from AmrMesh)
[in]gridsthe grids per level (e.g., from AmrMesh)
[in]boundary_handlera handler for boundary conditions, for example
See also
ElectrostaticSolver::PoissonBoundaryHandler
Parameters
[in]is_solver_multigridboolean to select the Poisson solver: 1 for Multigrid, 0 for FFT
[in]do_single_precision_commsperform communications in single precision
[in]rel_ref_ratiomesh refinement ratio between levels (default: 1)
[in]post_phi_calculationperform a calculation per level directly after phi was calculated; required for embedded boundaries (default: none)
[in]current_timethe current time; required for embedded boundaries (default: none)
[in]eb_farray_box_factorya factory for field data,
See also
amrex::EBFArrayBoxFactory; required for embedded boundaries (default: none)

◆ computePhiIGF()

void ablastr::fields::computePhiIGF ( amrex::MultiFab const &  rho,
amrex::MultiFab phi,
std::array< amrex::Real, 3 > const &  cell_size,
amrex::BoxArray const &  ba 
)

Compute the electrostatic potential using the Integrated Green Function method as in http://dx.doi.org/10.1103/PhysRevSTAB.9.044204.

Parameters
[in]rhothe charge density amrex::MultiFab
[out]phithe electrostatic potential amrex::MultiFab
[in]cell_sizean arreay of 3 reals dx dy dz
[in]baamrex::BoxArray with the grid of a given level

◆ computeVectorPotential()

template<typename T_BoundaryHandler , typename T_PostACalculationFunctor = std::nullopt_t, typename T_FArrayBoxFactory = void>
void ablastr::fields::computeVectorPotential ( amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > const &  curr,
amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > &  A,
amrex::Real const  relative_tolerance,
amrex::Real  absolute_tolerance,
int const  max_iters,
int const  verbosity,
amrex::Vector< amrex::Geometry > const &  geom,
amrex::Vector< amrex::DistributionMapping > const &  dmap,
amrex::Vector< amrex::BoxArray > const &  grids,
T_BoundaryHandler const  boundary_handler,
bool const  do_single_precision_comms = false,
std::optional< amrex::Vector< amrex::IntVect > >  rel_ref_ratio = std::nullopt,
[[maybe_unused] ] T_PostACalculationFunctor  post_A_calculation = std::nullopt,
[[maybe_unused] ] std::optional< amrex::Real const >  current_time = std::nullopt,
[[maybe_unused] ] std::optional< amrex::Vector< T_FArrayBoxFactory const * > >  eb_farray_box_factory = std::nullopt 
)

Compute the vector potential A by solving the Poisson equation

Uses J as a source, assuming that the source moves at a constant speed $\vec{\beta}$. This uses the AMReX solver.

More specifically, this solves the equation

\[ \vec{\nabla}^2 r \vec{A} - (\vec{\beta}\cdot\vec{\nabla})^2 r \vec{A} = - r \mu_0 \vec{J} \]

Template Parameters
T_BoundaryHandlerhandler for boundary conditions, for example
See also
MagnetostaticSolver::MultiPoissonBoundaryHandler
Template Parameters
T_PostACalculationFunctora calculation per level directly after A was calculated
T_FArrayBoxFactoryusually nothing or an amrex::EBFArrayBoxFactory (EB ONLY)
Parameters
[in]currThe current density a given species
[out]AThe vector potential to be computed by this function
[in]relative_toleranceThe relative convergence threshold for the MLMG solver
[in]absolute_toleranceThe absolute convergence threshold for the MLMG solver
[in]max_itersThe maximum number of iterations allowed for the MLMG solver
[in]verbosityThe verbosity setting for the MLMG solver
[in]geomthe geometry per level (e.g., from AmrMesh)
[in]dmapthe distribution mapping per level (e.g., from AmrMesh)
[in]gridsthe grids per level (e.g., from AmrMesh)
[in]boundary_handlera handler for boundary conditions, for example
See also
MagnetostaticSolver::VectorPoissonBoundaryHandler
Parameters
[in]do_single_precision_commsperform communications in single precision
[in]rel_ref_ratiomesh refinement ratio between levels (default: 1)
[in]post_A_calculationperform a calculation per level directly after A was calculated; required for embedded boundaries (default: none)
[in]current_timethe current time; required for embedded boundaries (default: none)
[in]eb_farray_box_factorya factory for field data,
See also
amrex::EBFArrayBoxFactory; required for embedded boundaries (default: none)

◆ IntegratedPotential()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real ablastr::fields::IntegratedPotential ( amrex::Real  x,
amrex::Real  y,
amrex::Real  z 
)

Implements equation 2 in https://doi.org/10.1103/PhysRevSTAB.10.129901 with some modification to symmetrize the function.

Parameters
[in]xx-coordinate of given location
[in]yy-coordinate of given location
[in]zz-coordinate of given location
Returns
the integrated Green function G