Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
17namespace amrex::EB2 {
18
20class GFab
21{
22public:
23
24 GFab () = default;
25
26 static constexpr int ng = 2;
27
31 void define(const Box& vbx) {
32 m_validbox = vbx;
33 const Box& bxg2 = amrex::grow(vbx,ng);
34 m_levelset.resize(amrex::surroundingNodes(bxg2));
35 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
36 m_facetype[idim].resize(amrex::convert(bxg2,IntVect::TheDimensionVector(idim)));
37#if (AMREX_SPACEDIM == 3)
38 m_edgetype[idim].resize(amrex::convert(bxg2,IntVect::TheNodeVector()
40#endif
41 }
42 }
43
45 Box validbox () const { return m_validbox; }
46
48 const BaseFab<Real>& getLevelSet () const { return m_levelset; }
49 BaseFab<Real>& getLevelSet () { return m_levelset; }
50
52 const Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getFaceType () const { return m_facetype; }
53 Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getFaceType () { return m_facetype; }
54
55#if (AMREX_SPACEDIM == 3)
57 const Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getEdgeType () const { return m_edgetype; }
58 Array<BaseFab<Type_t>,AMREX_SPACEDIM>& getEdgeType () { return m_edgetype; }
59#endif
60
62 const Graph& getGraph () const { return m_graph; }
63 Graph& getGraph () { return m_graph; }
64
70 void buildTypes (EBCellFlagFab& celltype);
71
72private:
73
74 Box m_validbox;
75 BaseFab<Real> m_levelset;
76 Array<BaseFab<Type_t>, AMREX_SPACEDIM> m_facetype;
77#if (AMREX_SPACEDIM == 3)
78 Array<BaseFab<Type_t>, AMREX_SPACEDIM> m_edgetype;
79#endif
80 Graph m_graph;
81};
82
85 : public LayoutData<GFab>
86{
87public:
88
89 MultiGFab () = default;
90
92 MultiGFab (const BoxArray& ba, const DistributionMapping& dm) {
93 define(ba,dm);
94 }
95
99 void define (const BoxArray& ba, const DistributionMapping& dm) {
101 for (MFIter mfi(*this); mfi.isValid(); ++mfi) {
102 const Box& bx = mfi.validbox();
103 auto& gfab = (*this)[mfi];
104 gfab.define(bx);
105 }
106 }
107
110};
111
112}
113
114#endif
A FortranArrayBox(FAB)-like object.
Definition AMReX_BaseFab.H:190
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:1629
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:568
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
Object that stores level-set, face/edge types, and EB graph per box.
Definition AMReX_EB2_MultiGFab.H:21
Box validbox() const
Valid box covered by this GFab.
Definition AMReX_EB2_MultiGFab.H:45
Graph & getGraph()
Definition AMReX_EB2_MultiGFab.H:63
const Graph & getGraph() const
Accessor for the EB graph structure stored within this tile.
Definition AMReX_EB2_MultiGFab.H:62
const BaseFab< Real > & getLevelSet() const
Access the nodal level-set field (const and mutable).
Definition AMReX_EB2_MultiGFab.H:48
const Array< BaseFab< Type_t >, 3 > & getFaceType() const
Access face-type classification arrays.
Definition AMReX_EB2_MultiGFab.H:52
const Array< BaseFab< Type_t >, 3 > & getEdgeType() const
Access edge-type arrays (3-D only).
Definition AMReX_EB2_MultiGFab.H:57
BaseFab< Real > & getLevelSet()
Definition AMReX_EB2_MultiGFab.H:49
Array< BaseFab< Type_t >, 3 > & getEdgeType()
Definition AMReX_EB2_MultiGFab.H:58
void buildTypes(EBCellFlagFab &celltype)
Derive face/edge types from the supplied EB cell flags.
Definition AMReX_EB2_MultiGFab.cpp:8
Array< BaseFab< Type_t >, 3 > & getFaceType()
Definition AMReX_EB2_MultiGFab.H:53
void define(const Box &vbx)
Allocate level-set and type arrays for valid box vbx.
Definition AMReX_EB2_MultiGFab.H:31
static constexpr int ng
Definition AMReX_EB2_MultiGFab.H:26
LayoutData wrapper that allocates a GFab per FAB/Box.
Definition AMReX_EB2_MultiGFab.H:86
void define(const BoxArray &ba, const DistributionMapping &dm)
Define the layout and allocate per-box GFab storage.
Definition AMReX_EB2_MultiGFab.H:99
MultiGFab(const BoxArray &ba, const DistributionMapping &dm)
Construct and define the layout immediately.
Definition AMReX_EB2_MultiGFab.H:92
MultiFab getLevelSet()
Collect the level-set data from each GFab into a MultiFab.
Definition AMReX_EB2_MultiGFab.cpp:41
FAB storing EBCellFlag data per cell.
Definition AMReX_EBCellFlag.H:324
__host__ static __device__ constexpr 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:801
__host__ static __device__ constexpr 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:790
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
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:172
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition AMReX_Box.H:1280
std::array< T, N > Array
Definition AMReX_Array.H:26
Definition AMReX_FabArrayBase.H:33
std::unordered_map< IntVect, Vector< Vertex >, IntVect::hasher > Graph
EB graph type: map from cell index to all EB vertices stored there.
Definition AMReX_EB2_Graph.H:105
__host__ __device__ BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Return a BoxND with different type.
Definition AMReX_Box.H:1558
__host__ __device__ BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with NODE based coordinates in direction dir that encloses BoxND b....
Definition AMReX_Box.H:1522