VoidFraction.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 "VoidFraction.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class CloudType>
35 {
36  if (thetaPtr_)
37  {
38  thetaPtr_->write();
39  }
40  else
41  {
43  << "thetaPtr not valid" << abort(FatalError);
44  }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 template<class CloudType>
52 (
53  const dictionary& dict,
54  CloudType& owner,
55  const word& modelName
56 )
57 :
58  CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
59  thetaPtr_(nullptr)
60 {}
61 
62 
63 template<class CloudType>
65 (
66  const VoidFraction<CloudType>& vf
67 )
68 :
70  thetaPtr_(nullptr)
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
76 template<class CloudType>
78 (
79  const typename parcelType::trackingData& td
80 )
81 {
82  if (thetaPtr_)
83  {
84  thetaPtr_->primitiveFieldRef() = 0.0;
85  }
86  else
87  {
88  const fvMesh& mesh = this->owner().mesh();
89 
90  thetaPtr_.reset
91  (
92  new volScalarField
93  (
94  IOobject
95  (
96  this->owner().name() + "Theta",
97  mesh.time().timeName(),
98  mesh,
99  IOobject::NO_READ,
100  IOobject::NO_WRITE
101  ),
102  mesh,
104  )
105  );
106  }
107 }
108 
109 
110 template<class CloudType>
112 (
113  const typename parcelType::trackingData& td
114 )
115 {
116  volScalarField& theta = thetaPtr_();
117 
118  const fvMesh& mesh = this->owner().mesh();
119 
120  theta.primitiveFieldRef() /= mesh.time().deltaTValue()*mesh.V();
123 }
124 
125 
126 template<class CloudType>
128 (
129  parcelType& p,
130  const scalar dt,
131  const point&,
132  const typename parcelType::trackingData& td
133 )
134 {
135  volScalarField& theta = thetaPtr_();
136 
137  theta[p.cell()] += dt*p.nParticle()*p.volume();
138 
139  return true;
140 }
141 
142 
143 // ************************************************************************* //
dictionary dict
Creates particle void fraction field on carrier phase.
Definition: VoidFraction.H:52
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
virtual bool postMove(parcelType &p, const scalar dt, const point &position0, const typename parcelType::trackingData &td)
Post-move hook.
Definition: VoidFraction.C:121
const dimensionSet dimless
Dimensionless.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
Definition: VoidFraction.C:105
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
errorManip< error > abort(error &err)
Definition: errorManip.H:139
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: VoidFraction.C:71
virtual void write()
Write post-processing info.
Definition: VoidFraction.C:27
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
VoidFraction(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: VoidFraction.C:45
volScalarField & p
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:67
Templated cloud function object base class.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127