Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_BCRec.H
Go to the documentation of this file.
1
2#ifndef AMREX_BCREC_H_
3#define AMREX_BCREC_H_
4#include <AMReX_Config.H>
5
6#include <AMReX_Box.H>
7#include <AMReX_BC_TYPES.H>
8
14namespace amrex {
24class BCRec
25{
26public:
29 BCRec () noexcept
30
31 = default;
45 BCRec (AMREX_D_DECL(int loX, int loY, int loZ),
46 AMREX_D_DECL(int hiX, int hiY, int hiZ)) noexcept
47 : bc {AMREX_D_DECL(loX,loY,loZ),
48 AMREX_D_DECL(hiX,hiY,hiZ)}
49 {}
57 BCRec (const int* a_lo, const int* a_hi) noexcept
58 : bc {AMREX_D_DECL(a_lo[0],a_lo[1],a_lo[2]),
59 AMREX_D_DECL(a_hi[0],a_hi[1],a_hi[2])}
60 {}
72 BCRec (const Box& bx,
73 const Box& domain,
74 const BCRec& bc_domain) noexcept
75 {
76 const int* bxlo = bx.loVect();
77 const int* bxhi = bx.hiVect();
78 const int* dlo = domain.loVect();
79 const int* dhi = domain.hiVect();
80 for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
81 {
82 int ilo = dir;
83 int ihi = dir+AMREX_SPACEDIM;
84 bc[ilo] = ( bxlo[dir]<=dlo[dir] ? bc_domain.bc[ilo] : BCType::int_dir );
85 bc[ihi] = ( bxhi[dir]>=dhi[dir] ? bc_domain.bc[ihi] : BCType::int_dir );
86 }
87 }
94 void setLo (int dir, int bc_val) noexcept { bc[dir] = bc_val; }
101 void setHi (int dir, int bc_val) noexcept { bc[AMREX_SPACEDIM+dir] = bc_val; }
108 void set (Orientation face, int bc_val) noexcept {
109 if (face.isLow()) {
110 setLo(face.coordDir(), bc_val);
111 } else {
112 setHi(face.coordDir(), bc_val);
113 }
114 }
117 const int* vect () const& noexcept{ return bc; }
118 const int* vect () && = delete;
119
122 const int* data () const& noexcept { return bc; }
123 const int* data () && = delete;
124
127 const int* lo () const& noexcept { return bc; }
128 const int* lo () && = delete;
131 const int* hi () const& noexcept { return bc+AMREX_SPACEDIM; }
132 const int* hi () && = delete;
135 int lo (int dir) const noexcept { return bc[dir]; }
138 int hi (int dir) const noexcept { return bc[AMREX_SPACEDIM+dir]; }
141 bool operator== (const BCRec& rhs) const noexcept {
142 bool retval = true;
143 for (int i = 0; i < 2*AMREX_SPACEDIM && retval; i++)
144 {
145 retval &= bc[i] == rhs.bc[i];
146 }
147 return retval;
148 }
151 bool operator!= (const BCRec& rhs) const noexcept { return !(*this == rhs); }
155 friend std::ostream& operator << (std::ostream&, const BCRec&);
156
157private:
161 int bc[2*AMREX_SPACEDIM]{AMREX_D_DECL(BCType::bogus,BCType::bogus,BCType::bogus),
163};
164
174void
175setBC (const Box& bx, const Box& domain, const BCRec& bc_dom, BCRec& bcr) noexcept
176{
177 const int* bxlo = bx.loVect();
178 const int* bxhi = bx.hiVect();
179 const int* dlo = domain.loVect();
180 const int* dhi = domain.hiVect();
181 for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
182 {
183 bcr.setLo(dir, ( bxlo[dir]<=dlo[dir] ? bc_dom.lo(dir) : BCType::int_dir ));
184 bcr.setHi(dir, ( bxhi[dir]>=dhi[dir] ? bc_dom.hi(dir) : BCType::int_dir ));
185 }
186}
187
199void
200setBC (const Box& bx,
201 const Box& domain,
202 int src_comp,
203 int dest_comp,
204 int ncomp,
205 const Vector<BCRec>& bc_dom,
206 Vector<BCRec>& bcr) noexcept;
207}
208
209#endif /*_BCREC_H_*/
Enumerations describing physical and mathematical boundary types.
Integer-lattice boxes and helpers for defining index-space regions.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Boundary condition record storing low/high face types per coordinate.
Definition AMReX_BCRec.H:25
const int * vect() &&=delete
const int * data() &&=delete
__host__ __device__ BCRec(const Box &bx, const Box &domain, const BCRec &bc_domain) noexcept
Initialize boundary faces relative to a domain record.
Definition AMReX_BCRec.H:72
__host__ __device__ int lo(int dir) const noexcept
Return the low-end boundary code for dimension dir.
Definition AMReX_BCRec.H:135
__host__ __device__ const int * data() const &noexcept
Equivalent to vect(); returns the same pointer to the internal boundary array.
Definition AMReX_BCRec.H:122
__host__ __device__ BCRec(const int *a_lo, const int *a_hi) noexcept
Construct from arrays of low/high face types.
Definition AMReX_BCRec.H:57
__host__ __device__ const int * hi() const &noexcept
Return pointer to the high-end face array.
Definition AMReX_BCRec.H:131
__host__ __device__ bool operator!=(const BCRec &rhs) const noexcept
Logical negation of operator==.
Definition AMReX_BCRec.H:151
__host__ __device__ const int * lo() const &noexcept
Return pointer to the low-end face array.
Definition AMReX_BCRec.H:127
const int * hi() &&=delete
__host__ __device__ bool operator==(const BCRec &rhs) const noexcept
Compare two records for identical boundary condition values.
Definition AMReX_BCRec.H:141
__host__ __device__ const int * vect() const &noexcept
Return pointer to the internal boundary array (low faces, then high faces). Legacy name for Fortran c...
Definition AMReX_BCRec.H:117
friend std::ostream & operator<<(std::ostream &, const BCRec &)
ASCII write to ostream.
Definition AMReX_BCRec.cpp:35
const int * lo() &&=delete
__host__ __device__ void setLo(int dir, int bc_val) noexcept
Set the low-face boundary for dimension dir.
Definition AMReX_BCRec.H:94
__host__ __device__ int hi(int dir) const noexcept
Return the high-end boundary code for dimension dir.
Definition AMReX_BCRec.H:138
__host__ __device__ void setHi(int dir, int bc_val) noexcept
Set the high-face boundary for dimension dir.
Definition AMReX_BCRec.H:101
__host__ __device__ void set(Orientation face, int bc_val) noexcept
Explicitly set the boundary value for a given face.
Definition AMReX_BCRec.H:108
__host__ __device__ BCRec() noexcept=default
Default constructor leaves all face types set to BCType::bogus.
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
@ int_dir
Definition AMReX_BC_TYPES.H:89
@ bogus
Definition AMReX_BC_TYPES.H:87
Definition AMReX_Amr.cpp:50
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
void setBC(const Box &bx, const Box &domain, int src_comp, int dest_comp, int ncomp, const Vector< BCRec > &bc_dom, Vector< BCRec > &bcr) noexcept
Populate a span of BCRec objects based on a domain record.
Definition AMReX_BCRec.cpp:8