mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge commit 'OpenCFD/master' into olesenm
Conflicts: src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C
This commit is contained in:
@ -5,7 +5,7 @@ coupleManager/coupleManager.C
|
||||
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
|
||||
derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C
|
||||
derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C
|
||||
|
||||
derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C
|
||||
|
||||
chtMultiRegionFoam.C
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "coupleManager.H"
|
||||
#include "OFstream.H"
|
||||
#include "regionProperties.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -74,6 +75,51 @@ Foam::coupleManager::~coupleManager()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::coupleManager::regionOwner() const
|
||||
{
|
||||
const fvMesh& nbrRegion = neighbourRegion();
|
||||
|
||||
const regionProperties& props =
|
||||
localRegion_.objectRegistry::parent().lookupObject<regionProperties>
|
||||
(
|
||||
"regionProperties"
|
||||
);
|
||||
|
||||
label myIndex = findIndex(props.fluidRegionNames(), localRegion_.name());
|
||||
if (myIndex == -1)
|
||||
{
|
||||
label i = findIndex(props.solidRegionNames(), localRegion_.name());
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
FatalErrorIn("coupleManager::regionOwner() const")
|
||||
<< "Cannot find region " << localRegion_.name()
|
||||
<< " neither in fluids " << props.fluidRegionNames()
|
||||
<< " nor in solids " << props.solidRegionNames()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
myIndex = props.fluidRegionNames().size() + i;
|
||||
}
|
||||
label nbrIndex = findIndex(props.fluidRegionNames(), nbrRegion.name());
|
||||
if (nbrIndex == -1)
|
||||
{
|
||||
label i = findIndex(props.solidRegionNames(), nbrRegion.name());
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
FatalErrorIn("coupleManager::regionOwner() const")
|
||||
<< "Cannot find region " << nbrRegion.name()
|
||||
<< " neither in fluids " << props.fluidRegionNames()
|
||||
<< " nor in solids " << props.solidRegionNames()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
nbrIndex = props.fluidRegionNames().size() + i;
|
||||
}
|
||||
|
||||
return myIndex < nbrIndex;
|
||||
}
|
||||
|
||||
|
||||
void Foam::coupleManager::checkCouple() const
|
||||
{
|
||||
Info<< "neighbourRegionName_ = " << neighbourRegionName_ << endl;
|
||||
|
||||
@ -74,9 +74,6 @@ class coupleManager
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
// coupleManager(const coupleManager&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const coupleManager&);
|
||||
|
||||
@ -129,6 +126,9 @@ public:
|
||||
template<class Type>
|
||||
inline const fvPatchField<Type>& neighbourPatchField() const;
|
||||
|
||||
//- Am I owner (= first to evaluate) of this region interface?
|
||||
bool regionOwner() const;
|
||||
|
||||
//- Check that the couple is valid
|
||||
void checkCouple() const;
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::updateCoeffs()
|
||||
const fvPatchField<scalar>& K =
|
||||
patch().lookupPatchField<volScalarField, scalar>(KName_);
|
||||
|
||||
gradient() = refCast<const solidWallTemperatureCoupledFvPatchScalarField>
|
||||
gradient() = -refCast<const solidWallTemperatureCoupledFvPatchScalarField>
|
||||
(neighbourField).flux()/K;
|
||||
|
||||
fixedGradientFvPatchScalarField::updateCoeffs();
|
||||
|
||||
@ -0,0 +1,252 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ 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"
|
||||
#include "regionProperties.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
coupleManager_(p),
|
||||
KName_("undefined-K")
|
||||
{
|
||||
this->refValue() = 0.0;
|
||||
this->refGrad() = 0.0;
|
||||
this->valueFraction() = 1.0;
|
||||
this->fixesValue_ = true;
|
||||
}
|
||||
|
||||
|
||||
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const solidWallMixedTemperatureCoupledFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(ptf, p, iF, mapper),
|
||||
coupleManager_(ptf.coupleManager_),
|
||||
KName_(ptf.KName_),
|
||||
fixesValue_(ptf.fixesValue_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
coupleManager_(p, dict),
|
||||
KName_(dict.lookup("K"))
|
||||
{
|
||||
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
|
||||
refValue() = static_cast<scalarField>(*this);
|
||||
refGrad() = 0.0;
|
||||
valueFraction() = 1.0;
|
||||
fixesValue_ = true;
|
||||
}
|
||||
|
||||
|
||||
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const solidWallMixedTemperatureCoupledFvPatchScalarField& wtcsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
mixedFvPatchScalarField(wtcsf, iF),
|
||||
coupleManager_(wtcsf.coupleManager_),
|
||||
KName_(wtcsf.KName_),
|
||||
fixesValue_(wtcsf.fixesValue_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::fvPatchScalarField&
|
||||
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::K() const
|
||||
{
|
||||
return this->patch().lookupPatchField<volScalarField, scalar>(KName_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tmp<scalarField> intFld = patchInternalField();
|
||||
|
||||
label nFixed = 0;
|
||||
|
||||
// Like snGrad but bypass switching on refValue/refGrad.
|
||||
tmp<scalarField> normalGradient =
|
||||
(*this-intFld())
|
||||
* patch().deltaCoeffs();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::"
|
||||
<< "updateCoeffs() :"
|
||||
<< " walltemperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
// if outgoing flux use fixed value.
|
||||
if (intFld()[i] > operator[](i))
|
||||
{
|
||||
this->refValue()[i] = operator[](i);
|
||||
this->refGrad()[i] = 0.0; // not used
|
||||
this->valueFraction()[i] = 1.0;
|
||||
nFixed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->refValue()[i] = 0.0; // not used
|
||||
this->refGrad()[i] = normalGradient()[i];
|
||||
this->valueFraction()[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
reduce(nFixed, sumOp<label>());
|
||||
|
||||
fixesValue_ = (nFixed > 0);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
label nTotSize = returnReduce(this->size(), sumOp<label>());
|
||||
|
||||
Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::"
|
||||
<< "updateCoeffs() : Out of " << nTotSize
|
||||
<< " fixedBC:" << nFixed
|
||||
<< " gradient:" << nTotSize-nFixed << endl;
|
||||
}
|
||||
|
||||
mixedFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::evaluate
|
||||
(
|
||||
const Pstream::commsTypes
|
||||
)
|
||||
{
|
||||
if (!this->updated())
|
||||
{
|
||||
this->updateCoeffs();
|
||||
}
|
||||
|
||||
if (!coupleManager_.regionOwner())
|
||||
{
|
||||
// I am the last one to evaluate.
|
||||
|
||||
tmp<scalarField> intFld = patchInternalField();
|
||||
|
||||
const fvPatch& nbrPatch = coupleManager_.neighbourPatch();
|
||||
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField =
|
||||
refCast<solidWallMixedTemperatureCoupledFvPatchScalarField>
|
||||
(
|
||||
const_cast<fvPatchField<scalar>&>
|
||||
(
|
||||
coupleManager_.neighbourPatchField<scalar>()
|
||||
)
|
||||
);
|
||||
tmp<scalarField> nbrIntFld = nbrField.patchInternalField();
|
||||
tmp<scalarField> myKDelta = K()*patch().deltaCoeffs();
|
||||
tmp<scalarField> nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
|
||||
|
||||
// Calculate common wall temperature and assign to both sides
|
||||
scalarField::operator=
|
||||
(
|
||||
(myKDelta()*intFld + nbrKDelta()*nbrIntFld)
|
||||
/ (myKDelta() + nbrKDelta())
|
||||
);
|
||||
|
||||
nbrField.scalarField::operator=(*this);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Setting master and slave to wall temperature "
|
||||
<< " min:" << gMin(*this)
|
||||
<< " max:" << gMax(*this)
|
||||
<< " avg:" << gAverage(*this)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
fvPatchScalarField::evaluate();
|
||||
}
|
||||
|
||||
|
||||
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
mixedFvPatchScalarField::write(os);
|
||||
coupleManager_.writeEntries(os);
|
||||
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,184 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ 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
|
||||
|
||||
Class
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
|
||||
Description
|
||||
Mixed boundary condition for temperature, to be used by the
|
||||
conjugate heat transfer solver.
|
||||
If my temperature is T1, neighbour is T2:
|
||||
|
||||
T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient.
|
||||
|
||||
|
||||
Example usage:
|
||||
myInterfacePatchName
|
||||
{
|
||||
type solidWallMixedTemperatureCoupled;
|
||||
neighbourRegionName fluid;
|
||||
neighbourPatchName fluidSolidInterface;
|
||||
neighbourFieldName T;
|
||||
K K;
|
||||
value uniform 300;
|
||||
}
|
||||
|
||||
SourceFiles
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef solidWallMixedTemperatureCoupledFvPatchScalarField_H
|
||||
#define solidWallMixedTemperatureCoupledFvPatchScalarField_H
|
||||
|
||||
#include "fvPatchFields.H"
|
||||
#include "mixedFvPatchFields.H"
|
||||
#include "coupleManager.H"
|
||||
#include "fvPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class solidWallMixedTemperatureCoupledFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
:
|
||||
public mixedFvPatchScalarField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Couple manager object
|
||||
coupleManager coupleManager_;
|
||||
|
||||
//- Name of thermal conductivity field
|
||||
word KName_;
|
||||
|
||||
bool fixesValue_;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("solidWallMixedTemperatureCoupled");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
// onto a new patch
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const solidWallMixedTemperatureCoupledFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new solidWallMixedTemperatureCoupledFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
const solidWallMixedTemperatureCoupledFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new solidWallMixedTemperatureCoupledFvPatchScalarField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Get corresponding K field
|
||||
const fvPatchScalarField& K() const;
|
||||
|
||||
//- Return true if this patch field fixes a value.
|
||||
// Needed to check if a level has to be specified while solving
|
||||
// Poissons equations.
|
||||
virtual bool fixesValue() const
|
||||
{
|
||||
return fixesValue_;
|
||||
}
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Evaluate the patch field
|
||||
virtual void evaluate
|
||||
(
|
||||
const Pstream::commsTypes commsType=Pstream::blocking
|
||||
);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -136,7 +136,7 @@ Foam::solidWallTemperatureCoupledFvPatchScalarField::flux() const
|
||||
|
||||
const fvPatchScalarField& Tw = *this;
|
||||
|
||||
return Tw.snGrad()*patch().magSf()*Kw;
|
||||
return Tw.snGrad()*Kw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Flux
|
||||
//- (intensive) flux
|
||||
tmp<scalarField> flux() const;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
thermof[i].rho()*thermof[i].Cp()*thermof[i].alpha()
|
||||
thermof[i].Cp()*thermof[i].alpha()
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -56,5 +56,5 @@
|
||||
}
|
||||
|
||||
// Update thermal conductivity
|
||||
Kf[i] = rhof[i]*thermof[i].Cp()*turb[i].alphaEff();
|
||||
Kf[i] = thermof[i].Cp()*turb[i].alphaEff();
|
||||
}
|
||||
|
||||
@ -6,4 +6,7 @@
|
||||
fvm::ddt(rhosCps[i], Ts[i]) - fvm::laplacian(Ks[i], Ts[i])
|
||||
);
|
||||
}
|
||||
|
||||
Info<< "Min/max T:" << min(Ts[i]) << ' ' << max(Ts[i])
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user