Alamo
IC.H
Go to the documentation of this file.
1 //
2 // Initial condition (IC) objects are used to set fields to specified values,
3 // through mathematical expressions, images, etc.
4 // They are often used as initial conditions, but may be used generally to
5 // incorporate static or time-dependent values.
6 // All IC methods inherit from the base IC class, and are implemented by
7 // overriding the "Add" method.
8 // (Initialize uses Add after setting the field to zero.)
9 //
10 #ifndef IC_IC_H_
11 #define IC_IC_H_
12 
13 #include <AMReX.H>
14 #include <AMReX_MultiFab.H>
15 #include "Util/Util.H"
16 #include "Set/Set.H"
17 
18 namespace IC
19 {
20 /// \brief Pure abstract IC object from which all other IC objects inherit.
21 class IC
22 {
23 public:
24  IC (amrex::Vector<amrex::Geometry> &_geom)
25  : geom(_geom) {} ;
26  virtual ~IC() {}
27 
28  virtual void Add(const int &lev, Set::Field<Set::Scalar> &field, Set::Scalar time) = 0;
29  virtual void Add(const int &lev, Set::Field<Set::Scalar> &field)
30  {
31  Add(lev,field,0.0);
32  }
33  virtual void Add(const int &, Set::Field<Set::Vector> &, Set::Scalar)
34  {Util::Abort(INFO,"Not yet implemented");};
35  void Initialize(const int &a_lev,
36  Set::Field<Set::Scalar> &a_field,
37  Set::Scalar a_time = 0.0)
38  {
39  Util::Assert(INFO,TEST(a_lev < a_field.size())," a_lev=",a_lev," size=",a_field.size());
40  a_field[a_lev]->setVal(0.0);
41  Add(a_lev,a_field,a_time);
42  };
43  void Initialize(const int &a_lev,
44  Set::Field<Set::Vector> &a_field,
45  Set::Scalar a_time = 0.0)
46  {
47  Util::Assert(INFO,TEST(a_lev < a_field.size())," a_lev=",a_lev," size=",a_field.size());
48  a_field[a_lev]->setVal(Set::Vector::Zero());
49  Add(a_lev,a_field,a_time);
50  };
51 
52  virtual void SetComp(int a_comp) final {comp = a_comp;}
53 protected:
54  amrex::Vector<amrex::Geometry> &geom;
55  int comp = 0;
56 };
57 }
58 #endif
IC::IC::Add
virtual void Add(const int &lev, Set::Field< Set::Scalar > &field)
Definition: IC.H:29
IC::IC::geom
amrex::Vector< amrex::Geometry > & geom
Definition: IC.H:54
IC::IC::Initialize
void Initialize(const int &a_lev, Set::Field< Set::Scalar > &a_field, Set::Scalar a_time=0.0)
Definition: IC.H:35
Util.H
IC::IC::~IC
virtual ~IC()
Definition: IC.H:26
TEST
#define TEST(x)
Definition: Util.H:21
IC::IC::IC
IC(amrex::Vector< amrex::Geometry > &_geom)
Definition: IC.H:24
Set::Field< Set::Scalar >
Definition: Set.H:236
Set::Scalar
amrex::Real Scalar
Definition: Base.H:19
IC::IC::Add
virtual void Add(const int &, Set::Field< Set::Vector > &, Set::Scalar)
Definition: IC.H:33
IC::IC::Initialize
void Initialize(const int &a_lev, Set::Field< Set::Vector > &a_field, Set::Scalar a_time=0.0)
Definition: IC.H:43
Util::Assert
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
Definition: Util.H:67
Util::Abort
void Abort(const char *msg)
Definition: Util.cpp:166
Set.H
IC
Definition: BMP.H:18
INFO
#define INFO
Definition: Util.H:20
IC::IC::SetComp
virtual void SetComp(int a_comp) final
Definition: IC.H:52
Set::Field< Set::Vector >