ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
eb_ Class Reference

Owns and exposes cell-centered and face-centered EB factories. More...

#include <ERF_EB.H>

Collaboration diagram for eb_:

Public Member Functions

 ~eb_ ()
 Destroy the EB factory manager. More...
 
 eb_ (amrex::Geometry const &a_geom, amrex::FArrayBox const &terrain_fab, amrex::Gpu::DeviceVector< amrex::Real > &a_dz_stretched, bool is_anelastic)
 Construct an EB description from terrain data. More...
 
 eb_ ()
 Construct an empty EB factory manager. More...
 
void define (int level, amrex::Geometry const &a_geom, amrex::EB2::Level const *a_eb_level, bool is_anelastic)
 Define the EB level metadata used by this factory manager. More...
 
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)
 Build cell-centered and staggered EB factories for the level. More...
 
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)
 Build only the cell-centered EB factory for the level. More...
 
int nghost_basic () const
 Number of ghost cells needed for basic EB flags. More...
 
int nghost_volume () const
 Number of ghost cells needed for EB volume data. More...
 
int nghost_full () const
 Number of ghost cells needed for full EB geometric data. More...
 
const std::unique_ptr< amrex::EBFArrayBoxFactory > & get_const_factory () const noexcept
 Return the cell-centered EB factory. More...
 
void set_connection_flags (amrex::EBFArrayBoxFactory *factory)
 Disconnect covered neighbors in an EB factory's cell flags. More...
 
eb_aux_ const * get_u_const_factory () const noexcept
 Return the ERF auxiliary x-face EB factory. More...
 
eb_aux_ const * get_v_const_factory () const noexcept
 Return the ERF auxiliary y-face EB factory. More...
 
eb_aux_ const * get_w_const_factory () const noexcept
 Return the ERF auxiliary z-face EB factory. More...
 

Private Member Functions

void make_terrain (amrex::Geometry const &a_geom)
 Build terrain EB geometry for the supplied Geometry. More...
 
template<class F >
void build_level (amrex::Geometry const &a_geom, amrex::EB2::GeometryShop< F > a_gshop)
 Construct EB levels from an AMReX GeometryShop. More...
 
amrex::FabArray< amrex::EBCellFlagFab > & getNonConstEBCellFlags (const amrex::EBFArrayBoxFactory &ebfact)
 Return mutable EB cell flags from an AMReX factory. More...
 
amrex::MultiFab & getNonConstVolFrac (const amrex::EBFArrayBoxFactory &ebfact)
 Return mutable volume fractions from an AMReX factory. More...
 
amrex::MultiCutFab & getNonConstCentroid (const amrex::EBFArrayBoxFactory &ebfact)
 Return mutable cell centroids from an AMReX factory. More...
 
amrex::Array< amrex::MultiCutFab *, AMREX_SPACEDIM > getNonConstAreaFrac (const amrex::EBFArrayBoxFactory &ebfact)
 Return mutable area-fraction arrays from an AMReX factory. More...
 
amrex::Array< amrex::MultiCutFab *, AMREX_SPACEDIM > getNonConstFaceCent (const amrex::EBFArrayBoxFactory &ebfact)
 Return mutable face-centroid arrays from an AMReX factory. More...
 

Private Attributes

int m_has_eb
 
std::string m_type
 
amrex::EBSupport m_support_level
 
int m_write_eb_surface
 
amrex::FabArray< amrex::EBCellFlagFab > * m_cellflags = nullptr
 
amrex::EB2::Level const * m_eb_level
 EB level constructed from building GeometryShop. More...
 
std::unique_ptr< amrex::EBFArrayBoxFactory > m_factory = nullptr
 
eb_aux_ m_u_factory
 
eb_aux_ m_v_factory
 
eb_aux_ m_w_factory
 
std::unique_ptr< amrex::EBFArrayBoxFactory > m_u_factory_fc = nullptr
 
std::unique_ptr< amrex::EBFArrayBoxFactory > m_v_factory_fc = nullptr
 
