tracer.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 "tracer.H"
27 #include "cloud_functionObject.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace clouds
37 {
40 }
41 namespace functionObjects
42 {
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
52 (
53  const LagrangianSubMesh& subMesh
54 ) const
55 {
56  return U(subMesh) & Uc.grad(subMesh);
57 }
58 
59 
61 {
62  return true;
63 }
64 
65 
67 (
68  const LagrangianSubScalarField& deltaT,
69  const bool final
70 )
71 {
72  if (!final) return;
73 
74  const LagrangianSubMesh& subMesh = deltaT.mesh();
75 
76  LagrangianSubVectorSubField& U = this->U.ref(subMesh);
77 
78  U = Uc(subMesh);
79 }
80 
81 
83 {
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
90 
92 (
94  const contextType context,
95  const dictionary& dict
96 )
97 :
98  cloud
99  (
100  mesh,
101  context,
103  (
104  "U",
105  mesh,
106  dimensionedVector("NaN", dimVelocity, vector::uniform(NaN)),
108  )
109  ),
110  carried(*this, dict)
111 {
112  // Create NaN values on newly injected particles. These values will then
113  // get corrected by a call to calculate as a result of reCalculateModified
114  // returning true. Alternatively, we could put a carrier field source here
115  // and set reCalculateModified to false. Either approach works.
116  U.sourcesRef().reset
117  (
118  U,
120  (
121  U,
122  LagrangianModels().modelTypeFieldSourceTypes
123  <
125  NaNLagrangianVectorFieldSource
126  >(),
128  )
129  );
130 }
131 
132 
133 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
134 
136 {}
137 
138 
139 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
140 
141 void Foam::clouds::tracer::solve(const bool initial, const bool final)
142 {
143  // Pre-solve operations ...
145 
146  // Solve
147  cloud::solve(initial, final);
148 
149  // Post-solve operations ...
150 }
151 
152 
153 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const GeoMesh & mesh() const
Return mesh.
Part of a geometric field used for setting the values associated with optional sources.
Generic GeometricField class.
Base class for Lagrangian injections. Minimal wrapper over LagrangianSource. Implements some utility ...
Class containing Lagrangian geometry and topology.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:61
contextType
Context in which this cloud is used.
Definition: cloud.H:203
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
Definition: cloud.C:608
Foam::LagrangianModels & LagrangianModels() const
Access the models.
Definition: cloud.C:597
virtual void partition()
Partition hook.
Definition: cloud.C:450
CloudStateField< vector > U
Velocity.
Definition: cloud.H:209
Base class for clouds which are carried by a fluid.
Definition: carried.H:57
void clearCarrierFields()
Clear the carrier fields.
Definition: carried.C:115
void resetCarrierFields(const bool initial)
Reset the carrier fields.
Definition: carried.C:132
const CarrierField< vector > & Uc
Carrier velocity.
Definition: carried.H:114
Cloud that follows the carrier flow. The elements have no size or mass and they have no physical mode...
Definition: tracer.H:55
virtual void solve(const bool initial, const bool final)
Solve the cloud's evolution over the current time-step.
Definition: tracer.C:141
virtual ~tracer()
Destructor.
Definition: tracer.C:135
virtual bool reCalculateModified()
Do we need to re-calculate particles that are modified?
Definition: tracer.C:60
virtual tmp< LagrangianSubVectorField > dUdt(const LagrangianSubMesh &) const
Return the acceleration with which to do second-order tracking.
Definition: tracer.C:52
tracer(LagrangianMesh &mesh, const contextType context, const dictionary &dict)
Construct from a mesh and context.
Definition: tracer.C:92
virtual void partition()
Partition hook.
Definition: tracer.C:82
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Update the cloud properties.
Definition: tracer.C:67
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A escape velocity boundary condition. Particles that hit a patch with this condition will be removed ...
A class for managing temporary objects.
Definition: tmp.H:55
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
addToRunTimeSelectionTable(cloud, dynamicParcel, LagrangianMesh)
defineTypeNameAndDebug(carried, 0)
makeCloudFunctionObject(dynamicParcel)
Namespace for OpenFOAM.
const dimensionSet & dimVelocity
Definition: dimensions.C:154
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dictionary dict