MPPICParcel.H
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) 2013-2023 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 Class
25  Foam::MPPICParcel
26 
27 Description
28  Wrapper around parcel types to add MPPIC modelling
29 
30 SourceFiles
31  MPPICParcelI.H
32  MPPICParcelTrackingDataI.H
33  MPPICParcel.C
34  MPPICParcelIO.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef MPPICParcel_H
39 #define MPPICParcel_H
40 
41 #include "particle.H"
42 #include "labelFieldIOField.H"
43 #include "vectorFieldIOField.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 
52 template<class ParcelType>
53 class MPPICParcel;
54 
55 template<class Type>
56 class AveragingMethod;
57 
58 // Forward declaration of friend functions
59 
60 template<class ParcelType>
61 Ostream& operator<<
62 (
63  Ostream&,
65 );
66 
67 /*---------------------------------------------------------------------------*\
68  Class MPPICParcelName Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 
73 
74 /*---------------------------------------------------------------------------*\
75  Class MPPICParcel Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class ParcelType>
79 class MPPICParcel
80 :
81  public ParcelType,
82  public MPPICParcelName
83 {
84  // Private Data
85 
86  //- Size in bytes of the fields
87  static const std::size_t sizeofFields_;
88 
89 
90 public:
91 
92  class trackingData
93  :
94  public ParcelType::trackingData
95  {
96  private:
97 
98  // Private Data
99 
100  // MPPIC Averages
101 
102  //- Volume average
103  autoPtr<AveragingMethod<scalar>> volumeAverage_;
104 
105  //- Radius average
106  autoPtr<AveragingMethod<scalar>> radiusAverage_;
107 
108  //- Density average
109  autoPtr<AveragingMethod<scalar>> rhoAverage_;
110 
111  //- Velocity average
113 
114  //- Magnitude velocity squared average
115  autoPtr<AveragingMethod<scalar>> uSqrAverage_;
116 
117  //- Frequency average
118  autoPtr<AveragingMethod<scalar>> frequencyAverage_;
119 
120  //- Mass average
121  autoPtr<AveragingMethod<scalar>> massAverage_;
122 
123 
124  public:
125 
126  //- Constructors
127 
128  //- Construct from components
129  template<class TrackCloudType>
130  inline trackingData(const TrackCloudType& cloud);
131 
132 
133  //- Update the MPPIC averages
134  template<class TrackCloudType>
135  inline void updateAverages(const TrackCloudType& cloud);
136  };
137 
138 
139 protected:
140 
141  // Protected data
142 
143  //- Processor and particle ID at the start of a tracking step. Allows
144  // values calculated at the end of the step to be mapped back to the
145  // starting state, in order to initialise a second corrector step.
146  labelPair id_;
147 
148 
149 public:
150 
151  // Static Data Members
152 
153  //- String representation of properties
154  AddToPropertyList(ParcelType, "");
155 
156 
157  // Constructors
158 
159  //- Construct from mesh, coordinates and topology
160  // Other properties initialised as null
161  inline MPPICParcel
162  (
163  const polyMesh& mesh,
164  const barycentric& coordinates,
165  const label celli,
166  const label tetFacei,
167  const label tetPti,
168  const label facei
169  );
170 
171  //- Construct from a position and a cell, searching for the rest of the
172  // required topology. Other properties are initialised as null.
173  inline MPPICParcel
174  (
175  const polyMesh& mesh,
176  const vector& position,
177  const label celli,
178  label& nLocateBoundaryHits
179  );
180 
181  //- Construct from Istream
182  MPPICParcel(Istream& is, bool readFields = true);
183 
184  //- Construct as a copy
185  MPPICParcel(const MPPICParcel& p);
186 
187  //- Construct and return a clone
188  virtual autoPtr<particle> clone() const
189  {
190  return autoPtr<particle>(new MPPICParcel(*this));
191  }
192 
193  //- Construct from Istream and return
194  static autoPtr<MPPICParcel> New(Istream& is)
195  {
196  return autoPtr<MPPICParcel>(new MPPICParcel(is));
197  }
198 
199 
200  // Member Functions
201 
202  // Access
203 
204  //- Return const access to the identifier
205  inline const labelPair& id() const;
206 
207  //- Return access to the identifier
208  inline labelPair& id();
209 
210 
211  // Friend Functions
212 
213  // I-O
214 
215  //- Read
216  template<class CloudType>
217  static void readFields(CloudType& c);
218 
219  //- Write
220  template<class CloudType>
221  static void writeFields(const CloudType& c);
222 
223 
224  // Ostream operator
225 
226  friend Ostream& operator<< <ParcelType>
227  (
228  Ostream&,
230  );
231 };
232 
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #include "MPPICParcelI.H"
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
246  #include "MPPICParcel.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
trackingData(const TrackCloudType &cloud)
Constructors.
void updateAverages(const TrackCloudType &cloud)
Update the MPPIC averages.
Wrapper around parcel types to add MPPIC modelling.
Definition: MPPICParcel.H:82
AddToPropertyList(ParcelType, "")
String representation of properties.
MPPICParcel(const polyMesh &mesh, const barycentric &coordinates, const label celli, const label tetFacei, const label tetPti, const label facei)
Construct from mesh, coordinates and topology.
Definition: MPPICParcelI.H:32
virtual autoPtr< particle > clone() const
Construct and return a clone.
Definition: MPPICParcel.H:187
static void writeFields(const CloudType &c)
Write.
Definition: MPPICParcelIO.C:81
static autoPtr< MPPICParcel > New(Istream &is)
Construct from Istream and return.
Definition: MPPICParcel.H:193
static void readFields(CloudType &c)
Read.
Definition: MPPICParcelIO.C:73
labelPair id_
Processor and particle ID at the start of a tracking step. Allows.
Definition: MPPICParcel.H:145
const labelPair & id() const
Return const access to the identifier.
Definition: MPPICParcelI.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A cloud is a collection of lagrangian particles.
Definition: cloud.H:55
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
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
TemplateName(FvFaceCellWave)
volScalarField & p