std::unique_ptr< amrex::EBFArrayBoxFactory > m_w_factory_fc = nullptr
 

Detailed Description

Owns and exposes cell-centered and face-centered EB factories.

The class builds AMReX EB factories for cell-centered state data and, depending on USE_FC_FACTORY, either native AMReX or ERF auxiliary factories for staggered velocity components.

Constructor & Destructor Documentation

◆ ~eb_()

eb_::~eb_ ( )

Destroy the EB factory manager.

26 {
27  // if (m_factory) { m_factory.reset(nullptr); }
28 }

◆ eb_() [1/2]

eb_::eb_ ( amrex::Geometry const &  a_geom,
amrex::FArrayBox const &  terrain_fab,
amrex::Gpu::DeviceVector< amrex::Real > &  a_dz_stretched,
bool  is_anelastic 
)

Construct an EB description from terrain data.

Parameters
a_geomGeometry used to place the terrain EB.
terrain_fabTerrain height data.
a_dz_stretchedDevice vector containing stretched vertical spacing.
is_anelasticWhether the owning level is using anelastic dynamics.

◆ eb_() [2/2]

eb_::eb_ ( )

Construct an empty EB factory manager.

31  : m_has_eb(0),
32  m_support_level(EBSupport::full),
34 { }
amrex::EBSupport m_support_level
Definition: ERF_EB.H:134
int m_has_eb
Definition: ERF_EB.H:127
int m_write_eb_surface
Definition: ERF_EB.H:136

Member Function Documentation

◆ build_level()

template<class F >
void eb_::build_level ( amrex::Geometry const &  a_geom,
amrex::EB2::GeometryShop< F >  a_gshop 
)
inlineprivate

Construct EB levels from an AMReX GeometryShop.

Template Parameters
FImplicit-function type stored by the GeometryShop.
Parameters
a_geomGeometry used to build the EB index space.
a_gshopGeometryShop describing the implicit EB.
170  {
171  int const req_lev(0);
172  int const max_lev(2);
173 
174  amrex::EB2::Build(a_gshop, a_geom, req_lev, max_lev);
175  const amrex::EB2::IndexSpace& ebis = amrex::EB2::IndexSpace::top();
176  m_eb_level = &(ebis.getLevel(a_geom));
177  }
amrex::EB2::Level const * m_eb_level
EB level constructed from building GeometryShop.
Definition: ERF_EB.H:141

◆ define()

void eb_::define ( int  level,
amrex::Geometry const &  a_geom,
amrex::EB2::Level const *  a_eb_level,
bool  is_anelastic 
)

Define the EB level metadata used by this factory manager.

Parameters
levelAMR level index.
a_geomGeometry for the level.
a_eb_levelAMReX EB level owned by the global EB index space.
is_anelasticWhether the owning level is using anelastic dynamics.

◆ get_const_factory()

const std::unique_ptr<amrex::EBFArrayBoxFactory>& eb_::get_const_factory ( ) const
inlinenoexcept

Return the cell-centered EB factory.

102 { return m_factory; }
std::unique_ptr< amrex::EBFArrayBoxFactory > m_factory
Definition: ERF_EB.H:143

Referenced by compute_gradp_xy(), compute_gradp_z(), ComputeTurbulentViscosityLES_EB(), erf_make_tau_terms(), erf_slow_rhs_pre(), ERF::estTimeStep(), and make_buoyancy().

Here is the caller graph for this function:

◆ get_u_const_factory()

eb_aux_ const* eb_::get_u_const_factory ( ) const
inlinenoexcept

Return the ERF auxiliary x-face EB factory.

119 { return &m_u_factory; }
eb_aux_ m_u_factory
Definition: ERF_EB.H:146

Referenced by AdvectionSrcForMom_EB(), compute_gradp_xy(), ComputeStrain_EB(), ComputeTurbulentViscosityLES_EB(), DiffusionSrcForMom_EB(), and make_mom_sources().

Here is the caller graph for this function:

◆ get_v_const_factory()

eb_aux_ const* eb_::get_v_const_factory ( ) const
inlinenoexcept

Return the ERF auxiliary y-face EB factory.

121 { return &m_v_factory; }
eb_aux_ m_v_factory
Definition: ERF_EB.H:147

Referenced by AdvectionSrcForMom_EB(), compute_gradp_xy(), ComputeStrain_EB(), ComputeTurbulentViscosityLES_EB(), DiffusionSrcForMom_EB(), and make_mom_sources().

Here is the caller graph for this function:

◆ get_w_const_factory()

eb_aux_ const* eb_::get_w_const_factory ( ) const
inlinenoexcept

Return the ERF auxiliary z-face EB factory.

123 { return &m_w_factory; }
eb_aux_ m_w_factory
Definition: ERF_EB.H:148

Referenced by AdvectionSrcForMom_EB(), compute_gradp_z(), ComputeStrain_EB(), ComputeTurbulentViscosityLES_EB(), DiffusionSrcForMom_EB(), and make_mom_sources().

Here is the caller graph for this function:

◆ getNonConstAreaFrac()

amrex::Array<amrex::MultiCutFab*, AMREX_SPACEDIM> eb_::getNonConstAreaFrac ( const amrex::EBFArrayBoxFactory &  ebfact)
inlineprivate

Return mutable area-fraction arrays from an AMReX factory.

206  {
207  auto afrac_const = ebfact.getAreaFrac();
208  amrex::Array<amrex::MultiCutFab*, AMREX_SPACEDIM> afrac;
209  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
210  afrac[dir] = const_cast<amrex::MultiCutFab*>(afrac_const[dir]);
211  }
212  return afrac;
213  }

◆ getNonConstCentroid()

amrex::MultiCutFab& eb_::getNonConstCentroid ( const amrex::EBFArrayBoxFactory &  ebfact)
inlineprivate

Return mutable cell centroids from an AMReX factory.

198  {
199  const amrex::MultiCutFab& vcent_const = ebfact.getCentroid();
200  return const_cast<amrex::MultiCutFab&>(vcent_const);
201  }

◆ getNonConstEBCellFlags()

amrex::FabArray<amrex::EBCellFlagFab>& eb_::getNonConstEBCellFlags ( const amrex::EBFArrayBoxFactory &  ebfact)
inlineprivate

Return mutable EB cell flags from an AMReX factory.

182  {
183  const amrex::FabArray<amrex::EBCellFlagFab>& flags_const = ebfact.getMultiEBCellFlagFab();
184  return const_cast<amrex::FabArray<amrex::EBCellFlagFab>&>(flags_const);
185  }

Referenced by set_connection_flags().

Here is the caller graph for this function:

◆ getNonConstFaceCent()

amrex::Array<amrex::MultiCutFab*, AMREX_SPACEDIM> eb_::getNonConstFaceCent ( const amrex::EBFArrayBoxFactory &  ebfact)
inlineprivate

Return mutable face-centroid arrays from an AMReX factory.

218  {
219  auto fcent_const = ebfact.getFaceCent();
220  amrex::Array<amrex::MultiCutFab*, AMREX_SPACEDIM> fcent;
221  for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
222  fcent[dir] = const_cast<amrex::MultiCutFab*>(fcent_const[dir]);
223  }
224  return fcent;
225  }

◆ getNonConstVolFrac()

amrex::MultiFab& eb_::getNonConstVolFrac ( const amrex::EBFArrayBoxFactory &  ebfact)
inlineprivate

Return mutable volume fractions from an AMReX factory.

190  {
191  const amrex::MultiFab& vfrac_const = ebfact.getVolFrac();
192  return const_cast<amrex::MultiFab&>(vfrac_const);
193  }

◆ make_all_factories()

void eb_::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 
)

Build cell-centered and staggered EB factories for the level.

Parameters
levelAMR level index.
a_geomGeometry for the level.
baBoxArray over which factories are defined.
dmDistributionMapping for the BoxArray.
a_eb_levelAMReX EB level used to populate factory data.
42 {
43  Print() << "making EB factory\n";
44  m_factory = std::make_unique<EBFArrayBoxFactory>(a_eb_level, a_geom, ba, dm,
46 
47  // Correct cell connectivity
49 
50 #if USE_FC_FACTORY
51  // New: Native AMReX FC factories (EB2::BuildFC called in ERF.cpp)
52  { int const idim(0);
53  Print() << "making EB staggered u-factory\n";
54  m_u_factory_fc = std::make_unique<EBFArrayBoxFactory>(
55  a_eb_level, a_geom, ba, dm,
56  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
57  m_support_level, idim);
59  }
60 
61  { int const idim(1);
62  Print() << "making EB staggered v-factory\n";
63  m_v_factory_fc = std::make_unique<EBFArrayBoxFactory>(
64  a_eb_level, a_geom, ba, dm,
65  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
66  m_support_level, idim);
68  }
69 
70  { int const idim(2);
71  Print() << "making EB staggered w-factory\n";
72  m_w_factory_fc = std::make_unique<EBFArrayBoxFactory>(
73  a_eb_level, a_geom, ba, dm,
74  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
75  m_support_level, idim);
77  }
78 #else
79  // Original: eb_aux_ factories
80  { int const idim(0);
81  Print() << "making EB staggered u-factory\n";
82  m_u_factory.define(level, idim, a_geom, ba, dm,
83  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
84  m_factory.get());
85  }
86 
87  { int const idim(1);
88  Print() << "making EB staggered v-factory\n";
89  m_v_factory.define(level, idim, a_geom, ba, dm,
90  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
91  m_factory.get());
92  }
93 
94  { int const idim(2);
95  Print() << "making EB staggered w-factory\n";
96  m_w_factory.define(level, idim, a_geom, ba, dm,
97  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()},
98  m_factory.get());
99  }
100 #endif
101  Print() << "\nDone making EB factory at level = " << level << ".\n\n";
102 }
int nghost_volume() const
Number of ghost cells needed for EB volume data.
Definition: ERF_EB.H:88
std::unique_ptr< amrex::EBFArrayBoxFactory > m_w_factory_fc
Definition: ERF_EB.H:153
std::unique_ptr< amrex::EBFArrayBoxFactory > m_v_factory_fc
Definition: ERF_EB.H:152
int nghost_full() const
Number of ghost cells needed for full EB geometric data.
Definition: ERF_EB.H:90
int nghost_basic() const
Number of ghost cells needed for basic EB flags.
Definition: ERF_EB.H:86
std::unique_ptr< amrex::EBFArrayBoxFactory > m_u_factory_fc
Definition: ERF_EB.H:151
void set_connection_flags(amrex::EBFArrayBoxFactory *factory)
Disconnect covered neighbors in an EB factory's cell flags.
Definition: ERF_EB.cpp:124
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:29
Here is the call graph for this function:

◆ make_cc_factory()

void eb_::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 
)

Build only the cell-centered EB factory for the level.

Parameters
levelAMR level index.
a_geomGeometry for the level.
baBoxArray over which the factory is defined.
dmDistributionMapping for the BoxArray.
a_eb_levelAMReX EB level used to populate factory data.
110 {
111  Print() << "making EB factory\n";
112  m_factory = std::make_unique<EBFArrayBoxFactory>(a_eb_level, a_geom, ba, dm,
113  Vector<int>{nghost_basic(), nghost_volume(), nghost_full()}, m_support_level);
114 
115  Print() << "\nDone making EB factory at level " << level << ".\n\n";
116 }
Here is the call graph for this function:

◆ make_terrain()

void eb_::make_terrain ( amrex::Geometry const &  a_geom)
private

Build terrain EB geometry for the supplied Geometry.

Parameters
a_geomGeometry used to define the EB index space.

◆ nghost_basic()

int eb_::nghost_basic ( ) const
inline

Number of ghost cells needed for basic EB flags.

86 { return 5; } // nghost_eb_basic ()

Referenced by make_all_factories(), and make_cc_factory().

