Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
9namespace amrex {
16class BCRec
17{
18public:
23 BCRec () noexcept
24
25 = default;
30 BCRec (AMREX_D_DECL(int loX, int loY, int loZ),
31 AMREX_D_DECL(int hiX, int hiY, int hiZ)) noexcept
32 : bc {AMREX_D_DECL(loX,loY,loZ),
33 AMREX_D_DECL(hiX,hiY,hiZ)}
34 {}
39 BCRec (const int* a_lo, const int* a_hi) noexcept
40 : bc {AMREX_D_DECL(a_lo[0],a_lo[1],a_lo[2]),
41 AMREX_D_DECL(a_hi[0],a_hi[1],a_hi[2])}
42 {}
43 /*
44 * \brief Yet another constructor. Inherits bndry types from bc_domain
45 * when bx lies on edge of domain otherwise gets interior Dirichlet.
46 */
48 BCRec (const Box& bx,
49 const Box& domain,
50 const BCRec& bc_domain) noexcept
51 {
52 const int* bxlo = bx.loVect();
53 const int* bxhi = bx.hiVect();
54 const int* dlo = domain.loVect();
55 const int* dhi = domain.hiVect();
56 for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
57 {
58 int ilo = dir;
59 int ihi = dir+AMREX_SPACEDIM;
60 bc[ilo] = ( bxlo[dir]<=dlo[dir] ? bc_domain.bc[ilo] : BCType::int_dir );
61 bc[ihi] = ( bxhi[dir]>=dhi[dir] ? bc_domain.bc[ihi] : BCType::int_dir );
62 }
63 }
64 /*
65 * \brief Explicitly set lo bndry value.
66 */
68 void setLo (int dir, int bc_val) noexcept { bc[dir] = bc_val; }
73 void setHi (int dir, int bc_val) noexcept { bc[AMREX_SPACEDIM+dir] = bc_val; }
78 void set (Orientation face, int bc_val) noexcept {
79 if (face.isLow()) {
80 setLo(face.coordDir(), bc_val);
81 } else {
82 setHi(face.coordDir(), bc_val);
83 }
84 }
89 const int* vect () const& noexcept{ return bc; }
90 const int* vect () && = delete;
91
93 const int* data () const& noexcept { return bc; }
94 const int* data () && = delete;
95
100 const int* lo () const& noexcept { return bc; }
101 const int* lo () && = delete;
106 const int* hi () const& noexcept { return bc+AMREX_SPACEDIM; }
107 const int* hi () && = delete;
112 int lo (int dir) const noexcept { return bc[dir]; }
117 int hi (int dir) const noexcept { return bc[AMREX_SPACEDIM+dir]; }
122 bool operator== (const BCRec& rhs) const noexcept {
123 bool retval = true;
124 for (int i = 0; i < 2*AMREX_SPACEDIM && retval; i++)
125 {
126 retval &= bc[i] == rhs.bc[i];
127 }
128 return retval;
129 }
134 bool operator!= (const BCRec& rhs) const noexcept { return !(*this == rhs); }
138 friend std::ostream& operator << (std::ostream&, const BCRec&);
139
140private:
144 int bc[2*AMREX_SPACEDIM]{AMREX_D_DECL(BCType::bogus,BCType::bogus,BCType::bogus),
145 AMREX_D_DECL(BCType::bogus,BCType::bogus,BCType::bogus)};
146};
147
152void
153setBC (const Box& bx, const Box& domain, const BCRec& bc_dom, BCRec& bcr) noexcept
154{
155 const int* bxlo = bx.loVect();
156 const int* bxhi = bx.hiVect();
157 const int* dlo = domain.loVect();
158 const int* dhi = domain.hiVect();
159 for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
160 {
161 bcr.setLo(dir, ( bxlo[dir]<=dlo[dir] ? bc_dom.lo(dir) : BCType::int_dir ));
162 bcr.setHi(dir, ( bxhi[dir]>=dhi[dir] ? bc_dom.hi(dir) : BCType::int_dir ));
163 }
164}
165
169void
170setBC (const Box& bx,
171 const Box& domain,
172 int src_comp,
173 int dest_comp,
174 int ncomp,
175 const Vector<BCRec>& bc_dom,
176 Vector<BCRec>& bcr) noexcept;
177}
178
179#endif /*_BCREC_H_*/
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Boundary Condition Records. Necessary information and functions for computing boundary conditions.
Definition AMReX_BCRec.H:17
const int * vect() &&=delete
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void setHi(int dir, int bc_val) noexcept
Explicitly set hi bndry value.
Definition AMReX_BCRec.H:73
const int * data() &&=delete
const int * hi() &&=delete
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * hi() const &noexcept
Return high-end boundary data.
Definition AMReX_BCRec.H:106
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * lo() const &noexcept
Return low-end boundary data.
Definition AMReX_BCRec.H:100
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void setLo(int dir, int bc_val) noexcept
Definition AMReX_BCRec.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator!=(const BCRec &rhs) const noexcept
Not equal test.
Definition AMReX_BCRec.H:134
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator==(const BCRec &rhs) const noexcept
Equal test.
Definition AMReX_BCRec.H:122
friend std::ostream & operator<<(std::ostream &, const BCRec &)
ASCII write to ostream.
Definition AMReX_BCRec.cpp:35
const int * lo() &&=delete
AMREX_GPU_HOST_DEVICE BCRec() noexcept=default
The default constructor, which does NOT set valid boundary types.
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void set(Orientation face, int bc_val) noexcept
Explicitly set bndry value for given face.
Definition AMReX_BCRec.H:78
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * vect() const &noexcept
Return bndry values (used in calls to FORTRAN).
Definition AMReX_BCRec.H:89
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int lo(int dir) const noexcept
Return low-end boundary data in direction <dir>.
Definition AMReX_BCRec.H:112
AMREX_GPU_HOST_DEVICE BCRec(const Box &bx, const Box &domain, const BCRec &bc_domain) noexcept
Definition AMReX_BCRec.H:48
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * data() const &noexcept
Definition AMReX_BCRec.H:93
int bc[2 *AMREX_SPACEDIM]
Array of integer values describing boundary conditions.
Definition AMReX_BCRec.H:144
AMREX_GPU_HOST_DEVICE BCRec(const int *a_lo, const int *a_hi) noexcept
Another constructor.
Definition AMReX_BCRec.H:39
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int hi(int dir) const noexcept
Return high-end boundary data in direction <dir>.
Definition AMReX_BCRec.H:117
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
Definition AMReX_Amr.cpp:49
BoxND< AMREX_SPACEDIM > Box
Definition AMReX_BaseFwd.H:27
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
Function for setting array of BCs.
Definition AMReX_BCRec.cpp:8