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  /**
33  * \brief Define face-centered EB geometry for one staggered direction.
34  *
35  * May be called more than once on the same object -- ERF::RemakeLevel and
36  * MakeNewLevelFromCoarse both redefine the factories of an existing level.
37  * Each call replaces the previously owned geometry, which is freed on
38  * reassignment of the owning unique_ptr.
39  * \param a_level AMR level index.
40  * \param a_idim Staggered direction for the target velocity grid.
41  * \param a_geom Cell-centered level geometry.
42  * \param a_grids Cell-centered grid boxes.
43  * \param a_dmap Distribution mapping for the grids.
44  * \param a_ngrow Ghost-cell counts for flags, volumes, and centroids.
45  * \param a_factory Source cell-centered EB factory.
46  */
47  void define ( int const& a_level,
48  int const& a_idim,
49  amrex::Geometry const& a_geom,
50  amrex::BoxArray const& a_grids,
51  amrex::DistributionMapping const& a_dmap,
52  amrex::Vector<int> const& a_ngrow,
53  amrex::EBFArrayBoxFactory const* a_factory);
54 
55  //! Enable verbose diagnostic output during factory construction.
56  void set_verbose ( ) { m_verbose = 1; }
57 
58  //! Return the reconstructed EB cell flags.
59  [[nodiscard]] const amrex::FabArray<amrex::EBCellFlagFab>& getMultiEBCellFlagFab () const;
60  //! Return the reconstructed volume fractions.
61  [[nodiscard]] const amrex::MultiFab& getVolFrac () const;
62  //! Return the reconstructed volume centroids.
63  [[nodiscard]] const amrex::MultiFab& getCentroid () const;
64  //! Return the reconstructed EB boundary areas.
65  [[nodiscard]] const amrex::MultiFab& getBndryArea () const;
66  //! Return the reconstructed EB boundary centroids.
67  [[nodiscard]] const amrex::MultiFab& getBndryCent () const;
68  //! Return the reconstructed EB boundary normals.
69  [[nodiscard]] const amrex::MultiFab& getBndryNormal () const;
70 
71  //! Return reconstructed area fractions for all coordinate directions.
72  [[nodiscard]] amrex::Array<const amrex::MultiFab*, AMREX_SPACEDIM> getAreaFrac () const;
73  //! Return reconstructed face centroids for all coordinate directions.
74  [[nodiscard]] amrex::Array<const amrex::MultiFab*, AMREX_SPACEDIM> getFaceCent () const;
75 
76  private:
77 
78  int m_verbose;
79 
80  // int m_defined;
81 
82  // These own the geometry they point at. define() may be called repeatedly on the
83  // same object, so ownership has to be explicit: assigning a new unique_ptr frees
84  // whatever the previous define() allocated.
85  std::unique_ptr<amrex::FabArray<amrex::EBCellFlagFab>> m_cellflags;
86  std::unique_ptr<amrex::MultiFab> m_volfrac;
87  std::unique_ptr<amrex::MultiFab> m_volcent;
88  std::unique_ptr<amrex::MultiFab> m_bndryarea;
89  std::unique_ptr<amrex::MultiFab> m_bndrycent;
90  std::unique_ptr<amrex::MultiFab> m_bndrynorm;
91 
92  amrex::Array<std::unique_ptr<amrex::MultiFab>,AMREX_SPACEDIM> m_areafrac;
93  amrex::Array<std::unique_ptr<amrex::MultiFab>,AMREX_SPACEDIM> m_facecent;
94  // amrex::Array<std::unique_ptr<amrex::MultiCutFab>,AMREX_SPACEDIM> m_edgecent;
95 
96 };
97 
98 #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:1173
amrex::Array< const amrex::MultiFab *, AMREX_SPACEDIM > getAreaFrac() const
Return reconstructed area fractions for all coordinate directions.
Definition: ERF_EBAux.cpp:1187
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:92
amrex::Array< const amrex::MultiFab *, AMREX_SPACEDIM > getFaceCent() const
Return reconstructed face centroids for all coordinate directions.
Definition: ERF_EBAux.cpp:1194
~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:90
const amrex::MultiFab & getBndryNormal() const
Return the reconstructed EB boundary normals.
Definition: ERF_EBAux.cpp:1180
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:56
std::unique_ptr< amrex::MultiFab > m_bndrycent
Definition: ERF_EBAux.H:89
std::unique_ptr< amrex::FabArray< amrex::EBCellFlagFab > > m_cellflags
Definition: ERF_EBAux.H:85
int m_verbose
Definition: ERF_EBAux.H:78
const amrex::MultiFab & getVolFrac() const
Return the reconstructed volume fractions.
Definition: ERF_EBAux.cpp:1152
std::unique_ptr< amrex::MultiFab > m_bndryarea
Definition: ERF_EBAux.H:88
amrex::Array< std::unique_ptr< amrex::MultiFab >, AMREX_SPACEDIM > m_facecent
Definition: ERF_EBAux.H:93
const amrex::MultiFab & getBndryArea() const
Return the reconstructed EB boundary areas.
Definition: ERF_EBAux.cpp:1166
const amrex::FabArray< amrex::EBCellFlagFab > & getMultiEBCellFlagFab() const
Return the reconstructed EB cell flags.
Definition: ERF_EBAux.cpp:1145
std::unique_ptr< amrex::MultiFab > m_volcent
Definition: ERF_EBAux.H:87
const amrex::MultiFab & getCentroid() const
Return the reconstructed volume centroids.
Definition: ERF_EBAux.cpp:1159
std::unique_ptr< amrex::MultiFab > m_volfrac
Definition: ERF_EBAux.H:86