LagrangianSp.H
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 Class
25  Foam::LagrangianSp
26 
27 Description
28  Wrapper around LagrangianCoeff to specialise for the implicit coefficient.
29  Trivial at present. The idea eventually is to make the vector implicit
30  coefficient automatically build tensor coefficients as and when a model
31  supplies tensor values.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef LagrangianSp_H
36 #define LagrangianSp_H
37 
38 #include "LagrangianCoeff.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 template<class Type>
46 class LagrangianSp;
47 
48 template<class Type>
49 class LagrangianEqn;
50 
51 template<class Type>
53 (
55  const LagrangianSp<Type>& Sp
56 );
57 
59 (
62 );
63 
64 /*---------------------------------------------------------------------------*\
65  Class LagrangianSp Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 template<class Type>
69 class LagrangianSp
70 :
71  public LagrangianCoeff<scalar, true>
72 {
73 public:
74 
75  // Constructors
76 
77  //- Inherit base class constructors
79 
80  //- Construct as copy
82 
83  //- Construct as copy or reuse as specified
85  (
86  const LagrangianEqnBase&,
88  const bool reuse
89  );
90 
91  //- Move construct
93 
94 
95  // Member Functions
96 
97  //- Return the scalar diagonal coefficient
99 
100  //- Return the scalar off-diagonal coefficients
102 
103  //- Return the equivalent explicit coefficient
105 
106  //- Return the equivalent explicit coefficient. Pass the equation
107  // explicitly so this can be used in the equation destructor when the
108  // reference held by the coeff classes might no longer be valid.
110 
111 
112  // Member Operators
113 
114  //- Addition assignment
116 
117  //- Addition assignment
118  template<class OtherType>
119  void operator+=(const LagrangianSp<OtherType>&);
120 
121  //- Subtraction assignment
123 
124  //- Subtraction assignment
125  template<class OtherType>
127 
128  //- Multiply assignment
130 
131  //- Division assignment
133 
134 
135  // Friend Operators
136 
137  //- Divide an Su by an Sp
138  friend tmp<LagrangianSubField<Type>> operator/ <Type>
139  (
141  const LagrangianSp<Type>& Sp
142  );
143 };
144 
145 
146 /*---------------------------------------------------------------------------*\
147  Class LagrangianSp<vector> Declaration
148 \*---------------------------------------------------------------------------*/
149 
150 template<>
151 class LagrangianSp<vector>
152 :
153  public tmp<LagrangianSp<vector>>::refCount
154 {
155  // Private Data
156 
157  //- Scalar coefficient
158  LagrangianCoeff<scalar, true> scalarCoeff_;
159 
160  //- Tensor coefficient
161  LagrangianCoeff<tensor, true> tensorCoeff_;
162 
163 
164  // Private Member Functions
165 
166  //- Promote the coefficient storage from scalar to tensor
167  void makeTensor();
168 
169 
170 public:
171 
172  // Constructors
173 
174  //- Construct empty
176 
177  //- Construct as copy
179  (
180  const LagrangianEqnBase& eqn,
181  const LagrangianSp<vector>& coeff
182  );
183 
184  //- Construct as copy or reuse as specified
186  (
187  const LagrangianEqnBase& eqn,
188  LagrangianSp<vector>& coeff,
189  const bool reuse
190  );
191 
192  //- Move construct
194 
195  //- Construct from a field
196  template<template<class> class PrimitiveField>
198  (
199  const LagrangianEqnBase& eqn,
201  );
202 
203  //- Construct from a tmp field
204  template<template<class> class PrimitiveField>
206  (
207  const LagrangianEqnBase& eqn,
209  );
210 
211 
212  // Member Functions
213 
214  //- Access the equation
215  const LagrangianEqnBase& eqn() const;
216 
217  //- Determine whether this coefficient has values or not
218  bool valid() const;
219 
220  //- In-place negation
221  void negate();
222 
223  //- Return the scalar diagonal coefficient
225 
226  //- Return the scalar off-diagonal coefficients
228 
229  //- Return the equivalent explicit coefficient
231 
232  //- Return the equivalent explicit coefficient. Pass the equation
233  // explicitly so this can be used in the equation destructor when the
234  // reference held by the coeff classes might no longer be valid.
236  (
237  const LagrangianEqn<vector>&
238  ) const;
239 
240 
241  // Member Operators
242 
243  //- Addition assignment
244  template<template<class> class PrimitiveField>
246 
247  //- Addition assignment
248  template<template<class> class PrimitiveField>
250 
251  //- Addition assignment
252  template<template<class> class PrimitiveField>
254 
255  //- Addition assignment
256  template<template<class> class PrimitiveField>
258 
259  //- Addition assignment
260  void operator+=(const LagrangianCoeff<scalar, true>& coeff);
261 
262  //- Addition assignment
263  void operator+=(const LagrangianCoeff<tensor, true>& coeff);
264 
265  //- Addition assignment
266  void operator+=(const LagrangianSp<vector>& Sp);
267 
268  //- Addition assignment
269  template<class OtherType>
271 
272  //- Addition assignment
273  void operator+=(const dimensioned<scalar>&);
274 
275  //- Addition assignment
276  void operator+=(const dimensioned<tensor>&);
277 
278  //- Addition assignment
279  void operator+=(const zero);
280 
281  //- Subtraction assignment
282  template<template<class> class PrimitiveField>
284 
285  //- Subtraction assignment
286  template<template<class> class PrimitiveField>
288 
289  //- Subtraction assignment
290  template<template<class> class PrimitiveField>
292 
293  //- Subtraction assignment
294  template<template<class> class PrimitiveField>
296 
297  //- Addition assignment
298  void operator-=(const LagrangianCoeff<scalar, true>& coeff);
299 
300  //- Addition assignment
301  void operator-=(const LagrangianCoeff<tensor, true>& coeff);
302 
303  //- Subtraction assignment
304  void operator-=(const LagrangianSp<vector>& Sp);
305 
306  //- Addition assignment
307  template<class OtherType>
309 
310  //- Subtraction assignment
311  void operator-=(const dimensioned<scalar>&);
312 
313  //- Subtraction assignment
314  void operator-=(const dimensioned<tensor>&);
315 
316  //- Subtraction assignment
317  void operator-=(const zero);
318 
319  //- Multiply assignment
320  template<template<class> class PrimitiveField>
322 
323  //- Multiply assignment
324  template<template<class> class PrimitiveField>
326 
327  //- Multiply assignment
328  void operator*=(const dimensioned<scalar>&);
329 
330  //- Division assignment
331  template<template<class> class PrimitiveField>
333 
334  //- Division assignment
335  template<template<class> class PrimitiveField>
337 
338  //- Division assignment
339  void operator/=(const dimensioned<scalar>& dt);
340 
341 
342  // Friend Operators
343 
344  //- Divide an Su by an Sp
345  friend tmp<LagrangianSubField<vector>> operator/
346  (
348  const LagrangianSp<vector>& Sp
349  );
350 };
351 
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 } // End namespace Foam
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #ifdef NoRepository
360  #include "LagrangianSp.C"
362 #endif
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 
366 #endif
367 
368 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
bool valid() const
Determine whether this coefficient has values or not.
const LagrangianEqnBase & eqn() const
Access the equation.
void operator/=(const LagrangianSubField< scalar, PrimitiveField > &)
Division assignment.
void operator*=(const LagrangianSubField< scalar, PrimitiveField > &)
Multiply assignment.
Non-templated base class for Lagrangian equations.
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
Wrapper around LagrangianCoeff to specialise for the implicit coefficient. Trivial at present....
Definition: LagrangianSp.H:71
tmp< LagrangianCoeff< Type, false > > H() const
Return the scalar off-diagonal coefficients.
Definition: LagrangianSp.C:72
tmp< LagrangianCoeff< Type, false > > Su() const
Return the equivalent explicit coefficient.
Definition: LagrangianSp.C:84
tmp< LagrangianCoeff< scalar, true > > A() const
Return the scalar diagonal coefficient.
Definition: LagrangianSp.C:64
void operator+=(const LagrangianSp< OtherType > &)
Addition assignment.
Definition: LagrangianSp.C:108
LagrangianSp(const LagrangianEqnBase &, const LagrangianSp< Type > &Sp)
Construct as copy.
Definition: LagrangianSp.C:32
void operator-=(const LagrangianSp< OtherType > &Sp)
Subtraction assignment.
Definition: LagrangianSp.C:116
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
A class for managing temporary objects.
Definition: tmp.H:55
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
tmp< VolField< Type > > Su(const VolField< Type > &su, const VolField< Type > &vf)
Definition: fvcSup.C:44
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
Namespace for OpenFOAM.