/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 . \*---------------------------------------------------------------------------*/ #include "mappedMixedFieldFvPatchField.H" #include "volFields.H" #include "interpolationCell.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::mappedMixedFieldFvPatchField::mappedMixedFieldFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : mixedFvPatchField(p, iF), mappedPatchBase(p.patch()), mappedPatchFieldBase(*this, *this), weightFieldName_() { this->refValue() = Zero; this->refGrad() = Zero; this->valueFraction() = 0.0; } template Foam::mappedMixedFieldFvPatchField::mappedMixedFieldFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : mixedFvPatchField(p, iF, dict), mappedPatchBase(p.patch(), dict), mappedPatchFieldBase(*this, *this, dict), weightFieldName_(dict.getOrDefault("weightField", word::null)) {} template Foam::mappedMixedFieldFvPatchField::mappedMixedFieldFvPatchField ( const mappedMixedFieldFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : mixedFvPatchField(ptf, p, iF, mapper), mappedPatchBase(p.patch(), ptf), mappedPatchFieldBase(*this, *this, ptf), weightFieldName_(ptf.weightFieldName_) {} template Foam::mappedMixedFieldFvPatchField::mappedMixedFieldFvPatchField ( const mappedMixedFieldFvPatchField& ptf ) : mixedFvPatchField(ptf), mappedPatchBase(ptf.patch().patch(), ptf), mappedPatchFieldBase(ptf), weightFieldName_(ptf.weightFieldName_) {} template Foam::mappedMixedFieldFvPatchField::mappedMixedFieldFvPatchField ( const mappedMixedFieldFvPatchField& ptf, const DimensionedField& iF ) : mixedFvPatchField(ptf, iF), mappedPatchBase(ptf.patch().patch(), ptf), mappedPatchFieldBase(*this, *this, ptf), weightFieldName_(ptf.weightFieldName_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::mappedMixedFieldFvPatchField::autoMap ( const fvPatchFieldMapper& m ) { mixedFvPatchField::autoMap(m); mappedPatchBase::clearOut(); } template void Foam::mappedMixedFieldFvPatchField::rmap ( const fvPatchField& ptf, const labelList& addr ) { mixedFvPatchField::rmap(ptf, addr); mappedPatchBase::clearOut(); } template void Foam::mappedMixedFieldFvPatchField::updateCoeffs() { if (this->updated()) { return; } const tmp> nbrIntFld(this->mappedInternalField()); //- Unweighted //const tmp nbrKDelta(this->mappedWeightField()); //- Weighted tmp myKDelta; tmp nbrKDelta; this->mappedWeightField(weightFieldName_, myKDelta, nbrKDelta); // Both sides agree on // - temperature : (myKDelta*fld + nbrKDelta*nbrFld)/(myKDelta+nbrKDelta) // - gradient : (temperature-fld)*delta // We've got a degree of freedom in how to implement this in a mixed bc. // (what gradient, what fixedValue and mixing coefficient) // Two reasonable choices: // 1. specify above temperature on one side (preferentially the high side) // and above gradient on the other. So this will switch between pure // fixedvalue and pure fixedgradient // 2. specify gradient and temperature such that the equations are the // same on both sides. This leads to the choice of // - refGradient = zero gradient // - refValue = neighbour value // - mixFraction = nbrKDelta / (nbrKDelta + myKDelta()) this->refValue() = nbrIntFld; this->refGrad() = Zero; this->valueFraction() = nbrKDelta()/(nbrKDelta() + myKDelta()); mixedFvPatchField::updateCoeffs(); if (debug) { auto limits = gMinMax(*this); auto avg = gAverage(*this); Info<< this->patch().boundaryMesh().mesh().name() << ':' << this->patch().name() << ':' << this->internalField().name() << " <- " << this->mapper_.sampleRegion() << ':' << this->mapper_.samplePatch() << ':' << this->fieldName_ << " :" << " value " << " min:" << limits.min() << " max:" << limits.max() << " avg:" << avg << endl; } } template void Foam::mappedMixedFieldFvPatchField::write(Ostream& os) const { mappedPatchBase::write(os); mappedPatchFieldBase::write(os); os.writeEntryIfDifferent("weightField", word::null, weightFieldName_); mixedFvPatchField::write(os); } // ************************************************************************* //