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 -------------------------------------------------------------------------------
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 \*---------------------------------------------------------------------------*/
27 
28 #include "VoidFraction.H"
29 
30 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
31 
32 template<class CloudType>
34 {
35  if (thetaPtr_.valid())
36  {
37  thetaPtr_->write();
38  }
39  else
40  {
42  << "thetaPtr not valid" << abort(FatalError);
43  }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 template<class CloudType>
51 (
52  const dictionary& dict,
53  CloudType& owner,
54  const word& modelName
55 )
56 :
57  CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
58  thetaPtr_(nullptr)
59 {}
60 
61 
62 template<class CloudType>
64 (
65  const VoidFraction<CloudType>& vf
66 )
67 :
69  thetaPtr_(nullptr)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 
75 template<class CloudType>
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class CloudType>
84 {
85  if (thetaPtr_.valid())
86  {
87  thetaPtr_->primitiveFieldRef() = 0.0;
88  }
89  else
90  {
91  const fvMesh& mesh = this->owner().mesh();
92 
93  thetaPtr_.reset
94  (
95  new volScalarField
96  (
97  IOobject
98  (
99  this->owner().name() + "Theta",
100  mesh.time().timeName(),
101  mesh,
102  IOobject::NO_READ,
103  IOobject::NO_WRITE
104  ),
105  mesh,
107  )
108  );
109  }
110 }
111 
112 
113 template<class CloudType>
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:104
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::VoidFraction::VoidFraction
VoidFraction(const dictionary &dict, CloudType &owner, const word &modelName)
Construct from dictionary.
Definition: VoidFraction.C:51
Foam::VoidFraction::postMove
virtual void postMove(parcelType &p, const scalar dt, const point &position0, bool &keepParticle)
Post-move hook.
Definition: VoidFraction.C:128
Foam::DSMCCloud::mesh
const fvMesh & mesh() const
Return reference to the mesh.
Definition: DSMCCloudI.H:44
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
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:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:735
Foam::VoidFraction::preEvolve
virtual void preEvolve()
Pre-evolve hook.
Definition: VoidFraction.C:83
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::Vector< scalar >
Foam::VoidFraction::~VoidFraction
virtual ~VoidFraction()
Destructor.
Definition: VoidFraction.C:76
Foam::VoidFraction
Creates particle void fraction field on carrier phase.
Definition: VoidFraction.H:55
Foam::CloudFunctionObject
Templated cloud function object base class.
Definition: CloudFunctionObject.H:61
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:208
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::VoidFraction::write
virtual void write()
Write post-processing info.
Definition: VoidFraction.C:33
Foam::VoidFraction::postEvolve
virtual void postEvolve()
Post-evolve hook.
Definition: VoidFraction.C:114
VoidFraction.H