CloudFunctionObject.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) 2020 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::CloudFunctionObject
29 
30 Group
31  grpLagrangianIntermediateFunctionObjects
32 
33 Description
34  Templated cloud function object base class
35 
36 SourceFiles
37  CloudFunctionObject.C
38  CloudFunctionObjectNew.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef CloudFunctionObject_H
43 #define CloudFunctionObject_H
44 
45 #include "IOdictionary.H"
46 #include "autoPtr.H"
47 #include "runTimeSelectionTables.H"
48 #include "CloudSubModelBase.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 class polyPatch;
56 class tetIndices;
57 
58 /*---------------------------------------------------------------------------*\
59  Class CloudFunctionObject Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class CloudType>
64 :
65  public CloudSubModelBase<CloudType>
66 {
67 private:
68 
69  //- Convenience typedef for parcel type
70  typedef typename CloudType::parcelType parcelType;
71 
72  // Private data
73 
74  //- Output path
75  fileName outputDir_;
76 
77 
78  // Private Member Functions
79 
80  //- Inherited write from CloudSubModelBase
82 
83  //- Write post-processing info
84  virtual void write();
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("cloudFunctionObject");
91 
92  //- Declare runtime constructor selection table
94  (
95  autoPtr,
97  dictionary,
98  (
99  const dictionary& dict,
100  CloudType& owner,
101  const word& modelName
102  ),
103  (dict, owner, modelName)
104  );
105 
106 
107  // Constructors
108 
109  //- Construct null from owner
111 
112  //- Construct from dictionary
114  (
115  const dictionary& dict,
116  CloudType& owner,
117  const word& objectType,
118  const word& modelName
119  );
120 
121  //- Construct copy
123 
124  //- Construct and return a clone
126  {
128  (
130  );
131  }
132 
133 
134  //- Destructor
135  virtual ~CloudFunctionObject() = default;
136 
137 
138  //- Selector
140  (
141  const dictionary& dict,
142  CloudType& owner,
143  const word& objectType,
144  const word& modelName
145  );
146 
147 
148  // Member Functions
149 
150  // Evaluation
151 
152  //- Pre-evolve hook
153  virtual void preEvolve(const typename parcelType::trackingData& td);
154 
155  //- Post-evolve hook
156  virtual void postEvolve
157  (
158  const typename parcelType::trackingData& td
159  );
160 
161  //- Post-move hook
162  virtual bool postMove
163  (
164  parcelType& p,
165  const scalar dt,
166  const point& position0,
167  const typename parcelType::trackingData& td
168  );
169 
170  //- Post-patch hook
171  virtual bool postPatch
172  (
173  const parcelType& p,
174  const polyPatch& pp,
175  const typename parcelType::trackingData& td
176  );
177 
178  //- Post-face hook
179  virtual bool postFace
180  (
181  const parcelType& p,
182  const typename parcelType::trackingData& td
183  );
184 
185 
186  // Input/output
187 
188  //- Return the output path
189  const fileName& outputDir() const;
190 
191  //- Return the output time path
192  fileName writeTimeDir() const;
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #define makeCloudFunctionObject(CloudType) \
203  \
204  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
205  defineNamedTemplateTypeNameAndDebug \
206  ( \
207  Foam::CloudFunctionObject<kinematicCloudType>, \
208  0 \
209  ); \
210  namespace Foam \
211  { \
212  defineTemplateRunTimeSelectionTable \
213  ( \
214  CloudFunctionObject<kinematicCloudType>, \
215  dictionary \
216  ); \
217  }
218 
219 
220 #define makeCloudFunctionObjectType(SS, CloudType) \
221  \
222  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
223  defineNamedTemplateTypeNameAndDebug(Foam::SS<kinematicCloudType>, 0); \
224  \
225  Foam::CloudFunctionObject<kinematicCloudType>:: \
226  adddictionaryConstructorToTable<Foam::SS<kinematicCloudType>> \
227  add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #ifdef NoRepository
233  #include "CloudFunctionObject.C"
234 #endif
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
A class for handling file names.
Definition: fileName.H:72
virtual ~CloudFunctionObject()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static autoPtr< CloudFunctionObject< CloudType > > New(const dictionary &dict, CloudType &owner, const word &objectType, const word &modelName)
Selector.
Base class for cloud sub-models.
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:98
const dictionary & dict() const
Return const access to the cloud dictionary.
Definition: subModelBase.C:104
const CloudType & owner() const
Return const access to the owner cloud.
virtual bool postPatch(const parcelType &p, const polyPatch &pp, const typename parcelType::trackingData &td)
Post-patch hook.
TypeName("cloudFunctionObject")
Runtime type information.
fileName writeTimeDir() const
Return the output time path.
A class for handling words, derived from Foam::string.
Definition: word.H:63
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const fileName & outputDir() const
Return the output path.
virtual bool postFace(const parcelType &p, const typename parcelType::trackingData &td)
Post-face hook.
declareRunTimeSelectionTable(autoPtr, CloudFunctionObject, dictionary,(const dictionary &dict, CloudType &owner, const word &modelName),(dict, owner, modelName))
Declare runtime constructor selection table.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
volScalarField & p
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
virtual bool postMove(parcelType &p, const scalar dt, const point &position0, const typename parcelType::trackingData &td)
Post-move hook.
CloudFunctionObject(CloudType &owner)
Construct null from owner.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
Templated cloud function object base class.
virtual autoPtr< CloudFunctionObject< CloudType > > clone() const
Construct and return a clone.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.