PressureGradientForce.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 \*---------------------------------------------------------------------------*/
25 
26 #include "PressureGradientForce.H"
27 #include "fvcDdt.H"
28 #include "fvcGrad.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class CloudType>
34 (
35  CloudType& owner,
36  const fvMesh& mesh,
37  const dictionary& dict,
38  const word& forceType
39 )
40 :
41  ParticleForce<CloudType>(owner, mesh, dict, forceType, true),
42  UName_(this->coeffs().template lookupOrDefault<word>("U", "U")),
43  DUcDtInterpPtr_(NULL)
44 {}
45 
46 
47 template<class CloudType>
49 (
50  const PressureGradientForce& pgf
51 )
52 :
54  UName_(pgf.UName_),
55  DUcDtInterpPtr_(NULL)
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
60 
61 template<class CloudType>
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class CloudType>
70 {
71  static word fName("DUcDt");
72 
73  bool fieldExists = this->mesh().template foundObject<volVectorField>(fName);
74 
75  if (store)
76  {
77  if (!fieldExists)
78  {
79  const volVectorField& Uc = this->mesh().template
80  lookupObject<volVectorField>(UName_);
81 
82  volVectorField* DUcDtPtr = new volVectorField
83  (
84  fName,
85  fvc::ddt(Uc) + (Uc & fvc::grad(Uc))
86  );
87 
88  DUcDtPtr->store();
89  }
90 
91  const volVectorField& DUcDt = this->mesh().template
92  lookupObject<volVectorField>(fName);
93 
94  DUcDtInterpPtr_.reset
95  (
97  (
98  this->owner().solution().interpolationSchemes(),
99  DUcDt
100  ).ptr()
101  );
102  }
103  else
104  {
105  DUcDtInterpPtr_.clear();
106 
107  if (fieldExists)
108  {
109  const volVectorField& DUcDt = this->mesh().template
110  lookupObject<volVectorField>(fName);
111 
112  const_cast<volVectorField&>(DUcDt).checkOut();
113  }
114  }
115 }
116 
117 
118 template<class CloudType>
120 (
121  const typename CloudType::parcelType& p,
122  const scalar dt,
123  const scalar mass,
124  const scalar Re,
125  const scalar muc
126 ) const
127 {
128  forceSuSp value(Zero, 0.0);
129 
130  vector DUcDt =
131  DUcDtInterp().interpolate(p.position(), p.currentTetIndices());
132 
133  value.Su() = mass*p.rhoc()/p.rho()*DUcDt;
134 
135  return value;
136 }
137 
138 
139 template<class CloudType>
141 (
142  const typename CloudType::parcelType&,
143  const scalar
144 ) const
145 {
146  return 0.0;
147 }
148 
149 
150 // ************************************************************************* //
dictionary dict
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
virtual scalar massAdd(const typename CloudType::parcelType &p, const scalar mass) const
Return the added mass.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual forceSuSp calcCoupled(const typename CloudType::parcelType &p, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the non-coupled force.
Abstract base class for particle forces.
Definition: ParticleForce.H:53
const vector & Su() const
Return const access to the explicit contribution [kg.m/s2].
Definition: forceSuSpI.H:56
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:61
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
Calculate the first temporal derivative.
dynamicFvMesh & mesh
Calculates particle pressure gradient force.
virtual void cacheFields(const bool store)
Cache fields.
Calculate the gradient of the given field.
A class for handling words, derived from string.
Definition: word.H:59
virtual ~PressureGradientForce()
Destructor.
static const zero Zero
Definition: zero.H:91
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:217
const word UName_
Name of velocity field.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Abstract base class for interpolation.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
PressureGradientForce(CloudType &owner, const fvMesh &mesh, const dictionary &dict, const word &forceType=typeName)
Construct from mesh.