From 22393b42620e5c4e58fbd03ac33a290b15010742 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 30 Dec 2008 22:00:17 +0000 Subject: [PATCH] new bc --- .../chtMultiRegionFoam/Make/files | 2 +- .../coupleManager/coupleManager.C | 46 ++++ .../coupleManager/coupleManager.H | 6 +- ...FluxTemperatureCoupledFvPatchScalarField.C | 2 +- ...ixedTemperatureCoupledFvPatchScalarField.C | 252 ++++++++++++++++++ ...ixedTemperatureCoupledFvPatchScalarField.H | 184 +++++++++++++ ...WallTemperatureCoupledFvPatchScalarField.C | 2 +- ...WallTemperatureCoupledFvPatchScalarField.H | 2 +- .../fluid/createFluidFields.H | 2 +- .../chtMultiRegionFoam/fluid/pEqn.H | 2 +- .../chtMultiRegionFoam/solid/solveSolid.H | 3 + .../system/bottomAir/changeDictionaryDict | 24 +- .../system/changeDictionaryDict | 192 ------------- .../multiRegionHeater/system/fvSchemes | 59 ---- .../multiRegionHeater/system/fvSolution | 123 --------- .../system/heater/changeDictionaryDict | 8 +- .../system/leftSolid/changeDictionaryDict | 6 +- .../system/rightSolid/changeDictionaryDict | 6 +- .../system/topAir/changeDictionaryDict | 24 +- 19 files changed, 528 insertions(+), 417 deletions(-) create mode 100644 applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C create mode 100644 applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H delete mode 100644 tutorials/chtMultiRegionFoam/multiRegionHeater/system/changeDictionaryDict delete mode 100644 tutorials/chtMultiRegionFoam/multiRegionHeater/system/fvSchemes delete mode 100644 tutorials/chtMultiRegionFoam/multiRegionHeater/system/fvSolution diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index e924e9de68..3ee71c0ea6 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -5,7 +5,7 @@ coupleManager/coupleManager.C derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C - +derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C chtMultiRegionFoam.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C index 710a9975da..58c7bdaa39 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C @@ -26,6 +26,7 @@ License #include "coupleManager.H" #include "OFstream.H" +#include "regionProperties.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -74,6 +75,51 @@ Foam::coupleManager::~coupleManager() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +bool Foam::coupleManager::regionOwner() const +{ + const fvMesh& nbrRegion = neighbourRegion(); + + const regionProperties& props = + localRegion_.objectRegistry::parent().lookupObject + ( + "regionProperties" + ); + + label myIndex = findIndex(props.fluidRegionNames(), localRegion_.name()); + if (myIndex == -1) + { + label i = findIndex(props.solidRegionNames(), localRegion_.name()); + + if (i == -1) + { + FatalErrorIn("coupleManager::regionOwner() const") + << "Cannot find region " << localRegion_.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + myIndex = props.fluidRegionNames().size() + i; + } + label nbrIndex = findIndex(props.fluidRegionNames(), nbrRegion.name()); + if (nbrIndex == -1) + { + label i = findIndex(props.solidRegionNames(), nbrRegion.name()); + + if (i == -1) + { + FatalErrorIn("coupleManager::regionOwner() const") + << "Cannot find region " << nbrRegion.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + nbrIndex = props.fluidRegionNames().size() + i; + } + + return myIndex < nbrIndex; +} + + void Foam::coupleManager::checkCouple() const { Info<< "neighbourRegionName_ = " << neighbourRegionName_ << endl; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H index aa56dedda3..177d9006bc 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H @@ -74,9 +74,6 @@ class coupleManager // Private Member Functions - //- Disallow default bitwise copy construct -// coupleManager(const coupleManager&); - //- Disallow default bitwise assignment void operator=(const coupleManager&); @@ -129,6 +126,9 @@ public: template inline const fvPatchField& neighbourPatchField() const; + //- Am I owner (= first to evaluate) of this region interface? + bool regionOwner() const; + //- Check that the couple is valid void checkCouple() const; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C index 3fa298b511..11cf785efa 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C @@ -115,7 +115,7 @@ void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::updateCoeffs() const fvPatchField& K = patch().lookupPatchField(KName_); - gradient() = refCast + gradient() = -refCast (neighbourField).flux()/K; fixedGradientFvPatchScalarField::updateCoeffs(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C new file mode 100644 index 0000000000..ba2ee599d0 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C @@ -0,0 +1,252 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "solidWallMixedTemperatureCoupledFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "regionProperties.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + coupleManager_(p), + KName_("undefined-K") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; + this->fixesValue_ = true; +} + + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const solidWallMixedTemperatureCoupledFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + coupleManager_(ptf.coupleManager_), + KName_(ptf.KName_), + fixesValue_(ptf.fixesValue_) +{} + + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + coupleManager_(p, dict), + KName_(dict.lookup("K")) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + refValue() = static_cast(*this); + refGrad() = 0.0; + valueFraction() = 1.0; + fixesValue_ = true; +} + + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const solidWallMixedTemperatureCoupledFvPatchScalarField& wtcsf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + coupleManager_(wtcsf.coupleManager_), + KName_(wtcsf.KName_), + fixesValue_(wtcsf.fixesValue_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::fvPatchScalarField& +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::K() const +{ + return this->patch().lookupPatchField(KName_); +} + + +void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + tmp intFld = patchInternalField(); + + label nFixed = 0; + + // Like snGrad but bypass switching on refValue/refGrad. + tmp normalGradient = + (*this-intFld()) + * patch().deltaCoeffs(); + + if (debug) + { + Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" + << "updateCoeffs() :" + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } + + forAll(*this, i) + { + // if outgoing flux use fixed value. + if (intFld()[i] > operator[](i)) + { + this->refValue()[i] = operator[](i); + this->refGrad()[i] = 0.0; // not used + this->valueFraction()[i] = 1.0; + nFixed++; + } + else + { + this->refValue()[i] = 0.0; // not used + this->refGrad()[i] = normalGradient()[i]; + this->valueFraction()[i] = 0.0; + } + } + + reduce(nFixed, sumOp