Loading...
Searching...
No Matches
Cloud.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::Cloud
29
30Description
31 Base cloud calls templated on particle type
32
33SourceFiles
34 Cloud.C
35 CloudIO.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_Cloud_H
40#define Foam_Cloud_H
41
42#include "cloud.H"
43#include "IDLList.H"
44#include "IOField.H"
45#include "CompactIOField.H"
46#include "polyMesh.H"
47#include "bitSet.H"
48#include "wordRes.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56template<class ParticleType> class Cloud;
57template<class ParticleType> class IOPosition;
58
59
60/*---------------------------------------------------------------------------*\
61 Class Cloud Declaration
62\*---------------------------------------------------------------------------*/
63
64template<class ParticleType>
65class Cloud
66:
67 public cloud,
68 public IDLList<ParticleType>
69{
70 // Private Data
71
72 //- Reference to the mesh database
73 const polyMesh& polyMesh_;
74
75 //- Temporary storage for addressing. Used in findTris.
76 mutable DynamicList<label> labels_;
77
78 //- Does the cell have wall faces
79 mutable autoPtr<bitSet> cellWallFacesPtr_;
80
81 //- Temporary storage for the global particle positions
82 mutable autoPtr<vectorField> globalPositionsPtr_;
83
84
85 // Private Member Functions
86
87 //- Check patches
88 void checkPatches() const;
89
90 //- Initialise cloud on IO constructor
91 void initCloud(const bool checkClass);
92
93 //- Find all cells which have wall faces
94 void calcCellWallFaces() const;
95
96 //- Read cloud properties dictionary
97 void readCloudUniformProperties();
98
99 //- Write cloud properties dictionary
100 void writeCloudUniformProperties() const;
101
102
103protected:
104
105 //- Geometry type
107
108
109public:
110
111 friend class particle;
112 template<class ParticleT>
113 friend class IOPosition;
114
115 typedef ParticleType particleType;
116
117 //- Parcels are just particles
118 typedef ParticleType parcelType;
119
120
121 //- Runtime type information
122 TypeName("Cloud");
123
124
125 // Static Data
127 //- Name of cloud properties dictionary
129
131 // Constructors
132
133 //- Construct without particles
134 Cloud
136 const polyMesh& mesh,
137 const Foam::zero,
138 const word& cloudName
139 );
140
141 //- Construct from mesh and a list of particles
142 Cloud
143 (
144 const polyMesh& mesh,
145 const word& cloudName,
146 const IDLList<ParticleType>& particles
147 );
148
149 //- Read construct from file(s) with given cloud instance.
150 Cloud
151 (
152 const polyMesh& pMesh,
153 const word& cloudName,
155 const bool checkClass = true
156 );
157
158
159 // Member Functions
160
161 // Access
162
163 //- Return the polyMesh reference
164 const polyMesh& pMesh() const noexcept
165 {
166 return polyMesh_;
167 }
168
169 //- Return the number of particles in the cloud
170 using IDLList<ParticleType>::size;
171
172 //- Return the number of particles in the cloud
173 virtual label nParcels() const
174 {
176 };
177
178 //- Return temporary addressing
179 DynamicList<label>& labels() const
180 {
181 return labels_;
182 }
183
184
185 // Iterators
186
187 using typename IDLList<ParticleType>::iterator;
189
190 using IDLList<ParticleType>::begin;
191 using IDLList<ParticleType>::cbegin;
192 using IDLList<ParticleType>::end;
193 using IDLList<ParticleType>::cend;
194
195
196 // Edit
197
198 //- Clear the particle list
199 using IDLList<ParticleType>::clear;
200
201 //- Transfer particle to cloud
202 void addParticle(ParticleType* pPtr);
203
204 //- Remove particle from cloud and delete
205 void deleteParticle(ParticleType& p);
207 //- Remove lost particles from cloud and delete
208 void deleteLostParticles();
209
210 //- Reset the particles
211 void cloudReset(const Cloud<ParticleType>& c);
212
213 //- Move the particles
214 template<class TrackCloudType>
215 void move
216 (
217 TrackCloudType& cloud,
218 typename ParticleType::trackingData& td,
219 const scalar trackTime
220 );
221
222 //- Remap the cells of particles corresponding to the
223 // mesh topology change
224 void autoMap(const mapPolyMesh&);
225
226
227 // Read
228
229 //- Check lagrangian data field
230 template<class DataType>
232 (
233 const Cloud<ParticleType>& c,
234 const IOField<DataType>& data
235 ) const;
236
237 //- Check lagrangian data fieldfield
238 template<class DataType>
240 (
241 const Cloud<ParticleType>& c,
243 ) const;
244
245 //- Helper function to store a cloud field on its registry
246 template<class Type>
247 bool readStoreFile
248 (
249 const IOobject& io,
250 const IOobject& ioNew
251 ) const;
252
253 //- Read from files into objectRegistry
254 void readFromFiles
255 (
256 objectRegistry& obr,
257 const wordRes& selectFields,
259 ) const;
260
261
262 // Write
263
264 //- Write the field data for the cloud of particles Dummy at
265 // this level.
266 virtual void writeFields() const;
267
268 //- Write using stream options.
269 // Only writes the cloud file if the Cloud isn't empty
270 virtual bool writeObject
271 (
272 IOstreamOption streamOpt,
273 const bool writeOnProc
274 ) const;
275
276 //- Write positions to <cloudName>_positions.obj file
277 void writePositions() const;
278
279 //- Call this before a topology change.
280 // Stores the particles global positions in the database
281 // for use during mapping.
282 void storeGlobalPositions() const;
283
284
285 // Housekeeping
286
287 //- Helper to construct IOobject for field and current time.
288 FOAM_DEPRECATED_FOR(2024-01, "newIOobject()")
290 (
291 const word& fieldName,
293 ) const
294 {
295 return this->newIOobject(fieldName, rOpt);
296 }
297};
298
299
300// Ostream Operator
301
302template<class ParticleType>
303Ostream& operator<<(Ostream& os, const Cloud<ParticleType>& c);
304
305
306// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307
308} // End namespace Foam
309
310// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311
312#ifdef NoRepository
313 #include "Cloud.C"
314#endif
315
316// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317
318#endif
319
320// ************************************************************************* //
Intrusive doubly-linked list.
wordRes excludeFields
const word cloudName(propsDict.get< word >("cloud"))
Base cloud calls templated on particle type.
Definition Cloud.H:64
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
Definition CloudIO.C:293
bool readStoreFile(const IOobject &io, const IOobject &ioNew) const
Helper function to store a cloud field on its registry.
Definition CloudIO.C:212
virtual label nParcels() const
Return the number of particles in the cloud.
Definition Cloud.H:206
static word cloudPropertiesName
Name of cloud properties dictionary.
Definition Cloud.H:149
void readFromFiles(objectRegistry &obr, const wordRes &selectFields, const wordRes &excludeFields=wordRes::null()) const
Read from files into objectRegistry.
Definition CloudIO.C:230
void checkFieldIOobject(const Cloud< ParticleType > &c, const IOField< DataType > &data) const
Check lagrangian data field.
Definition CloudIO.C:174
void writePositions() const
Write positions to <cloudName>_positions.obj file.
Definition Cloud.C:329
IOobject fieldIOobject(const word &fieldName, IOobjectOption::readOption rOpt=IOobjectOption::NO_READ) const
Helper to construct IOobject for field and current time.
Definition Cloud.H:361
void deleteParticle(ParticleType &p)
Remove particle from cloud and delete.
Definition Cloud.C:101
friend class particle
Definition Cloud.H:126
void deleteLostParticles()
Remove lost particles from cloud and delete.
Definition Cloud.C:108
DynamicList< label > & labels() const
Return temporary addressing.
Definition Cloud.H:214
Cloud(const polyMesh &mesh, const Foam::zero, const word &cloudName)
Construct without particles.
Definition Cloud.C:57
TypeName("Cloud")
Runtime type information.
virtual void writeFields() const
Write the field data for the cloud of particles Dummy at.
Definition CloudIO.C:285
void move(TrackCloudType &cloud, typename ParticleType::trackingData &td, const scalar trackTime)
Move the particles.
Definition Cloud.C:137
void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the.
Definition Cloud.C:297
friend class IOPosition
Definition Cloud.H:128
ParticleType parcelType
Parcels are just particles.
Definition Cloud.H:135
void cloudReset(const Cloud< ParticleType > &c)
Reset the particles.
Definition Cloud.C:125
const polyMesh & pMesh() const noexcept
Return the polyMesh reference.
Definition Cloud.H:193
cloud::geometryType geometryType_
Geometry type.
Definition Cloud.H:121
void storeGlobalPositions() const
Call this before a topology change.
Definition Cloud.C:348
void addParticle(ParticleType *pPtr)
Transfer particle to cloud.
Definition Cloud.C:94
void checkFieldFieldIOobject(const Cloud< ParticleType > &c, const CompactIOField< Field< DataType > > &data) const
Check lagrangian data fieldfield.
Definition CloudIO.C:193
ParticleType particleType
Definition Cloud.H:130
A Field of objects of type <T> with automated input and output using a compact storage....
A primitive const node iterator (bidirectional).
Definition DLListBase.H:358
A primitive non-const node iterator.
Definition DLListBase.H:287
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A primitive field of type <T> with automated input and output.
Definition IOField.H:53
Helper IO class to read and write particle coordinates (positions).
Definition IOPosition.H:52
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
readOption
Enumeration defining read preferences.
@ NO_READ
Nothing to be read.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
const iterator & end()
Definition UILList.H:489
const_iterator cbegin() const
Definition UILList.H:448
const const_iterator & cend() const
Definition UILList.H:497
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A cloud is a registry collection of lagrangian particles.
Definition cloud.H:56
geometryType
Cloud geometry type (internal or IO representations).
Definition cloud.H:63
cloud(const cloud &)=delete
No copy construct.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Registry of regIOobjects.
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
static const wordRes & null() noexcept
Return a null wordRes (reference to a nullObject). Behaves like a empty wordRes.
Definition wordRes.H:80
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
volScalarField & p
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
const auto & io
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
surface1 clear()
Namespace for OpenFOAM.
ILList< DLListBase, T > IDLList
Definition IDLList.H:39
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const direction noexcept
Definition scalarImpl.H:265
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68