WarpX
ElectrostaticSolver.H
Go to the documentation of this file.
1 /* Copyright 2021 Modern Electron
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef ELECTROSTATICSOLVER_H_
8 #define ELECTROSTATICSOLVER_H_
9 
10 #include <AMReX_Array.H>
11 #include <AMReX_Geometry.H>
12 #include <AMReX_MultiFab.H>
13 #include <AMReX_MLMG.H>
14 #include <AMReX_REAL.H>
15 #include <AMReX_Parser.H>
16 
17 #include <utility>
18 
20 
21  struct PhiCalculatorEB {
22 
23  amrex::Real t;
25 
27  amrex::Real operator()(const amrex::Real x, const amrex::Real z) const noexcept {
28  using namespace amrex::literals;
29  return potential_eb(x, 0.0_rt, z, t);
30  }
31 
33  amrex::Real operator()(const amrex::Real x, const amrex::Real y, const amrex::Real z) const noexcept {
34  return potential_eb(x, y, z, t);
35  }
36  };
37 
39  public:
40 
42  bool bcs_set = false;
43  std::array<bool, AMREX_SPACEDIM * 2> dirichlet_flag;
44  bool has_non_periodic = false;
45  bool phi_EB_only_t = true;
46 
47  void definePhiBCs (const amrex::Geometry& geom);
48 
49  void buildParsers ();
50  void buildParsersEB ();
51 
52  /* \brief Sets the EB potential string and updates the parsers
53  *
54  * \param [in] potential The string value of the potential
55  */
56  void setPotentialEB(const std::string potential) {
57  potential_eb_str = potential;
58  buildParsersEB();
59  }
60 
61  PhiCalculatorEB getPhiEB(amrex::Real t) const noexcept {
63  }
64 
65  // set default potentials to zero in order for current tests to pass
66  // but forcing the user to specify a potential might be better
67  std::string potential_xlo_str = "0";
68  std::string potential_xhi_str = "0";
69  std::string potential_ylo_str = "0";
70  std::string potential_yhi_str = "0";
71  std::string potential_zlo_str = "0";
72  std::string potential_zhi_str = "0";
73  std::string potential_eb_str = "0";
74 
83 
84  private:
85 
93  };
94 
100  private:
104 
105  public:
107  : m_e_field(std::move(e_field)) {}
108 
109  void operator()(amrex::MLMG & mlmg, int const lev) {
110  using namespace amrex::literals;
111 
112  mlmg.getGradSolution({m_e_field[lev]});
113  for (auto &field: m_e_field[lev]) {
114  field->mult(-1._rt);
115  }
116  }
117  };
118 } // namespace ElectrostaticSolver
119 
120 #endif // ELECTROSTATICSOLVER_H_
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
Definition: ElectrostaticSolver.H:99
amrex::Vector< amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > > m_e_field
Definition: ElectrostaticSolver.H:103
EBCalcEfromPhiPerLevel(amrex::Vector< amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > > e_field)
Definition: ElectrostaticSolver.H:106
void operator()(amrex::MLMG &mlmg, int const lev)
Definition: ElectrostaticSolver.H:109
Definition: ElectrostaticSolver.H:38
amrex::ParserExecutor< 1 > potential_xhi
Definition: ElectrostaticSolver.H:76
amrex::ParserExecutor< 1 > potential_yhi
Definition: ElectrostaticSolver.H:78
PhiCalculatorEB getPhiEB(amrex::Real t) const noexcept
Definition: ElectrostaticSolver.H:61
amrex::Parser potential_xlo_parser
Definition: ElectrostaticSolver.H:86
amrex::Parser potential_yhi_parser
Definition: ElectrostaticSolver.H:89
void setPotentialEB(const std::string potential)
Definition: ElectrostaticSolver.H:56
amrex::Parser potential_zlo_parser
Definition: ElectrostaticSolver.H:90
amrex::Parser potential_ylo_parser
Definition: ElectrostaticSolver.H:88
amrex::ParserExecutor< 1 > potential_zlo
Definition: ElectrostaticSolver.H:79
amrex::Array< amrex::LinOpBCType, AMREX_SPACEDIM > hibc
Definition: ElectrostaticSolver.H:41
amrex::ParserExecutor< 1 > potential_xlo
Definition: ElectrostaticSolver.H:75
amrex::ParserExecutor< 1 > potential_ylo
Definition: ElectrostaticSolver.H:77
amrex::ParserExecutor< 1 > potential_zhi
Definition: ElectrostaticSolver.H:80
amrex::ParserExecutor< 4 > potential_eb
Definition: ElectrostaticSolver.H:82
amrex::Parser potential_xhi_parser
Definition: ElectrostaticSolver.H:87
amrex::Parser potential_zhi_parser
Definition: ElectrostaticSolver.H:91
std::array< bool, AMREX_SPACEDIM *2 > dirichlet_flag
Definition: ElectrostaticSolver.H:43
amrex::Parser potential_eb_parser
Definition: ElectrostaticSolver.H:92
amrex::ParserExecutor< 1 > potential_eb_t
Definition: ElectrostaticSolver.H:81
void getGradSolution(const Vector< Array< AMF *, AMREX_SPACEDIM > > &a_grad_sol, Location a_loc=Location::FaceCenter)
Definition: ElectrostaticSolver.H:19
std::array< T, N > Array
string field
Definition: video_yt.py:31
Definition: ElectrostaticSolver.H:21
amrex::ParserExecutor< 4 > potential_eb
Definition: ElectrostaticSolver.H:24
amrex::Real t
Definition: ElectrostaticSolver.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real operator()(const amrex::Real x, const amrex::Real y, const amrex::Real z) const noexcept
Definition: ElectrostaticSolver.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real operator()(const amrex::Real x, const amrex::Real z) const noexcept
Definition: ElectrostaticSolver.H:27