12 #ifndef CD_IrregAmrStencilImplem_H
13 #define CD_IrregAmrStencilImplem_H
17 #include <CD_NamespaceHeader.H>
19 template <
class IrregSten>
22 CH_TIME(
"IrregAmrStencil::IrregAmrStencil");
26 template <
class IrregSten>
28 const Vector<EBISLayout>& a_ebisl,
29 const Vector<ProblemDomain>& a_domains,
30 const Vector<Real>& a_dx,
31 const int a_finestLevel,
36 CH_TIME(
"IrregAmrStencil::IrregAmrStencil");
38 this->define(a_grids, a_ebisl, a_domains, a_dx, a_finestLevel, a_order, a_radius, a_type);
41 template <
class IrregSten>
44 CH_TIME(
"IrregAmrStencil::~IrregAmrStencil");
47 template <
class IrregSten>
51 return *m_stencils[a_lvl];
54 template <
class IrregSten>
58 return *m_stencils[a_lvl];
61 template <
class IrregSten>
64 const Vector<EBISLayout>& a_ebisl,
65 const Vector<ProblemDomain>& a_domains,
66 const Vector<Real>& a_dx,
67 const int a_finestLevel,
72 CH_TIME(
"IrregAmrStencil::define");
77 m_domains = a_domains;
79 m_finestLevel = a_finestLevel;
82 m_stencilType = a_type;
85 m_stencils.resize(1 + m_finestLevel);
86 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
87 m_stencils[lvl] = RefCountedPtr<IrregStencil>(
88 new IrregSten(m_grids[lvl], m_ebisl[lvl], m_domains[lvl], m_dx[lvl], m_order, m_radius, m_stencilType));
94 template <
class IrregSten>
98 CH_TIME(
"IrregAmrStencil::apply(LD<EBCellFABx2, int)");
100 CH_assert(m_isDefined);
102 const DataIterator& dit = m_grids[a_lvl].dataIterator();
104 const int nbox = dit.size();
105 #pragma omp parallel for schedule(runtime)
106 for (
int mybox = 0; mybox < nbox; mybox++) {
107 const DataIndex& din = dit[mybox];
109 m_stencils[a_lvl]->apply(a_dst[din], a_src[din], din);
113 template <
class IrregSten>
117 CH_TIME(
"IrregAmrStencil::apply(LD<EBCellFAB, int)");
119 CH_assert(m_isDefined);
121 const DataIterator& dit = m_grids[a_lvl].dataIterator();
123 const int nbox = dit.size();
124 #pragma omp parallel for schedule(runtime)
125 for (
int mybox = 0; mybox < nbox; mybox++) {
126 const DataIndex& din = dit[mybox];
128 EBCellFAB& data = a_data[din];
136 m_stencils[a_lvl]->apply(data, cpy, din);
140 template <
class IrregSten>
143 const LevelData<EBCellFAB>& a_src,
144 const int a_lvl)
const
146 CH_TIME(
"IrregAmrStencil::apply(LD<BaseIVFAB>, LD<EBCellFAB>, int)");
148 CH_assert(m_isDefined);
150 const DataIterator& dit = m_grids[a_lvl].dataIterator();
152 const int nbox = dit.size();
153 #pragma omp parallel for schedule(runtime)
154 for (
int mybox = 0; mybox < nbox; mybox++) {
155 const DataIndex& din = dit[mybox];
157 m_stencils[a_lvl]->apply(a_dst[din], a_src[din], din);
161 template <
class IrregSten>
165 CH_TIME(
"IrregAmrStencil::apply");
167 CH_assert(m_isDefined);
169 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
170 this->apply(*a_data[lvl], lvl);
174 template <
class IrregSten>
178 CH_TIME(
"IrregAmrStencil::apply");
180 CH_assert(m_isDefined);
182 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
183 this->apply(*a_dst[lvl], *a_src[lvl], lvl);
187 template <
class IrregSten>
191 CH_TIME(
"IrregAmrStencil::apply");
193 CH_assert(m_isDefined);
195 for (
int lvl = 0; lvl <= m_finestLevel; lvl++) {
196 this->apply(*a_dst[lvl], *a_src[lvl], lvl);
200 template <
class IrregSten>
204 CH_TIME(
"IrregAmrStencil::apply");
206 const int dstSize = a_dst.size();
207 const int srcSize = a_src.size();
209 CH_assert(m_isDefined);
210 CH_assert(dstSize == srcSize);
212 for (
int i = 0; i < dstSize; i++) {
217 template <
class IrregSten>
221 CH_TIME(
"IrregAmrStencil::apply");
223 CH_assert(m_isDefined);
225 const int dstSize = a_data.size();
227 for (
int i = 0; i < dstSize; i++) {
228 this->apply(*a_data[i]);
232 template <
class IrregSten>
236 CH_TIME(
"IrregAmrStencil::apply");
238 const int dstSize = a_dst.size();
239 const int srcSize = a_src.size();
241 CH_assert(m_isDefined);
242 CH_assert(dstSize == srcSize);
244 for (
int i = 0; i < dstSize; i++) {
249 #include <CD_NamespaceFooter.H>
Class for holding stencils on irregular over an entire AMR hierarchy.
const IrregStencil & operator[](const int &a_lvl) const
Get the stencils over an AMR level.
Definition: CD_IrregAmrStencilImplem.H:49
virtual void define(const Vector< DisjointBoxLayout > &a_grids, const Vector< EBISLayout > &a_ebisl, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const int a_finestLevel, const int a_order, const int a_radius, const IrregStencil::StencilType a_type)
Define function.
Definition: CD_IrregAmrStencilImplem.H:63
IrregAmrStencil()
Empty constructor. You must subsequently call define.
Definition: CD_IrregAmrStencilImplem.H:20
virtual void apply(LevelData< EBCellFAB > &a_dst, const LevelData< EBCellFAB > &a_src, const int a_lvl) const
Apply the stencils to an existing data holder.
Definition: CD_IrregAmrStencilImplem.H:96
virtual ~IrregAmrStencil()
Destructor.
Definition: CD_IrregAmrStencilImplem.H:42
Class for holding stencils on irregular cells over a single AMR level.
Definition: CD_IrregStencil.H:38
StencilType
Enum for identifying stencil – only meant for enhancing code visibility.
Definition: CD_IrregStencil.H:44