CloudFunctionObjects/VolumeFraction: Replacement for VoidFraction

The volumeFraction cloud function will create and write a vol-field of
the cloud's volume fraction. It requires no additional controls. Example
in constant/cloudProperties:

    cloudFunctions
    {
        volumeFraction1
        {
            type volumeFraction;
        }
    }

This replaces voidFraction, which was incorrectly named in that it also
write the volume fraction (not one-minus the volume fraction), and who's
storage of the field was flawed in that it caused registration clashes
with fields stored by certain other Lagrangian models.
This commit is contained in:
Will Bainbridge
2023-09-06 12:07:00 +01:00
parent 889b811005
commit 31b096f63d
4 changed files with 84 additions and 188 deletions

View File

@ -38,7 +38,7 @@ License
#include "PatchPostProcessing.H"
#include "RelativeVelocity.H"
#include "SizeDistribution.H"
#include "VoidFraction.H"
#include "VolumeFraction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ License
makeCloudFunctionObjectType(PatchCollisionDensity, CloudType); \
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
makeCloudFunctionObjectType(RelativeVelocity, CloudType); \
makeCloudFunctionObjectType(VoidFraction, CloudType); \
makeCloudFunctionObjectType(VolumeFraction, CloudType); \
makeCloudFunctionObjectType(SizeDistribution, CloudType); \
makeCloudFunctionObjectType(VolumeFlux, CloudType);

View File

@ -1,139 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VoidFraction.H"
// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * //
template<class CloudType>
void Foam::VoidFraction<CloudType>::write()
{
if (thetaPtr_.valid())
{
thetaPtr_->write();
}
else
{
FatalErrorInFunction
<< "thetaPtr not valid" << abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::VoidFraction<CloudType>::VoidFraction
(
const dictionary& dict,
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
thetaPtr_(nullptr)
{}
template<class CloudType>
Foam::VoidFraction<CloudType>::VoidFraction
(
const VoidFraction<CloudType>& vf
)
:
CloudFunctionObject<CloudType>(vf),
thetaPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::VoidFraction<CloudType>::~VoidFraction()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::VoidFraction<CloudType>::preEvolve()
{
if (thetaPtr_.valid())
{
thetaPtr_->primitiveFieldRef() = 0.0;
}
else
{
const fvMesh& mesh = this->owner().mesh();
thetaPtr_.reset
(
new volScalarField
(
IOobject
(
this->owner().name() + "Theta",
mesh.time().name(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimless, 0)
)
);
}
}
template<class CloudType>
void Foam::VoidFraction<CloudType>::postEvolve()
{
volScalarField& theta = thetaPtr_();
const fvMesh& mesh = this->owner().mesh();
theta.primitiveFieldRef() /= mesh.time().deltaTValue()*mesh.V();
CloudFunctionObject<CloudType>::postEvolve();
}
template<class CloudType>
void Foam::VoidFraction<CloudType>::postMove
(
parcelType& p,
const scalar dt,
const point&,
bool&
)
{
volScalarField& theta = thetaPtr_();
theta[p.cell()] += dt*p.nParticle()*p.volume();
}
// ************************************************************************* //

View File

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VolumeFraction.H"
// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * //
template<class CloudType>
void Foam::VolumeFraction<CloudType>::write()
{
this->owner().alpha()->write();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::VolumeFraction<CloudType>::VolumeFraction
(
const dictionary& dict,
CloudType& owner,
const word& modelName
)
:
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName)
{}
template<class CloudType>
Foam::VolumeFraction<CloudType>::VolumeFraction
(
const VolumeFraction<CloudType>& vf
)
:
CloudFunctionObject<CloudType>(vf)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::VolumeFraction<CloudType>::~VolumeFraction()
{}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,21 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::VoidFraction
Foam::VolumeFraction
Description
Creates particle void fraction field on carrier phase
Creates particle volume fraction field on carrier phase
SourceFiles
VoidFraction.C
VolumeFraction.C
\*---------------------------------------------------------------------------*/
#ifndef VoidFraction_H
#define VoidFraction_H
#ifndef VolumeFraction_H
#define VolumeFraction_H
#include "CloudFunctionObject.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,26 +43,14 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class VoidFraction Declaration
Class VolumeFraction Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class VoidFraction
class VolumeFraction
:
public CloudFunctionObject<CloudType>
{
// Private Data
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Void fraction field
autoPtr<volScalarField> thetaPtr_;
protected:
// Protected Member Functions
@ -75,13 +62,13 @@ protected:
public:
//- Runtime type information
TypeName("voidFraction");
TypeName("volumeFraction");
// Constructors
//- Construct from dictionary
VoidFraction
VolumeFraction
(
const dictionary& dict,
CloudType& owner,
@ -89,40 +76,20 @@ public:
);
//- Construct copy
VoidFraction(const VoidFraction<CloudType>& vf);
VolumeFraction(const VolumeFraction<CloudType>& vf);
//- Construct and return a clone
virtual autoPtr<CloudFunctionObject<CloudType>> clone() const
{
return autoPtr<CloudFunctionObject<CloudType>>
(
new VoidFraction<CloudType>(*this)
new VolumeFraction<CloudType>(*this)
);
}
//- Destructor
virtual ~VoidFraction();
// Member Functions
// Evaluation
//- Pre-evolve hook
virtual void preEvolve();
//- Post-evolve hook
virtual void postEvolve();
//- Post-move hook
virtual void postMove
(
parcelType& p,
const scalar dt,
const point& position0,
bool& keepParticle
);
virtual ~VolumeFraction();
};
@ -133,7 +100,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "VoidFraction.C"
#include "VolumeFraction.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //