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 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
84  LagrangianSp(LagrangianSp<Type>& Sp, const bool reuse);
85 
86  //- Move construct
88 
89 
90  // Member Functions
91 
92  //- Return the scalar diagonal coefficient
94 
95  //- Return the scalar off-diagonal coefficients
97 
98  //- Return the equivalent explicit coefficient
100 
101  //- Return the equivalent explicit coefficient. Pass the equation
102  // explicitly so this can be used in the equation destructor when the
103  // reference held by the coeff classes might no longer be valid.
105 
106 
107  // Member Operators
108 
109  //- Addition assignment
111 
112  //- Addition assignment
113  void operator+=(const LagrangianSp<Type>& Sp);
114 
115  //- Subtraction assignment
117 
118  //- Subtraction assignment
119  void operator-=(const LagrangianSp<Type>& Sp);
120 
121  //- Multiply assignment
123 
124  //- Division assignment
126 
127 
128  // Friend Operators
129 
130  //- Divide an Su by an Sp
131  friend tmp<LagrangianSubField<Type>> operator/ <Type>
132  (
134  const LagrangianSp<Type>& Sp
135  );
136 };
137 
138 
139 /*---------------------------------------------------------------------------*\
140  Class LagrangianSp<vector> Declaration
141 \*---------------------------------------------------------------------------*/
142 
143 template<>
144 class LagrangianSp<vector>
145 :
146  public tmp<LagrangianSp<vector>>::refCount
147 {
148  // Private Member Data
149 
150  //- Scalar coefficient
151  LagrangianCoeff<scalar, true> scalarCoeff_;
152 
153  //- Tensor coefficient
154  LagrangianCoeff<tensor, true> tensorCoeff_;
155 
156 
157  // Private Member Functions
158 
159  //- Promote the coefficient storage from scalar to tensor
160  void makeTensor();
161 
162 
163 public:
164 
165  // Constructors
166 
167  //- Construct from a reference to the equation
169 
170  //- Construct as copy
171  LagrangianSp(const LagrangianSp<vector>& coeff);
172 
173  //- Construct as copy or reuse as specified
174  LagrangianSp(LagrangianSp<vector>& coeff, const bool reuse);
175 
176  //- Move construct
178 
179  //- Construct from a field
180  template<template<class> class PrimitiveField>
182  (
183  const LagrangianEqnBase& eqn,
185  );
186 
187  //- Construct from a tmp field
188  template<template<class> class PrimitiveField>
190  (
191  const LagrangianEqnBase& eqn,
193  );
194 
195 
196  // Member Functions
197 
198  //- Access the equation
199  const LagrangianEqnBase& eqn() const;
200 
201  //- Determine whether this coefficient has values or not
202  bool valid() const;
203 
204  //- In-place negation
205  void negate();
206 
207  //- Return the scalar diagonal coefficient
209 
210  //- Return the scalar off-diagonal coefficients
212 
213  //- Return the equivalent explicit coefficient
215 
216  //- Return the equivalent explicit coefficient. Pass the equation
217  // explicitly so this can be used in the equation destructor when the
218  // reference held by the coeff classes might no longer be valid.
220  (
221  const LagrangianEqn<vector>&
222  ) const;
223 
224 
225  // Member Operators
226 
227  //- Addition assignment
228  template<template<class> class PrimitiveField>
230 
231  //- Addition assignment
232  template<template<class> class PrimitiveField>
234 
235  //- Addition assignment
236  template<template<class> class PrimitiveField>
238 
239  //- Addition assignment
240  template<template<class> class PrimitiveField>
242 
243  //- Addition assignment
244  void operator+=(const LagrangianCoeff<scalar, true>& coeff);
245 
246  //- Addition assignment
247  void operator+=(const LagrangianCoeff<tensor, true>& coeff);
248 
249  //- Addition assignment
250  void operator+=(const LagrangianSp<vector>& Sp);
251 
252  //- Addition assignment
253  void operator+=(const dimensioned<scalar>&);
254 
255  //- Addition assignment
256  void operator+=(const dimensioned<tensor>&);
257 
258  //- Addition assignment
259  void operator+=(const zero);
260 
261  //- Subtraction assignment
262  template<template<class> class PrimitiveField>
264 
265  //- Subtraction assignment
266  template<template<class> class PrimitiveField>
268 
269  //- Subtraction assignment
270  template<template<class> class PrimitiveField>
272 
273  //- Subtraction assignment
274  template<template<class> class PrimitiveField>
276 
277  //- Addition assignment
278  void operator-=(const LagrangianCoeff<scalar, true>& coeff);
279 
280  //- Addition assignment
281  void operator-=(const LagrangianCoeff<tensor, true>& coeff);
282 
283  //- Subtraction assignment
284  void operator-=(const LagrangianSp<vector>& Sp);
285 
286  //- Subtraction assignment
287  void operator-=(const dimensioned<scalar>&);
288 
289  //- Subtraction assignment
290  void operator-=(const dimensioned<tensor>&);
291 
292  //- Subtraction assignment
293  void operator-=(const zero);
294 
295  //- Multiply assignment
296  template<template<class> class PrimitiveField>
298 
299  //- Multiply assignment
300  template<template<class> class PrimitiveField>
302 
303  //- Multiply assignment
304  void operator*=(const dimensioned<scalar>&);
305 
306  //- Division assignment
307  template<template<class> class PrimitiveField>
309 
310  //- Division assignment
311  template<template<class> class PrimitiveField>
313 
314  //- Division assignment
315  void operator/=(const dimensioned<scalar>& dt);
316 
317 
318  // Friend Operators
319 
320  //- Divide an Su by an Sp
321  friend tmp<LagrangianSubField<vector>> operator/
322  (
324  const LagrangianSp<vector>& Sp
325  );
326 };
327 
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 } // End namespace Foam
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 #ifdef NoRepository
336  #include "LagrangianSp.C"
338 #endif
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 #endif
343 
344 // ************************************************************************* //
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.
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:63
LagrangianSp(const LagrangianSp< Type > &Sp)
Construct as copy.
Definition: LagrangianSp.C:31
void operator-=(const LagrangianSp< Type > &Sp)
Subtraction assignment.
Definition: LagrangianSp.C:105
tmp< LagrangianCoeff< Type, false > > Su() const
Return the equivalent explicit coefficient.
Definition: LagrangianSp.C:75
tmp< LagrangianCoeff< scalar, true > > A() const
Return the scalar diagonal coefficient.
Definition: LagrangianSp.C:55
void operator+=(const LagrangianSp< Type > &Sp)
Addition assignment.
Definition: LagrangianSp.C:98
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.