ENH: Correcting righ lib for option file for fvOption source coded in CodedSource.C

Adding contact resistance to turbulentTemperatureCoupledBaffleMixed and turbulentTemperatureRadCoupledMixed
This commit is contained in:
Sergio Ferraris
2013-12-20 17:57:11 +00:00
parent 2d529e0240
commit 944ada0414
5 changed files with 207 additions and 52 deletions

View File

@ -65,14 +65,14 @@ void Foam::fv::CodedSource<Type>::prepare
dynCode.setMakeOptions dynCode.setMakeOptions
( (
"EXE_INC = -g \\\n" "EXE_INC = -g \\\n"
"-I$(LIB_SRC)/fieldSources/lnInclude \\\n" "-I$(LIB_SRC)/fvOptions/lnInclude \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
"-I$(LIB_SRC)/meshTools/lnInclude \\\n" "-I$(LIB_SRC)/meshTools/lnInclude \\\n"
"-I$(LIB_SRC)/sampling/lnInclude \\\n" "-I$(LIB_SRC)/sampling/lnInclude \\\n"
+ context.options() + context.options()
+ "\n\nLIB_LIBS = \\\n" + "\n\nLIB_LIBS = \\\n"
+ " -lmeshTools \\\n" + " -lmeshTools \\\n"
+ " -lfieldSources \\\n" + " -lfvOptions \\\n"
+ " -lsampling \\\n" + " -lsampling \\\n"
+ " -lfiniteVolume \\\n" + " -lfiniteVolume \\\n"
+ context.libs() + context.libs()

View File

@ -101,6 +101,24 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
<< exit(FatalError); << exit(FatalError);
} }
if (dict.found("thicknessLayers"))
{
dict.lookup("thicknessLayers") >> thicknessLayers_;
dict.lookup("kappaLayers") >> kappaLayers_;
if (thicknessLayers_.size() > 0)
{
forAll (thicknessLayers_, iLayer)
{
const scalar l = thicknessLayers_[iLayer];
if (l > 0.0)
{
contactRes_ += kappaLayers_[iLayer]/l;
}
}
}
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue")) if (dict.found("refValue"))
@ -129,7 +147,10 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
: :
mixedFvPatchScalarField(wtcsf, iF), mixedFvPatchScalarField(wtcsf, iF),
temperatureCoupledBase(patch(), wtcsf.KMethod(), wtcsf.kappaName()), temperatureCoupledBase(patch(), wtcsf.KMethod(), wtcsf.kappaName()),
TnbrName_(wtcsf.TnbrName_) TnbrName_(wtcsf.TnbrName_),
thicknessLayers_(wtcsf.thicknessLayers_),
kappaLayers_(wtcsf.kappaLayers_),
contactRes_(wtcsf.contactRes_)
{} {}
@ -155,7 +176,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
const fvPatch& nbrPatch = const fvPatch& nbrPatch =
refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI]; refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI];
tmp<scalarField> intFld = patchInternalField(); //tmp<scalarField> intFld = patchInternalField();
// Calculate the temperature by harmonic averaging // Calculate the temperature by harmonic averaging
@ -174,12 +195,22 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
); );
// Swap to obtain full local values of neighbour internal field // Swap to obtain full local values of neighbour internal field
scalarField nbrIntFld(nbrField.patchInternalField()); tmp<scalarField> nbrIntFld(new scalarField(nbrField.size(), 0.0));
mpp.distribute(nbrIntFld); tmp<scalarField> nbrKDelta(new scalarField(nbrField.size(), 0.0));
// Swap to obtain full local values of neighbour kappa*delta if (contactRes_ == 0.0)
scalarField nbrKDelta(nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs()); {
mpp.distribute(nbrKDelta); nbrIntFld() = nbrField.patchInternalField();
nbrKDelta() = nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs();
}
else
{
nbrIntFld() = nbrField;
nbrKDelta() = contactRes_;
}
mpp.distribute(nbrIntFld());
mpp.distribute(nbrKDelta());
tmp<scalarField> myKDelta = kappa(*this)*patch().deltaCoeffs(); tmp<scalarField> myKDelta = kappa(*this)*patch().deltaCoeffs();
@ -200,11 +231,11 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
// - mixFraction = nbrKDelta / (nbrKDelta + myKDelta()) // - mixFraction = nbrKDelta / (nbrKDelta + myKDelta())
this->refValue() = nbrIntFld; this->refValue() = nbrIntFld();
this->refGrad() = 0.0; this->refGrad() = 0.0;
this->valueFraction() = nbrKDelta/(nbrKDelta + myKDelta()); this->valueFraction() = nbrKDelta()/(nbrKDelta() + myKDelta());
mixedFvPatchScalarField::updateCoeffs(); mixedFvPatchScalarField::updateCoeffs();
@ -239,6 +270,11 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write
mixedFvPatchScalarField::write(os); mixedFvPatchScalarField::write(os);
os.writeKeyword("Tnbr")<< TnbrName_ os.writeKeyword("Tnbr")<< TnbrName_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("thicknessLayers")<< thicknessLayers_
<< token::END_STATEMENT << nl;
os.writeKeyword("kappaLayers")<< kappaLayers_
<< token::END_STATEMENT << nl;
temperatureCoupledBase::write(os); temperatureCoupledBase::write(os);
} }

