2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
|
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
|
|
\\ / O peration |
|
|
|
|
\\ / A nd | Copyright held by original author
|
|
|
|
\\/ M anipulation |
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
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 2 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, write to the Free Software Foundation,
|
|
|
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "solidWallMixedTemperatureCoupledFvPatchScalarField.H"
|
|
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
#include "fvPatchFieldMapper.H"
|
|
|
|
#include "volFields.H"
|
2010-08-26 14:22:03 +00:00
|
|
|
#include "directMappedPatchBase.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
#include "regionProperties.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
|
|
|
solidWallMixedTemperatureCoupledFvPatchScalarField
|
|
|
|
(
|
|
|
|
const fvPatch& p,
|
|
|
|
const DimensionedField<scalar, volMesh>& iF
|
|
|
|
)
|
|
|
|
:
|
|
|
|
mixedFvPatchScalarField(p, iF),
|
2010-08-26 14:22:03 +00:00
|
|
|
neighbourFieldName_("undefined-neighbourFieldName"),
|
2010-05-12 13:27:55 +00:00
|
|
|
KName_("undefined-K")
|
|
|
|
{
|
|
|
|
this->refValue() = 0.0;
|
|
|
|
this->refGrad() = 0.0;
|
|
|
|
this->valueFraction() = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
|
|
|
solidWallMixedTemperatureCoupledFvPatchScalarField
|
|
|
|
(
|
|
|
|
const solidWallMixedTemperatureCoupledFvPatchScalarField& ptf,
|
|
|
|
const fvPatch& p,
|
|
|
|
const DimensionedField<scalar, volMesh>& iF,
|
|
|
|
const fvPatchFieldMapper& mapper
|
|
|
|
)
|
|
|
|
:
|
|
|
|
mixedFvPatchScalarField(ptf, p, iF, mapper),
|
2010-08-26 14:22:03 +00:00
|
|
|
neighbourFieldName_(ptf.neighbourFieldName_),
|
|
|
|
KName_(ptf.KName_)
|
2010-05-12 13:27:55 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
|
|
|
solidWallMixedTemperatureCoupledFvPatchScalarField
|
|
|
|
(
|
|
|
|
const fvPatch& p,
|
|
|
|
const DimensionedField<scalar, volMesh>& iF,
|
|
|
|
const dictionary& dict
|
|
|
|
)
|
|
|
|
:
|
|
|
|
mixedFvPatchScalarField(p, iF),
|
2010-08-26 14:22:03 +00:00
|
|
|
neighbourFieldName_(dict.lookup("neighbourFieldName")),
|
2010-05-12 13:27:55 +00:00
|
|
|
KName_(dict.lookup("K"))
|
|
|
|
{
|
2010-08-26 14:22:03 +00:00
|
|
|
if (!isA<directMappedPatchBase>(this->patch().patch()))
|
|
|
|
{
|
|
|
|
FatalErrorIn
|
|
|
|
(
|
|
|
|
"solidWallMixedTemperatureCoupledFvPatchScalarField::"
|
|
|
|
"solidWallMixedTemperatureCoupledFvPatchScalarField\n"
|
|
|
|
"(\n"
|
|
|
|
" const fvPatch& p,\n"
|
|
|
|
" const DimensionedField<scalar, volMesh>& iF,\n"
|
|
|
|
" const dictionary& dict\n"
|
|
|
|
")\n"
|
|
|
|
) << "\n patch type '" << p.type()
|
|
|
|
<< "' not type '" << directMappedPatchBase::typeName << "'"
|
|
|
|
<< "\n for patch " << p.name()
|
|
|
|
<< " of field " << dimensionedInternalField().name()
|
|
|
|
<< " in file " << dimensionedInternalField().objectPath()
|
|
|
|
<< exit(FatalError);
|
|
|
|
}
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
|
2010-08-26 14:22:03 +00:00
|
|
|
|
|
|
|
if (dict.found("refValue"))
|
|
|
|
{
|
|
|
|
// Full restart
|
|
|
|
refValue() = scalarField("refValue", dict, p.size());
|
|
|
|
refGrad() = scalarField("refGradient", dict, p.size());
|
|
|
|
valueFraction() = scalarField("valueFraction", dict, p.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Start from user entered data. Assume fixedValue.
|
|
|
|
refValue() = *this;
|
|
|
|
refGrad() = 0.0;
|
|
|
|
valueFraction() = 1.0;
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
|
|
|
solidWallMixedTemperatureCoupledFvPatchScalarField
|
|
|
|
(
|
|
|
|
const solidWallMixedTemperatureCoupledFvPatchScalarField& wtcsf,
|
|
|
|
const DimensionedField<scalar, volMesh>& iF
|
|
|
|
)
|
|
|
|
:
|
|
|
|
mixedFvPatchScalarField(wtcsf, iF),
|
2010-08-26 14:22:03 +00:00
|
|
|
neighbourFieldName_(wtcsf.neighbourFieldName_),
|
|
|
|
KName_(wtcsf.KName_)
|
2010-05-12 13:27:55 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
const Foam::fvPatchScalarField&
|
|
|
|
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::K() const
|
|
|
|
{
|
|
|
|
return this->patch().lookupPatchField<volScalarField, scalar>(KName_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs()
|
|
|
|
{
|
|
|
|
if (updated())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
// Get the coupling information from the directMappedPatchBase
|
|
|
|
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
|
|
|
|
(
|
|
|
|
patch().patch()
|
|
|
|
);
|
|
|
|
const polyMesh& nbrMesh = mpp.sampleMesh();
|
|
|
|
const fvPatch& nbrPatch = refCast<const fvMesh>
|
|
|
|
(
|
|
|
|
nbrMesh
|
|
|
|
).boundary()[mpp.samplePolyPatch().index()];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
// Force recalculation of mapping and schedule
|
|
|
|
const mapDistribute& distMap = mpp.map();
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
tmp<scalarField> intFld = patchInternalField();
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
const solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField =
|
|
|
|
refCast<const solidWallMixedTemperatureCoupledFvPatchScalarField>
|
|
|
|
(
|
|
|
|
nbrPatch.lookupPatchField<volScalarField, scalar>
|
|
|
|
(
|
|
|
|
neighbourFieldName_
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Swap to obtain full local values of neighbour internal field
|
|
|
|
scalarField nbrIntFld = nbrField.patchInternalField();
|
|
|
|
mapDistribute::distribute
|
|
|
|
(
|
|
|
|
Pstream::defaultCommsType,
|
|
|
|
distMap.schedule(),
|
|
|
|
distMap.constructSize(),
|
|
|
|
distMap.subMap(), // what to send
|
|
|
|
distMap.constructMap(), // what to receive
|
|
|
|
nbrIntFld
|
|
|
|
);
|
|
|
|
|
|
|
|
// Swap to obtain full local values of neighbour K*delta
|
|
|
|
scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
|
|
|
|
mapDistribute::distribute
|
|
|
|
(
|
|
|
|
Pstream::defaultCommsType,
|
|
|
|
distMap.schedule(),
|
|
|
|
distMap.constructSize(),
|
|
|
|
distMap.subMap(), // what to send
|
|
|
|
distMap.constructMap(), // what to receive
|
|
|
|
nbrKDelta
|
|
|
|
);
|
|
|
|
|
|
|
|
tmp<scalarField> myKDelta = K()*patch().deltaCoeffs();
|
|
|
|
|
|
|
|
|
|
|
|
// Both sides agree on
|
|
|
|
// - temperature : (myKDelta*fld + nbrKDelta*nbrFld)/(myKDelta+nbrKDelta)
|
|
|
|
// - gradient : (temperature-fld)*delta
|
|
|
|
// We've got a degree of freedom in how to implement this in a mixed bc.
|
|
|
|
// (what gradient, what fixedValue and mixing coefficient)
|
|
|
|
// Two reasonable choices:
|
|
|
|
// 1. specify above temperature on one side (preferentially the high side)
|
|
|
|
// and above gradient on the other. So this will switch between pure
|
|
|
|
// fixedvalue and pure fixedgradient
|
|
|
|
// 2. specify gradient and temperature such that the equations are the
|
|
|
|
// same on both sides. This leads to the choice of
|
|
|
|
// - refGradient = zero gradient
|
|
|
|
// - refValue = neighbour value
|
|
|
|
// - mixFraction = nbrKDelta / (nbrKDelta + myKDelta())
|
|
|
|
|
|
|
|
|
|
|
|
this->refValue() = nbrIntFld;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
this->refGrad() = 0.0;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
this->valueFraction() = nbrKDelta / (nbrKDelta + myKDelta());
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
mixedFvPatchScalarField::updateCoeffs();
|
|
|
|
|
|
|
|
|
2010-08-26 14:22:03 +00:00
|
|
|
if (debug)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-08-26 14:22:03 +00:00
|
|
|
scalar Q = gSum(K()*patch().magSf()*snGrad());
|
|
|
|
|
|
|
|
Info<< patch().boundaryMesh().mesh().name() << ':'
|
|
|
|
<< patch().name() << ':'
|
|
|
|
<< this->dimensionedInternalField().name() << " -> "
|
|
|
|
<< nbrMesh.name() << ':'
|
|
|
|
<< nbrPatch.name() << ':'
|
|
|
|
<< this->dimensionedInternalField().name() << " :"
|
|
|
|
<< " heatFlux:" << Q
|
|
|
|
<< " walltemperature "
|
|
|
|
<< " min:" << gMin(*this)
|
|
|
|
<< " max:" << gMax(*this)
|
|
|
|
<< " avg:" << gAverage(*this)
|
|
|
|
<< endl;
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::write
|
|
|
|
(
|
|
|
|
Ostream& os
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
mixedFvPatchScalarField::write(os);
|
2010-08-26 14:22:03 +00:00
|
|
|
os.writeKeyword("neighbourFieldName")<< neighbourFieldName_
|
|
|
|
<< token::END_STATEMENT << nl;
|
2010-05-12 13:27:55 +00:00
|
|
|
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
namespace Foam
|
|
|
|
{
|
|
|
|
|
|
|
|
makePatchTypeField
|
|
|
|
(
|
|
|
|
fvPatchScalarField,
|
|
|
|
solidWallMixedTemperatureCoupledFvPatchScalarField
|
|
|
|
);
|
|
|
|
|
|
|
|
} // End namespace Foam
|
|
|
|
|
|
|
|
// ************************************************************************* //
|