OpenLB 1.8.1
Loading...
Searching...
No Matches
operator.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2024 Adrian Kummerlaender
4 *
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
25#ifndef REFINEMENT_PLATFORM_CPU_OPERATOR_H
26#define REFINEMENT_PLATFORM_CPU_OPERATOR_H
27
28#include "refinement/operator.h"
30
31namespace olb {
32
33template <typename T, typename DESCRIPTOR, Platform PLATFORM, typename OPERATOR>
34requires (isPlatformCPU(PLATFORM))
37 const auto& cellIdCoarse = data.getConcreteData().template getField<fields::refinement::CELL_ID_COARSE>();
38 const auto& cellIdFine = data.getConcreteData().template getField<fields::refinement::CELL_ID_FINE>();
39 auto parameters = data.getConcreteData().template getData<OperatorParameters<OPERATOR>>().parameters;
40
41 if constexpr (OPERATOR::scope == refinement::OperatorScope::PerCoarseCell) {
42 #ifdef PARALLEL_MODE_OMP
43 #pragma omp parallel for schedule(static)
44 #endif
45 for (CellID i=0; i < cellIdFine.getSize(); ++i) {
46 if (cellIdCoarse[0][i] != 0) {
47 cpu::Cell cCell{data.getCoarseLattice(), cellIdCoarse[0][i]};
48 cpu::Cell fCell{data.getFineLattice(), cellIdFine[0][i]};
49 cpu::Row cData{data.getConcreteData(), i};
50 OPERATOR().apply(cCell, fCell, cData, parameters);
51 }
52 }
53 } else if constexpr (OPERATOR::scope == refinement::OperatorScope::PerFineCell) {
54 if constexpr (OPERATOR::data::template contains<fields::refinement::CONTEXT_NEIGHBORS>()) {
55 #ifdef PARALLEL_MODE_OMP
56 #pragma omp parallel for schedule(static)
57 #endif
58 for (CellID i=0; i < cellIdFine.getSize(); ++i) {
59 cpu::Cell fCell{data.getFineLattice(), cellIdFine[0][i]};
60 refinement::CoarseCell cCell{cpu::Cell{data.getCoarseLattice(), cellIdCoarse[0][i]},
61 data.getFineLattice().getLatticeR(cellIdFine[0][i])};
63 OPERATOR().apply(cCell, fCell, cData, parameters);
64 }
65 } else {
66 #ifdef PARALLEL_MODE_OMP
67 #pragma omp parallel for schedule(static)
68 #endif
69 for (CellID i=0; i < cellIdFine.getSize(); ++i) {
70 cpu::Cell fCell{data.getFineLattice(), cellIdFine[0][i]};
71 refinement::CoarseCell cCell{cpu::Cell{data.getCoarseLattice(), cellIdCoarse[0][i]},
72 data.getFineLattice().getLatticeR(cellIdFine[0][i])};
74 OPERATOR().apply(cCell, fCell, cData, parameters);
75 }
76 }
77 }
78 }
79};
80
81}
82
83#endif
#define OPERATOR(OP, rhs)
Definition aDiffTape.h:64
Context for the execution of block refinement operators.
Cell concept for concrete block lattices on CPU platforms.
Definition cell.h:141
Row concept for concrete non-LBM lattices on CPU platforms.
Definition cell.h:85
@ PerFineCell
OPERATOR is provided a fine cell and a coarse cell proxy.
@ PerCoarseCell
OPERATOR is provided a coarse cell and its co-incident fine cell.
Top level namespace for all of OpenLB.
std::uint32_t CellID
Type for sequential block-local cell indices.
constexpr bool isPlatformCPU(Platform platform)
Returns true if platform is equal to Platform::CPU_*.
Definition platform.h:83
void apply(ConcreteBlockRefinementContextD< T, DESCRIPTOR, PLATFORM > &data)
Definition operator.h:36
Executor of a concrete block refinement operator in a given context.
Definition operator.h:40