ENH: Creation of fieldSources lib. Remove of fieldSources from

/src/finiteVolume/cfdTools/general
This commit is contained in:
sergio
2012-01-10 15:30:44 +00:00
parent 2b320a5488
commit 8267f356b2
51 changed files with 1418 additions and 13 deletions

View File

@ -0,0 +1,28 @@
basicSource/basicSource/basicSource.C
basicSource/basicSource/basicSourceIO.C
basicSource/basicSource/basicSourceList.C
basicSource/basicSource/IObasicSourceList.C
basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C
basicSource/pressureGradientExplicitSource/pressureGradientExplicitSourceIO.C
basicSource/explicitSource/explicitSource.C
basicSource/explicitSetValue/explicitSetValue.C
basicSource/rotorDiskSource/rotorDiskSource.C
basicSource/rotorDiskSource/bladeModel/bladeModel.C
basicSource/rotorDiskSource/profileModel/profileModel.C
basicSource/rotorDiskSource/profileModel/profileModelList.C
basicSource/rotorDiskSource/profileModel/lookup/lookupProfile.C
basicSource/rotorDiskSource/profileModel/series/seriesProfile.C
basicSource/actuationDiskSource/actuationDiskSource.C
basicSource/radialActuationDiskSource/radialActuationDiskSource.C
interRegion = basicSource/interRegionHeatTransferModel
$(interRegion)/interRegionHeatTransferModel/interRegionHeatTransferModel.C
$(interRegion)/constantHeatTransfer/constantHeatTransfer.C
$(interRegion)/tabulatedHeatTransfer/tabulatedHeatTransfer.C
$(interRegion)/variableHeatTransfer/variableHeatTransfer.C
LIB = $(FOAM_LIBBIN)/libfieldSources

View File

@ -0,0 +1,17 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels
LIB_LIBS = \
-lfiniteVolume \
-lsampling \
-lmeshTools \
-lbasicSolidThermo \
-lcompressibleTurbulenceModel

View File

