/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "expDirectionMixedFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template expDirectionMixedFvPatchField::expDirectionMixedFvPatchField ( const fvPatch& p, const DimensionedField& iF ) : fvPatchField(p, iF), refValue_(p.size()), refGrad_(p.size()), valueFraction_(p.size()) {} template expDirectionMixedFvPatchField::expDirectionMixedFvPatchField ( const expDirectionMixedFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : fvPatchField(ptf, p, iF, mapper), refValue_(ptf.refValue_, mapper), refGrad_(ptf.refGrad_, mapper), valueFraction_(ptf.valueFraction_, mapper) {} template expDirectionMixedFvPatchField::expDirectionMixedFvPatchField ( const fvPatch& p, const DimensionedField& iF, const dictionary& dict ) : fvPatchField(p, iF, dict), refValue_("refValue", dict, p.size()), refGrad_("refGradient", dict, p.size()), valueFraction_("valueFraction", dict, p.size()) { evaluate(); } template expDirectionMixedFvPatchField::expDirectionMixedFvPatchField ( const expDirectionMixedFvPatchField& ptf ) : fvPatchField(ptf), refValue_(ptf.refValue_), refGrad_(ptf.refGrad_), valueFraction_(ptf.valueFraction_) {} template expDirectionMixedFvPatchField::expDirectionMixedFvPatchField ( const expDirectionMixedFvPatchField& ptf, const DimensionedField& iF ) : fvPatchField(ptf, iF), refValue_(ptf.refValue_), refGrad_(ptf.refGrad_), valueFraction_(ptf.valueFraction_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void expDirectionMixedFvPatchField::autoMap ( const fvPatchFieldMapper& m ) { fvPatchField::autoMap(m); refValue_.autoMap(m); refGrad_.autoMap(m); valueFraction_.autoMap(m); } // Reverse-map the given fvPatchField onto this fvPatchField template void expDirectionMixedFvPatchField::rmap ( const fvPatchField& ptf, const labelList& addr ) { fvPatchField::rmap(ptf, addr); const expDirectionMixedFvPatchField& edmptf = refCast >(ptf); refValue_.rmap(edmptf.refValue_, addr); refGrad_.rmap(edmptf.refGrad_, addr); valueFraction_.rmap(edmptf.valueFraction_, addr); } template tmp > expDirectionMixedFvPatchField::snGrad() const { const vectorField& nHat = patch().faceNormals(); Field gradValue = patchInternalField() + refGrad_/patch().deltaCoeffs(); Field mixedValue = nHat*(nHat & refValue_) + gradValue - nHat*(nHat & gradValue); return valueFraction_* (mixedValue - patchInternalField())*patch().deltaCoeffs() + (1.0 - valueFraction_)*refGrad_; } template void expDirectionMixedFvPatchField::evaluate(const Pstream::commsTypes) { if (!updated()) { updateCoeffs(); } const vectorField& nHat = patch().faceNormals(); Field gradValue = patchInternalField() + refGrad_/patch().deltaCoeffs(); Field mixedValue = nHat*(nHat & refValue_) + gradValue - nHat*(nHat & gradValue); Field::operator= ( valueFraction_*mixedValue + (1.0 - valueFraction_)*gradValue ); fvPatchField::evaluate(); } template tmp > expDirectionMixedFvPatchField::valueInternalCoeffs ( const tmp& ) const { return Type(pTraits::one)*(1.0 - valueFraction_); } template tmp > expDirectionMixedFvPatchField::valueBoundaryCoeffs ( const tmp& ) const { const vectorField& nHat = patch().faceNormals(); Field gradValue = patchInternalField() + refGrad_/patch().deltaCoeffs(); Field mixedValue = nHat*(nHat & refValue_) + gradValue - nHat*(nHat & gradValue); return valueFraction_*mixedValue + (1.0 - valueFraction_)*refGrad_/patch().deltaCoeffs(); } template tmp > expDirectionMixedFvPatchField:: gradientInternalCoeffs() const { return -Type(pTraits::one)*valueFraction_*patch().deltaCoeffs(); } template tmp > expDirectionMixedFvPatchField:: gradientBoundaryCoeffs() const { const vectorField& nHat = patch().faceNormals(); Field gradValue = patchInternalField() + refGrad_/patch().deltaCoeffs(); Field mixedValue = nHat*(nHat & refValue_) + gradValue - nHat*(nHat & gradValue); return valueFraction_*patch().deltaCoeffs()*mixedValue + (1.0 - valueFraction_)*refGrad_; } template void expDirectionMixedFvPatchField::write(Ostream& os) const { fvPatchField::write(os); refValue_.writeEntry("refValue", os); refGrad_.writeEntry("refGradient", os); valueFraction_.writeEntry("valueFraction", os); writeEntry("value", os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // ************************************************************************* //