From 6c9949d9e8287d02548414712b64a6e9269317f4 Mon Sep 17 00:00:00 2001 From: sergio Date: Mon, 20 Feb 2012 11:38:25 +0000 Subject: [PATCH] ENH: Modification to regionModel and thermoBaffle models and bug in externalWallHeatFlux --- .../regionModel/regionModel/regionModel.C | 77 +++++++++++-------- .../regionModel/regionModel/regionModel.H | 3 + .../regionModel/regionModel/regionModelI.H | 15 +++- .../regionModel/regionModel1D/regionModel1D.C | 7 +- .../thermoBaffle2D/thermoBaffle2D.C | 29 ++++++- .../thermoBaffle2D/thermoBaffle2D.H | 6 +- .../thermoBaffleModel/thermoBaffleModel.C | 7 ++ .../thermoBaffleModel/thermoBaffleModel.H | 5 +- ...allHeatFluxTemperatureFvPatchScalarField.C | 2 +- 9 files changed, 104 insertions(+), 47 deletions(-) diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index f7f630147e..077a15b0e0 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -44,19 +44,22 @@ namespace regionModels void Foam::regionModels::regionModel::constructMeshObjects() { // construct region mesh - regionMeshPtr_.reset - ( - new fvMesh + if (!time_.foundObject(regionName_)) + { + regionMeshPtr_.reset ( - IOobject + new fvMesh ( - lookup("regionName"), - time_.timeName(), - time_, - IOobject::MUST_READ + IOobject + ( + regionName_, + time_.timeName(), + time_, + IOobject::MUST_READ + ) ) - ) - ); + ); + } } @@ -66,19 +69,22 @@ void Foam::regionModels::regionModel::constructMeshObjects ) { // construct region mesh - regionMeshPtr_.reset - ( - new fvMesh + if (!time_.foundObject(regionName_)) + { + regionMeshPtr_.reset ( - IOobject + new fvMesh ( - dict.lookup("regionName"), - time_.timeName(), - time_, - IOobject::MUST_READ + IOobject + ( + regionName_, + time_.timeName(), + time_, + IOobject::MUST_READ + ) ) - ) - ); + ); + } } @@ -109,11 +115,18 @@ void Foam::regionModels::regionModel::initialise() nBoundaryFaces += regionPatch.faceCells().size(); - const mappedWallPolyPatch& mapPatch = - refCast(regionPatch); + const mappedPatchBase& mapPatch = + refCast(regionPatch); - const label primaryPatchI = mapPatch.samplePolyPatch().index(); - primaryPatchIDs.append(primaryPatchI); + if + ( + primaryMesh_.time().foundObject(mapPatch.sampleRegion()) + ) + { + + const label primaryPatchI = mapPatch.samplePolyPatch().index(); + primaryPatchIDs.append(primaryPatchI); + } } } @@ -197,7 +210,8 @@ Foam::regionModels::regionModel::regionModel(const fvMesh& mesh) regionMeshPtr_(NULL), coeffs_(dictionary::null), primaryPatchIDs_(), - intCoupledPatchIDs_() + intCoupledPatchIDs_(), + regionName_("none") {} @@ -228,7 +242,8 @@ Foam::regionModels::regionModel::regionModel regionMeshPtr_(NULL), coeffs_(subOrEmptyDict(modelName + "Coeffs")), primaryPatchIDs_(), - intCoupledPatchIDs_() + intCoupledPatchIDs_(), + regionName_(lookup("regionName")) { if (active_) { @@ -273,7 +288,8 @@ Foam::regionModels::regionModel::regionModel regionMeshPtr_(NULL), coeffs_(dict.subOrEmptyDict(modelName + "Coeffs")), primaryPatchIDs_(), - intCoupledPatchIDs_() + intCoupledPatchIDs_(), + regionName_(dict.lookup("regionName")) { if (active_) { @@ -312,13 +328,6 @@ void Foam::regionModels::regionModel::evolve() { if (active_) { - if (primaryMesh_.changing()) - { - FatalErrorIn("regionModel::evolve()") - << "Currently not possible to apply " << modelName_ - << " model to moving mesh cases" << nl << abort(FatalError); - } - Info<< "\nEvolving " << modelName_ << " for region " << regionMesh().name() << endl; diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H index 49f708bcd8..f8444d6cec 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.H +++ b/src/regionModels/regionModel/regionModel/regionModel.H @@ -117,6 +117,9 @@ protected: //- List of patch IDs internally coupled with the primary region labelList intCoupledPatchIDs_; + //- Region name + word regionName_; + // Protected member functions diff --git a/src/regionModels/regionModel/regionModel/regionModelI.H b/src/regionModels/regionModel/regionModel/regionModelI.H index a0e43403f7..834bbfb022 100644 --- a/src/regionModels/regionModel/regionModel/regionModelI.H +++ b/src/regionModels/regionModel/regionModel/regionModelI.H @@ -60,7 +60,11 @@ inline const Foam::word& Foam::regionModels::regionModel::modelName() const inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const { - if (!regionMeshPtr_.valid()) + if (time_.foundObject(regionName_)) + { + return time_.lookupObject(regionName_); + } + else if (!regionMeshPtr_.valid()) { FatalErrorIn ( @@ -75,7 +79,14 @@ inline const Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() const inline Foam::fvMesh& Foam::regionModels::regionModel::regionMesh() { - if (!regionMeshPtr_.valid()) + if (time_.foundObject(regionName_)) + { + return const_cast + ( + time_.lookupObject(regionName_) + ); + } + else if (!regionMeshPtr_.valid()) { FatalErrorIn ( diff --git a/src/regionModels/regionModel/regionModel1D/regionModel1D.C b/src/regionModels/regionModel/regionModel1D/regionModel1D.C index 1651b6752d..372e19a3f3 100644 --- a/src/regionModels/regionModel/regionModel1D/regionModel1D.C +++ b/src/regionModels/regionModel/regionModel1D/regionModel1D.C @@ -39,7 +39,6 @@ namespace regionModels void Foam::regionModels::regionModel1D::constructMeshObjects() { - const fvMesh& regionMesh = regionMeshPtr_(); nMagSfPtr_.reset ( @@ -49,11 +48,11 @@ void Foam::regionModels::regionModel1D::constructMeshObjects() ( "nMagSf", time().timeName(), - regionMesh, + regionMesh(), IOobject::NO_READ, IOobject::NO_WRITE ), - regionMesh, + regionMesh(), dimensionedScalar("zero", dimArea, 0.0) ) ); @@ -163,7 +162,7 @@ bool Foam::regionModels::regionModel1D::read(const dictionary& dict) { if (regionModel::read(dict)) { - moveMesh_.readIfPresent("moveMesh", dict); + moveMesh_.readIfPresent("moveMesh", coeffs_); return true; } diff --git a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C index d46fb80a62..3e131d84b7 100644 --- a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C +++ b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.C @@ -27,6 +27,7 @@ License #include "thermoBaffle2D.H" #include "fvm.H" +#include "fvcDiv.H" #include "addToRunTimeSelectionTable.H" #include "zeroGradientFvPatchFields.H" #include "fvMatrices.H" @@ -58,6 +59,13 @@ bool thermoBaffle2D::read() } +bool thermoBaffle2D::read(const dictionary& dict) +{ + this->solution().lookup("nNonOrthCorr") >> nNonOrthCorr_; + return regionModel1D::read(dict); +} + + void thermoBaffle2D::solveEnergy() { if (debug) @@ -128,6 +136,19 @@ void thermoBaffle2D::solveEnergy() Q ); + if (moveMesh_) + { + surfaceScalarField phiMesh + ( + fvc::interpolate(rhoCp*T_)*regionMesh().phi() + ); + + TEqn -= fvc::div(phiMesh); + } + + Info<< "T gas min/max = " << min(T_).value() << ", " + << max(T_).value() << endl; + TEqn.relax(); TEqn.solve(); @@ -157,7 +178,7 @@ thermoBaffle2D::thermoBaffle2D regionMesh().time().timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::NO_WRITE ), regionMesh(), dimensionedScalar @@ -175,7 +196,7 @@ thermoBaffle2D::thermoBaffle2D regionMesh().time().timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::NO_WRITE ), regionMesh(), dimensionedScalar @@ -209,7 +230,7 @@ thermoBaffle2D::thermoBaffle2D regionMesh().time().timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::NO_WRITE ), regionMesh(), dimensionedScalar @@ -227,7 +248,7 @@ thermoBaffle2D::thermoBaffle2D regionMesh().time().timeName(), regionMesh(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::NO_WRITE ), regionMesh(), dimensionedScalar diff --git a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H index 9143aead35..bf915ec1a2 100644 --- a/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H +++ b/src/regionModels/thermoBaffleModels/thermoBaffle2D/thermoBaffle2D.H @@ -102,9 +102,13 @@ protected: // Protected member functions - //- Read control parameters from dictionary + //- Read control parameters IO dictionary virtual bool read(); + //- Read control parameters from dictionary + virtual bool read(const dictionary& dict); + + // Equations //- Solve energy equation diff --git a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C index 7764366004..8217c9b1f5 100644 --- a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C +++ b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.C @@ -53,6 +53,13 @@ bool thermoBaffleModel::read() } +bool thermoBaffleModel::read(const dictionary& dict) +{ + regionModel1D::read(dict); + return true; +} + + void thermoBaffleModel::init() { if (active_) diff --git a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H index b9e6e020ce..ee076ec523 100644 --- a/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H +++ b/src/regionModels/thermoBaffleModels/thermoBaffleModel/thermoBaffleModel.H @@ -91,9 +91,12 @@ protected: // Protected Member Functions - //- Read control parameters from dictionary + //- Read control parameters from IO dictionary virtual bool read(); + //- Read control parameters from dictionary + virtual bool read(const dictionary&); + public: diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index 87716b72be..d611c882ce 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -230,7 +230,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() else //out { this->refGrad()[i] = 0.0; - this->refValue()[i] = KDelta[i]*q[i] + patchInternalField()()[i]; + this->refValue()[i] = q[i]/KDelta[i] + patchInternalField()()[i]; this->valueFraction()[i] = 1.0; } }