OpenLB 1.8.1
Loading...
Searching...
No Matches
writeFunctorO.h
Go to the documentation of this file.
1/* Lattice Boltzmann sample, written in C++, using the OpenLB
2 * library
3 *
4 * Copyright (C) 2025 Shota Ito
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 WRITE_FUNCTOR_O_H
26#define WRITE_FUNCTOR_O_H
27
28#include <core/operator.h>
29#include "../concept.h"
30#include "../superLatticeO.h"
31
32namespace olb {
33
34namespace operators {
35
37template <typename FUNCTOR, typename TO>
40 using parameters = FUNCTOR::parameters;
41
42 int getPriority() const {
43 return 0;
44 }
45
46 template <typename CELL, typename PARAMETERS>
47 void apply(CELL& cell, PARAMETERS& parameters) any_platform
48 {
49 cell.template setField<TO>(FUNCTOR{}.compute(cell, parameters));
50 }
51};
52
53}
54
55// Returns a unique pointer to the SuperLatticeO with the writing operator
56template <typename FUNCTOR, typename TO, typename T, typename DESCRIPTOR>
60
61template <typename FUNCTOR, typename TO, typename T, typename DESCRIPTOR>
63 auto superLatticeO = makeSuperLatticeO<operators::WriteFunctorO<FUNCTOR,TO>>(lattice);
64 superLatticeO->execute();
65}
66
67template <typename FUNCTOR, typename TO, typename T, typename DESCRIPTOR>
70 auto superLatticeO = makeSuperLatticeO<operators::WriteFunctorO<FUNCTOR,TO>>(lattice);
71 superLatticeO->restrictTo(std::forward<FunctorPtr<SuperIndicatorF<T,DESCRIPTOR::d>>>(indicator));
72 superLatticeO->execute();
73}
74
75template <typename FUNCTOR, typename TO, typename T, typename DESCRIPTOR>
78 T conversionFactor = 1.0) {
79 auto superLatticeO = makeSuperLatticeO<operators::WriteFunctorO<FUNCTOR,TO>>(lattice);
80 superLatticeO->template setParameter<descriptors::CONVERSION>(conversionFactor);
81 superLatticeO->restrictTo(std::forward<FunctorPtr<SuperIndicatorF<T,DESCRIPTOR::d>>>(indicator));
82 superLatticeO->execute();
83}
84
85}
86#endif
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
Super class maintaining block lattices for a cuboid decomposition.
Top level namespace for all of OpenLB.
void writeFunctorTo(SuperLattice< T, DESCRIPTOR > &lattice)
auto makeWriteFunctorO(SuperLattice< T, DESCRIPTOR > &lattice)
auto makeSuperLatticeO(SuperLattice< T, DESCRIPTOR > &lattice)
OperatorScope
Block-wide operator application scopes.
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
void writePhysFunctorTo(SuperLattice< T, DESCRIPTOR > &lattice, FunctorPtr< SuperIndicatorF< T, DESCRIPTOR::d > > &&indicator, T conversionFactor=1.0)
std::conditional_t< D==2, SuperIndicatorF2D< T >, SuperIndicatorF3D< T > > SuperIndicatorF
Definition aliases.h:197
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
Operator which evaluate a functor and write its results into the passed field.
FUNCTOR::parameters parameters
static constexpr OperatorScope scope
void apply(CELL &cell, PARAMETERS &parameters) any_platform