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