Block-Structured AMR Software Framework
AMReX_EB2_MultiGFab.H
Go to the documentation of this file.
1 #ifndef AMREX_EB2_MULTIGFAB_H_
2 #define AMREX_EB2_MULTIGFAB_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_EB2_Graph.H>
6 #include <AMReX_EBCellFlag.H>
7 #include <AMReX_Array.H>
8 #include <AMReX_LayoutData.H>
9 #include <AMReX_MultiFab.H>
10 
11 namespace amrex::EB2 {
12 
13 class GFab
14 {
15 public:
16 
17  GFab () = default;
18 
19  static constexpr int ng = 2;
20 
21  void define(const Box& vbx) {
22  m_validbox = vbx;
23  const Box& bxg2 = amrex::grow(vbx,ng);
25  for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
26  m_facetype[idim].resize(amrex::convert(bxg2,IntVect::TheDimensionVector(idim)));
27 #if (AMREX_SPACEDIM == 3)
28  m_edgetype[idim].resize(amrex::convert(bxg2,IntVect::TheNodeVector()
30 #endif
31  }
32  }
33 
34  Box validbox () const { return m_validbox; }
35 
36  const BaseFab<Real>& getLevelSet () const { return m_levelset; }
38 
39  const Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getFaceType () const { return m_facetype; }
40  Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getFaceType () { return m_facetype; }
41 
42 #if (AMREX_SPACEDIM == 3)
43  const Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getEdgeType () const { return m_edgetype; }
44  Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getEdgeType () { return m_edgetype; }
45 #endif
46 
47  const Graph& getGraph () const { return m_graph; }
48  Graph& getGraph () { return m_graph; }
49 
50  void buildTypes (EBCellFlagFab& celltype);
51 
52 private:
53 
57 #if (AMREX_SPACEDIM == 3)
58  Array<BaseFab<Type_t>, AMREX_SPACEDIM> m_edgetype;
59 #endif
61 };
62 
63 class MultiGFab
64  : public LayoutData<GFab>
65 {
66 public:
67 
68  MultiGFab () = default;
69 
70  MultiGFab (const BoxArray& ba, const DistributionMapping& dm) {
71  define(ba,dm);
72  }
73 
74  void define (const BoxArray& ba, const DistributionMapping& dm) {
76  for (MFIter mfi(*this); mfi.isValid(); ++mfi) {
77  const Box& bx = mfi.validbox();
78  auto& gfab = (*this)[mfi];
79  gfab.define(bx);
80  }
81  }
82 
84 };
85 
86 }
87 
88 #endif
void resize(const Box &b, int N=1, Arena *ar=nullptr)
This function resizes a BaseFab so it covers the Box b with N components.
Definition: AMReX_BaseFab.H:2098
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
Definition: AMReX_EB2_MultiGFab.H:14
Box validbox() const
Definition: AMReX_EB2_MultiGFab.H:34
const Graph & getGraph() const
Definition: AMReX_EB2_MultiGFab.H:47
BaseFab< Real > m_levelset
Definition: AMReX_EB2_MultiGFab.H:55
Graph & getGraph()
Definition: AMReX_EB2_MultiGFab.H:48
Graph m_graph
Definition: AMReX_EB2_MultiGFab.H:60
void buildTypes(EBCellFlagFab &celltype)
Definition: AMReX_EB2_MultiGFab.cpp:8
BaseFab< Real > & getLevelSet()
Definition: AMReX_EB2_MultiGFab.H:37
void define(const Box &vbx)
Definition: AMReX_EB2_MultiGFab.H:21
Box m_validbox
Definition: AMReX_EB2_MultiGFab.H:54
const BaseFab< Real > & getLevelSet() const
Definition: AMReX_EB2_MultiGFab.H:36
static constexpr int ng
Definition: AMReX_EB2_MultiGFab.H:19
Array< BaseFab< Type_t >, AMREX_SPACEDIM > m_facetype
Definition: AMReX_EB2_MultiGFab.H:56
const Array< BaseFab< Type_t >, AMREX_SPACEDIM > & getFaceType() const
Definition: AMReX_EB2_MultiGFab.H:39
Array< BaseFab< Type_t >, AMREX_SPACEDIM > & getFaceType()
Definition: AMReX_EB2_MultiGFab.H:40
Definition: AMReX_EB2_MultiGFab.H:65
void define(const BoxArray &ba, const DistributionMapping &dm)
Definition: AMReX_EB2_MultiGFab.H:74
MultiGFab(const BoxArray &ba, const DistributionMapping &dm)
Definition: AMReX_EB2_MultiGFab.H:70
MultiFab getLevelSet()
Definition: AMReX_EB2_MultiGFab.cpp:41
Definition: AMReX_EBCellFlag.H:287
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheNodeVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:702
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheDimensionVector(int d) noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:691
a one-thingy-per-box distributed object
Definition: AMReX_LayoutData.H:13
void define(const BoxArray &a_grids, const DistributionMapping &a_dm)
Definition: AMReX_LayoutData.H:25
Definition: AMReX_MFIter.H:57
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition: AMReX_MFIter.H:141
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Definition: AMReX_FabArrayBase.H:32
std::unordered_map< IntVect, Vector< Vertex >, IntVect::hasher > Graph
Definition: AMReX_EB2_Graph.H:85
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition: AMReX_Box.H:1211
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Returns a BoxND with different type.
Definition: AMReX_Box.H:1435
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Returns a BoxND with NODE based coordinates in direction dir that encloses BoxND b....
Definition: AMReX_Box.H:1399
std::array< T, N > Array
Definition: AMReX_Array.H:24