ENH: add support for alpha field in temperatureCoupledBase

This commit is contained in:
sergio
2019-10-01 19:16:43 +02:00
committed by Andrew Heather
parent 9b1b024f02
commit 6532f27547
9 changed files with 281 additions and 70 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -57,7 +57,14 @@ externalWallHeatFluxTemperatureFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
mode_(fixedHeatFlux), mode_(fixedHeatFlux),
Q_(0), Q_(0),
q_(), q_(),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,14 @@ fixedIncidentRadiationFvPatchScalarField
) )
: :
fixedGradientFvPatchScalarField(p, iF), fixedGradientFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
qrIncident_(p.size(), Zero) qrIncident_(p.size(), Zero)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,14 @@ lumpedMassWallTemperatureFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
Cp_(0.0), Cp_(0.0),
mass_(0.0), mass_(0.0),
curTimeIndex_(-1) curTimeIndex_(-1)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -53,13 +53,15 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
const fvPatch& patch, const fvPatch& patch,
const word& calculationType, const word& calculationType,
const word& kappaName, const word& kappaName,
const word& alphaAniName const word& alphaAniName,
const word& alphaName
) )
: :
patch_(patch), patch_(patch),
method_(KMethodTypeNames_[calculationType]), method_(KMethodTypeNames_[calculationType]),
kappaName_(kappaName), kappaName_(kappaName),
alphaAniName_(alphaAniName) alphaAniName_(alphaAniName),
alphaName_(alphaName)
{} {}
@ -72,7 +74,8 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
patch_(patch), patch_(patch),
method_(KMethodTypeNames_.get("kappaMethod", dict)), method_(KMethodTypeNames_.get("kappaMethod", dict)),
kappaName_(dict.lookupOrDefault<word>("kappa", "none")), kappaName_(dict.lookupOrDefault<word>("kappa", "none")),
alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none")) alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none")),
alphaName_(dict.lookupOrDefault<word>("alpha","none"))
{ {
switch (method_) switch (method_)
{ {
@ -123,15 +126,11 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
patch_(patch), patch_(patch),
method_(base.method_), method_(base.method_),
kappaName_(base.kappaName_), kappaName_(base.kappaName_),
alphaAniName_(base.alphaAniName_) alphaAniName_(base.alphaAniName_),
alphaName_(base.alphaName_)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::temperatureCoupledBase::~temperatureCoupledBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
@ -148,48 +147,54 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
{ {
typedef compressible::turbulenceModel turbulenceModel; typedef compressible::turbulenceModel turbulenceModel;
const word turbName(turbulenceModel::propertiesName);
if
(
mesh.foundObject<turbulenceModel>(turbName)
)
{ {
const turbulenceModel& turbModel = const auto* ptr =
mesh.lookupObject<turbulenceModel>(turbName); mesh.cfindObject<turbulenceModel>
(
turbulenceModel::propertiesName
);
return turbModel.kappaEff(patchi); if (ptr)
{
return ptr->kappaEff(patchi);
}
} }
else if (mesh.foundObject<fluidThermo>(basicThermo::dictName))
{
const fluidThermo& thermo =
mesh.lookupObject<fluidThermo>(basicThermo::dictName);
return thermo.kappa(patchi);
}
else if (mesh.foundObject<basicThermo>(basicThermo::dictName))
{ {
const basicThermo& thermo = const auto* ptr =
mesh.lookupObject<basicThermo>(basicThermo::dictName); mesh.cfindObject<fluidThermo>(basicThermo::dictName);
return thermo.kappa(patchi); if (ptr)
{
return ptr->kappa(patchi);
}
} }
else if (mesh.foundObject<basicThermo>("phaseProperties"))
{
const basicThermo& thermo =
mesh.lookupObject<basicThermo>("phaseProperties");
return thermo.kappa(patchi);
}
else
{ {
FatalErrorInFunction const auto* ptr =
<< "kappaMethod defined to employ " mesh.cfindObject<basicThermo>(basicThermo::dictName);
<< KMethodTypeNames_[method_]
<< " method, but thermo package not available" if (ptr)
<< exit(FatalError); {
return ptr->kappa(patchi);
}
} }
{
const auto* ptr =
mesh.cfindObject<basicThermo>("phaseProperties");
if (ptr)
{
return ptr->kappa(patchi);
}
}
FatalErrorInFunction
<< "Using kappaMethod " << KMethodTypeNames_[method_]
<< ", but thermo package not available\n"
<< exit(FatalError);
break; break;
} }
@ -253,9 +258,6 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
<< " or volSymmTensorField." << " or volSymmTensorField."
<< exit(FatalError); << exit(FatalError);
} }
break; break;
} }
@ -268,10 +270,155 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
<< "and 'kappa' to the name of the volScalar" << "and 'kappa' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)" << " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError); << exit(FatalError);
break;
} }
} }
return scalarField(0); return scalarField();
}
Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha
(
const scalarField& Tp
) const
{
const fvMesh& mesh = patch_.boundaryMesh().mesh();
const label patchi = patch_.index();
switch (method_)
{
case mtFluidThermo:
{
typedef compressible::turbulenceModel turbulenceModel;
{
const auto* ptr =
mesh.cfindObject<turbulenceModel>
(
turbulenceModel::propertiesName
);
if (ptr)
{
return ptr->alphaEff(patchi);
}
}
{
const auto* ptr =
mesh.cfindObject<fluidThermo>(basicThermo::dictName);
if (ptr)
{
return ptr->alpha(patchi);
}
}
{
const auto* ptr =
mesh.cfindObject<basicThermo>(basicThermo::dictName);
if (ptr)
{
return ptr->alpha(patchi);
}
}
{
const auto* ptr =
mesh.cfindObject<basicThermo>("phaseProperties");
if (ptr)
{
return ptr->alpha(patchi);
}
}
FatalErrorInFunction
<< "Using kappaMethod " << KMethodTypeNames_[method_]
<< ", but thermo package not available\n"
<< exit(FatalError);
break;
}
case mtSolidThermo:
{
const solidThermo& thermo =
mesh.lookupObject<solidThermo>(basicThermo::dictName);
return thermo.alpha(patchi);
break;
}
case mtDirectionalSolidThermo:
{
const symmTensorField& alphaAni =
patch_.lookupPatchField<volSymmTensorField, scalar>
(
alphaAniName_
);
const vectorField n(patch_.nf());
return n & alphaAni & n;
}
case mtLookup:
{
if (mesh.foundObject<volScalarField>(alphaName_))
{
return
patch_.lookupPatchField<volScalarField, scalar>
(
alphaName_
);
}
else if (mesh.foundObject<volSymmTensorField>(alphaName_))
{
const symmTensorField& alphaWall =
patch_.lookupPatchField<volSymmTensorField, scalar>
(
alphaName_
);
const vectorField n(patch_.nf());
return n & alphaWall & n;
}
else
{
FatalErrorInFunction
<< "Did not find field " << alphaName_
<< " on mesh " << mesh.name() << " patch " << patch_.name()
<< nl
<< "Please set 'kappaMethod' to one of "
<< flatOutput(KMethodTypeNames_.sortedToc()) << nl
<< "and 'alpha' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError);
}
break;
}
default:
{
FatalErrorInFunction
<< "Unimplemented method " << KMethodTypeNames_[method_] << nl
<< "Please set 'kappaMethod' to one of "
<< flatOutput(KMethodTypeNames_.sortedToc()) << nl
<< "and 'alpha' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError);
break;
}
}
return scalarField();
} }
@ -280,6 +427,7 @@ void Foam::temperatureCoupledBase::write(Ostream& os) const
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]); os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
os.writeEntry("kappa", kappaName_); os.writeEntry("kappa", kappaName_);
os.writeEntry("alphaAni", alphaAniName_); os.writeEntry("alphaAni", alphaAniName_);
os.writeEntry("alpha", alphaName_);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -42,10 +42,11 @@ Description
\par Keywords provided by this class: \par Keywords provided by this class:
\table \table
Property | Description | Required | Default value Property | Description | Required | Default
kappaMethod | Thermal conductivity method | yes | kappaMethod | Thermal conductivity method | yes |
kappa | Name of thermal conductivity field | no | none kappa | Name of thermal conductivity field | no | none
alphaAni | Name of the non-isotropic alpha | no | Anialpha alpha | Name of thermal diffusivity field | no | none
alphaAni | Name of non-isotropic alpha | no | none
\endtable \endtable
Usage Usage
@ -85,7 +86,7 @@ class temperatureCoupledBase
{ {
public: public:
// Public enumerations // Public Enumerations
//- Type of supplied Kappa //- Type of supplied Kappa
enum KMethodType enum KMethodType
@ -99,7 +100,7 @@ public:
protected: protected:
// Protected data // Protected Data
static const Enum<KMethodType> KMethodTypeNames_; static const Enum<KMethodType> KMethodTypeNames_;
@ -115,6 +116,9 @@ protected:
//- Name of the non-Isotropic alpha (default: Anialpha) //- Name of the non-Isotropic alpha (default: Anialpha)
const word alphaAniName_; const word alphaAniName_;
//- Name of thermal diffusivity
const word alphaName_;
public: public:
@ -126,7 +130,8 @@ public:
const fvPatch& patch, const fvPatch& patch,
const word& calculationMethod, const word& calculationMethod,
const word& kappaName, const word& kappaName,
const word& alphaAniName const word& alphaAniName,
const word& alphaName
); );
//- Construct from patch and dictionary //- Construct from patch and dictionary
@ -136,7 +141,7 @@ public:
const dictionary& dict const dictionary& dict
); );
//- Construct from patch and temperatureCoupledBase //- Construct from patch and temperatureCoupledBase
temperatureCoupledBase temperatureCoupledBase
( (
const fvPatch& patch, const fvPatch& patch,
@ -145,7 +150,8 @@ public:
//- Destructor //- Destructor
virtual ~temperatureCoupledBase(); virtual ~temperatureCoupledBase() = default;
// Member functions // Member functions
@ -161,11 +167,20 @@ public:
return kappaName_; return kappaName_;
} }
//- Name of thermal diffusivity field
const word& alphaName() const
{
return alphaName_;
}
//- Given patch temperature calculate corresponding K field //- Given patch temperature calculate corresponding K field
virtual tmp<scalarField> kappa(const scalarField& Tp) const; virtual tmp<scalarField> kappa(const scalarField& Tp) const;
//- Given patch temperature calculate corresponding alphaEff field
virtual tmp<scalarField> alpha(const scalarField& Tp) const;
//- Write //- Write
void write(Ostream&) const; void write(Ostream& os) const;
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -48,7 +48,14 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
TnbrName_("undefined-Tnbr"), TnbrName_("undefined-Tnbr"),
thicknessLayers_(0), thicknessLayers_(0),
kappaLayers_(0), kappaLayers_(0),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -49,7 +49,14 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
TnbrName_("undefined-Tnbr"), TnbrName_("undefined-Tnbr"),
qrNbrName_("undefined-qrNbr"), qrNbrName_("undefined-qrNbr"),
qrName_("undefined-qr"), qrName_("undefined-qr"),

View File

@ -88,7 +88,6 @@ pyrModel() const
modelNames.append(iter()->regionMesh().name()); modelNames.append(iter()->regionMesh().name());
} }
FatalErrorInFunction FatalErrorInFunction
<< "Unable to locate pyrolysis region " << pyrolysisRegionName_ << "Unable to locate pyrolysis region " << pyrolysisRegionName_
<< ". Available regions include: " << modelNames << ". Available regions include: " << modelNames
@ -108,7 +107,14 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"undefined",
"undefined",
"undefined-K",
"undefined-alpha"
),
filmRegionName_("surfaceFilmProperties"), filmRegionName_("surfaceFilmProperties"),
pyrolysisRegionName_("pyrolysisProperties"), pyrolysisRegionName_("pyrolysisProperties"),
TnbrName_("undefined-Tnbr"), TnbrName_("undefined-Tnbr"),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -128,7 +128,14 @@ humidityTemperatureCoupledMixedFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "fluidThermo", "undefined", "undefined-K"), temperatureCoupledBase
(
patch(),
"fluidThermo",
"undefined",
"undefined-K",
"undefined-alpha"
),
mode_(mtConstantMass), mode_(mtConstantMass),
pName_("p"), pName_("p"),
UName_("U"), UName_("U"),