ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / CloudFunctionObjects / VoidFraction / VoidFraction.C
blob855db45c88a6d679342811c4f66dbd3c37d8562a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "VoidFraction.H"
28 // * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * //
30 template<class CloudType>
31 void Foam::VoidFraction<CloudType>::write()
33     if (thetaPtr_.valid())
34     {
35         thetaPtr_->write();
36     }
37     else
38     {
39         FatalErrorIn("void Foam::VoidFraction<CloudType>::write()")
40             << "thetaPtr not valid" << abort(FatalError);
41     }
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 template<class CloudType>
48 Foam::VoidFraction<CloudType>::VoidFraction
50     const dictionary& dict,
51     CloudType& owner
54     CloudFunctionObject<CloudType>(owner),
55     thetaPtr_(NULL)
59 template<class CloudType>
60 Foam::VoidFraction<CloudType>::VoidFraction
62     const VoidFraction<CloudType>& vf
65     CloudFunctionObject<CloudType>(vf),
66     thetaPtr_(NULL)
70 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
72 template<class CloudType>
73 Foam::VoidFraction<CloudType>::~VoidFraction()
77 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
79 template<class CloudType>
80 void Foam::VoidFraction<CloudType>::preEvolve()
82     if (thetaPtr_.valid())
83     {
84         thetaPtr_->internalField() = 0.0;
85     }
86     else
87     {
88         const fvMesh& mesh = this->owner().mesh();
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,
103                 dimensionedScalar("zero", dimless, 0.0)
104             )
105         );
106     }
110 template<class CloudType>
111 void Foam::VoidFraction<CloudType>::postEvolve()
113     volScalarField& theta = thetaPtr_();
115     const fvMesh& mesh = this->owner().mesh();
117     theta.internalField() /= mesh.time().deltaTValue()*mesh.V();
119     CloudFunctionObject<CloudType>::postEvolve();
123 template<class CloudType>
124 void Foam::VoidFraction<CloudType>::postMove
126     const parcelType& p,
127     const label cellI,
128     const scalar dt
131     volScalarField& theta = thetaPtr_();
133     theta[cellI] += dt*p.nParticle()*p.volume();
137 // ************************************************************************* //