diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index dcec73b26841787fb72ab1a6395e530c826a4dcf..68d70ae7187555261c2768c20fbb586f74fdf3da 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -1,7 +1,6 @@ regionProperties/regionProperties.C derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C -derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C fluid/compressibleCourantNo.C solid/solidRegionDiffNo.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C deleted file mode 100644 index 42a73343ccae04725b61e3b6b39a59adec180c63..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C +++ /dev/null @@ -1,381 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 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 "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 deleted file mode 100644 index f4766e5dc337baf2654a1386323806d8441d906a..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H +++ /dev/null @@ -1,192 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / 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 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 - 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 - -// ************************************************************************* //