chombo-discharge
Loading...
Searching...
No Matches
CD_BoxLoopsImplem.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_BOXLOOPSIMPLEM_H
14#define CD_BOXLOOPSIMPLEM_H
15
16// Our includes
17#include <CD_NamespaceHeader.H>
18
19#if CH_SPACEDIM == 2
20template <int Si, int Sj, typename Functor>
23{
24 static_assert(Si >= 1 && Sj >= 1, "BoxLoops::loop strides must be >= 1");
25
26 const int* lo = computeBox.loVect();
27 const int* hi = computeBox.hiVect();
28
29 for (int j = lo[1]; j <= hi[1]; j += Sj) {
31 for (int i = lo[0]; i <= hi[0]; i += Si) {
32 func(IntVect(i, j));
33 }
34 }
35}
36#else
37template <int Si, int Sj, int Sk, typename Functor>
40{
41 static_assert(Si >= 1 && Sj >= 1 && Sk >= 1, "BoxLoops::loop strides must be >= 1");
42
43 const int* lo = computeBox.loVect();
44 const int* hi = computeBox.hiVect();
45
46 for (int k = lo[2]; k <= hi[2]; k += Sk) {
47 for (int j = lo[1]; j <= hi[1]; j += Sj) {
49 for (int i = lo[0]; i <= hi[0]; i += Si) {
50 func(IntVect(i, j, k));
51 }
52 }
53 }
54}
55#endif
56
57template <typename Functor>
60{
61 for (IVSIterator iter(a_ivs); iter.ok(); ++iter) {
62 a_kernel(iter());
63 }
64}
65
66template <typename Functor>
74
75template <typename Functor>
78{
79
80 // TLDR: This runs through all cells in the vof-iterator and calls the kernel.
81 for (iter.reset(); iter.ok(); ++iter) {
82 a_kernel(iter());
83 }
84}
85
86template <typename Functor>
89{
90
91 // TLDR: This runs through all cells in the vof-iterator and calls the kernel.
92 for (iter.reset(); iter.ok(); ++iter) {
93 a_kernel(iter());
94 }
95}
96
97template <typename T, typename Functor>
100{
101 const std::vector<T>& stdVec = ((Vector<T>&)a_subset).stdVector();
102
103 for (const auto& v : stdVec) {
104 a_kernel(v);
105 }
106}
107
108#include <CD_NamespaceFooter.H>
109
110#endif
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26
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