LagrangianVectorSpTemplates.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 "LagrangianSp.H"
27 #include "LagrangianEqn.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<template<class> class PrimitiveField>
33 (
34  const LagrangianEqnBase& eqn,
35  const LagrangianSubField<scalar, PrimitiveField>& S
36 )
37 :
38  scalarCoeff_(eqn, S),
39  tensorCoeff_(eqn)
40 {}
41 
42 
43 template<template<class> class PrimitiveField>
45 (
46  const LagrangianEqnBase& eqn,
47  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
48 )
49 :
50  scalarCoeff_(eqn, tS),
51  tensorCoeff_(eqn)
52 {}
53 
54 
55 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
56 
57 template<template<class> class PrimitiveField>
59 (
61 )
62 {
63  if (tensorCoeff_.valid())
64  {
65  tensorCoeff_ += tensor::I*S;
66  }
67  else
68  {
69  scalarCoeff_ += S;
70  }
71 }
72 
73 
74 template<template<class> class PrimitiveField>
76 (
78 )
79 {
80  makeTensor();
81  tensorCoeff_ += S;
82 }
83 
84 
85 template<template<class> class PrimitiveField>
87 (
89 )
90 {
91  if (tensorCoeff_.valid())
92  {
93  tensorCoeff_ += tensor::I*tS;
94  }
95  else
96  {
97  scalarCoeff_ += tS;
98  }
99 }
100 
101 
102 template<template<class> class PrimitiveField>
104 (
106 )
107 {
108  makeTensor();
109  tensorCoeff_ += tS;
110 }
111 
112 
113 template<class OtherType>
115 (
117 )
118 {
119  if (Sp.valid())
120  {
121  this->operator+=(Sp.S());
122  }
123 }
124 
125 
126 template<template<class> class PrimitiveField>
128 (
130 )
131 {
132  if (tensorCoeff_.valid())
133  {
134  tensorCoeff_ -= tensor::I*S;
135  }
136  else
137  {
138  scalarCoeff_ -= S;
139  }
140 }
141 
142 
143 template<template<class> class PrimitiveField>
145 (
147 )
148 {
149  makeTensor();
150  tensorCoeff_ -= S;
151 }
152 
153 
154 template<template<class> class PrimitiveField>
156 (
158 )
159 {
160  if (tensorCoeff_.valid())
161  {
162  tensorCoeff_ -= tensor::I*tS;
163  }
164  else
165  {
166  scalarCoeff_ -= tS;
167  }
168 }
169 
170 
171 template<template<class> class PrimitiveField>
173 (
175 )
176 {
177  makeTensor();
178  tensorCoeff_ -= tS;
179 }
180 
181 
182 template<class OtherType>
184 (
186 )
187 {
188  if (Sp.valid())
189  {
190  this->operator+=(Sp.S());
191  }
192 }
193 
194 
195 template<template<class> class PrimitiveField>
197 (
198  const LagrangianSubField<scalar, PrimitiveField>& S
199 )
200 {
201  scalarCoeff_ *= S;
202  tensorCoeff_ *= S;
203 }
204 
205 
206 template<template<class> class PrimitiveField>
208 (
209  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
210 )
211 {
212  *this *= tS();
213  tS.clear();
214 }
215 
216 
217 template<template<class> class PrimitiveField>
219 (
220  const LagrangianSubField<scalar, PrimitiveField>& S
221 )
222 {
223  scalarCoeff_ /= S;
224  tensorCoeff_ /= S;
225 }
226 
227 
228 template<template<class> class PrimitiveField>
230 (
231  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
232 )
233 {
234  *this /= tS();
235  tS.clear();
236 }
237 
238 
239 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Wrapper around LagrangianCoeff to specialise for the implicit coefficient. Trivial at present....
Definition: LagrangianSp.H:71
LagrangianSp(const LagrangianEqnBase &, const LagrangianSp< Type > &Sp)
Construct as copy.
Definition: LagrangianSp.C:32
static const Tensor I
Definition: Tensor.H:83
A class for managing temporary objects.
Definition: tmp.H:55
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
void operator+=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Add to a finite-volume equation.
Definition: CarrierEqn.C:271