COM: Separate htc FO from general FO and reactingEuler solvers (#1714)

The phase systems tables for multiphase solvers create conflict
between each other as they are defined in the same namespace and using
similar class names.

Therefore a special htc function object for reactingEulerSolver was
added (reactingEulerHtcModel), located under
src/phaseSystemModels/reactingEulerFoam/functionObjects/

This commit includes the following:

- Relocate solvers/reactingEulerFoam functionObjects to
  src/phaseSystemModels
- Remove links for fieldFunctionObject to multiphase libs to avoid
  conflicts
- New FO for htc for reactingEulerFoam called reactingEulerHtcModel
This commit is contained in:
sergio
2020-06-01 12:53:30 -07:00
committed by Mark Olesen
parent cf09b67b28
commit 95f7ed0342
26 changed files with 421 additions and 85 deletions

View File

@ -100,8 +100,8 @@ wmake $targetType engine
conversion/Allwmake $targetType $*
phaseSystemModels/Allwmake $targetType $*
functionObjects/Allwmake $targetType $*
phaseSystemModels/Allwmake $targetType $*
wmake $targetType lumpedPointMotion
wmake $targetType sixDoFRigidBodyMotion

View File

@ -38,6 +38,4 @@ LIB_LIBS = \
-lcompressibleTurbulenceModels \
-lchemistryModel \
-lreactionThermophysicalModels \
-lpairPatchAgglomeration \
-ltwoPhaseReactingTurbulenceModels \
-lreactingPhaseSystem
-lpairPatchAgglomeration

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,7 +47,7 @@ bool Foam::functionObjects::heatTransferCoeff::calc()
{
volScalarField& htc = mesh_.lookupObjectRef<volScalarField>(resultName_);
htcModelPtr_->calc(htc);
htcModelPtr_->calc(htc, htcModelPtr_->q());
return true;
}
@ -63,14 +63,13 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff
)
:
fieldExpression(name, runTime, dict),
htcModelPtr_()
htcModelPtr_(nullptr)
{
read(dict);
setResultName(typeName, name + ":htc:" + htcModelPtr_->type());
volScalarField* heatTransferCoeffPtr
(
volScalarField* heatTransferCoeffPtr =
new volScalarField
(
IOobject
@ -83,8 +82,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff
),
mesh_,
dimensionedScalar(dimPower/dimArea/dimTemperature, Zero)
)
);
);
mesh_.objectRegistry::store(heatTransferCoeffPtr);
}

View File

@ -122,6 +122,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class heatTransferCoeffModel;
namespace functionObjects
@ -135,16 +136,19 @@ class heatTransferCoeff
:
public fieldExpression
{
private:
// Private data
// Private Data
//- Heat transfer coefficient model
autoPtr<heatTransferCoeffModel> htcModelPtr_;
// Private Member Functions
protected:
// Protected Member Functions
//- Calculate the heat transfer coefficient field
// \return true on success
virtual bool calc();
//- No copy construct
heatTransferCoeff(const heatTransferCoeff&) = delete;
@ -153,13 +157,6 @@ private:
void operator=(const heatTransferCoeff&) = delete;
protected:
//- Calculate the heat transfer coefficient field and return true
// if successful
virtual bool calc();
public:
//- Runtime type information
@ -185,7 +182,7 @@ public:
// Member Functions
//- Read the heatTransferCoeff data
virtual bool read(const dictionary&);
virtual bool read(const dictionary& dict);
};

View File

@ -243,7 +243,11 @@ bool Foam::heatTransferCoeffModels::ReynoldsAnalogy::read
}
void Foam::heatTransferCoeffModels::ReynoldsAnalogy::htc(volScalarField& htc)
void Foam::heatTransferCoeffModels::ReynoldsAnalogy::htc
(
volScalarField& htc,
const FieldField<Field, scalar>& q
)
{
const FieldField<Field, scalar> CfBf(Cf());
const scalar magU = mag(URef_);

View File

@ -131,7 +131,11 @@ protected:
tmp<FieldField<Field, scalar>> Cf() const;
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc);
virtual void htc
(
volScalarField& htc,
const FieldField<Field, scalar>& q
);
//- No copy construct

View File

