Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_MLMGBndry.H
Go to the documentation of this file.
1#ifndef AMREX_MLMGBNDRY_H_
2#define AMREX_MLMGBNDRY_H_
3#include <AMReX_Config.H>
4
6
7namespace amrex {
8
9template <typename MF>
11 : public InterpBndryDataT<MF>
12{
13public:
14
17
18 MLMGBndryT (const BoxArray& _grids, const DistributionMapping& _dmap,
19 int _ncomp, const Geometry& _geom);
20
21 ~MLMGBndryT () = default;
22
23 MLMGBndryT (MLMGBndryT<MF>&& rhs) = delete;
24 MLMGBndryT (const MLMGBndryT<MF>& rhs) = delete;
27
30 int ratio, const RealVect& a_loc,
31 LinOpBCType a_crse_fine_bc_type = LinOpBCType::Dirichlet);
32
35 IntVect const& ratio, const RealVect& a_loc,
36 LinOpBCType a_crse_fine_bc_type = LinOpBCType::Dirichlet);
37
38 static void setBoxBC (RealTuple& bloc, BCTuple& bctag, const Box& bx,
39 const Box& domain,
42 const Real* dx, IntVect const& ratio,
43 const RealVect& interior_bloc,
44 const Array<Real,AMREX_SPACEDIM>& domain_bloc_lo,
45 const Array<Real,AMREX_SPACEDIM>& domain_bloc_hi,
46 const GpuArray<int,AMREX_SPACEDIM>& is_periodic,
47 LinOpBCType a_crse_fine_bc_type);
48};
49
50template <typename MF>
52 int _ncomp, const Geometry& _geom)
53 : InterpBndryDataT<MF>(_grids,_dmap,_ncomp,_geom)
54{}
55
56template <typename MF>
57void
60 int ratio, const RealVect& a_loc,
61 LinOpBCType a_crse_fine_bc_type)
62{
63 setLOBndryConds(lo, hi, IntVect(ratio), a_loc, a_crse_fine_bc_type);
64}
65
66template <typename MF>
67void
70 IntVect const& ratio, const RealVect& a_loc,
71 LinOpBCType a_crse_fine_bc_type)
72{
73 const BoxArray& ba = this->boxes();
74 const Real* dx = this->geom.CellSize();
75 const Box& domain = this->geom.Domain();
76 const GpuArray<int,AMREX_SPACEDIM>& is_periodic = this->geom.isPeriodicArray();
77
78 AMREX_ASSERT(a_crse_fine_bc_type == LinOpBCType::Dirichlet ||
79 a_crse_fine_bc_type == LinOpBCType::Neumann);
80
81#ifdef AMREX_USE_OMP
82#pragma omp parallel
83#endif
84 for (FabSetIter fsi(this->bndry[Orientation(0,Orientation::low)]);
85 fsi.isValid(); ++fsi)
86 {
87 const int i = fsi.index();
88 const Box& grd = ba[i];
89 RealTuple& bloc = this->bcloc[fsi];
90 Vector< Vector<BoundCond> >& bctag = this->bcond[fsi];
91
92 for (int icomp = 0; icomp < this->nComp(); ++icomp) {
93 BCTuple bct;
94 setBoxBC(bloc, bct, grd, domain, lo[icomp], hi[icomp], dx, ratio, a_loc,
95 {{AMREX_D_DECL(Real(0.),Real(0.),Real(0.))}},
96 {{AMREX_D_DECL(Real(0.),Real(0.),Real(0.))}},
97 is_periodic, a_crse_fine_bc_type);
98 for (int idim = 0; idim < 2*AMREX_SPACEDIM; ++idim) {
99 bctag[idim][icomp] = bct[idim];
100 }
101 }
102 }
103}
104
105template <typename MF>
106void
108 const Box& bx, const Box& domain,
111 const Real* dx, IntVect const& ratio,
112 const RealVect& interior_bloc,
113 const Array<Real,AMREX_SPACEDIM>& domain_bloc_lo,
114 const Array<Real,AMREX_SPACEDIM>& domain_bloc_hi,
115 const GpuArray<int,AMREX_SPACEDIM>& is_periodic,
116 LinOpBCType a_crse_fine_bc_type)
117{
118 using T = typename MF::value_type;
119
120 for (OrientationIter fi; fi; ++fi)
121 {
122 const Orientation face = fi();
123 const int dir = face.coordDir();
124
125 if (domain[face] == bx[face] && !is_periodic[dir])
126 {
127 // All physical bc values are located on face.
128 bloc[face] = static_cast<T>
129 (face.isLow() ? domain_bloc_lo[dir] : domain_bloc_hi[dir]);
130 const auto linop_bc = face.isLow() ? lo[dir] : hi[dir];
131 if (linop_bc == LinOpBCType::Dirichlet) {
132 bctag[face] = AMREX_LO_DIRICHLET;
133 } else if (linop_bc == LinOpBCType::Neumann) {
134 bctag[face] = AMREX_LO_NEUMANN;
135 } else if (linop_bc == LinOpBCType::reflect_odd) {
136 bctag[face] = AMREX_LO_REFLECT_ODD;
137 } else {
138 amrex::Abort("MLMGBndry::setBoxBC: Unknown LinOpBCType");
139 }
140 }
141 else
142 {
143 // Internal bndry.
144 bctag[face] = static_cast<int>(a_crse_fine_bc_type);
145 bloc[face] = static_cast<T>(ratio[dir] > 0 ? Real(0.5)*static_cast<Real>(ratio[dir])*dx[dir]
146 : interior_bloc[dir]);
147 // If this is next to another same level box, BC type is wrong
148 // and bloc is wrong. But it doesn't matter, because we also
149 // have mask. It is used only if mask says it is next to coarse
150 // cells.
151 }
152 }
153}
154
156
157}
158
159#endif
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_LO_NEUMANN
Definition AMReX_LO_BCTYPES.H:6
#define AMREX_LO_DIRICHLET
Definition AMReX_LO_BCTYPES.H:5
#define AMREX_LO_REFLECT_ODD
Definition AMReX_LO_BCTYPES.H:7
Array< value_type, 2 *AMREX_SPACEDIM > RealTuple
Some useful typedefs.
Definition AMReX_BndryData.H:82
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:550
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:41
Definition AMReX_FabSet.H:149
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:73
An InterpBndryData object adds to a BndryData object the ability to manipulate and set the data store...
Definition AMReX_InterpBndryData.H:40
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:141
Definition AMReX_MLMGBndry.H:12
Array< BoundCond, 2 *BL_SPACEDIM > BCTuple
Definition AMReX_MLMGBndry.H:15
MLMGBndryT< MF > & operator=(const MLMGBndryT< MF > &rhs)=delete
void setLOBndryConds(const Vector< Array< LinOpBCType, AMREX_SPACEDIM > > &lo, const Vector< Array< LinOpBCType, AMREX_SPACEDIM > > &hi, int ratio, const RealVect &a_loc, LinOpBCType a_crse_fine_bc_type=LinOpBCType::Dirichlet)
Definition AMReX_MLMGBndry.H:58
typename BndryDataT< MF >::RealTuple RealTuple
Definition AMReX_MLMGBndry.H:16
static void setBoxBC(RealTuple &bloc, BCTuple &bctag, const Box &bx, const Box &domain, const Array< LinOpBCType, AMREX_SPACEDIM > &lo, const Array< LinOpBCType, AMREX_SPACEDIM > &hi, const Real *dx, IntVect const &ratio, const RealVect &interior_bloc, const Array< Real, AMREX_SPACEDIM > &domain_bloc_lo, const Array< Real, AMREX_SPACEDIM > &domain_bloc_hi, const GpuArray< int, AMREX_SPACEDIM > &is_periodic, LinOpBCType a_crse_fine_bc_type)
Definition AMReX_MLMGBndry.H:107
~MLMGBndryT()=default
MLMGBndryT(const MLMGBndryT< MF > &rhs)=delete
MLMGBndryT(const BoxArray &_grids, const DistributionMapping &_dmap, int _ncomp, const Geometry &_geom)
Definition AMReX_MLMGBndry.H:51
MLMGBndryT(MLMGBndryT< MF > &&rhs)=delete
An Iterator over the Orientation of Faces of a Box.
Definition AMReX_Orientation.H:135
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
AMREX_GPU_HOST_DEVICE int coordDir() const noexcept
Returns the coordinate direction.
Definition AMReX_Orientation.H:83
AMREX_GPU_HOST_DEVICE bool isLow() const noexcept
Returns true if Orientation is low.
Definition AMReX_Orientation.H:89
@ low
Definition AMReX_Orientation.H:34
A Real vector in SpaceDim-dimensional space.
Definition AMReX_RealVect.H:32
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:27
Definition AMReX_Amr.cpp:49
int nComp(FabArrayBase const &fa)
IntVectND< AMREX_SPACEDIM > IntVect
Definition AMReX_BaseFwd.H:30
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:225
std::array< T, N > Array
Definition AMReX_Array.H:24
Definition AMReX_Array.H:34