Here is the caller graph for this function:

◆ nghost_full()

int eb_::nghost_full ( ) const
inline

Number of ghost cells needed for full EB geometric data.

90 { return 4; } // nghost_eb_full ()

Referenced by make_all_factories(), and make_cc_factory().

Here is the caller graph for this function:

◆ nghost_volume()

int eb_::nghost_volume ( ) const
inline

Number of ghost cells needed for EB volume data.

88 { return 5; } // nghost_eb_volume ()

Referenced by make_all_factories(), and make_cc_factory().

Here is the caller graph for this function:

◆ set_connection_flags()

void eb_::set_connection_flags ( amrex::EBFArrayBoxFactory *  factory)

Disconnect covered neighbors in an EB factory's cell flags.

Reset cell flags to disconnect cells with zero volume fraction.

Parameters
factoryFactory whose non-const flag data are updated.

The factory EBCellFlagFab data are updated through a non-const reference.

125 {
126  // Get non-const reference to EBCellFlagFab FabArray
127  FabArray<EBCellFlagFab>& cellflag = getNonConstEBCellFlags(*factory);
128 
129  const MultiFab& volfrac = factory->getVolFrac();
130 
131  for (MFIter mfi(cellflag, false); mfi.isValid(); ++mfi) {
132  const Box& bx = mfi.validbox();
133  const Box gbx = amrex::grow(bx, cellflag.nGrow()-1); // Leave one cell layer
134 
135  Array4<EBCellFlag> const& flag = cellflag.array(mfi);
136  Array4<Real const> const& vfrac = volfrac.const_array(mfi);
137 
138  ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
139  {
140  for(int kk(-1); kk<=1; kk++) {
141  for(int jj(-1); jj<=1; jj++) {
142  for(int ii(-1); ii<=1; ii++)
143  {
144  if (vfrac(i+ii,j+jj,k+kk) == zero) {
145  flag(i,j,k).setDisconnected(ii,jj,kk);
146  }
147  }}}
148  });
149 
150  ParallelFor(gbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
151  {
152  if (vfrac(i,j,k)==zero) {
153  flag(i,j,k).setCovered();
154  }
155  });
156 
157  }
158 }
constexpr amrex::Real zero
Definition: ERF_Constants.H:8
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
amrex::FabArray< amrex::EBCellFlagFab > & getNonConstEBCellFlags(const amrex::EBFArrayBoxFactory &ebfact)
Return mutable EB cell flags from an AMReX factory.
Definition: ERF_EB.H:181

Referenced by make_all_factories().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_cellflags

amrex::FabArray<amrex::EBCellFlagFab>* eb_::m_cellflags = nullptr
private

◆ m_eb_level

amrex::EB2::Level const* eb_::m_eb_level
private

EB level constructed from building GeometryShop.

Referenced by build_level().

◆ m_factory

std::unique_ptr<amrex::EBFArrayBoxFactory> eb_::m_factory = nullptr
private

◆ m_has_eb

int eb_::m_has_eb
private

◆ m_support_level

amrex::EBSupport eb_::m_support_level
private

◆ m_type

std::string eb_::m_type
private

◆ m_u_factory

eb_aux_ eb_::m_u_factory
private

◆ m_u_factory_fc

std::unique_ptr<amrex::EBFArrayBoxFactory> eb_::m_u_factory_fc = nullptr
private

Referenced by make_all_factories().

◆ m_v_factory

eb_aux_ eb_::m_v_factory
private

◆ m_v_factory_fc

std::unique_ptr<amrex::EBFArrayBoxFactory> eb_::m_v_factory_fc = nullptr
private

Referenced by make_all_factories().

◆ m_w_factory

eb_aux_ eb_::m_w_factory
private

◆ m_w_factory_fc

std::unique_ptr<amrex::EBFArrayBoxFactory> eb_::m_w_factory_fc = nullptr
private

Referenced by make_all_factories().

◆ m_write_eb_surface

int eb_::m_write_eb_surface
private

The documentation for this class was generated from the following files: