ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_EBAux.H
Go to the documentation of this file.
1 /**
2  * \file ERF_EBAux.H
3  * \brief Declares auxiliary EB factories for face-centered data.
4  */
5 #ifndef ERF_EB_AUX_H_
6 #define ERF_EB_AUX_H_
7 
8 #include <memory>
9 
10 #include <AMReX_Geometry.H>
11 #include <AMReX_DistributionMapping.H>
12 #include <AMReX_BoxArray.H>
13 
14 #include <AMReX_EB2.H>
15 #include <AMReX_EBFabFactory.H>
16 
17 /**
18  * \brief Stores face-centered EB geometry reconstructed from a cell-centered factory.
19  *
20  * This class mirrors the subset of the AMReX EB factory interface needed by ERF
21  * staggered momentum fields when native face-centered EB factories are disabled.
22  */
23 class eb_aux_
24 {
25  public:
26 
27  //! Construct an undefined auxiliary EB factory.
28  eb_aux_ ();
29  //! Destroy the auxiliary EB factory; the owned geometry is released by its unique_ptrs.
30  ~eb_aux_ () = default;
31 
32  //! Release the geometry of the last define(), as for a level that no longer exists.
33  void clear ();
34 
35  /**
36  * \brief Define face-centered EB geometry for one staggered direction.
37  *
38  * May be called more than once on the same object -- ERF::RemakeLevel and
39  * MakeNewLevelFromCoarse both redefine the factories of an existing level.
40  * Each call replaces the previously owned geometry, which is freed on
41  * reassignment of the owning unique_ptr.
42  * \param a_level AMR level index.
43  * \param a_idim Staggered direction for the target velocity grid.
44  * \param a_geom Cell-centered level geometry.
45  * \param a_grids Cell-centered grid boxes.
46  * \param a_dmap Distribution mapping for the grids.
47  * \param a_ngrow Ghost-cell counts for flags, volumes, and centroids.
48  * \param a_factory Source cell-centered EB factory.
49  */
50  void define ( int const& a_level,
51  int const& a_idim,
52  amrex::Geometry const& a_geom,
53  amrex::BoxArray const& a_grids,
54  amrex::DistributionMapping const& a_dmap,
55  amrex::Vector<int> const& a_ngrow,
56  amrex::EBFArrayBoxFactory const* a_factory);
57 
58  //! Enable verbose diagnostic output during factory construction.
59  void set_verbose ( ) { m_verbose = 1; }
60 
61  //! Return the reconstructed EB cell flags.
62  [[nodiscard]] const amrex::FabArray<amrex::EBCellFlagFab>& getMultiEBCellFlagFab () const;
63  //! Return the reconstructed volume fractions.
64  [[nodiscard]] const amrex::MultiFab& getVolFrac () const;
65  //! Return the reconstructed volume centroids.
66  [[nodiscard]] const amrex::MultiFab& getCentroid () const;
67  //! Return the reconstructed EB boundary areas.
68  [[nodiscard]] const amrex::MultiFab& getBndryArea () const;
69  //! Return the reconstructed EB boundary centroids.
70  [[nodiscard]] const amrex::MultiFab& getBndryCent () const;
71  //! Return the reconstructed EB boundary normals.
72  [[nodiscard]] const amrex::MultiFab& getBndryNormal () const;
73 
74  //! Return reconstructed area fractions for all coordinate directions.
75  [[nodiscard]] amrex::Array<const amrex::MultiFab*, AMREX_SPACEDIM> getAreaFrac () const;
76  //! Return reconstructed face centroids for all coordinate directions.
77  [[nodiscard]] amrex::Array<const amrex::MultiFab*, AMREX_SPACEDIM> getFaceCent () const;
78 
79  private:
80 
81  int m_verbose;
82 
83  // int m_defined;
84 
85  // These own the geometry they point at. define() may be called repeatedly on the
86  // same object, so ownership has to be explicit: assigning a new unique_ptr frees
87  // whatever the previous define() allocated.
88  std::unique_ptr<amrex::FabArray<amrex::EBCellFlagFab>> m_cellflags;
89  std::unique_ptr<amrex::MultiFab> m_volfrac;
90  std::unique_ptr<amrex::MultiFab> m_volcent;
91  std::unique_ptr<amrex::MultiFab> m_bndryarea;
92  std::unique_ptr<amrex::MultiFab> m_bndrycent;
93  std::unique_ptr<amrex::MultiFab> m_bndrynorm;
94 
95  amrex::Array<std::unique_ptr<amrex::MultiFab>,AMREX_SPACEDIM> m_areafrac;
96  amrex::Array<std::unique_ptr<amrex::MultiFab>,AMREX_SPACEDIM> m_facecent;
97  // amrex::Array<std::unique_ptr<amrex::MultiCutFab>,AMREX_SPACEDIM> m_edgecent;
98 
99 };
100 
101 #endif
Stores face-centered EB geometry reconstructed from a cell-centered factory.
Definition: ERF_EBAux.H:24
const amrex::MultiFab & getBndryCent() const
Return the reconstructed EB boundary centroids.
Definition: ERF_EBAux.cpp:1189
amrex::Array< const amrex::MultiFab *, AMREX_SPACEDIM > getAreaFrac() const
Return reconstructed area fractions for all coordinate directions.
Definition: ERF_EBAux.cpp:1203
eb_aux_()
Construct an undefined auxiliary EB factory.
Definition: ERF_EBAux.cpp:17
amrex::Array< std::unique_ptr< amrex::MultiFab >, AMREX_SPACEDIM > m_areafrac
Definition: ERF_EBAux.H:95
amrex::Array< const amrex::MultiFab *, AMREX_SPACEDIM > getFaceCent() const
Return reconstructed face centroids for all coordinate directions.
Definition: ERF_EBAux.cpp:1210
~eb_aux_()=default
Destroy the auxiliary EB factory; the owned geometry is released by its unique_ptrs.
std::unique_ptr< amrex::MultiFab > m_bndrynorm
Definition: ERF_EBAux.H:93
const amrex::MultiFab & getBndryNormal() const
Return the reconstructed EB boundary normals.
Definition: ERF_EBAux.cpp:1196
void define(int const &a_level, int const &a_idim, amrex::Geometry const &a_geom, amrex::BoxArray const &a_grids, amrex::DistributionMapping const &a_dmap, amrex::Vector< int > const &a_ngrow, amrex::EBFArrayBoxFactory const *a_factory)
Define face-centered EB geometry for one staggered direction.
Definition: ERF_EBAux.cpp:24
void set_verbose()
Enable verbose diagnostic output during factory construction.
Definition: ERF_EBAux.H:59
std::unique_ptr< amrex::MultiFab > m_bndrycent
Definition: ERF_EBAux.H:92
std::unique_ptr< amrex::FabArray< amrex::EBCellFlagFab > > m_cellflags
Definition: ERF_EBAux.H:88
int m_verbose
Definition: ERF_EBAux.H:81
const amrex::MultiFab & getVolFrac() const
Return the reconstructed volume fractions.
Definition: ERF_EBAux.cpp:1168
std::unique_ptr< amrex::MultiFab > m_bndryarea
Definition: ERF_EBAux.H:91
amrex::Array< std::unique_ptr< amrex::MultiFab >, AMREX_SPACEDIM > m_facecent
Definition: ERF_EBAux.H:96
const amrex::MultiFab & getBndryArea() const
Return the reconstructed EB boundary areas.
Definition: ERF_EBAux.cpp:1182
const amrex::FabArray< amrex::EBCellFlagFab > & getMultiEBCellFlagFab() const
Return the reconstructed EB cell flags.
Definition: ERF_EBAux.cpp:1161
std::unique_ptr< amrex::MultiFab > m_volcent
Definition: ERF_EBAux.H:90
const amrex::MultiFab & getCentroid() const
Return the reconstructed volume centroids.
Definition: ERF_EBAux.cpp:1175
std::unique_ptr< amrex::MultiFab > m_volfrac
Definition: ERF_EBAux.H:89
void clear()
Release the geometry of the last define(), as for a level that no longer exists.
Definition: ERF_EBAux.cpp:1146