1 #ifndef AMReX_InSituUtils_H
2 #define AMReX_InSituUtils_H
3 #include <AMReX_Config.H>
5 #include <svtkDataSetAttributes.h>
6 #include <svtkUnsignedCharArray.h>
7 #include <svtkFloatArray.h>
8 #include <svtkDoubleArray.h>
25 namespace InSituUtils {
53 #define amrex_tt_specialize(cpp_t, svtk_t, svtk_t_e) \
55 struct amrex_tt<cpp_t> \
57 using svtk_type = svtk_t; \
60 constexpr int svtk_type_enum() { return svtk_t_e; } \
68 template<typename n_t>
71 template<
typename n_t>
75 template <
typename n_t,
typename op_t>
76 int UpdatePatch(
long *len,
int *lo,
int *hi, n_t *darray, n_t val)
81 long nxy = len[0]*len[1];
83 for (
int k = lo[2]; k <= hi[2]; ++k)
85 for (
int j = lo[1]; j <= hi[1]; ++j)
87 for (
int i = lo[0]; i <= hi[0]; ++i)
89 updateOp(darray[k*nxy + j*nx + i], val);
97 template <
typename n_t>
106 unsigned int nBoxes = boxes.
size();
108 darrays.resize(nBoxes,
nullptr);
111 for (
unsigned int p = 0; p < nBoxes; ++p)
121 for (
unsigned int q = 0; q < AMREX_SPACEDIM; ++q)
128 int lo[3] = {AMREX_ARLIM(box.
loVect())};
129 int hi[3] = {AMREX_ARLIM(box.
hiVect())};
132 for (
int q = 0; q < 3; ++q)
133 len[q] = hi[q] - lo[q] + 1;
136 for (
int q = 0; q < 3; ++q)
140 n_t *tmp = (n_t*)
malloc(
sizeof(n_t)*nxyz);
143 for (
long q = 0; q < nxyz; ++q)
154 template <
typename n_t>
157 std::vector<n_t*> &darrays)
169 unsigned int nBoxes = boxes.
size();
170 for (
unsigned int p = 0; p < nBoxes; ++p)
180 for (
int q = 0; q < AMREX_SPACEDIM; ++q)
190 int lo[3] = {AMREX_ARLIM(box.
loVect())};
191 int hi[3] = {AMREX_ARLIM(box.
hiVect())};
194 for (
int q = 0; q < 3; ++q)
195 len[q] = hi[q] - lo[q] + 1;
198 n_t *tmp = darrays[p];
201 for (
int q = 0; q < AMREX_SPACEDIM; ++q)
207 for (
int r = 0;
r < 3; ++
r)
210 for (
int r = 0;
r < 3; ++
r)
213 ghi[q] = glo[q] + ng - 1;
215 UpdatePatch<unsigned char,orOp<unsigned char>>(len,
219 for (
int r = 0;
r < 3; ++
r)
222 for (
int r = 0;
r < 3; ++
r)
225 glo[q] = ghi[q] + ng - 1;
227 UpdatePatch<unsigned char,orOp<unsigned char>>(len,
236 template <
typename n_t>
239 const IntVect &fRefRatio,
int ng, std::vector<n_t*> &cMasks)
250 unsigned int nCBoxes = cBoxes.
size();
251 for (
unsigned int p = 0; p < nCBoxes; ++p)
261 for (
int q = 0; q < AMREX_SPACEDIM; ++q)
268 int cLo[3] = {AMREX_ARLIM(cBox.
loVect())};
269 int cHi[3] = {AMREX_ARLIM(cBox.
hiVect())};
272 for (
int q = 0; q < 3; ++q)
273 cLen[q] = cHi[q] - cLo[q] + 1;
276 n_t *cMask = cMasks[p];
279 unsigned int nFBoxes = fBoxes.
size();
280 for (
unsigned int pp = 0;
pp < nFBoxes; ++
pp)
293 int iLo[3] = {AMREX_ARLIM(iBox.
loVect())};
294 int iHi[3] = {AMREX_ARLIM(iBox.
hiVect())};
296 UpdatePatch<n_t, orOp<n_t>>(cLen, iLo, iHi, cMask,
312 int GetIndex(
const std::string &arrayName,
313 int centering,
int &desc,
int &comp);
315 int Size(
int centering){
return this->
Map[centering].size(); }
317 int GetName(
int centering,
int id, std::string &name);
320 std::map<int,std::map<std::string,std::pair<int,int>>>
Map;
amrex::ParmParse pp
Input file parser instance for the given namespace.
Definition: AMReX_HypreIJIface.cpp:15
static constexpr int MPI_COMM_WORLD
Definition: AMReX_ccse-mpi.H:54
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:550
BoxArray & coarsen(int refinement_ratio)
Coarsen each Box in the BoxArray to the specified ratio.
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition: AMReX_BoxArray.H:597
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition: AMReX_Box.H:105
AMREX_GPU_HOST_DEVICE BoxND & shift(int dir, int nzones) noexcept
Shift this BoxND nzones indexing positions in coordinate direction dir.
Definition: AMReX_Box.H:496
AMREX_GPU_HOST_DEVICE BoxND & grow(int i) noexcept
Definition: AMReX_Box.H:627
AMREX_GPU_HOST_DEVICE const int * hiVect() const &noexcept
Returns a constant pointer the array of high end coordinates. Useful for calls to FORTRAN.
Definition: AMReX_Box.H:183
AMREX_GPU_HOST_DEVICE bool isEmpty() const noexcept
Checks if it is an empty BoxND.
Definition: AMReX_Box.H:196
AMREX_GPU_HOST_DEVICE const int * loVect() const &noexcept
Returns a constant pointer the array of low end coordinates. Useful for calls to FORTRAN.
Definition: AMReX_Box.H:178
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
Definition: AMReX_InSituUtils.H:308
int GetName(int centering, int id, std::string &name)
Definition: AMReX_InSituUtils.cpp:38
void Clear()
Definition: AMReX_InSituUtils.H:310
int Size(int centering)
Definition: AMReX_InSituUtils.H:315
int GetIndex(const std::string &arrayName, int centering, int &desc, int &comp)
Definition: AMReX_InSituUtils.cpp:10
std::map< int, std::map< std::string, std::pair< int, int > > > Map
Definition: AMReX_InSituUtils.H:320
svtkDoubleArray
Definition: AMReX_InSituUtils.H:64
int MaskCoveredCells(const amrex::Box &pdom, const amrex::BoxArray &cBoxes, const amrex::DistributionMapping &cMap, amrex::BoxArray fBoxes, const IntVect &fRefRatio, int ng, std::vector< n_t * > &cMasks)
Definition: AMReX_InSituUtils.H:237
CellGhostTypes
Definition: AMReX_InSituUtils.H:31
@ HIDDENCELL
Definition: AMReX_InSituUtils.H:37
@ LOWCONNECTIVITYCELL
Definition: AMReX_InSituUtils.H:34
@ HIGHCONNECTIVITYCELL
Definition: AMReX_InSituUtils.H:33
@ REFINEDCELL
Definition: AMReX_InSituUtils.H:35
@ EXTERIORCELL
Definition: AMReX_InSituUtils.H:36
@ DUPLICATECELL
Definition: AMReX_InSituUtils.H:32
int MaskGhostCells(const amrex::Box &pdom, const amrex::BoxArray &boxes, const amrex::DistributionMapping &dmap, unsigned int ng, std::vector< n_t * > &darrays)
Definition: AMReX_InSituUtils.H:155
int UpdatePatch(long *len, int *lo, int *hi, n_t *darray, n_t val)
Definition: AMReX_InSituUtils.H:76
PointGhostTypes
Definition: AMReX_InSituUtils.H:42
@ HIDDENPOINT
Definition: AMReX_InSituUtils.H:44
@ DUPLICATEPOINT
Definition: AMReX_InSituUtils.H:43
int AllocateBoxArray(const amrex::Box &pdom, const amrex::BoxArray &boxes, const amrex::DistributionMapping &dmap, int ng, std::vector< n_t * > &darrays)
Definition: AMReX_InSituUtils.H:98
amrex_tt_specialize(float, svtkFloatArray, SVTK_FLOAT) amrex_tt_specialize(double
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
Definition: AMReX_InSituUtils.H:51
Definition: AMReX_InSituUtils.H:69
void operator()(n_t &elem, n_t val)
Definition: AMReX_InSituUtils.H:69
Definition: AMReX_InSituUtils.H:72
void operator()(n_t &elem, n_t val)
Definition: AMReX_InSituUtils.H:72