@ -81,10 +81,11 @@ bool Foam::heatTransferCoeffModels::fixedReferenceTemperature::read
void Foam::heatTransferCoeffModels::fixedReferenceTemperature::htc
(
volScalarField& htc
volScalarField& htc,
const FieldField<Field, scalar>& q
)
{
const FieldField<Field, scalar> qBf(q());
//const FieldField<Field, scalar> qBf(q());
const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_);
const volScalarField::Boundary& Tbf = T.boundaryField();
const scalar eps = ROOTVSMALL;
@ -92,7 +93,7 @@ void Foam::heatTransferCoeffModels::fixedReferenceTemperature::htc
volScalarField::Boundary& htcBf = htc.boundaryFieldRef();
for (const label patchi : patchSet_)
{
htcBf[patchi] = qBf[patchi]/(TRef_ - Tbf[patchi] + eps);
htcBf[patchi] = q[patchi]/(TRef_ - Tbf[patchi] + eps);
}
}

View File

@ -94,7 +94,11 @@ protected:
// Protected Member Functions
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc);
virtual void htc
(
volScalarField& htc,
const FieldField<Field, scalar>& q
);
//- No copy construct
fixedReferenceTemperature(const fixedReferenceTemperature&) = delete;

View File

@ -30,7 +30,6 @@ License
#include "fluidThermo.H"
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "phaseSystem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -91,32 +90,10 @@ Foam::heatTransferCoeffModel::q() const
q[patchi] = alphabf[patchi]*hebf[patchi].snGrad();
}
}
else if (mesh_.foundObject<phaseSystem>("phaseProperties"))
{
const phaseSystem& fluid =
(
mesh_.lookupObject<phaseSystem>("phaseProperties")
);
for (label patchi : patchSet_)
{
forAll(fluid.phases(), phasei)
{
const phaseModel& phase = fluid.phases()[phasei];
const fvPatchScalarField& alpha =
phase.boundaryField()[patchi];
const volScalarField& he = phase.thermo().he();
const volScalarField::Boundary& hebf = he.boundaryField();
q[patchi] +=
alpha*phase.alphaEff(patchi)()*hebf[patchi].snGrad();
}
}
}
else
{
FatalErrorInFunction
<< "Unable to find a valid thermo model to evaluate q"
<< "Unable to find a valid thermo model to evaluate q" << nl
<< exit(FatalError);
}
@ -158,11 +135,7 @@ Foam::heatTransferCoeffModel::heatTransferCoeffModel
bool Foam::heatTransferCoeffModel::read(const dictionary& dict)
{
patchSet_ =
mesh_.boundaryMesh().patchSet
(
dict.get<wordRes>("patches")
);
patchSet_ = mesh_.boundaryMesh().patchSet(dict.get<wordRes>("patches"));
dict.readIfPresent("qr", qrName_);
@ -170,9 +143,13 @@ bool Foam::heatTransferCoeffModel::read(const dictionary& dict)
}
bool Foam::heatTransferCoeffModel::calc(volScalarField& result)
bool Foam::heatTransferCoeffModel::calc
(
volScalarField& result,
const FieldField<Field, scalar>& q
)
{
htc(result);
htc(result, q);
return true;
}

View File

@ -47,7 +47,6 @@ SourceFiles
#include "dictionary.H"
#include "HashSet.H"
#include "volFields.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,7 +65,7 @@ class heatTransferCoeffModel
{
protected:
// Protected Data
// Public Data
//- Mesh reference
const fvMesh& mesh_;
@ -77,16 +76,20 @@ protected:
//- Temperature name
const word TName_;
//- Name of radiative heat flux name, default = qr
//- Name of radiative heat flux (default = qr)
word qrName_;
protected:
// Protected Member Functions
tmp<FieldField<Field, scalar>> q() const;
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc) = 0;
virtual void htc
(
volScalarField& htc,
const FieldField<Field, scalar>& q
) = 0;
//- No copy construct
heatTransferCoeffModel(const heatTransferCoeffModel&) = delete;
@ -145,10 +148,42 @@ public:
// Member Functions
//- The mesh reference
const fvMesh& mesh() const
{
return mesh_;
}
//- Wall patches to process
const labelHashSet& patchSet() const
{
return patchSet_;
}
//- Temperature name
const word& TName() const
{
return TName_;
}
//- Name of radiative heat flux
const word& qrName() const
{
return qrName_;
}
//- Read from dictionary
virtual bool read(const dictionary& dict);
virtual bool calc(volScalarField& result);
virtual bool calc
(
volScalarField& result,
const FieldField<Field, scalar>& q
);
//- Return q boundary fields
tmp<FieldField<Field, scalar>> q() const;
};

View File

