ParticleForce.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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::ParticleForce
28 
29 Group
30  grpLagrangianIntermediateForceSubModels
31 
32 Description
33  Abstract base class for particle forces
34 
35 SourceFiles
36  ParticleForce.C
37  ParticleForceNew.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_ParticleForce_H
42 #define Foam_ParticleForce_H
43 
44 #include "dictionary.H"
45 #include "forceSuSp.H"
46 #include "fvMesh.H"
47 #include "runTimeSelectionTables.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class ParticleForce Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class CloudType>
59 class ParticleForce
60 {
61  // Private Data
62 
63  //- Reference to the owner cloud
64  CloudType& owner_;
65 
66  //- Reference to the mesh database
67  const fvMesh& mesh_;
68 
69  //- Force coefficients dictionary
70  const dictionary coeffs_;
71 
72 
73 public:
74 
75  //- Runtime type information
76  TypeName("particleForce");
77 
78  //- Declare runtime constructor selection table
80  (
81  autoPtr,
83  dictionary,
84  (
86  const fvMesh& mesh,
87  const dictionary& dict
88  ),
89  (owner, mesh, dict)
90  );
91 
92 
93  //- Convenience typedef for return type
95 
96 
97  // Constructors
98 
99  //- Construct from mesh
101  (
102  CloudType& owner,
103  const fvMesh& mesh,
104  const dictionary& dict,
105  const word& forceType,
106  const bool readCoeffs
107  );
108 
109  //- Construct copy
110  ParticleForce(const ParticleForce& pf);
111 
112  //- Construct and return a clone
113  virtual autoPtr<ParticleForce<CloudType>> clone() const
114  {
116  (
117  new ParticleForce<CloudType>(*this)
118  );
119  }
120 
121 
122  //- Destructor
123  virtual ~ParticleForce();
124 
125 
126  //- Selector
128  (
129  CloudType& owner,
130  const fvMesh& mesh,
131  const dictionary& dict,
132  const word& forceType
133  );
134 
135 
136  // Member Functions
137 
138  // Access
139 
140  //- Return const access to the cloud owner
141  const CloudType& owner() const noexcept { return owner_; }
142 
143  //- Return reference to the cloud owner
144  CloudType& owner() noexcept { return owner_; }
145 
146  //- Return the mesh database
147  const fvMesh& mesh() const noexcept { return mesh_; }
148 
149  //- Return the force coefficients dictionary
150  const dictionary& coeffs() const noexcept { return coeffs_; }
151 
152 
153  // Evaluation
154 
155  //- Cache fields
156  virtual void cacheFields(const bool store);
157 
158  //- Calculate the coupled force
159  virtual forceSuSp calcCoupled
160  (
161  const typename CloudType::parcelType& p,
162  const typename CloudType::parcelType::trackingData& td,
163  const scalar dt,
164  const scalar mass,
165  const scalar Re,
166  const scalar muc
167  ) const;
168 
169  //- Calculate the non-coupled force
171  (
172  const typename CloudType::parcelType& p,
173  const typename CloudType::parcelType::trackingData& td,
174  const scalar dt,
175  const scalar mass,
176  const scalar Re,
177  const scalar muc
178  ) const;
179 
180  //- Return the added mass
181  virtual scalar massAdd
182  (
183  const typename CloudType::parcelType& p,
184  const typename CloudType::parcelType::trackingData& td,
185  const scalar mass
186  ) const;
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #ifdef NoRepository
197  #include "ParticleForce.C"
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #define makeParticleForceModel(CloudType) \
203  \
204  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
205  defineNamedTemplateTypeNameAndDebug \
206  (Foam::ParticleForce<kinematicCloudType>, 0); \
207  \
208  namespace Foam \
209  { \
210  defineTemplateRunTimeSelectionTable \
211  ( \
212  ParticleForce<kinematicCloudType>, \
213  dictionary \
214  ); \
215  }
216 
217 
218 #define makeParticleForceModelType(SS, CloudType) \
219  \
220  typedef Foam::CloudType::kinematicCloudType kinematicCloudType; \
221  defineNamedTemplateTypeNameAndDebug(Foam::SS<kinematicCloudType>, 0); \
222  \
223  Foam::ParticleForce<kinematicCloudType>:: \
224  adddictionaryConstructorToTable<Foam::SS<kinematicCloudType>> \
225  add##SS##CloudType##kinematicCloudType##ConstructorToTable_;
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 
231 #endif
232 
233 // ************************************************************************* //
virtual forceSuSp calcNonCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the non-coupled force.
Definition: ParticleForce.C:92
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static autoPtr< ParticleForce< CloudType > > New(CloudType &owner, const fvMesh &mesh, const dictionary &dict, const word &forceType)
Selector.
virtual scalar massAdd(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar mass) const
Return the added mass.
Templated vector space.
Definition: VectorSpace.H:52
Abstract base class for particle forces.
Definition: ParticleForce.H:54
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:60
const fvMesh & mesh() const noexcept
Return the mesh database.
VectorSpace< Vector< vector >, vector, 2 > returnType
Convenience typedef for return type.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void cacheFields(const bool store)
Cache fields.
Definition: ParticleForce.C:67
Vector< scalar > vector
Definition: vector.H:57
ParticleForce(CloudType &owner, const fvMesh &mesh, const dictionary &dict, const word &forceType, const bool readCoeffs)
Construct from mesh.
Definition: ParticleForce.C:27
TypeName("particleForce")
Runtime type information.
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:290
const direction noexcept
Definition: Scalar.H:258
scalarField Re(const UList< complex > &cmplx)
Extract real component.
Definition: complexField.C:207
const CloudType & owner() const noexcept
Return const access to the cloud owner.
virtual forceSuSp calcCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the coupled force.
Definition: ParticleForce.C:73
virtual ~ParticleForce()
Destructor.
Definition: ParticleForce.C:60
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
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.
declareRunTimeSelectionTable(autoPtr, ParticleForce, dictionary,(CloudType &owner, const fvMesh &mesh, const dictionary &dict),(owner, mesh, dict))
Declare runtime constructor selection table.
volScalarField & p
const dictionary & coeffs() const noexcept
Return the force coefficients dictionary.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
virtual autoPtr< ParticleForce< CloudType > > clone() const
Construct and return a clone.
Namespace for OpenFOAM.