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 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, volMesh>
42  (
43  IOobject
44  (
45  lField.mesh().mesh().name() + ":" + lField.name(),
46  mesh_.time().name(),
47  mesh_,
48  IOobject::NO_READ,
49  IOobject::AUTO_WRITE
50  ),
51  mesh_,
52  dimensioned<Type>(lField.dimensions(), Zero)
53  )
54  );
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
60 template<class Type, bool Implicit>
61 template<class PsiType>
63 :
64  mesh_(psi.mesh())
65 {}
66 
67 
68 template<class Type, bool Implicit>
70 (
71  const CarrierCoeff<Type, Implicit>& coeff
72 )
73 :
74  mesh_(coeff.mesh_),
75  S_(coeff.S_, false)
76 {}
77 
78 
79 template<class Type, bool Implicit>
81 (
83  const bool reuse
84 )
85 :
86  mesh_(coeff.mesh_),
87  S_(coeff.S_, reuse)
88 {}
89 
90 
91 template<class Type, bool Implicit>
93 (
95 )
96 :
97  mesh_(coeff.mesh_),
98  S_(coeff.S_, true)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
103 
104 template<class Type, bool Implicit>
106 {
107  return S_.valid();
108 }
109 
110 
111 template<class Type, bool Implicit>
113 {
114  S_.clear();
115 }
116 
117 
118 template<class Type, bool Implicit>
121 {
122  return S_();
123 }
124 
125 
126 template<class Type, bool Implicit>
128 {
129  if (valid()) S_() = -S_();
130 }
131 
132 
133 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
134 
135 template<class Type, bool Implicit>
137 (
138  const LagrangianCoeff<Type, Implicit>& lCoeff
139 )
140 {
141  if (!lCoeff.valid()) return;
142 
143  initialise(lCoeff.S());
144 
145  Lagrangianc::accumulate(lCoeff.S(), S_(), lCoeff.eqn().name());
146 }
147 
148 
149 template<class Type, bool Implicit>
151 (
152  const LagrangianCoeff<Type, Implicit>& lCoeff
153 )
154 {
155  if (!lCoeff.valid()) return;
156 
157  initialise(lCoeff.S());
158 
159  Lagrangianc::accumulate((-lCoeff.S())(), S_(), lCoeff.eqn().name());
160 }
161 
162 
163 // ************************************************************************* //
Functions for accumulating Lagrangian values into cell fields.
Class to store a coefficient of a carrier equation.
Definition: CarrierCoeff.H:52
bool valid() const
Determine whether this coefficient has values or not.
Definition: CarrierCoeff.C:105
CarrierCoeff(const VolField< PsiType > &psi)
Construct from a reference to the field.
Definition: CarrierCoeff.C:62
void negate()
In-place negation.
Definition: CarrierCoeff.C:127
void clear()
Clear the coefficient values.
Definition: CarrierCoeff.C:112
const DimensionedField< Type, volMesh > & S() const
Access the field.
Definition: CarrierCoeff.C:120
Generic GeometricField class.
Class to store a coefficient of a Lagrangian equation.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const volScalarField & psi
tmp< DimensionedField< Type, CellMesh > > accumulate(const DimensionedField< Type, LagrangianMesh, PrimitiveField > &lPsi, const word &name)
bool valid(const PtrList< ModelType > &l)
static const zero Zero
Definition: zero.H:97