CarrierCoeff.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "CarrierCoeff.H"
27 #include "LagrangiancAccumulate.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class Type, bool Implicit>
33 (
34  const LagrangianSubField<Type>& lField
35 )
36 {
37  if (valid()) return;
38 
39  S_.set
40  (
41  new DimensionedField<Type, fvMesh>
42  (
43  IOobject
44  (
45  lField.mesh().mesh().name()
46  + ":" + eqn_.name()
47  + ":S" + (Implicit ? 'p' : 'u'),
48  eqn_.mesh().time().name(),
49  eqn_.mesh(),
50  IOobject::NO_READ,
51  IOobject::AUTO_WRITE
52  ),
53  eqn_.mesh(),
54  dimensioned<Type>(lField.dimensions(), Zero)
55  )
56  );
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
62 template<class Type, bool Implicit>
64 :
65  eqn_(eqn)
66 {}
67 
68 
69 template<class Type, bool Implicit>
71 (
72  const CarrierCoeff<Type, Implicit>& coeff
73 )
74 :
75  eqn_(coeff.eqn_),
76  S_(coeff.S_, false)
77 {}
78 
79 
80 template<class Type, bool Implicit>
82 (
84  const bool reuse
85 )
86 :
87  eqn_(coeff.eqn_),
88  S_(coeff.S_, reuse)
89 {}
90 
91 
92 template<class Type, bool Implicit>
94 (
96 )
97 :
98  eqn_(coeff.eqn_),
99  S_(coeff.S_, true)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
104 
105 template<class Type, bool Implicit>
107 {
108  return S_.valid();
109 }
110 
111 
112 template<class Type, bool Implicit>
114 {
115  S_.clear();
116 }
117 
118 
119 template<class Type, bool Implicit>
122 {
123  return S_();
124 }
125 
126 
127 template<class Type, bool Implicit>
129 {
130  if (valid()) S_() = -S_();
131 }
132 
133 
134 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
135 
136 template<class Type, bool Implicit>
138 (
139  const LagrangianCoeff<Type, Implicit>& lCoeff
140 )
141 {
142  if (!lCoeff.valid()) return;
143 
144  initialise(lCoeff.S());
145 
146  Lagrangianc::accumulate(lCoeff.S(), S_(), lCoeff.eqn().name());
147 }
148 
149 
150 template<class Type, bool Implicit>
152 (
153  const LagrangianCoeff<Type, Implicit>& lCoeff
154 )
155 {
156  if (!lCoeff.valid()) return;
157 
158  initialise(lCoeff.S());
159 
160  Lagrangianc::accumulate((-lCoeff.S())(), S_(), lCoeff.eqn().name());
161 }
162 
163 
164 template<class Type, bool Implicit>
166 (
167  const dimensionedScalar& s
168 )
169 {
170  if (valid()) S_() *= s;
171 }
172 
173 
174 template<class Type, bool Implicit>
176 (
177  const dimensionedScalar& s
178 )
179 {
180  if (valid()) S_() /= s;
181 }
182 
183 
184 // ************************************************************************* //
Functions for accumulating Lagrangian values into cell fields.
Class to store a coefficient of a carrier equation.
Definition: CarrierCoeff.H:53
bool valid() const
Determine whether this coefficient has values or not.
Definition: CarrierCoeff.C:106
CarrierCoeff(const CarrierEqnBase &eqn)
Construct from a reference to the equation.
Definition: CarrierCoeff.C:63
const DimensionedField< Type, fvMesh > & S() const
Access the field.
Definition: CarrierCoeff.C:121
void negate()
In-place negation.
Definition: CarrierCoeff.C:128
void clear()
Clear the coefficient values.
Definition: CarrierCoeff.C:113
Non-templated base class for carrier equations.
Class to store a coefficient of a Lagrangian equation.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< DimensionedField< Type, CellMesh > > accumulate(const DimensionedField< Type, LagrangianMesh, PrimitiveField > &lPsi, const word &name)
Accumulate a Lagrangian field into a finite volume field.
bool valid(const PtrList< ModelType > &l)
static const zero Zero
Definition: zero.H:97