LagrangianmSp.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 "LagrangianmSp.H"
27 #include "LagrangianSpScheme.H"
28 #include "LagrangianMesh.H"
29 #include "LagrangianSubFields.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 template<class Type, class SpType>
36 (
37  const LagrangianSubField<SpType>& Sp,
38  const LagrangianSubSubField<Type>& psi
39 )
40 {
41  if (isNull(Sp))
42  {
43  return tmp<LagrangianEqn<Type>>(new LagrangianEqn<Type>(psi));
44  }
45 
46  const LagrangianMesh& mesh = psi.mesh().mesh();
47 
48  return
50  (
51  mesh,
52  mesh.schemes().Sp("Sp(" + Sp.name() + ',' + psi.name() + ')')
53  ).ref().LagrangianmSp(Sp, psi);
54 }
55 
56 
57 template<class Type, class SpType, template<class> class PrimitiveField>
59 (
60  const LagrangianSubField<SpType>& Sp,
61  const LagrangianSubField<Type, PrimitiveField>& psi
62 )
63 {
64  return Lagrangianm::Sp(Sp, toSubField(psi)());
65 }
66 
67 
68 template<class Type>
70 (
72  const LagrangianSubSubField<Type>& psi
73 )
74 {
75  if (isNull(Sp))
76  {
77  return tmp<LagrangianEqn<Type>>(new LagrangianEqn<Type>(psi));
78  }
79 
80  tmp<LagrangianSubSubField<Type>> tpsi0 =
81  psi.nOldTimes()
82  ? toSubField(psi.oldTime())
83  : tmp<LagrangianSubSubField<Type>>(psi);
84 
85  return
86  Lagrangian::SpSchemes::Explicit<Type, scalar>
87  (
88  psi.mesh().mesh()
89  ).LagrangianmSp(Sp, tpsi0());
90 }
91 
92 
93 template<class Type>
95 (
98  const LagrangianSubSubField<Type>& psi
99 )
100 {
101  if (isNull(Sp))
102  {
103  return tmp<LagrangianEqn<Type>>(new LagrangianEqn<Type>(psi));
104  }
105 
106  tmp<LagrangianSubScalarSubField> tm0 =
107  m.nOldTimes()
108  ? toSubField(m.oldTime())
109  : tmp<LagrangianSubSubField<Type>>(m);
110  tmp<LagrangianSubSubField<Type>> tpsi0 =
111  psi.nOldTimes()
112  ? toSubField(psi.oldTime())
113  : tmp<LagrangianSubSubField<Type>>(psi);
114 
115  return
116  Lagrangian::SpSchemes::Explicit<Type, scalar>
117  (
118  psi.mesh().mesh()
119  ).LagrangianmSp(Sp*tm0, tpsi0());
120 }
121 
122 
123 template<class Type>
125 (
126  const LagrangianSubScalarField& deltaTSp,
127  const LagrangianSubSubField<Type>& psi
128 )
129 {
130  if (isNull(deltaTSp))
131  {
132  return tmp<LagrangianEqn<Type>>(new LagrangianEqn<Type>(psi));
133  }
134 
135  tmp<LagrangianEqn<Type>> tEqn(new LagrangianEqn<Type>(psi));
136 
137  tEqn.ref().deltaTSp += deltaTSp;
138 
139  return tEqn;
140 }
141 
142 
143 // ************************************************************************* //
Functions for calculating sources in a Lagrangian equation.
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1792
A class for managing temporary objects.
Definition: tmp.H:55
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const volScalarField & psi
tmp< LagrangianEqn< Type > > explicitSp0(const LagrangianSubScalarField &Sp, const LagrangianSubSubField< Type > &psi)
tmp< LagrangianEqn< Type > > Sp(const LagrangianSubField< SpType > &Sp, const LagrangianSubSubField< Type > &psi)
Return a source matrix.
tmp< LagrangianEqn< Type > > implicitDeltaTSp(const LagrangianSubScalarField &Sp, const LagrangianSubSubField< Type > &psi)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
Definition: fvcSup.C:67
DimensionedField< Type, LagrangianSubMesh, SubField > LagrangianSubSubField
LagrangianSubSubField< scalar > LagrangianSubScalarSubField
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:58
LagrangianSubField< scalar > LagrangianSubScalarField
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
tmp< DimensionedField< Type, GeoMesh, SubField > > toSubField(const DimensionedField< Type, GeoMesh, Field > &)
Return a temporary sub-field from a reference to a field.