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();
121 
123 }
124 
125 
126 template<class CloudType>
128 (
129  parcelType& p,
130  const scalar dt,
131  const point&,
132  bool&
133 )
134 {
135  volScalarField& theta = thetaPtr_();
136 
137  theta[p.cell()] += dt*p.nParticle()*p.volume();
138 }
139 
140 
141 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::VoidFraction::VoidFraction
VoidFraction(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: VoidFraction.C:52
Foam::VoidFraction::postMove
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: VoidFraction.C:128
Foam::VoidFraction::postEvolve
virtual void postEvolve(const typename parcelType::trackingData &td)
Post-evolve hook.
Definition: VoidFraction.C:112
Foam::DSMCCloud::mesh
const fvMesh & mesh() const
Return reference to the mesh.
Definition: DSMCCloudI.H:44
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
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::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::Vector< scalar >
Foam::VoidFraction
Creates particle void fraction field on carrier phase.
Definition: VoidFraction.H:56
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:62
Foam::primitiveMesh::reset
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
Definition: primitiveMesh.C:207
Foam::VoidFraction::preEvolve
virtual void preEvolve(const typename parcelType::trackingData &td)
Pre-evolve hook.
Definition: VoidFraction.C:78
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::VoidFraction::write
virtual void write()
Write post-processing info.
Definition: VoidFraction.C:34
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189
VoidFraction.H