Function1LagrangianFieldSourceTemplates.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-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 \*---------------------------------------------------------------------------*/
25 
27 #include "LagrangianFieldSource.H"
28 
29 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
30 
31 template<class Type>
34 (
35  const LagrangianSubMesh& subMesh,
36  const Function1<Type>& function
37 ) const
38 {
39  return value(subMesh, field_.internalDimensions(), function);
40 }
41 
42 
43 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
44 
45 template<class OtherType>
48 (
49  const LagrangianSubMesh& subMesh,
50  const dimensionSet& dims,
51  const Function1<OtherType>& function
52 )
53 {
54  const objectRegistry& db = subMesh.mesh();
55 
56  const scalar t1 = db.time().value();
57  const scalar t0 = t1 - db.time().deltaTValue();
58 
59  if
60  (
61  db.template foundObject<LagrangianInternalScalarDynamicField>
62  (
64  )
65  )
66  {
67  const LagrangianSubScalarSubField fractionSf
68  (
69  subMesh.sub
70  (
71  db.template lookupObject<LagrangianInternalScalarDynamicField>
72  (
74  )
75  )
76  );
77 
78  return
80  (
81  subMesh.sub(function.name()),
82  subMesh,
83  dims,
84  function.value(t0 + fractionSf*(t1 - t0))
85  );
86  }
87  else
88  {
89  return
91  (
92  subMesh.sub(function.name()),
93  subMesh,
94  dimensioned<OtherType>(dims, function.value(t0))
95  );
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101 
102 template<class Derived>
104 (
105  const Derived& field
106 )
107 :
108  field_(static_cast<const LagrangianFieldSourceBase&>(field))
109 {}
110 
111 
112 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const GeoMesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Function1LagrangianFieldSource(const Derived &)
Construct with reference to the derived field source.
tmp< LagrangianSubField< Type > > value(const LagrangianSubMesh &subMesh, const Function1< Type > &function) const
Return the source value.
Run-time selectable general function of one variable.
Definition: Function1.H:62
Base class for Lagrangian source conditions.
virtual const dimensionSet & internalDimensions() const =0
Return internal dimensions reference.
static const word fractionName
Name of the tracked fraction field.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
const LagrangianMesh & mesh() const
Return the mesh.
word sub(const word &fieldName) const
Return the name of a field corresponding to this sub-mesh.
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:34
Dimension set for the base types.
Definition: dimensionSet.H:125
Generic dimensioned Type class.
const Type & value() const
Return const reference to value.
Registry of regIOobjects.
const Time & time() const
Return time.
A class for managing temporary objects.
Definition: tmp.H:55