diff --git a/src/fvModels/Make/files b/src/fvModels/Make/files
index 3d2f71600b..01c4b4f323 100644
--- a/src/fvModels/Make/files
+++ b/src/fvModels/Make/files
@@ -1,5 +1,3 @@
-interRegionModel/interRegionModel.C
-
general/codedFvModel/codedFvModel.C
general/semiImplicitSource/semiImplicitSource.C
@@ -30,10 +28,13 @@ derived/volumeFractionSource/volumeFractionSource.C
derived/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
derived/massSource/massSource.C
-interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
-interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
-interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
-interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
+interRegion/interRegionModel/interRegionModel.C
interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C
+interRegion/interRegionHeatTransfer/interRegionHeatTransfer.C
+interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.C
+interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.C
+interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.C
+interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.C
+interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.C
LIB = $(FOAM_LIBBIN)/libfvModels
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.C b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.C
new file mode 100644
index 0000000000..783870297c
--- /dev/null
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.C
@@ -0,0 +1,152 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2011-2021 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "constant.H"
+#include "zeroGradientFvPatchFields.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+namespace heatTransferModels
+{
+ defineTypeNameAndDebug(constant, 0);
+ addToRunTimeSelectionTable(heatTransferModel, constant, mesh);
+ addToRunTimeSelectionTable(heatTransferModel, constant, model);
+}
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+void Foam::fv::heatTransferModels::constant::readCoeffs()
+{
+ IOobject htcIO
+ (
+ "htc",
+ mesh().time().constant(),
+ mesh(),
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE
+ );
+
+ if (coeffs().found("htc"))
+ {
+ htc_ =
+ dimensionedScalar
+ (
+ "htc",
+ dimPower/dimTemperature/dimArea,
+ coeffs()
+ );
+ htcPtr_.clear();
+ }
+ else if (htcIO.typeHeaderOk(false))
+ {
+ htc_ = dimensionedScalar("htc", dimPower/dimTemperature/dimArea, NaN);
+ htcPtr_.set(new volScalarField(htcIO, mesh()));
+ }
+ else
+ {
+ FatalIOErrorInFunction(coeffs())
+ << "Heat transfer coefficient (htc) not found. A uniform htc "
+ << "value should be specified, or a non-uniform field should "
+ << "exist at " << htcIO.objectPath()
+ << exit(FatalIOError);
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::fv::heatTransferModels::constant::constant
+(
+ const dictionary& dict,
+ const fvMesh& mesh
+)
+:
+ heatTransferModel(typeName, dict, mesh),
+ htc_("htc", dimPower/dimTemperature/dimArea, NaN),
+ htcPtr_(nullptr)
+{
+ readCoeffs();
+}
+
+
+Foam::fv::heatTransferModels::constant::constant
+(
+ const dictionary& dict,
+ const interRegionModel& model
+)
+:
+ constant(dict, model.mesh())
+{}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::fv::heatTransferModels::constant::~constant()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::tmp
+Foam::fv::heatTransferModels::constant::htc() const
+{
+ if (!htcPtr_.valid())
+ {
+ return volScalarField::New(type() + ":htc", mesh(), htc_);
+ }
+ else
+ {
+ return htcPtr_();
+ }
+}
+
+
+void Foam::fv::heatTransferModels::constant::correct()
+{}
+
+
+bool Foam::fv::heatTransferModels::constant::read(const dictionary& dict)
+{
+ if (heatTransferModel::read(dict))
+ {
+ readCoeffs();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.H b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.H
similarity index 62%
rename from src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.H
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.H
index e05c15d3ad..0d7bf18da1 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.H
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/constant/constant.H
@@ -22,19 +22,31 @@ License
along with OpenFOAM. If not, see .
Class
- Foam::fv::constantHeatTransfer
+ Foam::fv::heatTransferModels::constant
Description
- Constant heat transfer model. A heat transfer coefficieqt [W/m^2/K] field
- (htcConst) and area-per-unit-volume [1/m] field (AoV) must be provided in
+ Constant heat transfer model. The heat transfer coefficient [W/m^2/K] (htc)
+ must be provided as a value in the coefficients dictionary or as a field in
constant.
+Usage
+ Example usage:
+ \verbatim
+ {
+ type constant;
+
+ AoV 1e3;
+
+ htc 1e5;
+ }
+ \endverbatim
+
\*---------------------------------------------------------------------------*/
-#ifndef constantHeatTransfer_H
-#define constantHeatTransfer_H
+#ifndef constant_H
+#define constant_H
-#include "interRegionHeatTransferModel.H"
+#include "heatTransferModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -42,45 +54,59 @@ namespace Foam
{
namespace fv
{
+namespace heatTransferModels
+{
/*---------------------------------------------------------------------------*\
- Class constantHeatTransfer Declaration
+ Class constant Declaration
\*---------------------------------------------------------------------------*/
-class constantHeatTransfer
+class constant
:
- public interRegionHeatTransferModel
+ public heatTransferModel
{
+ // Private Data
+
+ //- Heat transfer coefficient [W/m^2/K]
+ dimensionedScalar htc_;
+
+ //- Heat transfer coefficient [W/m^2/K]
+ autoPtr htcPtr_;
+
+
// Private Member Functions
- //- Correct the heat transfer coefficient
- virtual void correctHtc() const;
+ //- Non-virtual read
+ void readCoeffs();
public:
//- Runtime type information
- TypeName("constantHeatTransfer");
+ TypeName("constant");
// Constructors
- //- Construct from dictionary
- constantHeatTransfer
- (
- const word& name,
- const word& modelType,
- const dictionary& dict,
- const fvMesh& mesh
- );
+ //- Construct from dictionary and mesh
+ constant(const dictionary& dict, const fvMesh& mesh);
+
+ //- Construct from dictionary and model
+ constant(const dictionary& dict, const interRegionModel& model);
//- Destructor
- virtual ~constantHeatTransfer();
+ virtual ~constant();
// Member Functions
+ //- Get the heat transfer coefficient
+ virtual tmp htc() const;
+
+ //- Correct the heat transfer coefficient
+ virtual void correct();
+
//- Read dictionary
virtual bool read(const dictionary& dict);
};
@@ -88,6 +114,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+} // End namespace heatTransferModels
} // End namespace fv
} // End namespace Foam
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.C
similarity index 56%
rename from src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.C
index df91342e99..2460d9c478 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.C
@@ -23,7 +23,8 @@ License
\*---------------------------------------------------------------------------*/
-#include "constantHeatTransfer.H"
+#include "function1.H"
+#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -32,80 +33,89 @@ namespace Foam
{
namespace fv
{
- defineTypeNameAndDebug(constantHeatTransfer, 0);
- addToRunTimeSelectionTable
- (
- fvModel,
- constantHeatTransfer,
- dictionary
- );
+namespace heatTransferModels
+{
+ defineTypeNameAndDebug(function1, 0);
+ addToRunTimeSelectionTable(heatTransferModel, function1, mesh);
+ addToRunTimeSelectionTable(heatTransferModel, function1, model);
+}
}
}
-
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-void Foam::fv::constantHeatTransfer::correctHtc() const
-{}
+void Foam::fv::heatTransferModels::function1::readCoeffs()
+{
+ UName_ = coeffs().lookupOrDefault("U", "U");
+
+ htcFunc_.reset(Function1::New("htcFunc", coeffs()).ptr());
+}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-Foam::fv::constantHeatTransfer::constantHeatTransfer
+Foam::fv::heatTransferModels::function1::function1
(
- const word& name,
- const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
- interRegionHeatTransferModel(name, modelType, dict, mesh)
+ heatTransferModel(typeName, dict, mesh),
+ UName_(word::null),
+ htcFunc_(nullptr)
{
- if (master())
- {
- const volScalarField htcConst
- (
- IOobject
- (
- "htcConst",
- mesh.time().constant(),
- mesh,
- IOobject::MUST_READ,
- IOobject::AUTO_WRITE
- ),
- mesh
- );
-
- const volScalarField AoV
- (
- IOobject
- (
- "AoV",
- mesh.time().constant(),
- mesh,
- IOobject::MUST_READ,
- IOobject::AUTO_WRITE
- ),
- mesh
- );
-
- htc_ = htcConst*AoV;
- }
+ readCoeffs();
}
+Foam::fv::heatTransferModels::function1::function1
+(
+ const dictionary& dict,
+ const interRegionModel& model
+)
+:
+ function1(dict, model.mesh())
+{}
+
+
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-Foam::fv::constantHeatTransfer::~constantHeatTransfer()
+Foam::fv::heatTransferModels::function1::~function1()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-bool Foam::fv::constantHeatTransfer::read(const dictionary& dict)
+Foam::tmp
+Foam::fv::heatTransferModels::function1::htc() const
{
- if (interRegionHeatTransferModel::read(dict))
+ const volVectorField& U = mesh().lookupObject(UName_);
+
+ tmp tHtc =
+ volScalarField::New
+ (
+ type() + ":htc",
+ mesh(),
+ dimPower/dimTemperature/dimArea,
+ zeroGradientFvPatchScalarField::typeName
+ );
+
+ tHtc->primitiveFieldRef() = htcFunc_->value(mag(U));
+ tHtc->correctBoundaryConditions();
+
+ return tHtc;
+}
+
+
+void Foam::fv::heatTransferModels::function1::correct()
+{}
+
+
+bool Foam::fv::heatTransferModels::function1::read(const dictionary& dict)
+{
+ if (heatTransferModel::read(dict))
{
+ readCoeffs();
return true;
}
else
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.H b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.H
new file mode 100644
index 0000000000..145a973fcd
--- /dev/null
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function1/function1.H
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2011-2021 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 .
+
+Class
+ Foam::fv::heatTransferModels::function1
+
+Description
+ Function1 heat transfer model. The 1D function returns the heat transfer
+ coefficient as a function of the local velocity magnitude.
+
+Usage
+ Example usage:
+ \verbatim
+ {
+ type function1;
+
+ AoV 1e3;
+
+ htcFunc
+ {
+ type constant;
+ value 1e5;
+ }
+ }
+ \endverbatim
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef function1_H
+#define function1_H
+
+#include "heatTransferModel.H"
+#include "Function1.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+namespace heatTransferModels
+{
+
+/*---------------------------------------------------------------------------*\
+ Class function1 Declaration
+\*---------------------------------------------------------------------------*/
+
+class function1
+:
+ public heatTransferModel
+{
+ // Private Data
+
+ //- Name of velocity field; default = U
+ word UName_;
+
+ //- Heat transfer coefficient [W/m^2/K]
+ autoPtr> htcFunc_;
+
+
+ // Private Member Functions
+
+ //- Non-virtual read
+ void readCoeffs();
+
+
+public:
+
+ //- Runtime type information
+ TypeName("function1");
+
+
+ // Constructors
+
+ //- Construct from dictionary and mesh
+ function1(const dictionary& dict, const fvMesh& mesh);
+
+ //- Construct from dictionary and model
+ function1(const dictionary& dict, const interRegionModel& model);
+
+
+ //- Destructor
+ virtual ~function1();
+
+
+ // Member Functions
+
+ //- Get the heat transfer coefficient
+ virtual tmp htc() const;
+
+ //- Correct the heat transfer coefficient
+ virtual void correct();
+
+ //- Read dictionary
+ virtual bool read(const dictionary& dict);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace heatTransferModels
+} // End namespace fv
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.C
similarity index 65%
rename from src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.C
index f2fb976799..d6b797a16b 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.C
@@ -23,7 +23,8 @@ License
\*---------------------------------------------------------------------------*/
-#include "function2HeatTransfer.H"
+#include "function2.H"
+#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -32,20 +33,18 @@ namespace Foam
{
namespace fv
{
- defineTypeNameAndDebug(function2HeatTransfer, 0);
- addToRunTimeSelectionTable
- (
- fvModel,
- function2HeatTransfer,
- dictionary
- );
+namespace heatTransferModels
+{
+ defineTypeNameAndDebug(function2, 0);
+ addToRunTimeSelectionTable(heatTransferModel, function2, model);
+}
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-void Foam::fv::function2HeatTransfer::readCoeffs()
+void Foam::fv::heatTransferModels::function2::readCoeffs()
{
UName_ = coeffs().lookupOrDefault("U", "U");
UNbrName_ = coeffs().lookupOrDefault("UNbr", "U");
@@ -54,51 +53,32 @@ void Foam::fv::function2HeatTransfer::readCoeffs()
}
-void Foam::fv::function2HeatTransfer::correctHtc() const
-{
- const volVectorField& U = mesh().lookupObject(UName_);
-
- const fvMesh& nbrMesh = mesh().time().lookupObject(nbrRegionName());
-
- const volVectorField& UNbr =
- nbrMesh.lookupObject(UNbrName_);
- const scalarField UMagNbr(mag(UNbr));
- const scalarField UMagNbrMapped(interpolate(UMagNbr));
-
- htc_.primitiveFieldRef() = htcFunc_->value(mag(U()), UMagNbrMapped)*AoV_();
-}
-
-
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-Foam::fv::function2HeatTransfer::function2HeatTransfer
+Foam::fv::heatTransferModels::function2::function2
(
- const word& name,
- const word& modelType,
const dictionary& dict,
- const fvMesh& mesh
+ const interRegionModel& model
)
:
- interRegionHeatTransferModel(name, modelType, dict, mesh),
+ heatTransferModel(typeName, dict, model),
+ model_(model),
UName_(word::null),
UNbrName_(word::null),
htcFunc_(),
- AoV_
+ htc_
(
- master()
- ? new volScalarField
+ IOobject
(
- IOobject
- (
- "AoV",
- mesh.time().constant(),
- mesh,
- IOobject::MUST_READ,
- IOobject::AUTO_WRITE
- ),
- mesh
- )
- : nullptr
+ type() + ":htc",
+ model.mesh().time().timeName(),
+ model.mesh(),
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ ),
+ model.mesh(),
+ dimensionedScalar(dimPower/dimTemperature/dimArea, 0),
+ zeroGradientFvPatchScalarField::typeName
)
{
readCoeffs();
@@ -107,15 +87,32 @@ Foam::fv::function2HeatTransfer::function2HeatTransfer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-Foam::fv::function2HeatTransfer::~function2HeatTransfer()
+Foam::fv::heatTransferModels::function2::~function2()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-bool Foam::fv::function2HeatTransfer::read(const dictionary& dict)
+void Foam::fv::heatTransferModels::function2::correct()
{
- if (interRegionHeatTransferModel::read(dict))
+ const fvMesh& mesh = model_.mesh();
+ const fvMesh& nbrMesh = model_.nbrMesh();
+
+ const volVectorField& U = mesh.lookupObject(UName_);
+
+ const volVectorField& UNbr =
+ nbrMesh.lookupObject(UNbrName_);
+ const scalarField UMagNbr(mag(UNbr));
+ const scalarField UMagNbrMapped(model_.interpolate(UMagNbr));
+
+ htc_.primitiveFieldRef() = htcFunc_->value(mag(U()), UMagNbrMapped);
+ htc_.correctBoundaryConditions();
+}
+
+
+bool Foam::fv::heatTransferModels::function2::read(const dictionary& dict)
+{
+ if (heatTransferModel::read(dict))
{
readCoeffs();
return true;
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.H b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.H
similarity index 69%
rename from src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.H
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.H
index 33253b236a..f98fe6ccb8 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.H
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/function2/function2.H
@@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see .
Class
- Foam::fv::function2HeatTransfer
+ Foam::fv::heatTransferModels::function2
Description
Function2 heat transfer model. The 2D function returns the heat transfer
@@ -30,12 +30,28 @@ Description
magnitudes. An area-per-unit-volume [1/m] field (AoV) must be provided in
constant.
+Usage
+ Example usage:
+ \verbatim
+ {
+ type function2;
+
+ AoV 1e3;
+
+ htcFunc
+ {
+ type constant;
+ value 1e5;
+ }
+ }
+ \endverbatim
+
\*---------------------------------------------------------------------------*/
-#ifndef function2HeatTransfer_H
-#define function2HeatTransfer_H
+#ifndef function2_H
+#define function2_H
-#include "interRegionHeatTransferModel.H"
+#include "heatTransferModel.H"
#include "Function2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -44,17 +60,22 @@ namespace Foam
{
namespace fv
{
+namespace heatTransferModels
+{
/*---------------------------------------------------------------------------*\
- Class function2HeatTransfer Declaration
+ Class function2 Declaration
\*---------------------------------------------------------------------------*/
-class function2HeatTransfer
+class function2
:
- public interRegionHeatTransferModel
+ public heatTransferModel
{
// Private Data
+ //- Reference to the inter region model
+ const interRegionModel& model_;
+
//- Name of velocity field; default = U
word UName_;
@@ -62,13 +83,10 @@ class function2HeatTransfer
word UNbrName_;
//- Heat transfer coefficient function ptr
- mutable autoPtr> htcFunc_;
+ autoPtr> htcFunc_;
- //- Area per unit volume of heat exchanger
- mutable autoPtr AoV_;
-
- //- Start time name
- const word startTimeName_;
+ //- Heat transfer coefficient [W/m^2/K]
+ volScalarField htc_;
// Private Member Functions
@@ -76,34 +94,34 @@ class function2HeatTransfer
//- Non-virtual read
void readCoeffs();
- //- Calculate the heat transfer coefficient
- virtual void correctHtc() const;
-
public:
//- Runtime type information
- TypeName("function2HeatTransfer");
+ TypeName("function2");
// Constructors
- //- Construct from dictionary
- function2HeatTransfer
- (
- const word& name,
- const word& modelType,
- const dictionary& dict,
- const fvMesh& mesh
- );
+ //- Construct from dictionary and model
+ function2(const dictionary& dict, const interRegionModel& model);
//- Destructor
- virtual ~function2HeatTransfer();
+ virtual ~function2();
// Member Functions
+ //- Get the heat transfer coefficient
+ virtual tmp htc() const
+ {
+ return htc_;
+ }
+
+ //- Correct the heat transfer coefficient
+ virtual void correct();
+
//- Read dictionary
virtual bool read(const dictionary& dict);
};
@@ -111,6 +129,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+} // End namespace heatTransferModels
} // End namespace fv
} // End namespace Foam
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.C b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.C
new file mode 100644
index 0000000000..b7151d41b5
--- /dev/null
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.C
@@ -0,0 +1,191 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2021 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "heatTransferModel.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+ defineTypeNameAndDebug(heatTransferModel, 0);
+ defineRunTimeSelectionTable(heatTransferModel, mesh);
+ defineRunTimeSelectionTable(heatTransferModel, model);
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+void Foam::fv::heatTransferModel::readCoeffs()
+{
+ IOobject AoVIO
+ (
+ "AoV",
+ mesh().time().constant(),
+ mesh(),
+ IOobject::MUST_READ,
+ IOobject::NO_WRITE
+ );
+
+ if (coeffs().found("AoV"))
+ {
+ AoV_ = dimensionedScalar("AoV", dimless/dimLength, coeffs());
+ AoVPtr_.clear();
+ }
+ else if (AoVIO.typeHeaderOk(false))
+ {
+ AoV_ = dimensionedScalar("AoV", dimless/dimLength, NaN);
+ AoVPtr_.set(new volScalarField(AoVIO, mesh()));
+ }
+ else
+ {
+ FatalIOErrorInFunction(coeffs())
+ << "Area per unit volume (AoV) not found. A uniform AoV "
+ << "value should be specified, or a non-uniform field should "
+ << "exist at " << AoVIO.objectPath()
+ << exit(FatalIOError);
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::fv::heatTransferModel::heatTransferModel
+(
+ const word& modelType,
+ const dictionary& dict,
+ const fvMesh& mesh
+)
+:
+ mesh_(mesh),
+ coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
+ AoV_("AoV", dimless/dimLength, NaN),
+ AoVPtr_(nullptr)
+{
+ readCoeffs();
+}
+
+
+Foam::fv::heatTransferModel::heatTransferModel
+(
+ const word& modelType,
+ const dictionary& dict,
+ const interRegionModel& model
+)
+:
+ heatTransferModel(modelType, dict, model.mesh())
+{}
+
+
+// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
+
+Foam::autoPtr
+Foam::fv::heatTransferModel::New(const dictionary& dict, const fvMesh& mesh)
+{
+ word heatTransferModelType(dict.lookup("type"));
+
+ Info<< "Selecting heatTransferModel "
+ << heatTransferModelType << endl;
+
+ meshConstructorTable::iterator cstrIter =
+ meshConstructorTablePtr_->find(heatTransferModelType);
+
+ if (cstrIter == meshConstructorTablePtr_->end())
+ {
+ FatalErrorInFunction
+ << "Unknown heatTransferModelType type "
+ << heatTransferModelType << endl << endl
+ << "Valid heatTransferModel types are : " << endl
+ << meshConstructorTablePtr_->sortedToc()
+ << exit(FatalError);
+ }
+
+ return cstrIter()(dict, mesh);
+}
+
+
+Foam::autoPtr
+Foam::fv::heatTransferModel::New
+(
+ const dictionary& dict,
+ const interRegionModel& model
+)
+{
+ word heatTransferModelType(dict.lookup("type"));
+
+ Info<< "Selecting heatTransferModel "
+ << heatTransferModelType << endl;
+
+ modelConstructorTable::iterator cstrIter =
+ modelConstructorTablePtr_->find(heatTransferModelType);
+
+ if (cstrIter == modelConstructorTablePtr_->end())
+ {
+ FatalErrorInFunction
+ << "Unknown heatTransferModelType type "
+ << heatTransferModelType << endl << endl
+ << "Valid heatTransferModel types are : " << endl
+ << modelConstructorTablePtr_->sortedToc()
+ << exit(FatalError);
+ }
+
+ return cstrIter()(dict, model);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::fv::heatTransferModel::~heatTransferModel()
+{}
+
+
+// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+
+Foam::tmp Foam::fv::heatTransferModel::AoV() const
+{
+ if (!AoVPtr_.valid())
+ {
+ return volScalarField::New(type() + ":AoV", mesh_, AoV_);
+ }
+ else
+ {
+ return AoVPtr_();
+ }
+}
+
+
+bool Foam::fv::heatTransferModel::read(const dictionary& dict)
+{
+ coeffs_ = dict.optionalSubDict(type() + "Coeffs");
+
+ readCoeffs();
+
+ return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.H b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.H
new file mode 100644
index 0000000000..4b56cf29b7
--- /dev/null
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/heatTransferModel/heatTransferModel.H
@@ -0,0 +1,191 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2021 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 .
+
+Class
+ Foam::fv::heatTransferModel
+
+Description
+ Base class for heat transfer coefficient modelling used in heat transfer
+ fvModels. Area per unit volume [1/m] (AoV) must be provided as a value in
+ the coefficients dictionary or as a field in constant.
+
+SourceFiles
+ heatTransferModel.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef heatTransferModel_H
+#define heatTransferModel_H
+
+#include "volFields.H"
+#include "interRegionModel.H"
+#include "runTimeSelectionTables.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+
+/*---------------------------------------------------------------------------*\
+ Class heatTransferModel Declaration
+\*---------------------------------------------------------------------------*/
+
+class heatTransferModel
+{
+ // Private Member Data
+
+ //- Reference to the mesh
+ const fvMesh& mesh_;
+
+ //- Dictionary containing source coefficients
+ dictionary coeffs_;
+
+ //- Area per unit volume [1/m]
+ dimensionedScalar AoV_;
+
+ //- Area per unit volume [1/m]
+ autoPtr AoVPtr_;
+
+
+ // Private Member Functions
+
+ //- Non-virtual read
+ void readCoeffs();
+
+
+public:
+
+ //- Runtime type information
+ TypeName("heatTransferModel");
+
+
+ // Declare runtime construction
+
+ declareRunTimeSelectionTable
+ (
+ autoPtr,
+ heatTransferModel,
+ mesh,
+ (
+ const dictionary& dict,
+ const fvMesh& mesh
+ ),
+ (dict, mesh)
+ );
+
+ declareRunTimeSelectionTable
+ (
+ autoPtr,
+ heatTransferModel,
+ model,
+ (
+ const dictionary& dict,
+ const interRegionModel& model
+ ),
+ (dict, model)
+ );
+
+
+ // Constructors
+
+ //- Construct from dictionary and mesh
+ heatTransferModel
+ (
+ const word& modelType,
+ const dictionary& dict,
+ const fvMesh& mesh
+ );
+
+ //- Construct from dictionary and model
+ heatTransferModel
+ (
+ const word& modelType,
+ const dictionary& dict,
+ const interRegionModel& model
+ );
+
+ //- Disallow default bitwise copy construction
+ heatTransferModel(const heatTransferModel&) = delete;
+
+
+ // Selectors
+
+ //- Select from dictionary and mesh
+ static autoPtr New
+ (
+ const dictionary& dict,
+ const fvMesh& mesh
+ );
+
+ //- Select from dictionary and model
+ static autoPtr New
+ (
+ const dictionary& dict,
+ const interRegionModel& model
+ );
+
+
+ //- Destructor
+ virtual ~heatTransferModel();
+
+
+ // Member Functions
+
+ //- Return reference to the mesh
+ inline const fvMesh& mesh() const
+ {
+ return mesh_;
+ }
+
+ //- Return coeffs dictionary
+ inline const dictionary& coeffs() const
+ {
+ return coeffs_;
+ }
+
+ //- Get the area per unit volume
+ tmp AoV() const;
+
+ //- Get the heat transfer coefficient
+ virtual tmp htc() const = 0;
+
+ //- Correct the heat transfer coefficient
+ virtual void correct() = 0;
+
+ //- Read dictionary
+ virtual bool read(const dictionary& dict);
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace fv
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.C
similarity index 54%
rename from src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.C
index 006e9a6c94..edeb0336e1 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.C
@@ -23,8 +23,9 @@ License
\*---------------------------------------------------------------------------*/
-#include "variableHeatTransfer.H"
+#include "variable.H"
#include "thermophysicalTransportModel.H"
+#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -33,111 +34,108 @@ namespace Foam
{
namespace fv
{
- defineTypeNameAndDebug(variableHeatTransfer, 0);
- addToRunTimeSelectionTable
- (
- fvModel,
- variableHeatTransfer,
- dictionary
- );
+namespace heatTransferModels
+{
+ defineTypeNameAndDebug(variable, 0);
+ addToRunTimeSelectionTable(heatTransferModel, variable, mesh);
+ addToRunTimeSelectionTable(heatTransferModel, variable, model);
}
}
+}
+
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-void Foam::fv::variableHeatTransfer::readCoeffs()
+void Foam::fv::heatTransferModels::variable::readCoeffs()
{
- UNbrName_ = coeffs().lookupOrDefault("UNbr", "U");
+ UName_ = coeffs().lookupOrDefault("U", "U");
a_ = coeffs().lookup("a");
b_ = coeffs().lookup("b");
c_ = coeffs().lookup("c");
- ds_ = coeffs().lookup("ds");
- Pr_ = coeffs().lookup("Pr");
-}
-
-
-void Foam::fv::variableHeatTransfer::correctHtc() const
-{
- const fvMesh& nbrMesh =
- mesh().time().lookupObject(nbrRegionName());
-
- const thermophysicalTransportModel& nbrTtm =
- nbrMesh.lookupObject
- (
- thermophysicalTransportModel::typeName
- );
-
- const compressibleMomentumTransportModel& nbrTurb =
- nbrTtm.momentumTransport();
-
- const fluidThermo& nbrThermo = nbrTtm.thermo();
-
- const volVectorField& UNbr =
- nbrMesh.lookupObject(UNbrName_);
-
- const volScalarField ReNbr(mag(UNbr)*ds_*nbrThermo.rho()/nbrTurb.mut());
-
- const volScalarField NuNbr(a_*pow(ReNbr, b_)*pow(Pr_, c_));
-
- const scalarField htcNbr(NuNbr*nbrTtm.kappaEff()/ds_);
-
- const scalarField htcNbrMapped(interpolate(htcNbr));
-
- htc_.primitiveFieldRef() = htcNbrMapped*AoV_;
+ L_ = dimensionedScalar("L", dimLength, coeffs());
+ Pr_ = dimensionedScalar("Pr", dimless, coeffs());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-Foam::fv::variableHeatTransfer::variableHeatTransfer
+Foam::fv::heatTransferModels::variable::variable
(
- const word& name,
- const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
- interRegionHeatTransferModel(name, modelType, dict, mesh),
- UNbrName_(word::null),
+ heatTransferModel(typeName, dict, mesh),
+ UName_(word::null),
a_(NaN),
b_(NaN),
c_(NaN),
- ds_(NaN),
- Pr_(NaN),
- AoV_
+ L_("L", dimLength, NaN),
+ Pr_("Pr", dimless, NaN),
+ htc_
(
- master()
- ? new volScalarField
+ IOobject
(
- IOobject
- (
- "AoV",
- mesh.time().constant(),
- mesh,
- IOobject::MUST_READ,
- IOobject::AUTO_WRITE
- ),
- mesh
- )
- : nullptr
+ type() + ":htc",
+ mesh.time().timeName(),
+ mesh,
+ IOobject::NO_READ,
+ IOobject::NO_WRITE
+ ),
+ mesh,
+ dimensionedScalar(dimPower/dimTemperature/dimArea, 0),
+ zeroGradientFvPatchScalarField::typeName
)
{
readCoeffs();
}
+Foam::fv::heatTransferModels::variable::variable
+(
+ const dictionary& dict,
+ const interRegionModel& model
+)
+:
+ variable(dict, model.mesh())
+{
+ readCoeffs();
+}
+
+
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-Foam::fv::variableHeatTransfer::~variableHeatTransfer()
+Foam::fv::heatTransferModels::variable::~variable()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-bool Foam::fv::variableHeatTransfer::read(const dictionary& dict)
+void Foam::fv::heatTransferModels::variable::correct()
{
- if (interRegionHeatTransferModel::read(dict))
+ const thermophysicalTransportModel& ttm =
+ mesh().lookupObject
+ (
+ thermophysicalTransportModel::typeName
+ );
+ const compressibleMomentumTransportModel& mtm =
+ ttm.momentumTransport();
+
+ const volVectorField& U =
+ mesh().lookupObject(UName_);
+
+ const volScalarField Re(mag(U)*L_/mtm.nuEff());
+ const volScalarField Nu(a_*pow(Re, b_)*pow(Pr_, c_));
+
+ htc_ = Nu*ttm.kappaEff()/L_;
+ htc_.correctBoundaryConditions();
+}
+
+
+bool Foam::fv::heatTransferModels::variable::read(const dictionary& dict)
+{
+ if (heatTransferModel::read(dict))
{
readCoeffs();
return true;
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.H b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.H
similarity index 66%
rename from src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.H
rename to src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.H
index 2e030c3afb..0a053e7268 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.H
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/heatTransferModels/variable/variable.H
@@ -22,11 +22,11 @@ License
along with OpenFOAM. If not, see .
Class
- Foam::fv::variableHeatTransfer
+ Foam::fv::heatTransferModels::variable
Description
- Variable heat transfer model depending on local values. The Nu number is
- calculated as:
+ Variable heat transfer model depending on local values. The Nusselt number
+ is calculated as:
\f[
Nu = a*Re^b*Pr^c
@@ -35,23 +35,38 @@ Description
And the heat transfer coefficient is calculated as:
\f[
- htc = Nu*K/ds
+ htc = Nu*\kappa/L
\f]
- where:
+ Where:
+
\vartable
- K | Conductivity
- ds | Strut diameter
+ \kappa | Conductivity
+ L | Length scale
\endvartable
- An area-per-unit-volume [1/m] field (AoV) must be provided in constant.
+Usage
+ Example usage:
+ \verbatim
+ {
+ type variable;
+
+ AoV 1e3;
+
+ a 1;
+ b 2;
+ c 3;
+ Pr 0.7;
+ L 1e-3;
+ }
+ \endverbatim
\*---------------------------------------------------------------------------*/
-#ifndef variableHeatTransfer_H
-#define variableHeatTransfer_H
+#ifndef heatTransferModels_variable_H
+#define heatTransferModels_variable_H
-#include "interRegionHeatTransferModel.H"
+#include "heatTransferModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -59,19 +74,21 @@ namespace Foam
{
namespace fv
{
+namespace heatTransferModels
+{
/*---------------------------------------------------------------------------*\
- Class variableHeatTransfer Declaration
+ Class variable Declaration
\*---------------------------------------------------------------------------*/
-class variableHeatTransfer
+class variable
:
- public interRegionHeatTransferModel
+ public heatTransferModel
{
// Private Data
//- Name of neighbour velocity field; default = U
- word UNbrName_;
+ word UName_;
//- Model constant
scalar a_;
@@ -82,14 +99,14 @@ class variableHeatTransfer
//- Model constant
scalar c_;
- //- Strut diameter
- scalar ds_;
+ //- Length scale
+ dimensionedScalar L_;
//- Fluid Prandtl number
- scalar Pr_;
+ dimensionedScalar Pr_;
- //- Area per unit volume of heat exchanger
- autoPtr AoV_;
+ //- Heat transfer coefficient [W/m^2/K]
+ volScalarField htc_;
// Private Member Functions
@@ -97,34 +114,37 @@ class variableHeatTransfer
//- Non-virtual read
void readCoeffs();
- //- Correct the heat transfer coefficient
- virtual void correctHtc() const;
-
public:
//- Runtime type information
- TypeName("variableHeatTransfer");
+ TypeName("variable");
// Constructors
- //- Construct from dictionary
- variableHeatTransfer
- (
- const word& name,
- const word& modelType,
- const dictionary& dict,
- const fvMesh& mesh
- );
+ //- Construct from dictionary and mesh
+ variable(const dictionary& dict, const fvMesh& mesh);
+
+ //- Construct from dictionary and model
+ variable(const dictionary& dict, const interRegionModel& model);
//- Destructor
- virtual ~variableHeatTransfer();
+ virtual ~variable();
// Member Functions
+ //- Get the heat transfer coefficient
+ virtual tmp htc() const
+ {
+ return htc_;
+ }
+
+ //- Correct the heat transfer coefficient
+ virtual void correct();
+
//- Read dictionary
virtual bool read(const dictionary& dict);
};
@@ -132,6 +152,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+} // End namespace heatTransferModels
} // End namespace fv
} // End namespace Foam
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.C b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.C
new file mode 100644
index 0000000000..521a2184d3
--- /dev/null
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.C
@@ -0,0 +1,229 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2011-2021 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "interRegionHeatTransfer.H"
+#include "basicThermo.H"
+#include "fvmSup.H"
+#include "zeroGradientFvPatchFields.H"
+#include "fvcVolumeIntegrate.H"
+#include "fvModels.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace fv
+{
+ defineTypeNameAndDebug(interRegionHeatTransfer, 0);
+ addToRunTimeSelectionTable
+ (
+ fvModel,
+ interRegionHeatTransfer,
+ dictionary
+ );
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+void Foam::fv::interRegionHeatTransfer::readCoeffs()
+{
+ semiImplicit_ = coeffs().lookup("semiImplicit");
+
+ TName_ = coeffs().lookupOrDefault("T", "T");
+ TNbrName_ = coeffs().lookupOrDefault("TNbr", "T");
+
+ if (master())
+ {
+ heatTransferModel_ = heatTransferModel::New(coeffs(), *this);
+ }
+}
+
+
+const Foam::fv::heatTransferModel&
+Foam::fv::interRegionHeatTransfer::nbrHeatTransferModel() const
+{
+ return
+ refCast(nbrModel()).heatTransferModel_;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::fv::interRegionHeatTransfer::interRegionHeatTransfer
+(
+ const word& name,
+ const word& modelType,
+ const dictionary& dict,
+ const fvMesh& mesh
+)
+:
+ interRegionModel(name, modelType, dict, mesh),
+ semiImplicit_(false),
+ TName_(word::null),
+ TNbrName_(word::null),
+ heatTransferModel_(nullptr)
+{
+ readCoeffs();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::fv::interRegionHeatTransfer::~interRegionHeatTransfer()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::wordList Foam::fv::interRegionHeatTransfer::addSupFields() const
+{
+ const basicThermo& thermo =
+ mesh().lookupObject(basicThermo::dictName);
+
+ return wordList(1, thermo.he().name());
+}
+
+
+void Foam::fv::interRegionHeatTransfer::addSup
+(
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ const volScalarField& he = eqn.psi();
+
+ const volScalarField& T =
+ mesh().lookupObject(TName_);
+ const volScalarField& Tnbr =
+ nbrMesh().lookupObject(TNbrName_);
+
+ tmp tTnbrMapped =
+ volScalarField::New(TName_ + "nbrMapped", T);
+ interpolate(Tnbr, tTnbrMapped->primitiveFieldRef());
+ volScalarField& TnbrMapped = tTnbrMapped.ref();
+
+ // Get the heat transfer coefficient field
+ tmp tHtcAoV;
+ if (master())
+ {
+ tmp mask =
+ volScalarField::New
+ (
+ "mask",
+ mesh(),
+ dimensionedScalar(dimless, 0)
+ );
+ tmp oneNbr =
+ volScalarField::New
+ (
+ "one",
+ nbrMesh(),
+ dimensionedScalar(dimless, 1)
+ );
+ interpolate(oneNbr(), mask.ref().primitiveFieldRef());
+ tHtcAoV =
+ mask
+ *heatTransferModel_->htc()
+ *heatTransferModel_->AoV();
+ }
+ else
+ {
+ tmp tHtcNbr =
+ nbrHeatTransferModel().htc()
+ *nbrHeatTransferModel().AoV();
+ tHtcAoV =
+ volScalarField::New
+ (
+ tHtcNbr().name(),
+ mesh(),
+ dimensionedScalar(tHtcNbr().dimensions(), 0)
+ );
+ interpolate(tHtcNbr(), tHtcAoV.ref().primitiveFieldRef());
+ }
+ const volScalarField& htcAoV = tHtcAoV();
+
+ if (semiImplicit_)
+ {
+ if (he.dimensions() == dimEnergy/dimMass)
+ {
+ const basicThermo& thermo =
+ mesh().lookupObject(basicThermo::dictName);
+
+ const volScalarField htcAoVByCpv(htcAoV/thermo.Cpv());
+
+ eqn +=
+ htcAoV*(TnbrMapped - T)
+ + htcAoVByCpv*he - fvm::Sp(htcAoVByCpv, he);
+ }
+ else if (he.dimensions() == dimTemperature)
+ {
+ eqn += htcAoV*TnbrMapped - fvm::Sp(htcAoV, he);
+ }
+ }
+ else
+ {
+ eqn += htcAoV*(TnbrMapped - T);
+ }
+}
+
+
+void Foam::fv::interRegionHeatTransfer::addSup
+(
+ const volScalarField& rho,
+ fvMatrix& eqn,
+ const word& fieldName
+) const
+{
+ addSup(eqn, fieldName);
+}
+
+
+void Foam::fv::interRegionHeatTransfer::correct()
+{
+ if (master())
+ {
+ heatTransferModel_->correct();
+ }
+}
+
+
+bool Foam::fv::interRegionHeatTransfer::read(const dictionary& dict)
+{
+ if (interRegionModel::read(dict))
+ {
+ readCoeffs();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.H b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.H
similarity index 57%
rename from src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.H
rename to src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.H
index 92be3c792f..c7baf6516f 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.H
+++ b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransfer.H
@@ -22,23 +22,60 @@ License
along with OpenFOAM. If not, see .
Class
- Foam::fv::interRegionHeatTransferModel
+ Foam::fv::interRegionHeatTransfer
Description
- Base class for inter region heat exchange. The derived classes must
- provide the heat transfer coefficient (htc) which is used as follows
- in the energy equation:
+ Model for inter-region heat exchange. Requires specification of a model for
+ the heat transfer coefficient (htc) and the area per unit volume (AoV).
+ These are then used to apply the following source to the energy equation:
+
\f[
- -htc*T_{mapped} + Sp(htc, T)
+ -htc*AoV*(T_{nbr,mapped} - T)
\f]
+ If the semiImplicit option is set, then this becomes:
+
+ \f[
+ -htc*AoV*(T_{nbr,mapped} - T) + htc*AoV/Cp*h - Sp(htc*AoV/Cp, h);
+ \f]
+
+Usage
+ Example usage:
+ \verbatim
+ interRegionHeatTransfer
+ {
+ type interRegionHeatTransfer;
+
+ interRegionHeatTransferCoeffs
+ {
+ nbrRegion other;
+
+ interpolationMethod cellVolumeWeight;
+ master true;
+
+ semiImplicit no;
+
+ type constant;
+
+ AoV 200;
+ htc 10;
+ }
+ }
+ \endverbatim
+
+See also
+ fv::heatTransferModel
+
+SourceFiles
+ interRegionHeatTransfer.C
+
\*---------------------------------------------------------------------------*/
-#ifndef interRegionHeatTransferModel_H
-#define interRegionHeatTransferModel_H
+#ifndef interRegionHeatTransfer_H
+#define interRegionHeatTransfer_H
#include "interRegionModel.H"
-#include "volFields.H"
+#include "heatTransferModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -48,21 +85,15 @@ namespace fv
{
/*---------------------------------------------------------------------------*\
- Class interRegionHeatTransferModel Declaration
+ Class interRegionHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
-class interRegionHeatTransferModel
+class interRegionHeatTransfer
:
public interRegionModel
{
// Private data
- //- Name of the model in the neighbour mesh
- word nbrModelName_;
-
- //- Time index - used for updating htc
- mutable label timeIndex_;
-
//- Flag to activate semi-implicit coupling
bool semiImplicit_;
@@ -72,75 +103,34 @@ class interRegionHeatTransferModel
//- Name of neighbour temperature field; default = "T"
word TNbrName_;
+ //- The heat transfer model
+ autoPtr heatTransferModel_;
+
// Private member functions
//- Non-virtual read
void readCoeffs();
- //- Get the neighbour interRegionHeatTransferModel
- interRegionHeatTransferModel& nbrModel() const;
-
- //- Correct to calculate the inter-region heat transfer coefficient
- void correct() const;
-
- //- Correct heat transfer coefficient
- virtual void correctHtc() const = 0;
-
protected:
- // Protected data
+ // Protected member functions
- //- Heat transfer coefficient [W/m^2/k] times area/volume [1/m]
- mutable volScalarField htc_;
-
-
- // Protected Member Functions
-
- //- Interpolate field with nbrModel specified
- template
- tmp> interpolate
- (
- const interRegionHeatTransferModel& nbrModel,
- const Field& field
- ) const;
-
- //- Interpolate field without nbrModel specified
- template
- tmp> interpolate
- (
- const Field& field
- ) const;
-
- //- Interpolate field with nbrModel specified
- template
- void interpolate
- (
- const interRegionHeatTransferModel& nbrModel,
- const Field& field,
- Field& result
- ) const;
-
- //- Interpolate field without nbrModel specified
- template
- void interpolate
- (
- const Field& field,
- Field& result
- ) const;
+ //- Get the neighbour heat transfer model
+ const heatTransferModel& nbrHeatTransferModel() const;
public:
//- Runtime type information
- TypeName("interRegionHeatTransferModel");
+ TypeName("interRegionHeatTransfer");
// Constructors
//- Construct from dictionary
- interRegionHeatTransferModel
+ interRegionHeatTransfer
(
const word& name,
const word& modelType,
@@ -150,7 +140,7 @@ public:
//- Destructor
- virtual ~interRegionHeatTransferModel();
+ virtual ~interRegionHeatTransfer();
// Member Functions
@@ -188,8 +178,8 @@ public:
// Correction
- //- Inherit base class correct method to avoid clang warning
- using interRegionModel::correct;
+ //- Correct the model
+ virtual void correct();
// IO
@@ -206,16 +196,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-#include "interRegionHeatTransferModelI.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifdef NoRepository
- #include "interRegionHeatTransferModelTemplates.C"
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
#endif
// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
deleted file mode 100644
index 8b7e6a7c25..0000000000
--- a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
+++ /dev/null
@@ -1,267 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration | Website: https://openfoam.org
- \\ / A nd | Copyright (C) 2011-2021 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 .
-
-\*---------------------------------------------------------------------------*/
-
-#include "interRegionHeatTransferModel.H"
-#include "basicThermo.H"
-#include "fvmSup.H"
-#include "zeroGradientFvPatchFields.H"
-#include "fvcVolumeIntegrate.H"
-#include "fvModels.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-namespace Foam
-{
-namespace fv
-{
- defineTypeNameAndDebug(interRegionHeatTransferModel, 0);
-}
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-
-void Foam::fv::interRegionHeatTransferModel::readCoeffs()
-{
- nbrModelName_ = coeffs().lookup("nbrModel");
-
- semiImplicit_ = coeffs().lookup("semiImplicit");
-
- TName_ = coeffs().lookupOrDefault("T", "T");
- TNbrName_ = coeffs().lookupOrDefault("TNbr", "T");
-}
-
-
-Foam::fv::interRegionHeatTransferModel&
-Foam::fv::interRegionHeatTransferModel::nbrModel() const
-{
- const fvMesh& nbrMesh = mesh().time().lookupObject(nbrRegionName());
-
- const PtrListDictionary& fvModels =
- nbrMesh.lookupObject("fvModels");
-
- if (fvModels.found(nbrModelName_))
- {
- return const_cast
- (
- refCast
- (
- fvModels[nbrModelName_]
- )
- );
- }
- else
- {
- FatalErrorInFunction
- << "Neighbour model not found" << nbrModelName_
- << " in region " << nbrMesh.name() << nl
- << exit(FatalError);
-
- return const_cast
- (
- NullObjectRef()
- );
- }
-}
-
-
-void Foam::fv::interRegionHeatTransferModel::correct() const
-{
- if (master())
- {
- if (mesh().time().timeIndex() != timeIndex_)
- {
- correctHtc();
- timeIndex_ = mesh().time().timeIndex();
- }
- }
- else
- {
- nbrModel().correctHtc();
- interpolate(nbrModel().htc(), htc_);
- }
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
-(
- const word& name,
- const word& modelType,
- const dictionary& dict,
- const fvMesh& mesh
-)
-:
- interRegionModel
- (
- name,
- modelType,
- dict,
- mesh
- ),
- nbrModelName_(word::null),
- timeIndex_(-1),
- semiImplicit_(false),
- TName_(word::null),
- TNbrName_(word::null),
- htc_
- (
- IOobject
- (
- type() + ":htc",
- mesh.time().timeName(),
- mesh,
- IOobject::NO_READ,
- IOobject::NO_WRITE
- ),
- mesh,
- dimensionedScalar
- (
- dimEnergy/dimTime/dimTemperature/dimVolume,
- 0
- ),
- zeroGradientFvPatchScalarField::typeName
- )
-{
- readCoeffs();
-}
-
-
-// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
-
-Foam::fv::interRegionHeatTransferModel::~interRegionHeatTransferModel()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-Foam::wordList Foam::fv::interRegionHeatTransferModel::addSupFields() const
-{
- const basicThermo& thermo =
- mesh().lookupObject(basicThermo::dictName);
-
- return wordList(1, thermo.he().name());
-}
-
-
-void Foam::fv::interRegionHeatTransferModel::addSup
-(
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- correct();
-
- const volScalarField& he = eqn.psi();
-
- const volScalarField& T = mesh().lookupObject(TName_);
-
- tmp tTmapped
- (
- volScalarField::New(type() + ":Tmapped", T)
- );
-
- volScalarField& Tmapped = tTmapped.ref();
-
- const fvMesh& nbrMesh = mesh().time().lookupObject(nbrRegionName());
-
- const volScalarField& Tnbr =
- nbrMesh.lookupObject(TNbrName_);
-
- interpolate(Tnbr, Tmapped.primitiveFieldRef());
-
- if (debug)
- {
- Info<< "Volumetric integral of htc: "
- << fvc::domainIntegrate(htc_).value()
- << endl;
-
- if (mesh().time().writeTime())
- {
- Tmapped.write();
- htc_.write();
- }
- }
-
- if (semiImplicit_)
- {
- if (he.dimensions() == dimEnergy/dimMass)
- {
- const basicThermo& thermo =
- mesh().lookupObject(basicThermo::dictName);
-
- const volScalarField htcByCpv(htc_/thermo.Cpv());
-
- eqn += htc_*(Tmapped - T) + htcByCpv*he - fvm::Sp(htcByCpv, he);
-
- if (debug)
- {
- const dimensionedScalar energy =
- fvc::domainIntegrate(htc_*(Tmapped - T));
-
- Info<< "Energy exchange from region " << nbrMesh.name()
- << " To " << mesh().name() << " : " << energy.value()
- << endl;
- }
- }
- else if (he.dimensions() == dimTemperature)
- {
- eqn += htc_*Tmapped - fvm::Sp(htc_, he);
- }
- }
- else
- {
- eqn += htc_*(Tmapped - T);
- }
-}
-
-
-void Foam::fv::interRegionHeatTransferModel::addSup
-(
- const volScalarField& rho,
- fvMatrix& eqn,
- const word& fieldName
-) const
-{
- addSup(eqn, fieldName);
-}
-
-
-bool Foam::fv::interRegionHeatTransferModel::read(const dictionary& dict)
-{
- if (interRegionModel::read(dict))
- {
- readCoeffs();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H b/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H
deleted file mode 100644
index bbe41fb422..0000000000
--- a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelI.H
+++ /dev/null
@@ -1,35 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration | Website: https://openfoam.org
- \\ / A nd | Copyright (C) 2012-2021 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 .
-
-\*---------------------------------------------------------------------------*/
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-inline const Foam::volScalarField&
-Foam::fv::interRegionHeatTransferModel::htc() const
-{
- return htc_;
-}
-
-
-// ************************************************************************* //
diff --git a/src/fvModels/interRegionModel/interRegionModel.C b/src/fvModels/interRegion/interRegionModel/interRegionModel.C
similarity index 74%
rename from src/fvModels/interRegionModel/interRegionModel.C
rename to src/fvModels/interRegion/interRegionModel/interRegionModel.C
index 10d3a13c29..12eef984d1 100644
--- a/src/fvModels/interRegionModel/interRegionModel.C
+++ b/src/fvModels/interRegion/interRegionModel/interRegionModel.C
@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "interRegionModel.H"
+#include "fvModels.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -42,7 +43,12 @@ void Foam::fv::interRegionModel::readCoeffs()
{
master_ = coeffs().lookupOrDefault("master", true);
- nbrRegionName_ = coeffs().lookup("nbrRegionName");
+ nbrRegionName_ =
+ coeffs().lookupBackwardsCompatible
+ ({
+ "nbrRegion",
+ "nbrRegionName"
+ });
interpolationMethod_ =
meshToMesh::interpolationMethodNames_.read
@@ -60,27 +66,24 @@ void Foam::fv::interRegionModel::setMapper() const
{
Info<< indent << "- selecting inter region mapping" << endl;
- const fvMesh& nbrMesh =
- mesh().time().lookupObject(nbrRegionName_);
-
- if (mesh().name() == nbrMesh.name())
+ if (mesh().name() == nbrMesh().name())
{
FatalErrorInFunction
<< "Inter-region model selected, but local and "
<< "neighbour regions are the same: " << nl
<< " local region: " << mesh().name() << nl
- << " secondary region: " << nbrMesh.name() << nl
+ << " secondary region: " << nbrMesh().name() << nl
<< exit(FatalError);
}
- if (mesh().bounds().overlaps(nbrMesh.bounds()))
+ if (mesh().bounds().overlaps(nbrMesh().bounds()))
{
meshInterpPtr_.reset
(
new meshToMesh
(
mesh(),
- nbrMesh,
+ nbrMesh(),
interpolationMethod_,
false // not interpolating patches
)
@@ -90,7 +93,7 @@ void Foam::fv::interRegionModel::setMapper() const
{
FatalErrorInFunction
<< "regions " << mesh().name() << " and "
- << nbrMesh.name() << " do not intersect"
+ << nbrMesh().name() << " do not intersect"
<< exit(FatalError);
}
}
@@ -99,6 +102,34 @@ void Foam::fv::interRegionModel::setMapper() const
}
+const Foam::fv::interRegionModel& Foam::fv::interRegionModel::nbrModel() const
+{
+ const fvMesh& nbrMesh = mesh().time().lookupObject(nbrRegionName());
+
+ const PtrListDictionary& fvModels =
+ nbrMesh.lookupObject("fvModels");
+
+ forAll(fvModels, fvModeli)
+ {
+ if (isA(fvModels[fvModeli]))
+ {
+ const interRegionModel& model =
+ refCast(fvModels[fvModeli]);
+
+ if (model.nbrRegionName() == mesh().name())
+ {
+ return model;
+ }
+ }
+ }
+
+ FatalErrorInFunction
+ << "Neighbour model not found in region " << nbrMesh.name() << nl
+ << exit(FatalError);
+ return NullObjectRef();
+}
+
+
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::interRegionModel::interRegionModel
diff --git a/src/fvModels/interRegionModel/interRegionModel.H b/src/fvModels/interRegion/interRegionModel/interRegionModel.H
similarity index 72%
rename from src/fvModels/interRegionModel/interRegionModel.H
rename to src/fvModels/interRegion/interRegionModel/interRegionModel.H
index d96d20000c..152f8555ef 100644
--- a/src/fvModels/interRegionModel/interRegionModel.H
+++ b/src/fvModels/interRegion/interRegionModel/interRegionModel.H
@@ -77,6 +77,14 @@ class interRegionModel
void setMapper() const;
+protected:
+
+ // Protected member functions
+
+ //- Get the neighbour interRegionModel
+ const interRegionModel& nbrModel() const;
+
+
public:
//- Runtime type information
@@ -109,10 +117,48 @@ public:
//- Return const access to the neighbour region name
inline const word& nbrRegionName() const;
+ //- Return const access to the neighbour mesh
+ inline const fvMesh& nbrMesh() const;
+
//- Return const access to the mapToMap pointer
inline const meshToMesh& meshInterp() const;
+ // Interpolation
+
+ //- Interpolate field with nbrModel specified
+ template
+ tmp> interpolate
+ (
+ const interRegionModel& nbrModel,
+ const Field& field
+ ) const;
+
+ //- Interpolate field without nbrModel specified
+ template
+ tmp> interpolate
+ (
+ const Field& field
+ ) const;
+
+ //- Interpolate field with nbrModel specified
+ template
+ void interpolate
+ (
+ const interRegionModel& nbrModel,
+ const Field& field,
+ Field& result
+ ) const;
+
+ //- Interpolate field without nbrModel specified
+ template
+ void interpolate
+ (
+ const Field& field,
+ Field& result
+ ) const;
+
+
// IO
//- Read dictionary
@@ -129,6 +175,10 @@ public:
#include "interRegionModelI.H"
+#ifdef NoRepository
+ #include "interRegionModelTemplates.C"
+#endif
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
diff --git a/src/fvModels/interRegionModel/interRegionModelI.H b/src/fvModels/interRegion/interRegionModel/interRegionModelI.H
similarity index 80%
rename from src/fvModels/interRegionModel/interRegionModelI.H
rename to src/fvModels/interRegion/interRegionModel/interRegionModelI.H
index d6a6be15b8..078b387661 100644
--- a/src/fvModels/interRegionModel/interRegionModelI.H
+++ b/src/fvModels/interRegion/interRegionModel/interRegionModelI.H
@@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::fv::interRegionModel::master() const
{
@@ -31,15 +31,19 @@ inline bool Foam::fv::interRegionModel::master() const
}
-inline const Foam::word&
-Foam::fv::interRegionModel::nbrRegionName() const
+inline const Foam::word& Foam::fv::interRegionModel::nbrRegionName() const
{
return nbrRegionName_;
}
-inline const Foam::meshToMesh&
-Foam::fv::interRegionModel::meshInterp() const
+inline const Foam::fvMesh& Foam::fv::interRegionModel::nbrMesh() const
+{
+ return mesh().time().lookupObject(nbrRegionName_);
+}
+
+
+inline const Foam::meshToMesh& Foam::fv::interRegionModel::meshInterp() const
{
if (!meshInterpPtr_.valid())
{
diff --git a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelTemplates.C b/src/fvModels/interRegion/interRegionModel/interRegionModelTemplates.C
similarity index 85%
rename from src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelTemplates.C
rename to src/fvModels/interRegion/interRegionModel/interRegionModelTemplates.C
index 5d7d94c2a2..f07f1b7370 100644
--- a/src/fvModels/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelTemplates.C
+++ b/src/fvModels/interRegion/interRegionModel/interRegionModelTemplates.C
@@ -23,11 +23,15 @@ License
\*---------------------------------------------------------------------------*/
+#include "interRegionModel.H"
+
+// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+
template
Foam::tmp>
-Foam::fv::interRegionHeatTransferModel::interpolate
+Foam::fv::interRegionModel::interpolate
(
- const interRegionHeatTransferModel& nbrModel,
+ const interRegionModel& nbrModel,
const Field& field
) const
{
@@ -44,7 +48,7 @@ Foam::fv::interRegionHeatTransferModel::interpolate
template
Foam::tmp>
-Foam::fv::interRegionHeatTransferModel::interpolate
+Foam::fv::interRegionModel::interpolate
(
const Field& field
) const
@@ -54,9 +58,9 @@ Foam::fv::interRegionHeatTransferModel::interpolate
template
-void Foam::fv::interRegionHeatTransferModel::interpolate
+void Foam::fv::interRegionModel::interpolate
(
- const interRegionHeatTransferModel& nbrModel,
+ const interRegionModel& nbrModel,
const Field& field,
Field& result
) const
@@ -73,7 +77,7 @@ void Foam::fv::interRegionHeatTransferModel::interpolate
template
-void Foam::fv::interRegionHeatTransferModel::interpolate
+void Foam::fv::interRegionModel::interpolate
(
const Field& field,
Field& result
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvModels b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvModels
index f067248de8..d574c9c983 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvModels
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvModels
@@ -17,14 +17,17 @@ FoamFile
airToporous
{
- type constantHeatTransfer;
+ type interRegionHeatTransfer;
- interpolationMethod cellVolumeWeight;
- nbrRegionName porous;
- master false;
+ interRegionHeatTransferCoeffs
+ {
+ nbrRegion porous;
- nbrModel porousToair;
- semiImplicit no;
+ interpolationMethod cellVolumeWeight;
+ master false;
+
+ semiImplicit no;
+ }
}
porosityBlockage
@@ -33,8 +36,9 @@ porosityBlockage
interRegionExplicitPorositySourceCoeffs
{
+ nbrRegion porous;
+
interpolationMethod cellVolumeWeight;
- nbrRegionName porous;
type DarcyForchheimer;
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/AoV b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/AoV
deleted file mode 100644
index 22e6e050e6..0000000000
--- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/AoV
+++ /dev/null
@@ -1,31 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration | Website: https://openfoam.org
- \\ / A nd | Version: dev
- \\/ M anipulation |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
- version 2.0;
- format ascii;
- class volScalarField;
- location "constant";
- object AoV;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions [0 -1 0 0 0 0 0];
-
-internalField uniform 200;
-
-boundaryField
-{
- ".*"
- {
- type zeroGradient;
- }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/fvModels b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/fvModels
index 88f2de83f8..643cbe2be2 100644
--- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/fvModels
+++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/fvModels
@@ -17,14 +17,22 @@ FoamFile
porousToair
{
- type constantHeatTransfer;
+ type interRegionHeatTransfer;
- interpolationMethod cellVolumeWeight;
- nbrRegionName air;
- master true;
+ interRegionHeatTransferCoeffs
+ {
+ nbrRegion air;
- nbrModel airToporous;
- semiImplicit no;
+ interpolationMethod cellVolumeWeight;
+ master true;
+
+ semiImplicit no;
+
+ type constant;
+
+ htc 10;
+ AoV 200;
+ }
}
diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/htcConst b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/htcConst
deleted file mode 100644
index 2eb6ce652b..0000000000
--- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/porous/htcConst
+++ /dev/null
@@ -1,31 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration | Website: https://openfoam.org
- \\ / A nd | Version: dev
- \\/ M anipulation |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
- version 2.0;
- format ascii;
- class volScalarField;
- location "constant";
- object htcConst;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions [1 0 -3 -1 0 0 0];
-
-internalField uniform 10;
-
-boundaryField
-{
- ".*"
- {
- type zeroGradient;
- }
-}
-
-
-// ************************************************************************* //