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