@ -74,10 +74,11 @@ bool Foam::heatTransferCoeffModels::localReferenceTemperature::read
void Foam::heatTransferCoeffModels::localReferenceTemperature::htc
(
volScalarField& htc
volScalarField& htc,
const FieldField<Field, scalar>& q
)
{
const FieldField<Field, scalar> qBf(q());
///const FieldField<Field, scalar> qBf(q());
const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_);
const volScalarField::Boundary& Tbf = T.boundaryField();
const scalar eps = ROOTVSMALL;
@ -87,7 +88,7 @@ void Foam::heatTransferCoeffModels::localReferenceTemperature::htc
for (const label patchi : patchSet_)
{
const scalarField Tc(Tbf[patchi].patchInternalField());
htcBf[patchi] = qBf[patchi]/(Tc - Tbf[patchi] + eps);
htcBf[patchi] = q[patchi]/(Tc - Tbf[patchi] + eps);
}
}

View File

@ -81,7 +81,16 @@ class localReferenceTemperature
:
public heatTransferCoeffModel
{
// Private Member Functions
protected:
// Protected Member Functions
//- Set the heat transfer coefficient
virtual void htc
(
volScalarField& htc,
const FieldField<Field, scalar>& q
);
//- No copy construct
localReferenceTemperature(const localReferenceTemperature&) = delete;
@ -90,14 +99,6 @@ class localReferenceTemperature
void operator=(const localReferenceTemperature&) = delete;
protected:
// Protected Member Functions
//- Set the heat transfer coefficient
virtual void htc(volScalarField& htc);
public:
//- Runtime type information

View File

@ -11,5 +11,6 @@ wclean libso reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseCompressibl
wclean libso reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem
wclean libso reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels
wclean libso reactingEulerFoam/functionObjects
#------------------------------------------------------------------------------

View File

@ -27,5 +27,6 @@ wmake $targetType reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem
wmake $targetType reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels
wmake $targetType reactingEulerFoam/phaseSystems
wmake $targetType reactingEulerFoam/functionObjects
#------------------------------------------------------------------------------

View File

@ -0,0 +1,5 @@
sizeDistribution/sizeDistribution.C
phaseForces/phaseForces.C
reactingEulerHtcModel/reactingEulerHtcModel.C
LIB = $(FOAM_LIBBIN)/libreactingEulerFoamFunctionObjects

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/functionObjects/field/lnInclude \
-I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/interfacialModels/lnInclude \
-I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/phaseSystems/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lfieldFunctionObjects

View File

@ -0,0 +1,308 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "phaseForces.H"
#include "addToRunTimeSelectionTable.H"
#include "BlendedInterfacialModel.H"
#include "dragModel.H"
#include "virtualMassModel.H"
#include "liftModel.H"
#include "wallLubricationModel.H"
#include "turbulentDispersionModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(phaseForces, 0);
addToRunTimeSelectionTable(functionObject, phaseForces, dictionary);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
template<class modelType>
Foam::tmp<Foam::volVectorField>
Foam::functionObjects::phaseForces::nonDragForce(const phasePair& pair) const
{
const BlendedInterfacialModel<modelType>& model =
fluid_.lookupBlendedSubModel<modelType>(pair);
if (&pair.phase1() == &phase_)
{
return model.template F<vector>();
}
else
{
return -model.template F<vector>();
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::phaseForces::phaseForces
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
phase_
(
mesh_.lookupObject<phaseModel>
(
IOobject::groupName("alpha", dict.get<word>("phase"))
)
),
fluid_(mesh_.lookupObject<phaseSystem>("phaseProperties"))
{
read(dict);
forAllConstIter
(
phaseSystem::phasePairTable,
fluid_.phasePairs(),
iter
)
{
const phasePair& pair = iter();
if (pair.contains(phase_) && !pair.ordered())
{
if (fluid_.foundBlendedSubModel<dragModel>(pair))
{
forceFields_.set
(
dragModel::typeName,
new volVectorField
(
IOobject
(
IOobject::groupName("dragForce", phase_.name()),
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedVector(dimForce/dimVolume)
)
);
}
if (fluid_.foundBlendedSubModel<virtualMassModel>(pair))
{
forceFields_.set
(
virtualMassModel::typeName,
new volVectorField
(
IOobject
(
IOobject::groupName
(
"virtualMassForce",
phase_.name()
),
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedVector(dimForce/dimVolume)
)
);
}
if (fluid_.foundBlendedSubModel<liftModel>(pair))
{
forceFields_.set
(
liftModel::typeName,
new volVectorField
(
IOobject
(
IOobject::groupName("liftForce", phase_.name()),
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedVector(dimForce/dimVolume)
)
);
}
if (fluid_.foundBlendedSubModel<wallLubricationModel>(pair))
{
forceFields_.set
(
wallLubricationModel::typeName,
new volVectorField
(
IOobject
(
IOobject::groupName
(
"wallLubricationForce",
phase_.name()
),
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedVector(dimForce/dimVolume)
)
);
}
if (fluid_.foundBlendedSubModel<turbulentDispersionModel>(pair))
{
forceFields_.set
(
turbulentDispersionModel::typeName,
new volVectorField
(
IOobject
(
IOobject::groupName
(
"turbulentDispersionForce",
phase_.name()
),
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedVector(dimForce/dimVolume)
)
);
}
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::phaseForces::~phaseForces()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::phaseForces::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
return true;
}
bool Foam::functionObjects::phaseForces::execute()
{
forAllIter
(
HashPtrTable<volVectorField>,
forceFields_,
iter
)
{
const word& type = iter.key();
volVectorField& force = *iter();
force *= 0.0;
forAllConstIter
(
phaseSystem::phasePairTable,
fluid_.phasePairs(),
iter2
)
{
const phasePair& pair = iter2();
if (pair.contains(phase_) && !pair.ordered())
{
if (type == "dragModel")
{
force +=
fluid_.lookupBlendedSubModel<dragModel>(pair).K()
*(pair.otherPhase(phase_).U() - phase_.U());
}
if (type == "virtualMassModel")
{
force +=
fluid_.lookupBlendedSubModel<virtualMassModel>(pair).K()
*(
pair.otherPhase(phase_).DUDt()
- phase_.DUDt()
);
}
if (type == "liftModel")
{
force = nonDragForce<liftModel>(pair);
}
if (type == "wallLubricationModel")
{
force = nonDragForce<wallLubricationModel>(pair);
}
if (type == "turbulentDispersionModel")
{
force = nonDragForce<turbulentDispersionModel>(pair);
}
}
}
}
return true;
}
bool Foam::functionObjects::phaseForces::write()
{
forAllIter
(
HashPtrTable<volVectorField>,
forceFields_,
iter
)
{
writeObject(iter()->name());
}
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
-------------------------------------------------------------------------------
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/>.
Class
Foam::functionObjects::phaseForces
Description
This function object calculates and outputs the blended interfacial forces
acting on a given phase, i.e. drag, virtual mass, lift, wall-lubrication and
turbulent dispersion. Note that it works only in run-time processing mode
and in combination with the reactingEulerFoam solvers.
For a simulation involving more than two phases, the accumulated force is
calculated by looping over all phasePairs involving that phase. The fields
are stored in the database so that they can be processed further, e.g. with
the fieldAveraging functionObject.
Example of function object specification:
\verbatim
phaseForces.water
{
type phaseForces;
libs (reactingEulerFoamFunctionObjects);
writeControl writeTime;
writeInterval 1;
...
phaseName water;
}
\endverbatim
Usage
\table
Property | Description | Required | Default value
type | type name: phaseForces | yes |
phaseName | Name of evaluated phase | yes |
\endtable
See also
Foam::BlendedInterfacialModel
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObject
SourceFiles
phaseForces.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_phaseForces_H
#define functionObjects_phaseForces_H
#include "fvMeshFunctionObject.H"
#include "phaseSystem.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class phaseForces Declaration
\*---------------------------------------------------------------------------*/
class phaseForces
:
public fvMeshFunctionObject
{
// Private Member Functions
//- Disallow default bitwise copy construct
phaseForces(const phaseForces&);
//- Disallow default bitwise assignment
void operator=(const phaseForces&);
protected:
// Protected data
HashPtrTable<volVectorField> forceFields_;
//- Phase for which forces are evaluated
const phaseModel& phase_;
//- Constant access to phaseSystem
const phaseSystem& fluid_;
// Protected Member Functions
//- Evaluate and return non-drag force
template<class modelType>
tmp<volVectorField> nonDragForce(const phasePair& key) const;
public:
//- Runtime type information
TypeName("phaseForces");
// Constructors
//- Construct from Time and dictionary
phaseForces
(
const word& name,
const Time& runTime,
const dictionary&
);
//- Destructor
virtual ~phaseForces();
// Member Functions
//- Read the input data
virtual bool read(const dictionary& dict);
//- Calculate the force fields
virtual bool execute();
//- Write the force fields
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "reactingEulerHtcModel.H"
#include "phaseSystem.H"
#include "addToRunTimeSelectionTable.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(reactingEulerHtcModel, 0);
addToRunTimeSelectionTable
(
functionObject,
reactingEulerHtcModel,
dictionary
);
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::FieldField<Foam::Field, Foam::scalar>>
Foam::functionObjects::reactingEulerHtcModel::q() const
{
const fvMesh& mesh = htcModelPtr_->mesh();
const volScalarField& T =
mesh.lookupObject<volScalarField>(htcModelPtr_->TName());
const volScalarField::Boundary& Tbf = T.boundaryField();
auto tq = tmp<FieldField<Field, scalar>>::New(Tbf.size());
auto& q = tq.ref();
forAll(q, patchi)
{
q.set(patchi, new Field<scalar>(Tbf[patchi].size(), Zero));
}
const auto* fluidPtr =
mesh.cfindObject<phaseSystem>("phaseProperties");
if (!fluidPtr)
{
FatalErrorInFunction
<< "Unable to find a valid phaseSystem to evaluate q" << nl
<< exit(FatalError);
}
const phaseSystem& fluid = *fluidPtr;
for (const label patchi : htcModelPtr_->patchSet())
{
for (const phaseModel& phase : fluid.phases())
{
const fvPatchScalarField& alpha = phase.boundaryField()[patchi];
const volScalarField& he = phase.thermo().he();
const volScalarField::Boundary& hebf = he.boundaryField();
q[patchi] +=
alpha*phase.alphaEff(patchi)()*hebf[patchi].snGrad();
}
}
// Add radiative heat flux contribution if present
const volScalarField* qrPtr =
mesh.cfindObject<volScalarField>(htcModelPtr_->qrName());
if (qrPtr)
{
const volScalarField::Boundary& qrbf = qrPtr->boundaryField();
for (const label patchi : htcModelPtr_->patchSet())
{
q[patchi] += qrbf[patchi];
}
}
return tq;
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::reactingEulerHtcModel::calc()
{
auto& htc =
htcModelPtr_->mesh().lookupObjectRef<volScalarField>(resultName_);
htcModelPtr_->calc(htc, q());
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::reactingEulerHtcModel::reactingEulerHtcModel
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fieldExpression(name, runTime, dict),
htcModelPtr_(nullptr)
{
read(dict);
setResultName(typeName, name + ":htc:" + htcModelPtr_->type());
volScalarField* htcPtr =
new volScalarField
(
IOobject
(
resultName_,
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar(dimPower/dimArea/dimTemperature, Zero)
);
mesh_.objectRegistry::store(htcPtr);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::reactingEulerHtcModel::read(const dictionary& dict)
{
if (fieldExpression::read(dict))
{
htcModelPtr_ = heatTransferCoeffModel::New(dict, mesh_, fieldName_);
htcModelPtr_->read(dict);
return true;
}
return false;
}
// ************************************************************************* //

View File

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Class
Foam::reactingEulerHtcModel
Description
A heat transfer coefficient for reactingEuler solvers
SourceFiles
reactingEulerHtcModel.C
\*---------------------------------------------------------------------------*/
#ifndef reactingEulerHtcModel_H
#define reactingEulerHtcModel_H
#include "HashSet.H"
#include "volFields.H"
#include "fieldExpression.H"
#include "runTimeSelectionTables.H"
#include "heatTransferCoeffModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class reactingEulerHtcModel Declaration
\*---------------------------------------------------------------------------*/
class reactingEulerHtcModel
:
public fieldExpression
{
// Private Data
//- Heat transfer coefficient model
autoPtr<heatTransferCoeffModel> htcModelPtr_;
protected:
// Protected Member Functions
//- Calculate the heat transfer coefficient field
// \return true on success
virtual bool calc();
//- Calculate heat flux
tmp<FieldField<Field, scalar>> q() const;
//- No copy construct
reactingEulerHtcModel(const reactingEulerHtcModel&) = delete;
//- No copy assignment
void operator=(const reactingEulerHtcModel&) = delete;
public:
//- Runtime type information
TypeName("reactingEulerHtcModel");
// Constructors
//- Construct from components
reactingEulerHtcModel
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~reactingEulerHtcModel() = default;
// Member Functions
//- Read the heatTransferCoeff data
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,600 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "sizeDistribution.H"
#include "sizeGroup.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(sizeDistribution, 0);
addToRunTimeSelectionTable(functionObject, sizeDistribution, dictionary);
}
}
const Foam::Enum
<
Foam::functionObjects::sizeDistribution::selectionModeTypes
>
Foam::functionObjects::sizeDistribution::selectionModeTypeNames_
({
{selectionModeTypes::rtCellZone, "cellZone"},
{selectionModeTypes::rtAll, "all"},
});
const Foam::Enum
<
Foam::functionObjects::sizeDistribution::functionTypes
>
Foam::functionObjects::sizeDistribution::functionTypeNames_
({
{functionTypes::ftNdf, "numberDensity"},
{functionTypes::ftVdf, "volumeDensity"},
{functionTypes::ftNc, "numberConcentration"},
{functionTypes::ftMom, "moments"},
});
const Foam::Enum
<
Foam::functionObjects::sizeDistribution::abszissaTypes
>
Foam::functionObjects::sizeDistribution::abszissaTypeNames_
({
{abszissaTypes::atDiameter, "diameter"},
{abszissaTypes::atVolume, "volume"},
});
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::functionObjects::sizeDistribution::initialise
(
const dictionary& dict
)
{
switch (functionType_)
{
case ftNdf:
{
break;
}
case ftVdf:
{
break;
}
case ftNc:
{
break;
}
case ftMom:
{
break;
}
default:
{
FatalIOErrorInLookup
(
dict,
"functionType",
word::null,
functionTypeNames_
) << exit(FatalIOError);
}
}
switch (abszissaType_)
{
case atDiameter:
{
break;
}
case atVolume:
{
break;
}
default:
{
FatalIOErrorInLookup
(
dict,
"abszissaType",
word::null,
abszissaTypeNames_
) << exit(FatalIOError);
}
}
setCellZoneCells();
if (nCells_ == 0)
{
FatalIOErrorInFunction(dict)
<< type() << " " << name() << ": "
<< selectionModeTypeNames_[selectionModeType_]
<< '(' << selectionModeTypeName_ << "):" << nl
<< " Selection has no cells" << exit(FatalIOError);
}
volume_ = volume();
Info<< type() << " " << name() << ":"
<< selectionModeTypeNames_[selectionModeType_]
<< '(' << selectionModeTypeName_ << "):" << nl
<< " total cells = " << nCells_ << nl
<< " total volume = " << volume_
<< nl << endl;
}
void Foam::functionObjects::sizeDistribution::setCellZoneCells()
{
switch (selectionModeType_)
{
case rtCellZone:
{
dict().readEntry("cellZone", selectionModeTypeName_);
label zoneId =
mesh().cellZones().findZoneID(selectionModeTypeName_);
if (zoneId < 0)
{
FatalIOErrorInFunction(dict_)
<< "Unknown cellZone name: " << selectionModeTypeName_
<< ". Valid cellZone names are: "
<< mesh().cellZones().names()
<< nl << exit(FatalIOError);
}
cellId_ = mesh().cellZones()[zoneId];
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
case rtAll:
{
cellId_ = identity(mesh().nCells());
nCells_ = returnReduce(cellId_.size(), sumOp<label>());
break;
}
default:
{
FatalIOErrorInLookup
(
dict_,
"selectionMode",
word::null,
selectionModeTypeNames_
) << exit(FatalIOError);
}
}
}
Foam::scalar Foam::functionObjects::sizeDistribution::volume() const
{
return gSum(filterField(mesh().V()));
}
void Foam::functionObjects::sizeDistribution::combineFields(scalarField& field)
{
List<scalarField> allValues(Pstream::nProcs());
allValues[Pstream::myProcNo()] = field;
Pstream::gatherList(allValues);
if (Pstream::master())
{
field =
ListListOps::combine<scalarField>
(
allValues,
accessOp<scalarField>()
);
}
}
Foam::tmp<Foam::scalarField>
Foam::functionObjects::sizeDistribution::filterField
(
const scalarField& field
) const
{
return tmp<scalarField>(new scalarField(field, cellId_));
}
void Foam::functionObjects::sizeDistribution::writeFileHeader
(
const label i
)
{
OFstream& file = this->file();
switch (functionType_)
{
case ftNdf:
{
writeHeader(file, "Number density function");
break;
}
case ftVdf:
{
writeHeader(file, "Volume density function");
break;
}
case ftNc:
{
writeHeader(file, "Number concentration");
break;
}
case ftMom:
{
writeHeader(file, "Moments");
break;
}
}
switch (abszissaType_)
{
case atVolume:
{
writeCommented(file, "Time/volume");
break;
}
case atDiameter:
{
writeCommented(file, "Time/diameter");
break;
}
}
switch (functionType_)
{
case ftMom:
{
for (label i = 0; i <= momentOrder_; i++)
{
file() << tab << i;
}
break;
}
default:
{
forAll(popBal_.sizeGroups(), sizeGroupi)
{
const diameterModels::sizeGroup& fi =
popBal_.sizeGroups()[sizeGroupi];
switch (abszissaType_)
{
case atDiameter:
{
file() << tab << fi.d().value();
break;
}
case atVolume:
{
file() << tab << fi.x().value();
break;
}
}
}
break;
}
}
file << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::sizeDistribution::sizeDistribution
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
writeFile(obr_, name),
dict_(dict),
selectionModeType_
(
selectionModeTypeNames_.get("selectionMode", dict)
),
selectionModeTypeName_(word::null),
functionType_(functionTypeNames_.get("functionType", dict)),
abszissaType_(abszissaTypeNames_.get("abszissaType", dict)),
nCells_(0),
cellId_(),
volume_(0.0),
writeVolume_(dict.getOrDefault("writeVolume", false)),
popBal_
(
obr_.lookupObject<Foam::diameterModels::populationBalanceModel>
(
dict.get<word>("populationBalance")
)
),
N_(popBal_.sizeGroups().size()),
momentOrder_(dict.getOrDefault<label>("momentOrder", 0)),
normalize_(dict.getOrDefault("normalize", false)),
sumN_(0.0),
sumV_(0.0)
{
read(dict);
resetFile(name);
createFile(name);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::sizeDistribution::~sizeDistribution()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::sizeDistribution::read(const dictionary& dict)
{
if (dict != dict_)
{
dict_ = dict;
}
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
initialise(dict);
return true;
}
bool Foam::functionObjects::sizeDistribution::execute()
{
return true;
}
bool Foam::functionObjects::sizeDistribution::write()
{
writeFileHeader();
writeCurrentTime(file());
Log << type() << " " << name() << " write" << nl;
scalarField V(filterField(mesh().V()));
combineFields(V);
sumN_ = 0;
sumV_ = 0;
forAll(N_, i)
{
const Foam::diameterModels::sizeGroup& fi = popBal_.sizeGroups()[i];
const volScalarField& alpha = fi.VelocityGroup().phase();
scalarField Ni(fi*alpha/fi.x());
scalarField values(filterField(Ni));
scalarField V(filterField(mesh().V()));
// Combine onto master
combineFields(values);
combineFields(V);
if (Pstream::master())
{
// Calculate volume-averaged number concentration
N_[i] = sum(V*values)/sum(V);
}
sumN_ += N_[i];
sumV_ += N_[i]*fi.x().value();
}
if (Pstream::master())
{
switch (functionType_)
{
case ftMom:
{
for (label m = 0; m <= momentOrder_; m++)
{
scalar result(0.0);
forAll(N_, i)
{
const Foam::diameterModels::sizeGroup& fi =
popBal_.sizeGroups()[i];
switch (abszissaType_)
{
case atVolume:
{
result += pow(fi.x().value(), m)*N_[i];
break;
}
case atDiameter:
{
result += pow(fi.d().value(), m)*N_[i];
break;
}
}
}
file() << tab << result;
}
break;
}
default:
{
forAll(popBal_.sizeGroups(), i)
{
const Foam::diameterModels::sizeGroup& fi =
popBal_.sizeGroups()[i];
scalar result(0.0);
scalar delta(0.0);
switch (abszissaType_)
{
case atVolume:
{
delta = popBal_.v()[i+1].value()
- popBal_.v()[i].value();
break;
}
case atDiameter:
{
const scalar& formFactor =
fi.VelocityGroup().formFactor().value();
delta =
pow
(
popBal_.v()[i+1].value()
/formFactor,
1.0/3.0
)
- pow
(
popBal_.v()[i].value()
/formFactor,
1.0/3.0
);
break;
}
}
switch (functionType_)
{
case ftNdf:
{
if (normalize_ == true)
{
result = N_[i]/delta/sumN_;
}
else
{
result = N_[i]/delta;
}
break;
}
case ftVdf:
{
if (normalize_ == true)
{
result = N_[i]*fi.x().value()/delta/sumV_;
}
else
{
result = N_[i]*fi.x().value()/delta;
}
break;
}
case ftNc:
{
if (normalize_ == true)
{
result = N_[i]/sumN_;
}
else
{
result = N_[i];
}
break;
}
default:
{
break;
}
}
file()<< tab << result;
}
}
}
}
{
file()<< endl;
}
Log << endl;
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,279 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenFOAM Foundation
-------------------------------------------------------------------------------
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/>.
Class
Foam::functionObjects::sizeDistribution
Description
This function object calculates and outputs information about the size
distribution of the dispersed phase, such as the number density function or
its moments. It is designed to be used exclusively with the population
balance modeling functionality of the reactingEulerFoam solvers. It can be
applied to a specific cellZone or the entire domain.
Example of function object specification:
\verbatim
box.all.numberDensity.volume.bubbles
{
type sizeDistribution;
libs (reactingEulerFoamFunctionObjects);
writeControl outputTime;
writeInterval 1;
log true;
...
functionType numberDensity;
abszissaType volume;
selectionMode all;
populationBalanceModel bubbles;
normalize true;
}
\endverbatim
Usage
\table
Property | Description | Required | Default value
type | type name: sizeDistribution | yes |
functionType | numberDensity, volumeDensity, numberConcentration,
moments | yes |
abszissaType | volume, diameter | yes |
momentOrder | Write moment up to given order | no | 0
selectionMode | Evaluate for cellZone or entire mesh | yes |
cellZone | Required if selectionMode is cellZone | |
populationBalanceModel | Respective populationBalanceModel | yes |
normalize | Normalization | no |
\endtable
See also
Foam::diameterModels::populationBalanceModel
Foam::functionObject
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::writeFile
SourceFiles
sizeDistribution.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_sizeDistribution_H
#define functionObjects_sizeDistribution_H
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "populationBalanceModel.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class sizeDistribution Declaration
\*---------------------------------------------------------------------------*/
class sizeDistribution
:
public fvMeshFunctionObject,
public writeFile
{
public:
// Public data types
//- Selection mode type enumeration
enum selectionModeTypes
{
rtCellZone,
rtAll
};
//- Selection mode type names
static const Enum<selectionModeTypes> selectionModeTypeNames_;
//- Function type enumeration
enum functionTypes
{
ftNdf,
ftVdf,
ftNc,
ftMom
};
//- Function type names
static const Enum<functionTypes> functionTypeNames_;
//- abszissa type enumeration
enum abszissaTypes
{
atDiameter,
atVolume,
};
//- Abszissa type names
static const Enum<abszissaTypes> abszissaTypeNames_;
protected:
// Protected data
//- Construction dictionary
dictionary dict_;
//- Selection mode type
selectionModeTypes selectionModeType_;
//- Name of selection
word selectionModeTypeName_;
//- Function type
functionTypes functionType_;
//- Abszissa type
abszissaTypes abszissaType_;
//- Global number of cells
label nCells_;
//- Local list of cell IDs
labelList cellId_;
//- Total volume of the evaluated selection
scalar volume_;
//- Optionally write the volume of the sizeDistribution
bool writeVolume_;
//- PopulationBalance
const Foam::diameterModels::populationBalanceModel& popBal_;
//- Number concentrations
List<scalar> N_;
//- Write moments up to specified order with respect to abszissaType
label momentOrder_;
//- Normalization switch
const Switch normalize_;
//- Sum of number concentrations
scalar sumN_;
//- Volumertic sum
scalar sumV_;
// Protected Member Functions
//- Initialise, e.g. cell addressing
void initialise(const dictionary& dict);
//- Set cells to evaluate based on a cell zone
void setCellZoneCells();
//- Calculate and return volume of the evaluated cell zone
scalar volume() const;
//- Combine fields from all processor domains into single field
void combineFields(scalarField& field);
//- Filter field according to cellIds
tmp<scalarField> filterField(const scalarField& field) const;
//- Output file header information
void writeFileHeader(const label i = 0);
public:
//- Runtime type information
TypeName("sizeDistribution");
// Constructors
//- Construct from Time and dictionary
sizeDistribution
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~sizeDistribution();
// Member Functions
//- Return the reference to the construction dictionary
const dictionary& dict() const
{
return dict_;
}
//- Return the local list of cell IDs
const labelList& cellId() const
{
return cellId_;
}
//- Helper function to return the reference to the mesh
const fvMesh& mesh() const
{
return refCast<const fvMesh>(obr_);
}
//- Read from dictionary
virtual bool read(const dictionary& dict);
//- Execute
virtual bool execute();
//- Write
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //