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 | 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 \*---------------------------------------------------------------------------*/
28 
29 #include "PressureGradientForce.H"
30 #include "fvcDdt.H"
31 #include "fvcGrad.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class CloudType>
37 (
38  CloudType& owner,
39  const fvMesh& mesh,
40  const dictionary& dict,
41  const word& forceType
42 )
43 :
44  ParticleForce<CloudType>(owner, mesh, dict, forceType, true),
45  UName_(this->coeffs().template getOrDefault<word>("U", "U")),
46  DUcDtInterpPtr_(nullptr)
47 {}
48 
49 
50 template<class CloudType>
52 (
53  const PressureGradientForce& pgf
54 )
55 :
57  UName_(pgf.UName_),
58  DUcDtInterpPtr_(nullptr)
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
63 
64 template<class CloudType>
66 {}
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
71 template<class CloudType>
73 {
74  static word fName("DUcDt");
75 
76  bool fieldExists = this->mesh().template foundObject<volVectorField>(fName);
77 
78  if (store)
79  {
80  if (!fieldExists)
81  {
82  const volVectorField& Uc = this->mesh().template
83  lookupObject<volVectorField>(UName_);
84 
85  volVectorField* DUcDtPtr = new volVectorField
86  (
87  fName,
88  fvc::ddt(Uc) + (Uc & fvc::grad(Uc))
89  );
90 
91  DUcDtPtr->store();
92  }
93 
94  const volVectorField& DUcDt = this->mesh().template
95  lookupObject<volVectorField>(fName);
96 
97  DUcDtInterpPtr_.reset
98  (
100  (
101  this->owner().solution().interpolationSchemes(),
102  DUcDt
103  ).ptr()
104  );
105  }
106  else
107  {
108  DUcDtInterpPtr_.clear();
109 
110  if (fieldExists)
111  {
112  volVectorField& DUcDt =
113  this->mesh().template lookupObjectRef<volVectorField>(fName);
114 
115  DUcDt.checkOut();
116  }
117  }
118 }
119 
120 
121 template<class CloudType>
123 (
124  const typename CloudType::parcelType& p,
125  const typename CloudType::parcelType::trackingData& td,
126  const scalar dt,
127  const scalar mass,
128  const scalar Re,
129  const scalar muc
130 ) const
131 {
132  forceSuSp value(Zero);
133 
134  vector DUcDt =
135  DUcDtInterp().interpolate(p.coordinates(), p.currentTetIndices());
136 
137  value.Su() = mass*td.rhoc()/p.rho()*DUcDt;
138 
139  return value;
140 }
141 
142 
143 template<class CloudType>
145 (
146  const typename CloudType::parcelType&,
147  const typename CloudType::parcelType::trackingData& td,
148  const scalar
149 ) const
150 {
151  return 0.0;
152 }
153 
154 
155 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:55
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::PressureGradientForce::PressureGradientForce
PressureGradientForce(CloudType &owner, const fvMesh &mesh, const dictionary &dict, const word &forceType=typeName)
Construct from mesh.
Definition: PressureGradientForce.C:37
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
PressureGradientForce.H
Foam::PressureGradientForce::~PressureGradientForce
virtual ~PressureGradientForce()
Destructor.
Definition: PressureGradientForce.C:65
Foam::fac::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:56
Foam::PressureGradientForce::cacheFields
virtual void cacheFields(const bool store)
Cache fields.
Definition: PressureGradientForce.C:72
Foam::forceSuSp::Su
const vector & Su() const
Return const access to the explicit contribution [kg.m/s2].
Definition: forceSuSpI.H:61
Foam::PressureGradientForce
Calculates particle pressure gradient force.
Definition: PressureGradientForce.H:57
Foam::PressureGradientForce::calcCoupled
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 non-coupled force.
Definition: PressureGradientForce.C:123
Foam::forceSuSp
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:64
Foam::ParticleForce
Abstract base class for particle forces.
Definition: ParticleForce.H:59
Foam::PressureGradientForce::UName_
const word UName_
Name of velocity field.
Definition: PressureGradientForce.H:66
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
Foam::Vector< scalar >
fvcGrad.H
Calculate the gradient of the given field.
Foam::fac::ddt
tmp< GeometricField< Type, faPatchField, areaMesh > > ddt(const dimensioned< Type > dt, const faMesh &mesh)
Definition: facDdt.C:47
Foam::Re
scalarField Re(const UList< complex > &cf)
Extract real component.
Definition: complexField.C:159
Foam::DSMCCloud::parcelType
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:220
fvcDdt.H
Calculate the first temporal derivative.
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::PressureGradientForce::massAdd
virtual scalar massAdd(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar mass) const
Return the added mass.
Definition: PressureGradientForce.C:145