LagrangianModel.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 
26 #include "LagrangianModel.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
34 }
35 
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class Type>
41 (
42  const LagrangianSubScalarField& deltaT,
43  const LagrangianSubSubField<Type>& field,
45 ) const
46 {}
47 
48 
49 template<class Type>
51 (
52  const LagrangianSubScalarField& deltaT,
53  const LagrangianSubScalarSubField& vOrM,
54  const LagrangianSubSubField<Type>& field,
56 ) const
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const word& name,
65  const LagrangianMesh& mesh
66 )
67 :
68  name_(name),
69  mesh_(mesh)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
74 
76 (
77  const word& name,
78  const LagrangianMesh& mesh,
79  const dictionary& modelDict
80 )
81 {
82  const word type(modelDict.lookup("type"));
83 
84  Info<< indentOrNl << "Selecting " << typeName
85  << " with name " << name
86  << " of type " << type << endl;
87 
88  if
89  (
90  !dictionaryConstructorTablePtr_
91  || dictionaryConstructorTablePtr_->find(type)
92  == dictionaryConstructorTablePtr_->end()
93  )
94  {
95  if (!libs.open(modelDict, "libs", dictionaryConstructorTablePtr_))
96  {
97  libs.open("lib" + type.remove(':') + ".so", false);
98  }
99 
100  if (!dictionaryConstructorTablePtr_)
101  {
103  << "Unknown " << typeName << " type "
104  << type << nl << nl
105  << "Table of " << typeName << "s is empty"
106  << exit(FatalError);
107  }
108  }
109 
110  dictionaryConstructorTable::iterator cstrIter =
111  dictionaryConstructorTablePtr_->find(type);
112 
113  if (cstrIter == dictionaryConstructorTablePtr_->end())
114  {
115  FatalIOErrorInFunction(modelDict)
116  << "Unknown " << typeName << " " << type << nl << nl
117  << "Valid " << typeName << "s are:" << nl
118  << dictionaryConstructorTablePtr_->sortedToc()
119  << exit(FatalIOError);
120  }
121 
122  const dictionary& coeffsDict = modelDict.optionalTypeDict(type);
123 
124  printDictionary print(coeffsDict);
125 
126  return cstrIter()(name, mesh, coeffsDict, stateDict(name, mesh));
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
133 {}
134 
135 
136 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
137 
139 {
140  return wordList::null();
141 }
142 
143 
145 {}
146 
147 
149 {}
150 
151 
153 (
154  const LagrangianMesh& mesh,
155  DynamicList<elementModification>& elementModifications
156 ) const
157 {}
158 
159 
161 (
163  const LagrangianSubMesh& modifiedMesh
164 ) const
165 {
166  return mesh_.subNone();
167 }
168 
169 
171 (
172  const LagrangianSubScalarField& deltaT,
173  const bool final
174 )
175 {}
176 
177 
179 (
180  const LagrangianSubScalarField& deltaT,
181  const bool final
182 )
183 {}
184 
185 
187 (
188  const LagrangianSubScalarField& deltaT,
190 ) const
191 {}
192 
193 
195 (
197  LagrangianModel
198 )
199 
200 
202 (
204  LagrangianModel
205 )
206 
207 
209 (
210  const LagrangianSubScalarField& deltaT,
211  const bool final
212 )
213 {}
214 
215 
217 {}
218 
219 
221 {}
222 
223 
225 {}
226 
227 
229 {
230  return true;
231 }
232 
233 
234 bool Foam::LagrangianModel::write(const bool write) const
235 {
236  return write;
237 }
238 
239 
240 // ************************************************************************* //
#define IMPLEMENT_LAGRANGIAN_MODEL_ADD_FIELD_SUP(Type, modelType)
#define IMPLEMENT_LAGRANGIAN_MODEL_ADD_V_OR_M_FIELD_SUP(Type, modelType)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
Definition: LagrangianEqn.H:56
Class containing Lagrangian geometry and topology.
Base class for Lagrangian models.
virtual ~LagrangianModel()
Destructor.
virtual void addSup(const LagrangianSubScalarField &deltaT, LagrangianEqn< scalar > &eqn) const
Add a fractional source term.
virtual wordList addSupFields() const
Return the list of fields for which the LagrangianModel adds.
virtual void postConstruct()
Do post construction steps which require access to other models.
void addSupType(const LagrangianSubScalarField &deltaT, const LagrangianSubSubField< Type > &field, LagrangianEqn< Type > &eqn) const
Add a source term to an equation.
virtual void preModify(const LagrangianMesh &mesh, DynamicList< elementModification > &elementModifications) const
Identify elements in the Lagrangian mesh which are to be.
virtual void correct()
Correct the LagrangianModel.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual bool read(const dictionary &modelDict)
Read dictionary.
virtual bool write(const bool write) const
Write data.
LagrangianModel(const word &name, const LagrangianMesh &mesh)
Construct from components.
virtual void preAddSup(const LagrangianSubScalarField &deltaT, const bool final)
Hook before source evaluation.
virtual LagrangianSubMesh modify(LagrangianMesh &mesh, const LagrangianSubMesh &modifiedMesh) const
Instantaneously modify and/or create and remove elements in the.
virtual void postAddSup(const LagrangianSubScalarField &deltaT, const bool final)
Add a source term to an equation.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Solve equations and/or update continually changing properties.
static autoPtr< LagrangianModel > New(const word &name, const LagrangianMesh &mesh, const dictionary &modelDict)
Selector.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
const dictionary & optionalTypeDict(const word &typeName) const
Find and return an optional type sub-dictionary.
Definition: dictionary.C:921
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Enables the printing of a dictionary and subsequently looked-up defaulted entries.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
dlLibraryTable libs
Table of loaded dynamic libraries.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
messageStream Info
defineRunTimeSelectionTable(fvConstraint, dictionary)
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & indentOrNl(Ostream &os)
Indent stream or add newline if indent level == 0.
Definition: Ostream.H:250
error FatalError
LagrangianSubField< scalar > LagrangianSubScalarField
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
static const char nl
Definition: Ostream.H:297
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict