cloudFunctionObjectUList.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 
27 #include "cloud.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 (
42  const cloud& c,
43  const bool inner
44 )
45 :
46  UPtrList<functionObjects::cloudFunctionObject>
47  (
48  c.time().functionObjects().size()
49  ),
50  inner_(inner)
51 {
52  const functionObjectList& functions = c.time().functionObjects();
53 
54  label cloudFunctioni = 0;
55 
56  forAll(functions, functioni)
57  {
58  const functionObject& fo =
59  isA<functionObjects::timeControl>(functions[functioni])
60  ? refCast<const functionObjects::timeControl>
61  (
62  functions[functioni]
63  ).filter()
64  : functions[functioni];
65 
66  if (!isA<functionObjects::cloudFunctionObject>(fo)) continue;
67 
69  refCast<const functionObjects::cloudFunctionObject>(fo);
70 
71  if (&cfo.cloud() != &c) continue;
72 
74  (
75  cloudFunctioni ++,
76  const_cast<functionObjects::cloudFunctionObject*>(&cfo)
77  );
78  }
79 
81 
82  if (inner_) return;
83 
84  forAll(*this, cloudFunctioni)
85  {
86  this->operator[](cloudFunctioni).preSolve();
87  }
88 }
89 
90 
91 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
92 
94 {
95  if (inner_) return;
96 
97  forAll(*this, cloudFunctioni)
98  {
99  this->operator[](cloudFunctioni).postSolve();
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
105 
107 (
108  const LagrangianSubScalarField& deltaT,
109  const bool final
110 )
111 {
112  forAll(*this, cloudFunctioni)
113  {
114  this->operator[](cloudFunctioni).calculate(deltaT, final);
115  }
116 }
117 
118 
120 (
122 )
123 {
124  forAll(*this, cloudFunctioni)
125  {
126  this->operator[](cloudFunctioni).preCrossFaces(fraction);
127  }
128 
129  if (size())
130  {
131  const Foam::cloud& cloud = first().cloud();
132 
133  preCrossFaces
134  (
135  cloud.mesh().sub(LagrangianGroup::inInternalMesh).sub(fraction)
136  );
137 
138  forAll(cloud.mesh().boundary(), patchi)
139  {
140  preCrossFaces
141  (
142  cloud.mesh().boundary()[patchi].mesh().sub(fraction)
143  );
144  }
145  }
146 }
147 
148 
150 (
151  const LagrangianSubScalarSubField& fraction
152 )
153 {
154  forAll(*this, cloudFunctioni)
155  {
156  this->operator[](cloudFunctioni).preCrossFaces(fraction);
157  }
158 }
159 
160 
162 (
163  const LagrangianSubScalarSubField& fraction
164 )
165 {
166  forAll(*this, cloudFunctioni)
167  {
168  this->operator[](cloudFunctioni).postCrossFaces(fraction);
169  }
170 }
171 
172 
174 (
176 )
177 {
178  if (size())
179  {
180  const Foam::cloud& cloud = first().cloud();
181 
182  postCrossFaces
183  (
184  cloud.mesh().sub(LagrangianGroup::inInternalMesh).sub(fraction)
185  );
186 
187  forAll(cloud.mesh().boundary(), patchi)
188  {
189  postCrossFaces
190  (
191  cloud.mesh().boundary()[patchi].mesh().sub(fraction)
192  );
193  }
194  }
195 
196  forAll(*this, cloudFunctioni)
197  {
198  this->operator[](cloudFunctioni).postCrossFaces(fraction);
199  }
200 }
201 
202 
203 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const LagrangianMesh & mesh() const
Return the mesh reference.
const LagrangianBoundaryMesh & boundary() const
Return reference to boundary mesh.
LagrangianSubMesh sub(const LagrangianGroup group) const
Return a sub-mesh for the given group.
SubList< Type > sub(const List< Type > &list) const
Return a sub-list corresponding to this sub-mesh.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
bool set(const label) const
Is element set.
Definition: UPtrListI.H:87
void resize(const label)
Reset size of UPtrList. This can only be used to set the size.
Definition: UPtrListI.H:71
const functionObjects::cloudFunctionObject & operator[](const label) const
Return element const reference.
Definition: UPtrListI.H:105
List of references to the cloud function objects. Designed to be constructed temporarily for the scop...
virtual ~cloudFunctionObjectUList()
Destructor.
cloudFunctionObjectUList(const cloud &, const bool inner=false)
Construct from a cloud.
virtual void postCrossFaces(const LagrangianSubScalarSubField &fraction)
Hook following face crossings of a specific sub-mesh.
virtual void calculate(const LagrangianSubScalarField &deltaT, const bool final)
Solve equations and/or update continually changing properties.
virtual void preCrossFaces(const LagrangianScalarInternalDynamicField &fraction)
Hook before face crossings.
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
List of function objects with start(), execute() and end() functions that is called for each object.
Abstract base-class for Time/database functionObjects.
Base class for function objects that refer to a cloud. Provides hooks into the cloud solution process...
virtual void preSolve()
Hook before solution steps.
const Cloud & cloud() const
Get a reference to the cloud.
label patchi
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
defineTypeNameAndDebug(combustionModel, 0)