Skip to content
Snippets Groups Projects
Commit b20a324c authored by andy's avatar andy
Browse files

ENH: Updated inter-region heat transfer models to use new mesh-to-mesh interpolation class

parent 985219c0
Branches
Tags
No related merge requests found
Showing
with 279 additions and 104 deletions
......@@ -86,9 +86,9 @@ void Foam::fv::option::setSelection(const dictionary& dict)
}
case smMapRegion:
{
dict_.lookup("nbrModelName") >> nbrModelName_;
dict_.lookup("nbrRegionName") >> nbrRegionName_;
master_ = readBool(dict_.lookup("master"));
dict.lookup("nbrModelName") >> nbrModelName_;
dict.lookup("nbrRegionName") >> nbrRegionName_;
master_ = readBool(dict.lookup("master"));
break;
}
case smAll:
......@@ -131,7 +131,6 @@ void Foam::fv::option::setCellSet()
WarningIn("option::setCellSet()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
}
}
......@@ -167,40 +166,44 @@ void Foam::fv::option::setCellSet()
}
case smMapRegion:
{
if (active_)
if (active_ && master_)
{
IInfo<< "- selecting inter region mapping" << endl;
const fvMesh& nbrMesh =
mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
boundBox BB(mesh_.points(), false);
boundBox nbrBB(nbrMesh.points(), false);
if (nbrBB.overlaps(BB))
if (mesh_.name() == nbrMesh.name())
{
// Dummy patches
wordList cuttingPatches;
HashTable<word> patchMap;
FatalErrorIn("option::setCellIds()")
<< "Inter-region model selected, but local and "
<< "neighbour regions are the same: " << nl
<< " local region: " << mesh_.name() << nl
<< " secondary region: " << nbrMesh.name() << nl
<< exit(FatalError);
}
secondaryToPrimaryInterpPtr_.reset
if (mesh_.bounds().overlaps(nbrMesh.bounds()))
{
meshInterpPtr_.reset
(
new meshToMesh
new meshToMeshNew
(
nbrMesh,
mesh_,
patchMap,
cuttingPatches
nbrMesh,
readBool(dict_.lookup("consistentMeshes"))
)
);
}
else
{
FatalErrorIn("option::setCellSet()")
<< "regions do not overlap " << nbrMesh.name()
<< " in region " << mesh_.name() << nl
<< "regions " << mesh_.name() << " and "
<< nbrMesh.name() << " do not intersect"
<< exit(FatalError);
}
V_ = meshInterpPtr_->V();
}
break;
}
......@@ -257,7 +260,7 @@ Foam::fv::option::option
selectionMode_(selectionModeTypeNames_.read(dict_.lookup("selectionMode"))),
cellSetName_("none"),
V_(0.0),
secondaryToPrimaryInterpPtr_(),
meshInterpPtr_(),
nbrModelName_("none"),
nbrRegionName_("none"),
master_(false),
......@@ -296,7 +299,7 @@ Foam::autoPtr<Foam::fv::option> Foam::fv::option::New
{
word modelType(coeffs.lookup("type"));
IInfo<< "Selecting source model type " << modelType << endl;
IInfo<< "Selecting finite volume options model type " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
......@@ -317,12 +320,7 @@ Foam::autoPtr<Foam::fv::option> Foam::fv::option::New
Foam::fv::option::~option()
{
if (!secondaryToPrimaryInterpPtr_.empty())
{
secondaryToPrimaryInterpPtr_.clear();
}
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......
......@@ -35,7 +35,7 @@ Description
selectionMode cellSet; // cellSet // points //cellZone
// mapRegion
Note:
On evaluation, source expects to be added to the rhs of the equation
On evaluation, source/sink options are to be added to the equation rhs
SourceFiles
fvOption.C
......@@ -50,7 +50,7 @@ SourceFiles
#include "volFieldsFwd.H"
#include "cellSet.H"
#include "autoPtr.H"
#include "meshToMesh.H"
#include "meshToMeshNew.H"
#include "runTimeSelectionTables.H"
......@@ -131,8 +131,8 @@ protected:
// Data for smMapRegion only
//- Mesh to mesh mapping for map option
autoPtr<meshToMesh> secondaryToPrimaryInterpPtr_;
//- Mesh to mesh interpolation object
autoPtr<meshToMeshNew> meshInterpPtr_;
//- Name of the model in the neighbour mesh
word nbrModelName_;
......@@ -294,9 +294,8 @@ public:
//- Return const access to the neighbour region name
inline const word& nbrRegionName() const;
//- Return const access to the mapToMap Ptr
inline const autoPtr<meshToMesh>
secondaryToPrimaryInterpPtr() const;
//- Return const access to the mapToMap pointer
inline const meshToMeshNew& meshInterp() const;
//- Return const access to the cell set
inline const labelList& cells() const;
......
......@@ -138,10 +138,16 @@ inline const Foam::word& Foam::fv::option::nbrRegionName() const
}
inline const Foam::autoPtr<Foam::meshToMesh>
Foam::fv::option::secondaryToPrimaryInterpPtr() const
inline const Foam::meshToMeshNew& Foam::fv::option::meshInterp() const
{
return secondaryToPrimaryInterpPtr_;
if (!meshInterpPtr_.valid())
{
FatalErrorIn("const meshToMeshNew& meshInterp() const")
<< "Interpolation object not set"
<< abort(FatalError);
}
return meshInterpPtr_();
}
......
......@@ -57,7 +57,7 @@ Foam::fv::constantHeatTransfer::constantHeatTransfer
htcConst_(),
AoV_()
{
if (master_)
if (active() && master_)
{
htcConst_.reset
(
......@@ -95,12 +95,7 @@ Foam::fv::constantHeatTransfer::constantHeatTransfer
htcConst_().dimensionedInternalField();
const DimensionedField<scalar, volMesh>& AoVi =
AoV_().dimensionedInternalField();
dimensionedScalar interVol
(
"V",
dimVolume,
secondaryToPrimaryInterpPtr_->V()
);
dimensionedScalar interVol("V", dimVolume, meshInterp().V());
htc_.dimensionedInternalField() = htcConsti*AoVi*interVol/mesh.V();
htc_.correctBoundaryConditions();
......
......@@ -25,7 +25,7 @@ License
#include "interRegionHeatTransferModel.H"
#include "fluidThermo.H"
#include "fvm.H"
#include "fvmSup.H"
#include "zeroGradientFvPatchFields.H"
#include "fvcVolumeIntegrate.H"
#include "fvOptionList.H"
......@@ -43,8 +43,13 @@ namespace fv
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
void Foam::fv::interRegionHeatTransferModel::check()
void Foam::fv::interRegionHeatTransferModel::setNbrModel()
{
if (!firstIter_)
{
return;
}
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
const optionList& fvOptions = nbrMesh.lookupObject<optionList>("fvOptions");
......@@ -67,10 +72,12 @@ void Foam::fv::interRegionHeatTransferModel::check()
if (!nbrModelFound)
{
FatalErrorIn("interRegionHeatTransferModel::check()")
<< "Neighbour model name not found" << nbrModelName_
<< "Neighbour model not found" << nbrModelName_
<< " in region " << nbrMesh.name() << nl
<< exit(FatalError);
}
firstIter_ = false;
}
......@@ -85,7 +92,7 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
)
:
option(name, modelType, dict, mesh),
nbrModel_(),
nbrModel_(NULL),
firstIter_(true),
htc_
(
......@@ -132,19 +139,12 @@ void Foam::fv::interRegionHeatTransferModel::addSup
const label fieldI
)
{
if (!secondaryToPrimaryInterpPtr_.valid())
{
return;
}
if (firstIter_)
{
check();
firstIter_ = false;
}
setNbrModel();
const volScalarField& h = eqn.psi();
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
tmp<volScalarField> tTmapped
(
new volScalarField
......@@ -157,8 +157,7 @@ void Foam::fv::interRegionHeatTransferModel::addSup
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("T", dimTemperature, 0.0)
T
)
);
......@@ -168,23 +167,11 @@ void Foam::fv::interRegionHeatTransferModel::addSup
const volScalarField& Tnbr = nbrMesh.lookupObject<volScalarField>("T");
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
Tmapped,
Tnbr,
meshToMesh::MAP,
eqOp<scalar>()
);
interpolate(Tnbr, Tmapped.internalField());
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
nbrModel_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
eqOp<scalar>()
);
interpolate(nbrModel().calculateHtc()(), htc_);
}
if (debug)
......@@ -226,7 +213,6 @@ void Foam::fv::interRegionHeatTransferModel::addSup
}
else
{
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
eqn += htc_*(Tmapped - T);
}
}
......
......@@ -26,7 +26,12 @@ Class
Description
Base class for inter region heat exchange. The derived classes must
provide the heat transfer coefficient (htc)
provide the heat transfer coeffisine (htc) which is used as follows
in the energy equation.
\f[
-htc*Tmapped + Sp(htc, T)
\f]
\*---------------------------------------------------------------------------*/
......@@ -66,8 +71,8 @@ private:
// Private members
//- Check coupled interRegionHeatTransferModel
void check();
//- Set the neighbour interRegionHeatTransferModel
void setNbrModel();
protected:
......@@ -82,6 +87,41 @@ protected:
bool semiImplicit_;
// Protected member functions
//- Interpolate field with nbrModel specified
template<class Type>
tmp<Field<Type> > interpolate
(
const interRegionHeatTransferModel& nbrModel,
const Field<Type>& field
) const;
//- Interpolate field without nbrModel specified
template<class Type>
tmp<Field<Type> > interpolate
(
const Field<Type>& field
) const;
//- Interpolate field with nbrModel specified
template<class Type>
void interpolate
(
const interRegionHeatTransferModel& nbrModel,
const Field<Type>& field,
Field<Type>& result
) const;
//- Interpolate field without nbrModel specified
template<class Type>
void interpolate
(
const Field<Type>& field,
Field<Type>& result
) const;
public:
//- Runtime type information
......@@ -110,10 +150,13 @@ public:
// Access
//- Return the heat transfer coefficient
const volScalarField& htc() const
{
return htc_;
}
inline const volScalarField& htc() const;
//- Return const access to the neighbour model
inline const interRegionHeatTransferModel& nbrModel() const;
//- Return access to the neighbour model
inline interRegionHeatTransferModel& nbrModel();
//-Source term to fvMatrix<scalar>
virtual void addSup(fvMatrix<scalar>& eqn, const label fieldI);
......@@ -138,6 +181,17 @@ public:
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "interRegionHeatTransferModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "interRegionHeatTransferModelTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline const Foam::volScalarField&
Foam::fv::interRegionHeatTransferModel::htc() const
{
return htc_;
}
inline const Foam::fv::interRegionHeatTransferModel&
Foam::fv::interRegionHeatTransferModel::nbrModel() const
{
if (nbrModel_ == NULL)
{
FatalErrorIn("const interRegionHeatTransferModel& nbrModel() const")
<< "Neighbour model not set"
<< abort(FatalError);
}
return *nbrModel_;
}
inline Foam::fv::interRegionHeatTransferModel&
Foam::fv::interRegionHeatTransferModel::nbrModel()
{
if (nbrModel_ == NULL)
{
FatalErrorIn("interRegionHeatTransferModel& nbrModel()")
<< "Neighbour model not set"
<< abort(FatalError);
}
return *nbrModel_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::fv::interRegionHeatTransferModel::interpolate
(
const interRegionHeatTransferModel& nbrModel,
const Field<Type>& field
) const
{
if (master_)
{
return meshInterp().mapTgtToSrc(field);
}
else
{
return (nbrModel.meshInterp().mapSrcToTgt(field));
}
}
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::fv::interRegionHeatTransferModel::interpolate
(
const Field<Type>& field
) const
{
return interpolate(nbrModel(), field);
}
template<class Type>
void Foam::fv::interRegionHeatTransferModel::interpolate
(
const interRegionHeatTransferModel& nbrModel,
const Field<Type>& field,
Field<Type>& result
) const
{
if (master_)
{
meshInterp().mapTgtToSrc(field, plusEqOp<scalar>(), result);
}
else
{
nbrModel.meshInterp().mapSrcToTgt(field, plusEqOp<scalar>(), result);
}
}
template<class Type>
void Foam::fv::interRegionHeatTransferModel::interpolate
(
const Field<Type>& field,
Field<Type>& result
) const
{
return interpolate(nbrModel(), field, result);
}
// ************************************************************************* //
......@@ -115,15 +115,9 @@ Foam::fv::tabulatedHeatTransfer::calculateHtc()
const volVectorField& UNbr = nbrMesh.lookupObject<volVectorField>(UName_);
scalarField UMagNbrMapped(htc_.internalField().size(), 0.0);
const scalarField UMagNbr(mag(UNbr));
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
UMagNbrMapped,
mag(UNbr),
meshToMesh::MAP,
eqOp<scalar>()
);
const scalarField UMagNbrMapped(interpolate(UMagNbr));
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
......@@ -134,7 +128,7 @@ Foam::fv::tabulatedHeatTransfer::calculateHtc()
htcc[i] = hTable()(mag(U[i]), UMagNbrMapped[i]);
}
htcc = htcc*AoV()*secondaryToPrimaryInterpPtr_->V()/mesh_.V();
htcc = htcc*AoV()*meshInterp().V()/mesh_.V();
return htc_;
}
......
......@@ -109,24 +109,17 @@ Foam::fv::variableHeatTransfer::calculateHtc()
const fluidThermo& nbrThermo =
nbrMesh.lookupObject<fluidThermo>("thermophysicalProperties");
const volVectorField& U = nbrMesh.lookupObject<volVectorField>(UName_);
const volVectorField& UNbr = nbrMesh.lookupObject<volVectorField>(UName_);
const volScalarField Re(mag(U)*ds_*nbrThermo.rho()/nbrTurb.mut());
const volScalarField ReNbr(mag(UNbr)*ds_*nbrThermo.rho()/nbrTurb.mut());
const volScalarField Nu(a_*pow(Re, b_)*pow(Pr_, c_));
const volScalarField NuNbr(a_*pow(ReNbr, b_)*pow(Pr_, c_));
scalarField htcNbrMapped(htc_.internalField().size(), 0.0);
const scalarField htcNbr(NuNbr*nbrTurb.kappaEff()/ds_);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htcNbrMapped,
Nu*nbrTurb.kappaEff()/ds_,
meshToMesh::MAP,
eqOp<scalar>()
);
const scalarField htcNbrMapped(interpolate(htcNbr));
htc_.internalField() =
htcNbrMapped*AoV_*secondaryToPrimaryInterpPtr_->V()/mesh_.V();
htc_.internalField() = htcNbrMapped*AoV_*meshInterp().V()/mesh_.V();
return htc_;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment