chombo-discharge
Loading...
Searching...
No Matches
Functions
BoxLoops Namespace Reference

Namespace for encapsulating loop types. More...

Functions

template<int Si, int Sj, int Sk, typename Functor >
ALWAYS_INLINE void loop (const Box &a_computeBox, Functor &&kernel)
 Launch a C++ kernel over a regular grid with compile-time per-dimension strides.
 
template<typename Functor >
ALWAYS_INLINE void loop (const IntVectSet &a_ivs, Functor &&a_kernel)
 Launch a C++ kernel over a subset of cells.
 
template<typename Functor >
ALWAYS_INLINE void loop (const DenseIntVectSet &a_ivs, Functor &&a_kernel)
 Launch a C++ kernel over a subset of cells.
 
template<typename Functor >
ALWAYS_INLINE void loop (VoFIterator &a_iter, Functor &&a_kernel)
 Launch a C++ kernel over cut-cells.
 
template<typename Functor >
ALWAYS_INLINE void loop (FaceIterator &a_iter, Functor &&a_kernel)
 Launch a C++ kernel over faces.
 
template<typename T , typename Functor >
ALWAYS_INLINE void loop (const Vector< T > &a_subset, Functor &&a_kernel)
 Launch a C++ kernel over a specified subset of something.
 

Detailed Description

Namespace for encapsulating loop types.

BoxLoops provides several overloads of loop for iterating over structured and unstructured grid data. The general pattern is:

Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
ALWAYS_INLINE void loop(const Box &a_computeBox, Functor &&kernel)
Launch a C++ kernel over a regular grid with compile-time per-dimension strides.
Definition CD_BoxLoopsImplem.H:39

where kernel is a callable (lambda or functor) taking the element type for that overload.

Box loop — compile-time stride: Strides are non-type template parameters, making their value visible to the compiler so the inner loop can be auto-vectorized. All strides must be >= 1 (enforced by static_assert). Use D_DECL for dimension-independent call sites. Unit-stride iteration is D_DECL(1,1,1):

BoxLoops::loop<D_DECL(1, 1, 1)>(box, [&](const IntVect& iv) {
phi(iv, 0) = 0.0;
});
BoxLoops::loop<D_DECL(2, 2, 2)>(colorBox, [&](const IntVect& iv) {
phi(iv, 0) = 0.0;
});

VoF, face, and set iterators:

BoxLoops::loop(vofIt, [&](const VolIndex& vof) { ... });
BoxLoops::loop(faceIt, [&](const FaceIndex& face) { ... });
BoxLoops::loop(ivs, [&](const IntVect& iv) { ... });

Function Documentation

◆ loop() [1/6]

template<int Si, int Sj, int Sk, typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( const Box a_computeBox,
Functor &&  kernel 
)

Launch a C++ kernel over a regular grid with compile-time per-dimension strides.

Strides are encoded as non-type template parameters, making them visible to the compiler as constants and enabling auto-vectorization of the innermost loop. All strides must be >= 1 (enforced by static_assert).

Note: IntVect cannot be a non-type template parameter in C++14, so per-dimension int parameters are used instead. Call sites can use D_DECL for dimension independence, e.g.:

BoxLoops::loop<D_DECL(2, 2, 2)>(box, kernel);
Parameters
[in]a_computeBoxComputation box
[in]kernelKernel

◆ loop() [2/6]

template<typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( const DenseIntVectSet a_ivs,
Functor &&  a_kernel 
)

Launch a C++ kernel over a subset of cells.

Parameters
[in,out]a_kernelKernel to launch
[in]a_ivsIvs

◆ loop() [3/6]

template<typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( const IntVectSet a_ivs,
Functor &&  a_kernel 
)

Launch a C++ kernel over a subset of cells.

Parameters
[in,out]a_kernelKernel to launch
[in]a_ivsIvs

◆ loop() [4/6]

template<typename T , typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( const Vector< T > &  a_subset,
Functor &&  a_kernel 
)

Launch a C++ kernel over a specified subset of something.

Parameters
[in,out]a_subsetSubset. E.g. a std::vector<VolIndex>
[in,out]a_kernelKernel to launch

◆ loop() [5/6]

template<typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( FaceIterator a_iter,
Functor &&  a_kernel 
)

Launch a C++ kernel over faces.

Parameters
[in,out]a_kernelKernel to launch
[in]a_iterIter

◆ loop() [6/6]

template<typename Functor >
ALWAYS_INLINE void BoxLoops::loop ( VoFIterator a_iter,
Functor &&  a_kernel 
)

Launch a C++ kernel over cut-cells.

Parameters
[in,out]a_kernelKernel to launch
[in]a_iterIter