ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_EB.H
Go to the documentation of this file.
1 #ifndef ERF_EB_H_
2 #define ERF_EB_H_
3 
4 #include <AMReX_Geometry.H>
5 #include <AMReX_DistributionMapping.H>
6 #include <AMReX_BoxArray.H>
7 
8 #include <AMReX_EB2.H>
9 #include <AMReX_EBFabFactory.H>
10 
11 #include <ERF_EBAux.H>
12 
13 class eb_ {
14 
15  public:
16 
17  ~eb_ ();
18 
19  eb_ (amrex::Geometry const& a_geom,
20  amrex::FArrayBox const& terrain_fab,
21  amrex::Gpu::DeviceVector<amrex::Real>& a_dz_stretched,
22  bool is_anelastic);
23  eb_ ();
24 
25  void define (int level,
26  amrex::Geometry const& a_geom,
27  amrex::EB2::Level const* a_eb_level,
28  bool is_anelastic);
29 
30  void make_all_factories ( int level,
31  amrex::Geometry const& a_geom,
32  amrex::BoxArray const& ba,
33  amrex::DistributionMapping const& dm,
34  amrex::EB2::Level const& a_eb_level);
35 
36  void make_cc_factory ( int level,
37  amrex::Geometry const& a_geom,
38  amrex::BoxArray const& ba,
39  amrex::DistributionMapping const& dm,
40  amrex::EB2::Level const& a_eb_level);
41 
42  int nghost_basic () const { return 5; } // nghost_eb_basic ()
43  int nghost_volume () const { return 5; } // nghost_eb_volume ()
44  int nghost_full () const { return 4; } // nghost_eb_full ()
45 
46  const std::unique_ptr<amrex::EBFArrayBoxFactory>& get_const_factory () const noexcept { return m_factory; }
47 
48  void set_connection_flags ();
49 
50  void WriteEBSurface (const amrex::BoxArray & ba,
51  const amrex::DistributionMapping & dmap,
52  const amrex::Geometry & geom,
53  const amrex::EBFArrayBoxFactory * ebf,
54  const int level);
55 
56  eb_aux_ const* get_u_const_factory() const noexcept { return &m_u_factory; }
57  eb_aux_ const* get_v_const_factory() const noexcept { return &m_v_factory; }
58  eb_aux_ const* get_w_const_factory() const noexcept { return &m_w_factory; }
59 
60  class EBToPVD;
61 
62  private:
63 
64  int m_has_eb;
65  std::string m_type;
66 
67  amrex::EBSupport m_support_level;
68 
70 
71  amrex::FabArray<amrex::EBCellFlagFab>* m_cellflags = nullptr;
72 
73  //! EB level constructed from building GeometryShop
74  amrex::EB2::Level const* m_eb_level;
75 
76  std::unique_ptr<amrex::EBFArrayBoxFactory> m_factory = nullptr;
77 
81 
82  void make_box (amrex::Geometry const& a_geom);
83  void make_terrain (amrex::Geometry const& a_geom);
84 
85  //! Construct EB levels from Geometry shop.
86  template<class F>
87  void build_level (amrex::Geometry const& a_geom,
88  amrex::EB2::GeometryShop<F> a_gshop)
89  {
90  int const req_lev(0);
91  int const max_lev(2);
92 
93  amrex::EB2::Build(a_gshop, a_geom, req_lev, max_lev);
94  const amrex::EB2::IndexSpace& ebis = amrex::EB2::IndexSpace::top();
95  m_eb_level = &(ebis.getLevel(a_geom));
96  }
97 
98  // Wrapper to get non-const version of EBCellFlagFab using const_cast
99  inline amrex::FabArray<amrex::EBCellFlagFab>&
100  getNonConstEBCellFlags(const amrex::EBFArrayBoxFactory& ebfact)
101  {
102  const amrex::FabArray<amrex::EBCellFlagFab>& flags_const = ebfact.getMultiEBCellFlagFab();
103  return const_cast<amrex::FabArray<amrex::EBCellFlagFab>&>(flags_const);
104  }
105 
106 };
107 #endif
Definition: ERF_EB.H:13
amrex::FabArray< amrex::EBCellFlagFab > & getNonConstEBCellFlags(const amrex::EBFArrayBoxFactory &ebfact)
Definition: ERF_EB.H:100
eb_()
Definition: ERF_EB.cpp:26
void define(int level, amrex::Geometry const &a_geom, amrex::EB2::Level const *a_eb_level, bool is_anelastic)
void make_terrain(amrex::Geometry const &a_geom)
eb_aux_ const * get_w_const_factory() const noexcept
Definition: ERF_EB.H:58
void build_level(amrex::Geometry const &a_geom, amrex::EB2::GeometryShop< F > a_gshop)
Construct EB levels from Geometry shop.
Definition: ERF_EB.H:87
void WriteEBSurface(const amrex::BoxArray &ba, const amrex::DistributionMapping &dmap, const amrex::Geometry &geom, const amrex::EBFArrayBoxFactory *ebf, const int level)
Definition: ERF_EB.cpp:136
amrex::EB2::Level const * m_eb_level
EB level constructed from building GeometryShop.
Definition: ERF_EB.H:74
void make_all_factories(int level, amrex::Geometry const &a_geom, amrex::BoxArray const &ba, amrex::DistributionMapping const &dm, amrex::EB2::Level const &a_eb_level)
Definition: ERF_EB.cpp:33
amrex::FabArray< amrex::EBCellFlagFab > * m_cellflags
Definition: ERF_EB.H:71
const std::unique_ptr< amrex::EBFArrayBoxFactory > & get_const_factory() const noexcept
Definition: ERF_EB.H:46
eb_aux_ m_w_factory
Definition: ERF_EB.H:80
std::unique_ptr< amrex::EBFArrayBoxFactory > m_factory
Definition: ERF_EB.H:76
amrex::EBSupport m_support_level
Definition: ERF_EB.H:67
int nghost_volume() const
Definition: ERF_EB.H:43
void make_cc_factory(int level, amrex::Geometry const &a_geom, amrex::BoxArray const &ba, amrex::DistributionMapping const &dm, amrex::EB2::Level const &a_eb_level)
Definition: ERF_EB.cpp:77
eb_aux_ m_u_factory
Definition: ERF_EB.H:78
~eb_()
Definition: ERF_EB.cpp:21
eb_(amrex::Geometry const &a_geom, amrex::FArrayBox const &terrain_fab, amrex::Gpu::DeviceVector< amrex::Real > &a_dz_stretched, bool is_anelastic)
eb_aux_ const * get_v_const_factory() const noexcept
Definition: ERF_EB.H:57
eb_aux_ m_v_factory
Definition: ERF_EB.H:79
int m_has_eb
Definition: ERF_EB.H:60
int nghost_full() const
Definition: ERF_EB.H:44
int nghost_basic() const
Definition: ERF_EB.H:42
int m_write_eb_surface
Definition: ERF_EB.H:69
void make_box(amrex::Geometry const &a_geom)
Definition: ERF_EBBox.cpp:22
eb_aux_ const * get_u_const_factory() const noexcept
Definition: ERF_EB.H:56
std::string m_type
Definition: ERF_EB.H:65
void set_connection_flags()
Definition: ERF_EB.cpp:99
Definition: ERF_EBAux.H:12