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 (
60  const LagrangianSubField<scalar, PrimitiveField>& S
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 (
77  const LagrangianSubField<tensor, PrimitiveField>& S
78 )
79 {
80  makeTensor();
81  tensorCoeff_ += S;
82 }
83 
84 
85 template<template<class> class PrimitiveField>
87 (
88  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
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 (
105  const tmp<LagrangianSubField<tensor, PrimitiveField>>& tS
106 )
107 {
108  makeTensor();
109  tensorCoeff_ += tS;
110 }
111 
112 
113 template<template<class> class PrimitiveField>
115 (
116  const LagrangianSubField<scalar, PrimitiveField>& S
117 )
118 {
119  if (tensorCoeff_.valid())
120  {
121  tensorCoeff_ -= tensor::I*S;
122  }
123  else
124  {
125  scalarCoeff_ -= S;
126  }
127 }
128 
129 
130 template<template<class> class PrimitiveField>
132 (
133  const LagrangianSubField<tensor, PrimitiveField>& S
134 )
135 {
136  makeTensor();
137  tensorCoeff_ -= S;
138 }
139 
140 
141 template<template<class> class PrimitiveField>
143 (
144  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
145 )
146 {
147  if (tensorCoeff_.valid())
148  {
149  tensorCoeff_ -= tensor::I*tS;
150  }
151  else
152  {
153  scalarCoeff_ -= tS;
154  }
155 }
156 
157 
158 template<template<class> class PrimitiveField>
160 (
161  const tmp<LagrangianSubField<tensor, PrimitiveField>>& tS
162 )
163 {
164  makeTensor();
165  tensorCoeff_ -= tS;
166 }
167 
168 
169 template<template<class> class PrimitiveField>
171 (
172  const LagrangianSubField<scalar, PrimitiveField>& S
173 )
174 {
175  scalarCoeff_ *= S;
176  tensorCoeff_ *= S;
177 }
178 
179 
180 template<template<class> class PrimitiveField>
182 (
183  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
184 )
185 {
186  *this *= tS();
187  tS.clear();
188 }
189 
190 
191 template<template<class> class PrimitiveField>
193 (
194  const LagrangianSubField<scalar, PrimitiveField>& S
195 )
196 {
197  scalarCoeff_ /= S;
198  tensorCoeff_ /= S;
199 }
200 
201 
202 template<template<class> class PrimitiveField>
204 (
205  const tmp<LagrangianSubField<scalar, PrimitiveField>>& tS
206 )
207 {
208  *this /= tS();
209  tS.clear();
210 }
211 
212 
213 // ************************************************************************* //
Wrapper around LagrangianCoeff to specialise for the implicit coefficient. Trivial at present....
Definition: LagrangianSp.H:71
LagrangianSp(const LagrangianSp< Type > &Sp)
Construct as copy.
Definition: LagrangianSp.C:31
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
static const Identity< scalar > I
Definition: Identity.H:93