@ -38,16 +38,17 @@ namespace Foam
template<> const char* NamedEnum
<
basicSource::selectionModeType,
4
5
>::names[] =
{
"points",
"cellSet",
"cellZone",
"mapRegion",
"all"
};
const NamedEnum<basicSource::selectionModeType, 4>
const NamedEnum<basicSource::selectionModeType, 5>
basicSource::selectionModeTypeNames_;
}
@ -73,6 +74,13 @@ void Foam::basicSource::setSelection(const dictionary& dict)
dict.lookup("cellZone") >> cellSetName_;
break;
}
case smMapRegion:
{
dict_.lookup("secondarySourceName") >> secondarySourceName_;
dict_.lookup("mapRegionName") >> mapRegionName_;
master_ = readBool(dict_.lookup("master"));
break;
}
case smAll:
{
break;
@ -151,6 +159,47 @@ void Foam::basicSource::setCellSet()
break;
}
case smMapRegion:
{
if(active_)
{
Info<< indent << "- selecting inter region mapping" << endl;
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const boundBox primaryBB = mesh_.bounds();
const boundBox secondaryBB = secondaryMesh.bounds();
if (secondaryBB.overlaps(primaryBB))
{
// Dummy patches
wordList cuttingPatches;
HashTable<word> patchMap;
secondaryToPrimaryInterpPtr_.reset
(
new meshToMesh
(
secondaryMesh,
mesh_,
patchMap,
cuttingPatches
)
);
}
else
{
FatalErrorIn
(
"Foam::basicSource::setCellSet()"
) << "regions dont overlap "
<< secondaryMesh.name()
<< " in region " << mesh_.name()
<< nl
<< exit(FatalError);
}
}
break;
}
case smAll:
{
Info<< indent << "- selecting all cells" << endl;
@ -169,16 +218,19 @@ void Foam::basicSource::setCellSet()
}
// Set volume information
V_ = 0.0;
forAll(cells_, i)
if(selectionMode_ != smMapRegion)
{
V_ += mesh_.V()[cells_[i]];
}
reduce(V_, sumOp<scalar>());
V_ = 0.0;
forAll(cells_, i)
{
V_ += mesh_.V()[cells_[i]];
}
reduce(V_, sumOp<scalar>());
Info<< indent << "- selected "
<< returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
Info<< indent << "- selected "
<< returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
}
}
@ -205,6 +257,11 @@ Foam::basicSource::basicSource
),
cellSetName_("none"),
V_(0.0),
secondaryToPrimaryInterpPtr_(),
secondarySourceName_("none"),
mapRegionName_("none"),
master_(false),
fieldNames_(),
applied_()
{
@ -246,6 +303,13 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
return autoPtr<basicSource>(cstrIter()(name, modelType, coeffs, mesh));
}
Foam::basicSource::~basicSource()
{
if (!secondaryToPrimaryInterpPtr_.empty())
{
secondaryToPrimaryInterpPtr_.clear();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -32,6 +32,7 @@ Description
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
// mapRegion
On evaluation, source expects to be added to the rhs of the equation
@ -48,6 +49,8 @@ SourceFiles
#include "fvMatricesFwd.H"
#include "cellSet.H"
#include "autoPtr.H"
#include "meshToMesh.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -57,6 +60,7 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
Class basicSource Declaration
\*---------------------------------------------------------------------------*/
@ -73,11 +77,13 @@ public:
smPoints,
smCellSet,
smCellZone,
smMapRegion,
smAll
};
//- Word list of selection mode type names
static const NamedEnum<selectionModeType, 4> selectionModeTypeNames_;
static const NamedEnum<selectionModeType, 5>
selectionModeTypeNames_;
protected:
@ -120,6 +126,21 @@ protected:
//- Sum of cell volumes
scalar V_;
// Data for smMapRegion only
//- Mesh to mesh mapping for map optiom
autoPtr<meshToMesh> secondaryToPrimaryInterpPtr_;
//- Name of the source in the secondary mesh
word secondarySourceName_;
//- Name of the region to map
word mapRegionName_;
//- Master or slave region
bool master_;
//- Field names to apply source to - populated by derived models
wordList fieldNames_;
@ -227,8 +248,8 @@ public:
//- Destructor
virtual ~basicSource()
{}
virtual ~basicSource();
// Member Functions
@ -266,6 +287,15 @@ public:
//- Return const access to the total cell volume
inline scalar V() const;
//- Return const access to the secondarySourceName
inline const word secondarySourceName() const;
//- Return const access to the mapToMap Ptr
inline const autoPtr<meshToMesh> secondaryToPrimaryInterpPtr() const;
//- Return const referenc to the mapRegion
inline const word mapRegionName() const;
//- Return const access to the cell set
inline const labelList& cells() const;

View File

@ -118,4 +118,21 @@ inline Foam::scalar& Foam::basicSource::duration()
}
inline const Foam::word Foam::basicSource::secondarySourceName() const
{
return secondarySourceName_;
}
inline const Foam::autoPtr<Foam::meshToMesh> Foam::basicSource::
secondaryToPrimaryInterpPtr() const
{
return secondaryToPrimaryInterpPtr_;
}
inline const Foam::word Foam::basicSource::mapRegionName() const
{
return mapRegionName_;
}
// ************************************************************************* //

View File

@ -72,6 +72,10 @@ void Foam::basicSource::writeData(Ostream& os) const
{
break;
}
case smMapRegion:
{
break;
}
default:
{
FatalErrorIn("basicSource::writeData(Ostream&) const")

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
#include "constantHeatTransfer.H"
#include "fvm.H"
#include "IObasicSourceList.H"
#include "addToRunTimeSelectionTable.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(constantHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
constantHeatTransfer,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::constantHeatTransfer::constantHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
htCoeffs_(),
area_()
{
if (master_)
{
htCoeffs_.reset
(
new volScalarField
(
IOobject
(
"htCoeffs",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
);
area_.reset
(
new volScalarField
(
IOobject
(
"area",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
);
htc_.internalField() = htCoeffs_()*area_()/mesh_.V();
htc_.correctBoundaryConditions();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::constantHeatTransfer::~constantHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField>Foam::constantHeatTransfer::
calculateHtc()
{
return htc_;
}
void Foam::constantHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os << indent << "constantHeatTransfer";
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::constantHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::constantHeatTransfer
Description
Constant heat transfer model. htCoeffs [W/m2/K] and area [m2] must be
provided.
\*---------------------------------------------------------------------------*/
#ifndef constantHeatTransfer_H
#define constantHeatTransfer_H
#include "interRegionHeatTransferModel.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class constantHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class constantHeatTransfer
:
public interRegionHeatTransferModel
{
private:
// Private data
//- Heat transfer coefficient
autoPtr<volScalarField> htCoeffs_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
public:
//- Runtime type information
TypeName("constantHeatTransfer");
// Constructors
//- Construct from dictionary
constantHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~constantHeatTransfer();
// Public Functions
//- Calculate the heat transfer coefficient
virtual const tmp<volScalarField> calculateHtc();
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict) ;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,273 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
#include "interRegionHeatTransferModel.H"
#include "basicThermo.H"
#include "fvm.H"
#include "IObasicSourceList.H"
#include "zeroGradientFvPatchFields.H"
#include "fvcVolumeIntegrate.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(interRegionHeatTransferModel, 0);
};
// * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
void Foam::interRegionHeatTransferModel::check()
{
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
const basicSourceList& IObsl =
secondaryMesh.lookupObject<basicSourceList>
(
"sourcesProperties"
);
const PtrList<basicSource>& bsl = IObsl;
bool secSourceFound(false);
forAll(bsl, i)
{
if (bsl[i].name() == secondarySourceName_)
{
secIrht_ = &const_cast<interRegionHeatTransferModel&>
(
refCast<const interRegionHeatTransferModel>(bsl[i])
);
secSourceFound = true;
break;
}
}
if(!secSourceFound)
{
FatalErrorIn
(
"constantHeatTransfer::interRegionHeatTransferModel"
"("
" const word& name,"
" const word& modelType,"
" const dictionary& dict,"
" const fvMesh& mesh"
")"
) << "Secondary source name not found" << secondarySourceName_
<< " in region " << secondaryMesh.name()
<< nl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::interRegionHeatTransferModel::interRegionHeatTransferModel
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, modelType, dict, mesh),
secIrht_(),
firstIter_(true),
htc_
(
IOobject
(
"htc",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar
(
"htc",
dimEnergy/dimTime/dimTemperature/dimVolume,
0.0
),
zeroGradientFvPatchScalarField::typeName
)
{
coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false);
}
Foam::interRegionHeatTransferModel::~interRegionHeatTransferModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::interRegionHeatTransferModel::addSup
(
fvMatrix<scalar>& eEqn,
const label fieldI
)
{
if (firstIter_)
{
check();
firstIter_ = false;
}
const volScalarField& h = eEqn.psi();
tmp<volScalarField> tTmapped
(
new volScalarField
(
IOobject
(
"Tmapped" + mesh_.name(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("T", dimTemperature, 0.0)
)
);
volScalarField& Tmapped = tTmapped();
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName_);
basicThermo& secondaryThermo =
const_cast<basicThermo&>
(
secondaryMesh.lookupObject<basicThermo>("thermophysicalProperties")
);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
Tmapped,
secondaryThermo.T(),
meshToMesh::MAP,
eqOp<scalar>()
);
if (!master_)
{
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htc_,
secIrht_->calculateHtc(),
meshToMesh::CELL_VOLUME_WEIGHT,
eqOp<scalar>()
);
}
if (debug)
{
Info<< " Volumetric integral of htc : "
<< fvc::domainIntegrate(htc_).value()
<< endl;
}
//SAF: temporarily output
if (mesh_.time().outputTime())
{
Tmapped.write();
htc_.write();
}
if (h.dimensions() == dimEnergy/dimMass)
{
const basicThermo& primaryThermo =
mesh_.lookupObject<basicThermo>("thermophysicalProperties");
eEqn += htc_*Tmapped - fvm::Sp(htc_/primaryThermo.Cp(), h);
if (debug)
{
Info<< " Energy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate
(
htc_*(h/primaryThermo.Cp() - Tmapped)
).value()
<< endl;
}
}
else if(h.dimensions() == dimTemperature)
{
eEqn += htc_*Tmapped - fvm::Sp(htc_, h);
if (debug)
{
Info<< " Enegy exchange from region " << secondaryMesh.name()
<< " To " << mesh_.name() << " : "
<< fvc::domainIntegrate(htc_*(h - Tmapped)).value()
<< endl;
}
}
}
void Foam::interRegionHeatTransferModel::writeData(Ostream& os) const
{
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
os.writeKeyword("mapRegionName") << mapRegionName_
<< token::END_STATEMENT << nl;
os.writeKeyword("secondarySourceName") << secondarySourceName_
<< token::END_STATEMENT << nl;
os.writeKeyword("master") << master_ << token::END_STATEMENT << nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
dict_.write(os);
}
bool Foam::interRegionHeatTransferModel::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::interRegionHeatTransferModel
Description
Base class for inter region heat exchange. The derived classes must
provide the heat transfer coefficient (htc)
NOTE: mapToMap does to work in paralell
\*---------------------------------------------------------------------------*/
#ifndef interRegionHeatTransferModel_H
#define interRegionHeatTransferModel_H
#include "basicSource.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class interRegionHeatTransferModel Declaration
\*---------------------------------------------------------------------------*/
class interRegionHeatTransferModel
:
public basicSource
{
private:
// Private data
//- Pointer to secondary interRegionHeatTransferModel
interRegionHeatTransferModel* secIrht_;
//- First iteration
bool firstIter_;
// Private members
//- Check coupled interRegionHeatTransferModel
void check();
protected:
// Protected data
//- Heat transfer coefficient [W/m2/k] by area/volume [1/m]
// registered on the master mesh
volScalarField htc_;
public:
//- Runtime type information
TypeName("interRegionHeatTransferModel");
// Constructors
//- Construct from dictionary
interRegionHeatTransferModel
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~interRegionHeatTransferModel();
// Member Functions
// Access
//- Return the heat transfer coefficient
const volScalarField& htc() const
{
return htc_;
}
//-Source term to fvMatrix<scalar>
virtual void addSup(fvMatrix<scalar>& eEqn, const label fieldI);
//- Calculate heat transfer coefficient
virtual const tmp<volScalarField> calculateHtc() = 0;
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
#include "tabulatedHeatTransfer.H"
#include "turbulenceModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(tabulatedHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
tabulatedHeatTransfer,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tabulatedHeatTransfer::tabulatedHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
hTable_(),
area_()
{
if (master_)
{
hTable_.reset
(
new interpolation2DTable<scalar>
(
dict.subDict(typeName + "Coeffs")
)
);
area_.reset
(
new volScalarField
(
IOobject
(
"area",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tabulatedHeatTransfer::~tabulatedHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField>Foam::tabulatedHeatTransfer::
calculateHtc()
{
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName());
const volVectorField& Usecondary =
secondaryMesh.lookupObject<volVectorField>("U");
scalarField UMagMapped(htc_.internalField().size(), 0.0);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
UMagMapped,
mag(Usecondary),
meshToMesh::MAP,
eqOp<scalar>()
);
const volVectorField& U = mesh_.lookupObject<volVectorField>("U");
forAll (htc_.internalField(), i)
{
htc_.internalField()[i] =
hTable_->operator()(mag(U[i]), UMagMapped[i]);
}
htc_.internalField() = htc_*area_/mesh_.V();
return htc_;
}
void Foam::tabulatedHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os << indent << "tabulatedHeatTransfer";
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::tabulatedHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::tabulatedHeatTransfer
Description
Tabulated heat transfer model. The heat exchange area must be
provided. The 2D table look for heat transfer coefficients uses the
primary and secondary region velocities
\*---------------------------------------------------------------------------*/
#ifndef tabulatedHeatTransfer_H
#define tabulatedHeatTransfer_H
#include "interRegionHeatTransferModel.H"
#include "autoPtr.H"
#include "interpolation2DTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tabulatedHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class tabulatedHeatTransfer
:
public interRegionHeatTransferModel
{
private:
// Private data
//- 2D look up table
autoPtr<interpolation2DTable<scalar> > hTable_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
public:
//- Runtime type information
TypeName("tabulatedHeatTransfer");
// Constructors
//- Construct from dictionary
tabulatedHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~tabulatedHeatTransfer();
// Public Functions
//- Calculate the heat transfer coefficient
virtual const tmp<volScalarField> calculateHtc();
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict) ;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
\*---------------------------------------------------------------------------*/
#include "variableHeatTransfer.H"
#include "IObasicSourceList.H"
#include "turbulenceModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(variableHeatTransfer, 0);
addToRunTimeSelectionTable
(
basicSource,
variableHeatTransfer,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::variableHeatTransfer::variableHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
interRegionHeatTransferModel(name, modelType, dict, mesh),
a_(0),
b_(0),
c_(0),
ds_(0),
Pr_(0),
area_()
{
if (master_)
{
a_ = readScalar(dict_.lookup("a"));
b_ = readScalar(dict_.lookup("b"));
c_ = readScalar(dict_.lookup("c"));
ds_ = readScalar(dict_.lookup("ds"));
Pr_ = readScalar(dict_.lookup("Pr"));
area_.reset
(
new volScalarField
(
IOobject
(
"area",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::variableHeatTransfer::~variableHeatTransfer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::tmp<Foam::volScalarField> Foam::variableHeatTransfer::
calculateHtc()
{
const fvMesh& secondaryMesh =
mesh_.time().lookupObject<fvMesh>(mapRegionName());
const compressible::turbulenceModel& turb =
secondaryMesh.lookupObject<compressible::turbulenceModel>
(
"turbulenceModel"
);
const basicThermo& secondaryThermo =
secondaryMesh.lookupObject<basicThermo>
(
"thermophysicalProperties"
);
const volVectorField& U =
secondaryMesh.lookupObject<volVectorField>("U");
const volScalarField Re
(
mag(U)*ds_*secondaryThermo.rho()/turb.mut()
);
const volScalarField Nu(a_*pow(Re, b_)*pow(Pr_, c_));
const volScalarField K(turb.alphaEff()*secondaryThermo.Cp());
scalarField htcMapped(htc_.internalField().size(), 0.0);
secondaryToPrimaryInterpPtr_->interpolateInternalField
(
htcMapped,
Nu*K/ds_,
meshToMesh::MAP,
eqOp<scalar>()
);
htc_.internalField() = htcMapped*area_/mesh_.V();
return htc_;
}
void Foam::variableHeatTransfer::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
interRegionHeatTransferModel::writeData(os);
os.writeKeyword("a") << a_ << token::END_STATEMENT << nl;
os.writeKeyword("b") << b_ << token::END_STATEMENT << nl;
os.writeKeyword("c") << c_ << token::END_STATEMENT << nl;
os.writeKeyword("ds") << ds_ << token::END_STATEMENT << nl;
os.writeKeyword("Pr") << Pr_ << token::END_STATEMENT << nl;
os << indent << "variableHeatTransfer";
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::variableHeatTransfer::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("a", a_);
subDictCoeffs.readIfPresent("b", b_);
subDictCoeffs.readIfPresent("c", c_);
subDictCoeffs.readIfPresent("ds", ds_);
subDictCoeffs.readIfPresent("Pr", Pr_);
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 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/>.
Class
Foam::variableHeatTransfer
Description
Variable heat transfer model depending on local values. The area of contact
between regions (area) must be provided. The Nu number is calculated as:
Nu = a*pow(Re, b)*pow(Pr, c)
and the heat transfer coefficient as:
htc = Nu*K/ds
where:
K is the heat conduction
ds is the strut diameter
\*---------------------------------------------------------------------------*/
#ifndef variableHeatTransfer_H
#define variableHeatTransfer_H
#include "interRegionHeatTransferModel.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class variableHeatTransfer Declaration
\*---------------------------------------------------------------------------*/
class variableHeatTransfer
:
public interRegionHeatTransferModel
{
private:
// Private data
//- Model constants
scalar a_;
scalar b_;
scalar c_;
//- Strut diameter
scalar ds_;
//- Fluid Prandt number
scalar Pr_;
//- Area of heat exchange
autoPtr<volScalarField> area_;
public:
//- Runtime type information
TypeName("variableHeatTransfer");
// Constructors
//- Construct from dictionary
variableHeatTransfer
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~variableHeatTransfer();
// Public Functions
//- Calculate the heat transfer coefficient
virtual const tmp<volScalarField> calculateHtc();
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict) ;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //