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-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::cloud
29 
30 Description
31  A cloud is a registry collection of lagrangian particles.
32 
33 SourceFiles
34  cloud.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_cloud_H
39 #define Foam_cloud_H
40 
41 #include "objectRegistry.H"
42 #include "Enum.H"
43 #include "point.H"
44 #include "IOField.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 class mapPolyMesh;
53 
54 /*---------------------------------------------------------------------------*\
55  Class cloud Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class cloud
59 :
60  public objectRegistry
61 {
62 public:
63 
64  //- Cloud geometry type (internal or IO representations)
65  enum class geometryType
66  {
67  COORDINATES,
68  POSITIONS
69  };
70 
71  //- Named enumerations "coordinates", "positions"
73 
74 
75  // Static Data Members
76 
77  //- The prefix to local: %lagrangian
78  static const word prefix;
79 
80  //- The default cloud name: %defaultCloud
81  static word defaultName;
82 
83 
84  //- Runtime type information
85  TypeName("cloud");
86 
87 
88  // Generated Methods
89 
90  //- No copy construct
91  cloud(const cloud&) = delete;
92 
93  //- No copy assignment
94  void operator=(const cloud&) = delete;
95 
96 
97  // Constructors
98 
99  //- Construct for given objectRegistry. Uses default cloud name
100  explicit cloud(const objectRegistry& obr);
101 
102  //- Construct for given objectRegistry and named cloud
103  cloud(const objectRegistry& obr, const word& cloudName);
104 
105 
106  //- Destructor
107  virtual ~cloud() = default;
108 
109 
110  // Member Functions
111 
112  // Sizes
113 
114  //- Number of parcels for the hosting cloud
115  virtual label nParcels() const;
116 
117 
118  // Edit
119 
120  //- Remap the cells of particles corresponding to the
121  //- mesh topology change
122  virtual void autoMap(const mapPolyMesh&);
123 
124 
125  // I-O
126 
127  //- Read particle fields from objects in the obr registry
128  virtual void readObjects(const objectRegistry& obr);
129 
130  //- Write particle fields as objects into the obr registry
131  virtual void writeObjects(objectRegistry& obr) const;
132 
133  //- Helper to construct IOField on a supplied object registry
134  template<class Type>
136  (
137  const word& fieldName,
138  const label nParticle,
139  objectRegistry& obr
140  );
141 
142  //- Locate an IOField within object registry
143  // \return nullptr if not found or wrong type
144  template<class Type>
145  static const IOField<Type>* findIOField
146  (
147  const word& fieldName,
148  const objectRegistry& obr
149  )
150  {
151  return obr.cfindObject<IOField<Type>>(fieldName);
152  }
153 
154  //- Locate the "position" IOField within object registry
155  // \return nullptr if not found or wrong type
156  static const IOField<point>* findIOPosition
157  (
158  const objectRegistry& obr
159  )
160  {
161  return obr.cfindObject<IOField<point>>("position");
162  }
163 
164  //- Lookup an IOField within object registry
165  // Fatal if not found or wrong type
166  template<class Type>
167  static const IOField<Type>& lookupIOField
168  (
169  const word& fieldName,
170  const objectRegistry& obr
171  )
172  {
173  return obr.lookupObject<IOField<Type>>(fieldName);
174  }
175 };
176 
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #ifdef NoRepository
185  #include "cloudTemplates.C"
186 #endif
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #endif
191 
192 // ************************************************************************* //
static word defaultName
The default cloud name: defaultCloud.
Definition: cloud.H:84
static const IOField< point > * findIOPosition(const objectRegistry &obr)
Locate the "position" IOField within object registry.
Definition: cloud.H:188
static const IOField< Type > * findIOField(const word &fieldName, const objectRegistry &obr)
Locate an IOField within object registry.
Definition: cloud.H:174
virtual ~cloud()=default
Destructor.
virtual label nParcels() const
Number of parcels for the hosting cloud.
Definition: cloud.C:72
static IOField< Type > & createIOField(const word &fieldName, const label nParticle, objectRegistry &obr)
Helper to construct IOField on a supplied object registry.
geometryType
Cloud geometry type (internal or IO representations)
Definition: cloud.H:62
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
static const IOField< Type > & lookupIOField(const word &fieldName, const objectRegistry &obr)
Lookup an IOField within object registry.
Definition: cloud.H:202
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:157
virtual void autoMap(const mapPolyMesh &)
Remap the cells of particles corresponding to the mesh topology change.
Definition: cloud.C:79
TypeName("cloud")
Runtime type information.
virtual void readObjects(const objectRegistry &obr)
Read particle fields from objects in the obr registry.
Definition: cloud.C:85
const word cloudName(propsDict.get< word >("cloud"))
void operator=(const cloud &)=delete
No copy assignment.
A class for handling words, derived from Foam::string.
Definition: word.H:63
A cloud is a registry collection of lagrangian particles.
Definition: cloud.H:53
virtual void writeObjects(objectRegistry &obr) const
Write particle fields as objects into the obr registry.
Definition: cloud.C:91
Registry of regIOobjects.
A primitive field of type <T> with automated input and output.
static const Enum< geometryType > geometryTypeNames
Named enumerations "coordinates", "positions".
Definition: cloud.H:71
Namespace for OpenFOAM.
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:79
cloud(const cloud &)=delete
No copy construct.