ENH: coupling BC: allow Function1. Fixes #2277.

This commit is contained in:
Mattijs Janssens 2021-12-02 18:03:16 +00:00 committed by Sergio Ferraris
parent 6abbcb3eac
commit 29c70e9bbb
15 changed files with 571 additions and 93 deletions

View File

@ -261,6 +261,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap
)
{
mixedFvPatchScalarField::autoMap(mapper);
temperatureCoupledBase::autoMap(mapper);
if (q_)
{
@ -289,6 +290,9 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::rmap
const auto& rhs =
refCast<const externalWallHeatFluxTemperatureFvPatchScalarField>(ptf);
temperatureCoupledBase::rmap(rhs, addr);
if (q_)
{
q_->rmap(rhs.q_(), addr);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2019,2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,6 +131,7 @@ void Foam::radiation::fixedIncidentRadiationFvPatchScalarField::autoMap
)
{
fixedGradientFvPatchScalarField::autoMap(m);
temperatureCoupledBase::autoMap(m);
qrIncident_.autoMap(m);
}
@ -149,6 +150,7 @@ void Foam::radiation::fixedIncidentRadiationFvPatchScalarField::rmap
psf
);
temperatureCoupledBase::rmap(thftpsf, addr);
qrIncident_.rmap(thftpsf.qrIncident_, addr);
}

View File

@ -129,6 +129,34 @@ lumpedMassWallTemperatureFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::lumpedMassWallTemperatureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& mapper
)
{
mixedFvPatchScalarField::autoMap(mapper);
temperatureCoupledBase::autoMap(mapper);
}
void Foam::lumpedMassWallTemperatureFvPatchScalarField::rmap
(
const fvPatchField<scalar>& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
const lumpedMassWallTemperatureFvPatchScalarField& tiptf =
refCast
<
const lumpedMassWallTemperatureFvPatchScalarField
>(ptf);
temperatureCoupledBase::rmap(tiptf, addr);
}
void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated() || (curTimeIndex_ == this->db().time().timeIndex()))

View File

@ -166,6 +166,22 @@ public:
// Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<scalar>&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,7 +43,8 @@ Foam::temperatureCoupledBase::KMethodTypeNames_
{ KMethodType::mtFluidThermo, "fluidThermo" },
{ KMethodType::mtSolidThermo, "solidThermo" },
{ KMethodType::mtDirectionalSolidThermo, "directionalSolidThermo" },
{ KMethodType::mtLookup, "lookup" }
{ KMethodType::mtLookup, "lookup" },
{ KMethodType::mtFunction, "function" }
};
@ -74,9 +75,9 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
:
patch_(patch),
method_(KMethodTypeNames_.get("kappaMethod", dict)),
kappaName_(dict.getOrDefault<word>("kappa", "none")),
alphaAniName_(dict.getOrDefault<word>("alphaAni", "none")),
alphaName_(dict.getOrDefault<word>("alpha", "none"))
kappaName_(dict.getOrDefault<word>("kappa", word::null)),
alphaAniName_(dict.getOrDefault<word>("alphaAni", word::null)),
alphaName_(dict.getOrDefault<word>("alpha", word::null))
{
switch (method_)
{
@ -110,6 +111,22 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
break;
}
case mtFunction:
{
kappaFunction1_ = PatchFunction1<scalar>::New
(
patch.patch(),
"kappaValue",
dict
);
alphaFunction1_ = PatchFunction1<scalar>::New
(
patch.patch(),
"alphaValue",
dict
);
}
default:
{
break;
@ -118,6 +135,21 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
}
Foam::temperatureCoupledBase::temperatureCoupledBase
(
const temperatureCoupledBase& base
)
:
patch_(base.patch_),
method_(base.method_),
kappaName_(base.kappaName_),
alphaAniName_(base.alphaAniName_),
alphaName_(base.alphaName_),
kappaFunction1_(base.kappaFunction1_.clone(patch_.patch())),
alphaFunction1_(base.alphaFunction1_.clone(patch_.patch()))
{}
Foam::temperatureCoupledBase::temperatureCoupledBase
(
const fvPatch& patch,
@ -128,12 +160,47 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
method_(base.method_),
kappaName_(base.kappaName_),
alphaAniName_(base.alphaAniName_),
alphaName_(base.alphaName_)
alphaName_(base.alphaName_),
kappaFunction1_(base.kappaFunction1_.clone(patch_.patch())),
alphaFunction1_(base.alphaFunction1_.clone(patch_.patch()))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::temperatureCoupledBase::autoMap
(
const FieldMapper& mapper
)
{
if (kappaFunction1_)
{
kappaFunction1_().autoMap(mapper);
}
if (alphaFunction1_)
{
alphaFunction1_().autoMap(mapper);
}
}
void Foam::temperatureCoupledBase::rmap
(
const temperatureCoupledBase& ptf,
const labelList& addr
)
{
if (kappaFunction1_)
{
kappaFunction1_().rmap(ptf.kappaFunction1_(), addr);
}
if (alphaFunction1_)
{
alphaFunction1_().rmap(ptf.alphaFunction1_(), addr);
}
}
Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
(
const scalarField& Tp
@ -262,6 +329,13 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
break;
}
case KMethodType::mtFunction:
{
const auto& tm = patch_.patch().boundaryMesh().mesh().time();
return kappaFunction1_->value(tm.timeOutputValue());
break;
}
default:
{
FatalErrorInFunction
@ -405,6 +479,13 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha
break;
}
case KMethodType::mtFunction:
{
const auto& tm = patch_.patch().boundaryMesh().mesh().time();
return alphaFunction1_->value(tm.timeOutputValue());
break;
}
default:
{
FatalErrorInFunction
@ -426,9 +507,26 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha
void Foam::temperatureCoupledBase::write(Ostream& os) const
{
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
os.writeEntry("kappa", kappaName_);
os.writeEntry("alphaAni", alphaAniName_);
os.writeEntry("alpha", alphaName_);
if (!kappaName_.empty())
{
os.writeEntry("kappa", kappaName_);
}
if (!alphaAniName_.empty())
{
os.writeEntry("alphaAni", alphaAniName_);
}
if (!alphaName_.empty())
{
os.writeEntry("alpha", alphaName_);
}
if (kappaFunction1_)
{
kappaFunction1_->writeData(os);
}
if (alphaFunction1_)
{
alphaFunction1_->writeData(os);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019,2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,15 +39,18 @@ Description
- 'directionalSolidThermo': uses look up for volSymmTensorField for
transformed kappa vector. Field name definable in 'alphaAni',
named 'Anialpha' in solid solver by default
- 'function' : kappa, alpha directly specified as Function1
- 'phaseSystem' : used for multiphase thermos
\par Keywords provided by this class:
\table
Property | Description | Required | Default
kappaMethod | Thermal conductivity method | yes |
kappa | Name of thermal conductivity field | no | none
alpha | Name of thermal diffusivity field | no | none
alphaAni | Name of non-isotropic alpha | no | none
kappa | Name of thermal conductivity field | no |
alpha | Name of thermal diffusivity field | no |
alphaAni | Name of non-isotropic alpha | no |
kappaValue | Function1 supplying kappa | no |
alphaValue | Function1 supplying alpha | no |
\endtable
Usage
@ -56,12 +59,22 @@ Usage
{
...
kappaMethod directionalSolidThermo;
kappa none;
alphaAni Anialpha;
...
}
\endverbatim
\verbatim
specifiedWall
{
...
kappaMethod function;
kappaFunction constant 1.0;
alphaFunction constant 100.0;
...
}
\endverbatim
SourceFiles
temperatureCoupledBase.C
@ -73,6 +86,7 @@ SourceFiles
#include "scalarField.H"
#include "Enum.H"
#include "fvPatch.H"
#include "PatchFunction1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,7 +109,8 @@ public:
mtFluidThermo,
mtSolidThermo,
mtDirectionalSolidThermo,
mtLookup
mtLookup,
mtFunction
};
@ -120,6 +135,12 @@ protected:
//- Name of thermal diffusivity
const word alphaName_;
//- Function1 for kappa
autoPtr<PatchFunction1<scalar>> kappaFunction1_;
//- Function1 for alpha
autoPtr<PatchFunction1<scalar>> alphaFunction1_;
public:
@ -149,6 +170,12 @@ public:
const temperatureCoupledBase& base
);
//- Construct as copy
temperatureCoupledBase
(
const temperatureCoupledBase&
);
//- Destructor
virtual ~temperatureCoupledBase() = default;
@ -174,6 +201,19 @@ public:
return alphaName_;
}
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const FieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const temperatureCoupledBase&,
const labelList&
);
//- Given patch temperature calculate corresponding K field
virtual tmp<scalarField> kappa(const scalarField& Tp) const;

View File

@ -62,9 +62,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
mappedPatchFieldBase<scalar>::mapper(p, iF),
*this
),
TnbrName_("undefined-Tnbr"),
thicknessLayers_(0),
kappaLayers_(0)
TnbrName_("undefined-Tnbr")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
@ -91,7 +89,9 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
),
TnbrName_(ptf.TnbrName_),
thicknessLayers_(ptf.thicknessLayers_),
kappaLayers_(ptf.kappaLayers_)
thicknessLayer_(ptf.thicknessLayer_.clone(p.patch())),
kappaLayers_(ptf.kappaLayers_),
kappaLayer_(ptf.kappaLayer_.clone(p.patch()))
{}
@ -111,9 +111,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
*this,
dict
),
TnbrName_(dict.get<word>("Tnbr")),
thicknessLayers_(0),
kappaLayers_(0)
TnbrName_(dict.get<word>("Tnbr"))
{
if (!isA<mappedPatchBase>(this->patch().patch()))
{
@ -132,10 +130,25 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
<< "the assemble coupled option for energy. "
<< endl;
// Read list of layers
if (dict.readIfPresent("thicknessLayers", thicknessLayers_))
{
dict.readEntry("kappaLayers", kappaLayers_);
}
// Read single additional PatchFunction1
thicknessLayer_ = PatchFunction1<scalar>::NewIfPresent
(
p.patch(),
"thicknessLayer",
dict
);
kappaLayer_ = PatchFunction1<scalar>::NewIfPresent
(
p.patch(),
"kappaLayer",
dict
);
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
@ -187,7 +200,9 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
),
TnbrName_(wtcsf.TnbrName_),
thicknessLayers_(wtcsf.thicknessLayers_),
kappaLayers_(wtcsf.kappaLayers_)
thicknessLayer_(wtcsf.thicknessLayer_.clone(patch().patch())),
kappaLayers_(wtcsf.kappaLayers_),
kappaLayer_(wtcsf.kappaLayer_.clone(patch().patch()))
{}
@ -207,12 +222,96 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
),
TnbrName_(wtcsf.TnbrName_),
thicknessLayers_(wtcsf.thicknessLayers_),
kappaLayers_(wtcsf.kappaLayers_)
thicknessLayer_(wtcsf.thicknessLayer_.clone(patch().patch())),
kappaLayers_(wtcsf.kappaLayers_),
kappaLayer_(wtcsf.kappaLayer_.clone(patch().patch()))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& mapper
)
{
mixedFvPatchScalarField::autoMap(mapper);
temperatureCoupledBase::autoMap(mapper);
//mappedPatchFieldBase<scalar>::autoMap(mapper);
if (thicknessLayer_)
{
thicknessLayer_().autoMap(mapper);
kappaLayer_().autoMap(mapper);
}
}
void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::rmap
(
const fvPatchField<scalar>& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& tiptf =
refCast
<
const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
>(ptf);
temperatureCoupledBase::rmap(tiptf, addr);
//mappedPatchFieldBase<scalar>::rmap(ptf, addr);
if (thicknessLayer_)
{
thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr);
kappaLayer_().rmap(tiptf.kappaLayer_(), addr);
}
}
tmp<Foam::scalarField>
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::kappa
(
const scalarField& Tp
) const
{
// Get kappa from relevant thermo
tmp<scalarField> tk(temperatureCoupledBase::kappa(Tp));
// Optionally modify with explicit resistance
if (thicknessLayer_ || thicknessLayers_.size())
{
scalarField KDelta(tk*patch().deltaCoeffs());
// Harmonic averaging of kappa*deltaCoeffs
{
KDelta = 1.0/KDelta;
if (thicknessLayer_)
{
const scalar t = db().time().timeOutputValue();
KDelta +=
thicknessLayer_().value(t)
/kappaLayer_().value(t);
}
if (thicknessLayers_.size())
{
forAll(thicknessLayers_, iLayer)
{
KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
}
}
KDelta = 1.0/KDelta;
}
// Update kappa from KDelta
tk = KDelta/patch().deltaCoeffs();
}
return tk;
}
void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
{
if (updated())
@ -233,17 +332,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
this->internalField()
);
const tmp<scalarField> myKDelta = kappa(*this)*patch().deltaCoeffs();
if (thicknessLayers_.size() > 0)
{
myKDelta.ref() = 1.0/myKDelta.ref();
forAll(thicknessLayers_, iLayer)
{
myKDelta.ref() += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
}
myKDelta.ref() = 1.0/myKDelta.ref();
}
const scalarField& Tp = *this;
const scalarField kappaTp(kappa(Tp));
const tmp<scalarField> myKDelta = kappaTp*patch().deltaCoeffs();
scalarField nbrIntFld;
@ -306,7 +397,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
if (debug)
{
scalar Q = gSum(kappa(*this)*patch().magSf()*snGrad());
scalar Q = gSum(kappaTp*patch().magSf()*snGrad());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
@ -381,6 +472,11 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write
{
mixedFvPatchScalarField::write(os);
os.writeEntry("Tnbr", TnbrName_);
if (thicknessLayer_)
{
thicknessLayer_().writeData(os);
kappaLayer_().writeData(os);
}
if (thicknessLayers_.size())
{
thicknessLayers_.writeEntry("thicknessLayers", os);

View File

@ -50,6 +50,8 @@ Usage
Tnbr | name of the field | no | T
thicknessLayers | list of thicknesses per layer [m] | no |
kappaLayers | list of thermal conductivities per layer [W/m/K] | no |
thicknessLayer | single thickness of layer [m] | no |
kappaLayer | corresponding thermal conductivity [W/m/K] | no |
kappaMethod | inherited from temperatureCoupledBase | inherited |
kappa | inherited from temperatureCoupledBase | inherited |
\endtable
@ -110,9 +112,11 @@ class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
//- Thickness of layers
scalarList thicknessLayers_;
autoPtr<PatchFunction1<scalar>> thicknessLayer_;
//- Conductivity of layers
scalarList kappaLayers_;
autoPtr<PatchFunction1<scalar>> kappaLayer_;
// Private member functions
@ -204,6 +208,27 @@ public:
// Member Functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<scalar>&,
const labelList&
);
//- Given patch temperature calculate corresponding K field. Override
//- temperatureCoupledBase::kappa to includes effect of any
//- explicit kappaThickness
virtual tmp<scalarField> kappa(const scalarField& Tp) const;
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -67,8 +67,6 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
TnbrName_("undefined-Tnbr"),
qrNbrName_("undefined-qrNbr"),
qrName_("undefined-qr"),
thicknessLayers_(0),
kappaLayers_(0),
thermalInertia_(false)
{
this->refValue() = 0.0;
@ -99,7 +97,9 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
qrNbrName_(psf.qrNbrName_),
qrName_(psf.qrName_),
thicknessLayers_(psf.thicknessLayers_),
thicknessLayer_(psf.thicknessLayer_.clone(p.patch())),
kappaLayers_(psf.kappaLayers_),
kappaLayer_(psf.kappaLayer_.clone(p.patch())),
thermalInertia_(psf.thermalInertia_)
{}
@ -123,8 +123,6 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
TnbrName_(dict.getOrDefault<word>("Tnbr", "T")),
qrNbrName_(dict.getOrDefault<word>("qrNbr", "none")),
qrName_(dict.getOrDefault<word>("qr", "none")),
thicknessLayers_(0),
kappaLayers_(0),
thermalInertia_(dict.getOrDefault<Switch>("thermalInertia", false))
{
if (!isA<mappedPatchBase>(this->patch().patch()))
@ -137,10 +135,65 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
<< exit(FatalError);
}
//const auto* eptr = dict.findEntry("thicknessLayers");
//if (eptr)
//{
// // Detect either a list (parsed as a scalarList) or
// // a single entry (parsed as a PatchFunction1) or
//
// if
// (
// eptr->isStream()
// && eptr->stream().peek().isPunctuation(token::BEGIN_LIST)
// )
// {
// // Backwards compatibility
// thicknessLayers_ = dict.get<scalarList>("thicknessLayers");
// kappaLayers_ = dict.get<scalarList>("kappaLayers");
//
// if (thicknessLayers_.size() != kappaLayers_.size())
// {
// FatalIOErrorInFunction(dict) << "Inconstent sizes :"
// << "thicknessLayers:" << thicknessLayers_
// << "kappaLayers:" << kappaLayers_
// << exit(FatalIOError);
// }
// }
// else
// {
// thicknessLayer_ = PatchFunction1<scalar>::New
// (
// p.patch(),
// "thicknessLayers",
// dict
// );
// kappaLayer_ = PatchFunction1<scalar>::New
// (
// p.patch(),
// "kappaLayers",
// dict
// );
// }
//}
// Read list of layers
if (dict.readIfPresent("thicknessLayers", thicknessLayers_))
{
dict.readEntry("kappaLayers", kappaLayers_);
}
// Read single additional PatchFunction1
thicknessLayer_ = PatchFunction1<scalar>::NewIfPresent
(
p.patch(),
"thicknessLayer",
dict
);
kappaLayer_ = PatchFunction1<scalar>::NewIfPresent
(
p.patch(),
"kappaLayer",
dict
);
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
@ -194,7 +247,9 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
qrNbrName_(psf.qrNbrName_),
qrName_(psf.qrName_),
thicknessLayers_(psf.thicknessLayers_),
thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())),
kappaLayers_(psf.kappaLayers_),
kappaLayer_(psf.kappaLayer_.clone(patch().patch())),
thermalInertia_(psf.thermalInertia_)
{}
@ -217,13 +272,97 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
qrNbrName_(psf.qrNbrName_),
qrName_(psf.qrName_),
thicknessLayers_(psf.thicknessLayers_),
thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())),
kappaLayers_(psf.kappaLayers_),
kappaLayer_(psf.kappaLayer_.clone(patch().patch())),
thermalInertia_(psf.thermalInertia_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& mapper
)
{
mixedFvPatchScalarField::autoMap(mapper);
temperatureCoupledBase::autoMap(mapper);
//mappedPatchFieldBase<scalar>::autoMap(mapper);
if (thicknessLayer_)
{
thicknessLayer_().autoMap(mapper);
kappaLayer_().autoMap(mapper);
}
}
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::rmap
(
const fvPatchField<scalar>& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
const turbulentTemperatureRadCoupledMixedFvPatchScalarField& tiptf =
refCast
<
const turbulentTemperatureRadCoupledMixedFvPatchScalarField
>(ptf);
temperatureCoupledBase::rmap(tiptf, addr);
//mappedPatchFieldBase<scalar>::rmap(ptf, addr);
if (thicknessLayer_)
{
thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr);
kappaLayer_().rmap(tiptf.kappaLayer_(), addr);
}
}
tmp<Foam::scalarField>
turbulentTemperatureRadCoupledMixedFvPatchScalarField::kappa
(
const scalarField& Tp
) const
{
// Get kappa from relevant thermo
tmp<scalarField> tk(temperatureCoupledBase::kappa(Tp));
// Optionally modify with explicit resistance
if (thicknessLayer_ || thicknessLayers_.size())
{
scalarField KDelta(tk*patch().deltaCoeffs());
// Harmonic averaging of kappa*deltaCoeffs
{
KDelta = 1.0/KDelta;
if (thicknessLayer_)
{
const scalar t = db().time().timeOutputValue();
KDelta +=
thicknessLayer_().value(t)
/kappaLayer_().value(t);
}
if (thicknessLayers_.size())
{
forAll(thicknessLayers_, iLayer)
{
KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
}
}
KDelta = 1.0/KDelta;
}
// Update kappa from KDelta
tk = KDelta/patch().deltaCoeffs();
}
return tk;
}
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
{
if (updated())
@ -250,17 +389,8 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
const scalarField Tc(patchInternalField());
const scalarField& Tp = *this;
scalarField KDelta(kappa(Tp)*patch().deltaCoeffs());
if (thicknessLayers_.size() > 0)
{
KDelta = 1.0/KDelta;
forAll(thicknessLayers_, iLayer)
{
KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer];
}
KDelta = 1.0/KDelta;
}
const scalarField kappaTp(kappa(Tp));
const scalarField KDelta(kappaTp*patch().deltaCoeffs());
scalarField TcNbr;
@ -400,13 +530,13 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
valueFraction() = alpha/(alpha + KDelta);
scalarField c(KDeltaNbr*TcNbr + (mCpDt + mCpDtNbr)*TpOld);
refValue() = c/alpha;
refGrad() = (qr + qrNbr)/kappa(Tp);
refGrad() = (qr + qrNbr)/kappaTp;
}
else
{
valueFraction() = KDeltaNbr/(KDeltaNbr + KDelta);
refValue() = TcNbr;
refGrad() = (qr + qrNbr)/kappa(Tp);
refGrad() = (qr + qrNbr)/kappaTp;
}
source() = Zero;
@ -426,7 +556,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
if (debug)
{
scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
scalar Q = gSum(kappaTp*patch().magSf()*snGrad());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
@ -604,6 +734,11 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
os.writeEntry("qr", qrName_);
os.writeEntry("thermalInertia", thermalInertia_);
if (thicknessLayer_)
{
thicknessLayer_().writeData(os);
kappaLayer_().writeData(os);
}
if (thicknessLayers_.size())
{
thicknessLayers_.writeEntry("thicknessLayers", os);

View File

@ -45,6 +45,8 @@ Usage
qr | name of the radiative flux in this region | no | none
thicknessLayers | list of thicknesses per layer [m] | no |
kappaLayers | list of thermal conductivites per layer [W/m/K] | no |
thicknessLayer | single thickness of layer [m] | no |
kappaLayer | corresponding thermal conductivity [W/m/K] | no |
kappaMethod | inherited from temperatureCoupledBase | inherited |
kappa | inherited from temperatureCoupledBase | inherited |
thermalInertia | Add thermal inertia to wall node | no | false
@ -114,11 +116,13 @@ class turbulentTemperatureRadCoupledMixedFvPatchScalarField
//- Name of the radiative heat flux in local region
const word qrName_;
//- Thickness of layers
//- Thickness of layers (either scalarList or a single PatchFunction1)
scalarList thicknessLayers_;
autoPtr<PatchFunction1<scalar>> thicknessLayer_;
//- Conductivity of layers
scalarList kappaLayers_;
autoPtr<PatchFunction1<scalar>> kappaLayer_;
//- Thermal inertia term
Switch thermalInertia_;
@ -224,6 +228,27 @@ public:
// Member Functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<scalar>&,
const labelList&
);
//- Given patch temperature calculate corresponding K field. Override
//- temperatureCoupledBase::kappa to includes effect of any
//- explicit kappaThickness
virtual tmp<scalarField> kappa(const scalarField& Tp) const;
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -225,6 +225,34 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& mapper
)
{
mixedFvPatchScalarField::autoMap(mapper);
temperatureCoupledBase::autoMap(mapper);
}
void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::rmap
(
const fvPatchField<scalar>& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField& tiptf =
refCast
<
const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField
>(ptf);
temperatureCoupledBase::rmap(tiptf, addr);
}
void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::updateCoeffs()
{
if (updated())

View File

@ -216,6 +216,22 @@ public:
// Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<scalar>&,
const labelList&
);
//- Get corresponding K field
tmp<scalarField> K() const;

View File

@ -139,26 +139,6 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void thermalBaffleFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
mixedFvPatchScalarField::autoMap(m);
}
void thermalBaffleFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
}
void thermalBaffleFvPatchScalarField::createPatchMesh()
{
const fvMesh& thisMesh = patch().boundaryMesh().mesh();

View File

@ -325,23 +325,6 @@ public:
// Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -383,6 +383,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::autoMap
)
{
mixedFvPatchScalarField::autoMap(m);
temperatureCoupledBase::autoMap(m);
if (fluid_)
{
@ -411,6 +412,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::rmap
ptf
);
temperatureCoupledBase::rmap(tiptf, addr);
if (fluid_)
{
mass_.rmap(tiptf.mass_, addr);