View File

@ -22,11 +22,20 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::compressible::turbulentTemperatureCoupledBaffleMixedFvPatchScalarField Foam::
compressible::
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
Description Description
Mixed boundary condition for temperature, to be used for heat-transfer Mixed boundary condition for temperature, to be used for heat-transfer
on back-to-back baffles. on back-to-back baffles.Optional thin thermal layer
resistances can be specified through thicknessLayers and kappaLayers
entries.
The thermal conductivity, \c kappa, can either be retrieved from the
mesh database using the \c lookup option, or from a \c solidThermo
or \c fluidThermo thermophysical package.
Specifies gradient and temperature such that the equations are the same Specifies gradient and temperature such that the equations are the same
on both sides: on both sides:
@ -36,29 +45,41 @@ Description
where KDelta is heat-transfer coefficient K * deltaCoeffs where KDelta is heat-transfer coefficient K * deltaCoeffs
Example usage: \heading Patch usage
myInterfacePatchName
{ \table
type compressible::turbulentTemperatureCoupledBaffleMixed; Property | Description | Required | Default value
Tnbr T; kappa | thermal conductivity option | yes |
kappa lookup; kappaName | name of thermal conductivity field | no |
kappaName kappa; Tnbr | name of the field | no | T
value uniform 300; thicknessLayers | list of thicknesses per layer [m] | no |
} kappaLayers | list of thermal conductivites per layer [W/m/K] | no |
\endtable
Example of the boundary condition specification:
\verbatim
myPatch
{
type compressible::turbulentTemperatureCoupledBaffleMixed;
Tnbr T;
kappa lookup;
KappaName kappa;
thicknessLayers (0.1 0.2 0.3 0.4);
kappaLayers (1 2 3 4)
value uniform 300;
}
Needs to be on underlying mapped(Wall)FvPatch. Needs to be on underlying mapped(Wall)FvPatch.
Note: kappa : heat conduction at patch. Gets supplied how to lookup Note: kappa : heat conduction at patch. Gets supplied how to lookup
calculate kappa: calculate kappa:
- 'lookup' : lookup volScalarField (or volSymmTensorField) with name - 'lookup' : lookup volScalarField (or volSymmTensorField) with name
- 'fluidThermo' : use fluidThermo and compressible::RASmodel to calculate - 'fluidThermo' : use fluidThermo and compressible::RASmodel to calculate
kappa kappa
- 'solidThermo' : use solidThermo kappa() - 'solidThermo' : use solidThermo kappa()
- 'directionalSolidThermo' directionalKappa() - 'directionalSolidThermo' directionalKappa()
Note: runs in parallel with arbitrary decomposition. Uses mapped
functionality to calculate exchange.
SourceFiles SourceFiles
turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C
@ -91,6 +112,15 @@ class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
//- Name of field on the neighbour region //- Name of field on the neighbour region
const word TnbrName_; const word TnbrName_;
//- Thickness of layers
scalarField thicknessLayers_;
//- Conductivity of layers
scalarField kappaLayers_;
//- Total contact resistance
scalar contactRes_;
public: public:

View File

@ -49,7 +49,10 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
temperatureCoupledBase(patch(), "undefined", "undefined-K"), temperatureCoupledBase(patch(), "undefined", "undefined-K"),
TnbrName_("undefined-Tnbr"), TnbrName_("undefined-Tnbr"),
QrNbrName_("undefined-QrNbr"), QrNbrName_("undefined-QrNbr"),
QrName_("undefined-Qr") QrName_("undefined-Qr"),
thicknessLayers_(),
kappaLayers_(),
contactRes_(0)
{ {
this->refValue() = 0.0; this->refValue() = 0.0;
this->refGrad() = 0.0; this->refGrad() = 0.0;
@ -70,7 +73,10 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()), temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()),
TnbrName_(psf.TnbrName_), TnbrName_(psf.TnbrName_),
QrNbrName_(psf.QrNbrName_), QrNbrName_(psf.QrNbrName_),
QrName_(psf.QrName_) QrName_(psf.QrName_),
thicknessLayers_(psf.thicknessLayers_),
kappaLayers_(psf.kappaLayers_),
contactRes_(psf.contactRes_)
{} {}
@ -86,7 +92,10 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
temperatureCoupledBase(patch(), dict), temperatureCoupledBase(patch(), dict),
TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")), TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")),
QrNbrName_(dict.lookupOrDefault<word>("QrNbr", "none")), QrNbrName_(dict.lookupOrDefault<word>("QrNbr", "none")),
QrName_(dict.lookupOrDefault<word>("Qr", "none")) QrName_(dict.lookupOrDefault<word>("Qr", "none")),
thicknessLayers_(),
kappaLayers_(),
contactRes_(0.0)
{ {
if (!isA<mappedPatchBase>(this->patch().patch())) if (!isA<mappedPatchBase>(this->patch().patch()))
{ {
@ -107,6 +116,24 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
<< exit(FatalError); << exit(FatalError);
} }
if (dict.found("thicknessLayers"))
{
dict.lookup("thicknessLayers") >> thicknessLayers_;
dict.lookup("kappaLayers") >> kappaLayers_;
if (thicknessLayers_.size() > 0)
{
forAll (thicknessLayers_, iLayer)
{
const scalar l = thicknessLayers_[iLayer];
if (l > 0.0)
{
contactRes_ += kappaLayers_[iLayer]/l;
}
}
}
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue")) if (dict.found("refValue"))
@ -137,7 +164,10 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()), temperatureCoupledBase(patch(), psf.KMethod(), psf.kappaName()),
TnbrName_(psf.TnbrName_), TnbrName_(psf.TnbrName_),
QrNbrName_(psf.QrNbrName_), QrNbrName_(psf.QrNbrName_),
QrName_(psf.QrName_) QrName_(psf.QrName_),
thicknessLayers_(psf.thicknessLayers_),
kappaLayers_(psf.kappaLayers_),
contactRes_(psf.contactRes_)
{} {}
@ -180,9 +210,17 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
// Swap to obtain full local values of neighbour K*delta // Swap to obtain full local values of neighbour K*delta
scalarField KDeltaNbr(nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs()); tmp<scalarField> KDeltaNbr(new scalarField(TcNbr.size(), 0.0));
mpp.distribute(KDeltaNbr); if (contactRes_ == 0.0)
{
// Swap to obtain full local values of neighbour K*delta
KDeltaNbr() = nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs();
}
else
{
KDeltaNbr() = contactRes_;
}
mpp.distribute(KDeltaNbr());
scalarField KDelta(kappa(*this)*patch().deltaCoeffs()); scalarField KDelta(kappa(*this)*patch().deltaCoeffs());
@ -199,16 +237,34 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
mpp.distribute(QrNbr); mpp.distribute(QrNbr);
} }
scalarField alpha(KDeltaNbr - (Qr + QrNbr)/Tp); scalarField alpha(KDeltaNbr() - (Qr + QrNbr)/Tp);
valueFraction() = alpha/(alpha + KDelta); valueFraction() = alpha/(alpha + KDelta);
refValue() = (KDeltaNbr*TcNbr)/alpha; refValue() = (KDeltaNbr()*TcNbr)/alpha;
mixedFvPatchScalarField::updateCoeffs();
if (debug)
{
scalar Q = gSum(kappa(*this)*patch().magSf()*snGrad());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
<< this->dimensionedInternalField().name() << " <- "
<< nbrMesh.name() << ':'
<< nbrPatch.name() << ':'
<< this->dimensionedInternalField().name() << " :"
<< " heat transfer rate:" << Q
<< " walltemperature "
<< " min:" << gMin(*this)
<< " max:" << gMax(*this)
<< " avg:" << gAverage(*this)
<< endl;
}
// Restore tag // Restore tag
UPstream::msgType() = oldTag; UPstream::msgType() = oldTag;
mixedFvPatchScalarField::updateCoeffs();
} }
@ -221,6 +277,11 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl; os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl;
os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl; os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl;
os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl; os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
os.writeKeyword("thicknessLayers")<< thicknessLayers_
<< token::END_STATEMENT << nl;
os.writeKeyword("kappaLayers")<< kappaLayers_
<< token::END_STATEMENT << nl;
temperatureCoupledBase::write(os); temperatureCoupledBase::write(os);
} }

View File

@ -28,23 +28,45 @@ Class
Description Description
Mixed boundary condition for temperature and radiation heat transfer Mixed boundary condition for temperature and radiation heat transfer
to be used for in multiregion cases to be used for in multiregion cases. Optional thin thermal layer
resistances can be specified through thicknessLayers and kappaLayers
entries.
Example usage: The thermal conductivity, \c kappa, can either be retrieved from the
myInterfacePatchName mesh database using the \c lookup option, or from a \c solidThermo
{ or \c fluidThermo thermophysical package.
type compressible::turbulentTemperatureRadCoupledMixed;
Tnbr T; // name of T field on neighbour region \heading Patch usage
kappa lookup;
KappaName kappa; \table
QrNbr Qr; // or none. Name of Qr field on neighbour region Property | Description | Required | Default value
Qr Qr; // or none. Name of Qr field on local region kappa | thermal conductivity option | yes |
value uniform 300; kappaName | name of thermal conductivity field | no |
} Tnbr | name of the field | no | T
QrNbr | name of the radiative flux in the nbr region | no | none
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 |
\endtable
Example of the boundary condition specification:
\verbatim
myPatch
{
type compressible::turbulentTemperatureRadCoupledMixed;
Tnbr T;
kappa lookup;
KappaName kappa;
QrNbr Qr; // or none. Name of Qr field on neighbour region
Qr Qr; // or none. Name of Qr field on local region
thicknessLayers (0.1 0.2 0.3 0.4);
kappaLayers (1 2 3 4)
value uniform 300;
}
Needs to be on underlying mapped(Wall)FvPatch. Needs to be on underlying mapped(Wall)FvPatch.
Note: kappa : heat conduction at patch. Gets supplied how to Note: kappa : heat conduction at patch. Gets supplied how to
lookup/calculate lookup/calculate
kappa: kappa:
- 'lookup' : lookup volScalarField (or volSymmTensorField) with name - 'lookup' : lookup volScalarField (or volSymmTensorField) with name
@ -52,9 +74,6 @@ Description
- 'solidThermo' : use solidThermo kappa() - 'solidThermo' : use solidThermo kappa()
- 'directionalSolidThermo' directionalKappa() - 'directionalSolidThermo' directionalKappa()
Note: runs in parallel with arbitrary decomposition. Uses mapped
functionality to calculate exchange.
SourceFiles SourceFiles
turbulentTemperatureRadCoupledMixedFvPatchScalarField.C turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
@ -93,6 +112,15 @@ class turbulentTemperatureRadCoupledMixedFvPatchScalarField
//- Name of the radiative heat flux in local region //- Name of the radiative heat flux in local region
const word QrName_; const word QrName_;
//- Thickness of layers
scalarField thicknessLayers_;
//- Conductivity of layers
scalarField kappaLayers_;
//- Total contact resistance
scalar contactRes_;
public: public: