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

@ -3,6 +3,5 @@ cd "${0%/*}" || exit # Run from this directory
wclean reactingTwoPhaseEulerFoam
wclean reactingMultiphaseEulerFoam
wclean libso functionObjects
#------------------------------------------------------------------------------

View File

@ -16,6 +16,5 @@ esac
reactingTwoPhaseEulerFoam/Allwmake $targetType $*
reactingMultiphaseEulerFoam/Allwmake $targetType $*
wmake $targetType functionObjects
#------------------------------------------------------------------------------

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

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

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

@ -49,4 +49,19 @@ adjustTimeStep no;
maxCo 0.5;
functions
{
htc
{
type heatTransferCoeff;
libs (fieldFunctionObjects);
field T;
writeControl outputTime;
writeInterval 1;
htcModel fixedReferenceTemperature;
patches (ceiling);
TRef 373;
}
}
// ************************************************************************* //

View File

@ -63,8 +63,8 @@ functions
{
htc
{
type heatTransferCoeff;
libs (fieldFunctionObjects);
type reactingEulerHtcModel;
libs (reactingEulerFoamFunctionObjects);
region water;
field T.liquid;
writeControl outputTime;
@ -94,7 +94,7 @@ functions
operation areaAverage;
fields ( heatTransferCoeff(T.liquid) );
fields ( reactingEulerHtcModel(T.liquid) );
}
}