diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index f9d90502d1b729abc916106a3261ec5af75ac56a..dcec73b26841787fb72ab1a6395e530c826a4dcf 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -1,6 +1,10 @@ +regionProperties/regionProperties.C + derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C +derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C fluid/compressibleCourantNo.C +solid/solidRegionDiffNo.C chtMultiRegionFoam.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options index 842fa2f08678232bd14e5c7633ecf30576ddb46f..4cd6539edfbc9612e34b9915a5de2365cce47059 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -2,11 +2,11 @@ EXE_INC = \ -Ifluid \ -Isolid \ -IregionProperties \ + -Iinclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ - -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ - -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel EXE_LIBS = \ -lbasicThermophysicalModels \ diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index 5a56c2709ffcbb19348eb109f4a44f95d48a20e1..b7e5c0e7c71c16d6007dc28f24dc93049ab543cd 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -37,6 +37,7 @@ Description #include "fixedGradientFvPatchFields.H" #include "regionProperties.H" #include "compressibleCourantNo.H" +#include "solidRegionDiffNo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,23 +57,24 @@ int main(int argc, char *argv[]) #include "initContinuityErrs.H" #include "readTimeControls.H" + #include "readSolidTimeControls.H" + + + #include "compressibleMultiRegionCourantNo.H" + #include "solidRegionDiffusionNo.H" + #include "setInitialMultiRegionDeltaT.H" - if (fluidRegions.size()) - { - #include "compressibleMultiRegionCourantNo.H" - #include "setInitialDeltaT.H" - } while (runTime.run()) { #include "readTimeControls.H" + #include "readSolidTimeControls.H" #include "readPIMPLEControls.H" - if (fluidRegions.size()) - { - #include "compressibleMultiRegionCourantNo.H" - #include "setDeltaT.H" - } + + #include "compressibleMultiRegionCourantNo.H" + #include "solidRegionDiffusionNo.H" + #include "setMultiRegionDeltaT.H" runTime++; @@ -117,7 +119,7 @@ int main(int argc, char *argv[]) << nl << endl; } - Info<< "End\n" << endl; + Info << "End\n" << endl; return 0; } 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 0000000000000000000000000000000000000000..5d5c8d999dcb39b1a226ef5fcd0f280a89d53192 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C @@ -0,0 +1,382 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 "directMappedPatchBase.H" +#include "regionProperties.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::interfaceOwner +( + const polyMesh& nbrRegion +) const +{ + const fvMesh& myRegion = patch().boundaryMesh().mesh(); + + const regionProperties& props = + myRegion.objectRegistry::parent().lookupObject<regionProperties> + ( + "regionProperties" + ); + + label myIndex = findIndex(props.fluidRegionNames(), myRegion.name()); + if (myIndex == -1) + { + label i = findIndex(props.solidRegionNames(), myRegion.name()); + + if (i == -1) + { + FatalErrorIn + ( + "solidWallMixedTemperatureCoupledFvPatchScalarField" + "::interfaceOwner(const polyMesh&) const" + ) << "Cannot find region " << myRegion.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::interfaceOwner(const polyMesh&) 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; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_("undefined-neighbourFieldName"), + 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<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + neighbourFieldName_(ptf.neighbourFieldName_), + KName_(ptf.KName_), + fixesValue_(ptf.fixesValue_) +{} + + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_(dict.lookup("neighbourFieldName")), + KName_(dict.lookup("K")) +{ + if (!isA<directMappedPatchBase>(this->patch().patch())) + { + FatalErrorIn + ( + "solidWallMixedTemperatureCoupledFvPatchScalarField::" + "solidWallMixedTemperatureCoupledFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField<scalar, volMesh>& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << p.type() + << "' not type '" << directMappedPatchBase::typeName << "'" + << "\n for patch " << p.name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + fixesValue_ = readBool(dict.lookup("fixesValue")); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + fixesValue_ = true; + } +} + + +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: +solidWallMixedTemperatureCoupledFvPatchScalarField +( + const solidWallMixedTemperatureCoupledFvPatchScalarField& wtcsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + neighbourFieldName_(wtcsf.neighbourFieldName_), + KName_(wtcsf.KName_), + fixesValue_(wtcsf.fixesValue_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::fvPatchScalarField& +Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::K() const +{ + return this->patch().lookupPatchField<volScalarField, scalar>(KName_); +} + + +void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + (void)distMap.schedule(); + + tmp<scalarField> intFld = patchInternalField(); + + if (interfaceOwner(nbrMesh)) + { + // Note: other side information could be cached - it only needs + // to be updated the first time round the iteration (i.e. when + // switching regions) but unfortunately we don't have this information. + + const fvPatch& nbrPatch = refCast<const fvMesh> + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + + // Calculate the temperature by harmonic averaging + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + const solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField = + refCast<const solidWallMixedTemperatureCoupledFvPatchScalarField> + ( + nbrPatch.lookupPatchField<volScalarField, scalar> + ( + neighbourFieldName_ + ) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField nbrIntFld = nbrField.patchInternalField(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrIntFld + ); + + // Swap to obtain full local values of neighbour K*delta + scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrKDelta + ); + + + tmp<scalarField> myKDelta = K()*patch().deltaCoeffs(); + + // Calculate common wall temperature. Reuse *this to store common value. + scalarField Twall + ( + (myKDelta()*intFld() + nbrKDelta*nbrIntFld) + / (myKDelta() + nbrKDelta) + ); + // Assign to me + fvPatchScalarField::operator=(Twall); + // Distribute back and assign to neighbour + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + nbrField.size(), + distMap.constructMap(), // reverse : what to send + distMap.subMap(), + Twall + ); + const_cast<solidWallMixedTemperatureCoupledFvPatchScalarField&> + ( + nbrField + ).fvPatchScalarField::operator=(Twall); + } + + + // Switch between fixed value (of harmonic avg) or gradient + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + label nFixed = 0; + + // Like snGrad but bypass switching on refValue/refGrad. + tmp<scalarField> normalGradient = (*this-intFld())*patch().deltaCoeffs(); + + if (debug) + { + scalar Q = gSum(K()*patch().magSf()*normalGradient()); + + Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" + << "updateCoeffs() :" + << " patch:" << patch().name() + << " heatFlux:" << Q + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } + + forAll(*this, i) + { + // if outgoing flux use fixed value. + if (normalGradient()[i] < 0.0) + { + this->refValue()[i] = operator[](i); + this->refGrad()[i] = 0.0; // not used by me + this->valueFraction()[i] = 1.0; + nFixed++; + } + else + { + // Fixed gradient. Make sure to have valid refValue (even though + // I am not using it - other boundary conditions might) + this->refValue()[i] = operator[](i); + this->refGrad()[i] = normalGradient()[i]; + this->valueFraction()[i] = 0.0; + } + } + + reduce(nFixed, sumOp<label>()); + + fixesValue_ = (nFixed > 0); + + if (debug) + { + label nTotSize = returnReduce(this->size(), sumOp<label>()); + + Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" + << "updateCoeffs() :" + << " patch:" << patch().name() + << " out of:" << nTotSize + << " fixedBC:" << nFixed + << " gradient:" << nTotSize-nFixed << endl; + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("neighbourFieldName")<< neighbourFieldName_ + << token::END_STATEMENT << nl; + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + os.writeKeyword("fixesValue") << fixesValue_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makePatchTypeField +( + fvPatchScalarField, + solidWallMixedTemperatureCoupledFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..f4abacf648aad7283f04baa44b8ad29f856a54db --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Class + solidWallMixedTemperatureCoupledFvPatchScalarField + +Description + Mixed boundary condition for temperature, to be used by the + conjugate heat transfer solver. + If my temperature is T1, neighbour is T2: + + T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient. + + + Example usage: + myInterfacePatchName + { + type solidWallMixedTemperatureCoupled; + neighbourFieldName T; + K K; + value uniform 300; + } + + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + + Note: lags interface data so both sides use same data. + - problem: schedule to calculate average would interfere + with standard processor swaps. + - so: updateCoeffs sets both to same Twall. Only need to do + this for last outer iteration but don't have access to this. + +SourceFiles + solidWallMixedTemperatureCoupledFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallMixedTemperatureCoupledFvPatchScalarField_H +#define solidWallMixedTemperatureCoupledFvPatchScalarField_H + +#include "fvPatchFields.H" +#include "mixedFvPatchFields.H" +#include "fvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidWallMixedTemperatureCoupledFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class solidWallMixedTemperatureCoupledFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of field on the neighbour region + const word neighbourFieldName_; + + //- Name of thermal conductivity field + const word KName_; + + bool fixesValue_; + + + // Private Member Functions + + //- Am I or neighbour owner of interface + bool interfaceOwner(const polyMesh& nbrRegion) const; + + +public: + + //- Runtime type information + TypeName("solidWallMixedTemperatureCoupled"); + + + // Constructors + + //- Construct from patch and internal field + solidWallMixedTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + solidWallMixedTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // solidWallMixedTemperatureCoupledFvPatchScalarField onto a new patch + solidWallMixedTemperatureCoupledFvPatchScalarField + ( + const solidWallMixedTemperatureCoupledFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new solidWallMixedTemperatureCoupledFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + solidWallMixedTemperatureCoupledFvPatchScalarField + ( + const solidWallMixedTemperatureCoupledFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new solidWallMixedTemperatureCoupledFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + const fvPatchScalarField& K() const; + + //- Return true if this patch field fixes a value. + // Needed to check if a level has to be specified while solving + // Poissons equations. + virtual bool fixesValue() const + { + return fixesValue_; + } + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C index 93e42ee0d5ac828e3c4bcb72769fdf83866d19e9..a3d68f55ca4d2f5ffdca0b4e995d69aeadddda94 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C @@ -47,10 +47,10 @@ Foam::scalar Foam::compressibleCourantNo / fvc::interpolate(rho); CoNum = max(SfUfbyDelta/mesh.magSf()) - .value()*runTime.deltaTValue(); + .value()*runTime.deltaT().value(); meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) - .value()*runTime.deltaTValue(); + .value()*runTime.deltaT().value(); } Info<< "Region: " << mesh.name() << " Courant Number mean: " << meanCoNum diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H index 3ca2f685819312306802794b946f5048e91e6e51..8f1f654d2b6d133a3d7adabcf77dfcf83955f59c 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H @@ -1,15 +1,18 @@ scalar CoNum = -GREAT; - forAll(fluidRegions, regionI) + if (fluidRegions.size()) { - CoNum = max - ( - compressibleCourantNo + forAll(fluidRegions, regionI) + { + CoNum = max ( - fluidRegions[regionI], - runTime, - rhoFluid[regionI], - phiFluid[regionI] - ), - CoNum - ); + compressibleCourantNo + ( + fluidRegions[regionI], + runTime, + rhoFluid[regionI], + phiFluid[regionI] + ), + CoNum + ); + } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 7c82fec14467cbda552a300bef51aa382af977af..1826a77217e86ac89941941c2d8e452d783e94fb 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -41,6 +41,24 @@ ) ); + Info<< " Adding to KFluid\n" << endl; + KFluid.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermoFluid[i].Cp()*thermoFluid[i].alpha() + ) + ); + Info<< " Adding to UFluid\n" << endl; UFluid.set ( @@ -111,24 +129,6 @@ ).ptr() ); - Info<< " Adding to KFluid\n" << endl; - KFluid.set - ( - i, - new volScalarField - ( - IOobject - ( - "K", - runTime.timeName(), - fluidRegions[i], - IOobject::NO_READ, - IOobject::NO_WRITE - ), - thermoFluid[i].Cp()*turbulence[i].alphaEff() - ) - ); - Info<< " Adding to DpDtFluid\n" << endl; DpDtFluid.set ( diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H new file mode 100644 index 0000000000000000000000000000000000000000..37bb5f9da2a8af8647c0aeaf1cbda7262b40fb2a --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setInitialMultiRegionDeltaT.H @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Global + setInitialDeltaT + +Description + Set the initial timestep for the CHT MultiRegion solver. + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ + if ((runTime.timeIndex() == 0) && ((CoNum > SMALL) || (DiNum > SMALL))) + { + + if (CoNum == -GREAT) + { + CoNum = SMALL; + } + + if (DiNum == -GREAT) + { + DiNum = SMALL; + } + + runTime.setDeltaT + ( + min + ( + min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(), + maxDeltaT + ) + ); + Info<< "deltaT = " << runTime.deltaT().value() << endl; + } +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H new file mode 100644 index 0000000000000000000000000000000000000000..fb180c713d1178be7c7a279a011231fc7c355a98 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/include/setMultiRegionDeltaT.H @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Global + setMultiRegionDeltaT + +Description + Reset the timestep to maintain a constant maximum courant and diffusion + Number. Reduction of time-step is immediate, but increase is damped to avoid + unstable oscillations. + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ + if (CoNum == -GREAT) + { + CoNum = SMALL; + } + + if (DiNum == -GREAT) + { + DiNum = SMALL; + } + + scalar maxDeltaTFluid = maxCo/(CoNum + SMALL); + scalar maxDeltaTSolid = maxDi/(DiNum + SMALL); + + scalar deltaTFluid = + min + ( + min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid), + 1.2 + ); + + runTime.setDeltaT + ( + min + ( + min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(), + maxDeltaT + ) + ); + + Info<< "deltaT = " << runTime.deltaT().value() << endl; +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C new file mode 100644 index 0000000000000000000000000000000000000000..469bf80074b01da17503da8dccc420066238e9bc --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 "regionProperties.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::regionProperties::regionProperties(const Time& runTime) +: + IOdictionary + ( + IOobject + ( + "regionProperties", + runTime.time().constant(), + runTime.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + fluidRegionNames_(lookup("fluidRegionNames")), + solidRegionNames_(lookup("solidRegionNames")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::regionProperties::~regionProperties() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::List<Foam::word>& Foam::regionProperties::fluidRegionNames() const +{ + return fluidRegionNames_; +} + + +const Foam::List<Foam::word>& Foam::regionProperties::solidRegionNames() const +{ + return solidRegionNames_; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H new file mode 100644 index 0000000000000000000000000000000000000000..f46e2fc1da1f74a7ebfcf5c184d75558ba095d12 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Class + regionProperties + +Description + Simple class to hold region information for coupled region simulations + +SourceFiles + regionProperties.C + +\*---------------------------------------------------------------------------*/ + +#ifndef regionProperties_H +#define regionProperties_H + +#include "IOdictionary.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class regionProperties Declaration +\*---------------------------------------------------------------------------*/ + +class regionProperties +: + public IOdictionary +{ + // Private data + + //- List of the fluid region names + List<word> fluidRegionNames_; + + //- List of the solid region names + List<word> solidRegionNames_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + regionProperties(const regionProperties&); + + //- Disallow default bitwise assignment + void operator=(const regionProperties&); + + +public: + + // Constructors + + //- Construct from components + regionProperties(const Time& runTime); + + + // Destructor + + ~regionProperties(); + + + // Member Functions + + // Access + + //- Return const reference to the list of fluid region names + const List<word>& fluidRegionNames() const; + + //- Return const reference to the list of solid region names + const List<word>& solidRegionNames() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidTimeControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidTimeControls.H new file mode 100644 index 0000000000000000000000000000000000000000..7007fd20d72cfe8a444a03d1b544064c86eab379 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidTimeControls.H @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Global + readSolidTimeControls + +Description + Read the control parameters used in the solid + +\*---------------------------------------------------------------------------*/ + +scalar maxDi = runTime.controlDict().lookupOrDefault<scalar>("maxDi", 10.0); + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.C new file mode 100644 index 0000000000000000000000000000000000000000..b2804da9c91f9dd19022319730fc74c2f82e1b70 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 "solidRegionDiffNo.H" +#include "fvc.H" + +Foam::scalar Foam::solidRegionDiffNo +( + const fvMesh& mesh, + const Time& runTime, + const volScalarField& Cprho, + const volScalarField& K +) +{ + scalar DiNum = 0.0; + scalar meanDiNum = 0.0; + + //- Can have fluid domains with 0 cells so do not test. + if (mesh.nInternalFaces()) + { + surfaceScalarField KrhoCpbyDelta = + mesh.surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(K) + / fvc::interpolate(Cprho); + + DiNum = max(KrhoCpbyDelta.internalField())*runTime.deltaT().value(); + + meanDiNum = (average(KrhoCpbyDelta)).value()*runTime.deltaT().value(); + } + + Info<< "Region: " << mesh.name() << " Diffusion Number mean: " << meanDiNum + << " max: " << DiNum << endl; + + return DiNum; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H new file mode 100644 index 0000000000000000000000000000000000000000..814686c7be46e0160efb61f7d23b9bdd32a38552 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffNo.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 + +Description + Calculates and outputs the mean and maximum Diffusion Numbers for the solid + regions + +\*---------------------------------------------------------------------------*/ + +#ifndef solidRegionDiff_H +#define solidRegionDiff_H + +#include "fvMesh.H" + +namespace Foam +{ + scalar solidRegionDiffNo + ( + const fvMesh& mesh, + const Time& runTime, + const volScalarField& Cprho, + const volScalarField& K + ); +} + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H new file mode 100644 index 0000000000000000000000000000000000000000..752d4e938133eada11cd80dba576911b1dd804f0 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H @@ -0,0 +1,18 @@ + scalar DiNum = -GREAT; + if (solidRegions.size())// + { + forAll(solidRegions, regionI) + { + DiNum = max + ( + solidRegionDiffNo + ( + solidRegions[regionI], + runTime, + rhosCps[regionI], + Ks[regionI] + ), + DiNum + ); + } + }