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