OpenFOAM-dev / data /src /finiteVolume /fields /fvPatchFields /derived /mappedValue /mappedValueFvPatchField.C
Download data/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 7.41 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C
-
curl -L -o mappedValueFvPatchField.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/finiteVolume/fields/fvPatchFields/derived/mappedValue/mappedValueFvPatchField.C
7.41 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation | |
| \\/ 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/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // | |
| template<class Type> | |
| const Foam::mappedPatchBase& | |
| Foam::mappedValueFvPatchField<Type>::mapper() const | |
| { | |
| return | |
| mapperPtr_.valid() | |
| ? mapperPtr_() | |
| : mappedPatchBase::getMap(patch().poly()); | |
| } | |
| template<class Type> | |
| const Foam::fvPatchField<Type>& | |
| Foam::mappedValueFvPatchField<Type>::nbrPatchField() const | |
| { | |
| const fvMesh& nbrMesh = | |
| refCast<const fvMesh>(this->mapper().nbrMesh()); | |
| const VolField<Type>& nbrField = | |
| this->mapper().sameRegion() | |
| && this->fieldName_ == internalField().name() | |
| ? refCast<const VolField<Type>>(internalField()) | |
| : nbrMesh.template lookupObject<VolField<Type>>(this->fieldName_); | |
| const label nbrPatchi = this->mapper().nbrPolyPatch().index(); | |
| return nbrField.boundaryField()[nbrPatchi]; | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::Field<Type>> | |
| Foam::mappedValueFvPatchField<Type>::mappedValues | |
| ( | |
| const Field<Type>& nbrPatchField | |
| ) const | |
| { | |
| // Since we're inside initEvaluate/evaluate there might be processor | |
| // comms underway. Change the tag we use. | |
| int oldTag = UPstream::msgType(); | |
| UPstream::msgType() = oldTag + 1; | |
| // Map values | |
| tmp<Field<Type>> tResult = this->mapper().fromNeighbour(nbrPatchField); | |
| // Set the average, if necessary | |
| if (setAverage_) | |
| { | |
| const Type nbrAverageValue = | |
| gSum(patch().magSf()*tResult()) | |
| /gSum(patch().magSf()); | |
| if (mag(nbrAverageValue)/mag(average_) > 0.5) | |
| { | |
| tResult.ref() *= mag(average_)/mag(nbrAverageValue); | |
| } | |
| else | |
| { | |
| tResult.ref() += average_ - nbrAverageValue; | |
| } | |
| } | |
| // Restore tag | |
| UPstream::msgType() = oldTag; | |
| return tResult; | |
| } | |
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | |
| template<class Type> | |
| Foam::mappedValueFvPatchField<Type>::mappedValueFvPatchField | |
| ( | |
| const fvPatch& p, | |
| const DimensionedField<Type, fvMesh>& iF | |
| ) | |
| : | |
| fixedValueFvPatchField<Type>(p, iF), | |
| fieldName_(iF.name()), | |
| setAverage_(false), | |
| average_(Zero), | |
| mapperPtr_(nullptr) | |
| {} | |
| template<class Type> | |
| Foam::mappedValueFvPatchField<Type>::mappedValueFvPatchField | |
| ( | |
| const fvPatch& p, | |
| const DimensionedField<Type, fvMesh>& iF, | |
| const dictionary& dict | |
| ) | |
| : | |
| fixedValueFvPatchField<Type>(p, iF, dict), | |
| fieldName_(dict.lookupOrDefault<word>("field", iF.name())), | |
| setAverage_ | |
| ( | |
| dict.lookupOrDefault<bool>("setAverage", dict.found("average")) | |
| ), | |
| average_ | |
| ( | |
| setAverage_ | |
| ? dict.lookup<Type>("average", iF.dimensions()) | |
| : Zero | |
| ), | |
| mapperPtr_ | |
| ( | |
| mappedPatchBase::specified(dict) | |
| ? new mappedPatchBase | |
| ( | |
| p.poly(), | |
| dict, | |
| mappedPatchBase::transformType::specified | |
| ) | |
| : nullptr | |
| ) | |
| { | |
| if (!mapperPtr_.valid() && !isA<mappedPatchBase>(p.poly())) | |
| { | |
| OStringStream str; | |
| str << "Field " << internalField().name() << " of type " | |
| << type() << " on patch " << patch().name() | |
| << " of type " << p.poly().type() << " does not " | |
| << "have mapping specified (i.e., neighbourPatch, and/or " | |
| << "neighbourRegion entries) nor is the patch of " | |
| << mappedPolyPatch::typeName << " type"; | |
| FatalIOErrorInFunction(dict) | |
| << stringOps::breakIntoIndentedLines(str.str()).c_str() | |
| << exit(FatalIOError); | |
| } | |
| this->mapper().validateForField | |
| ( | |
| *this, | |
| iF, | |
| dict, | |
| this->mapper().sameUntransformedPatch() | |
| && this->fieldName_ == internalField().name() | |
| ? mappedPatchBase::from::differentPatch | |
| : mappedPatchBase::from::any | |
| ); | |
| } | |
| template<class Type> | |
| Foam::mappedValueFvPatchField<Type>::mappedValueFvPatchField | |
| ( | |
| const mappedValueFvPatchField<Type>& ptf, | |
| const fvPatch& p, | |
| const DimensionedField<Type, fvMesh>& iF, | |
| const fieldMapper& mapper | |
| ) | |
| : | |
| fixedValueFvPatchField<Type>(ptf, p, iF, mapper), | |
| fieldName_(ptf.fieldName_), | |
| setAverage_(ptf.setAverage_), | |
| average_(ptf.average_), | |
| mapperPtr_ | |
| ( | |
| ptf.mapperPtr_.valid() | |
| ? new mappedPatchBase(p.poly(), ptf.mapperPtr_()) | |
| : nullptr | |
| ) | |
| {} | |
| template<class Type> | |
| Foam::mappedValueFvPatchField<Type>::mappedValueFvPatchField | |
| ( | |
| const mappedValueFvPatchField<Type>& ptf, | |
| const DimensionedField<Type, fvMesh>& iF | |
| ) | |
| : | |
| fixedValueFvPatchField<Type>(ptf, iF), | |
| fieldName_(ptf.fieldName_), | |
| setAverage_(ptf.setAverage_), | |
| average_(ptf.average_), | |
| mapperPtr_ | |
| ( | |
| ptf.mapperPtr_.valid() | |
| ? new mappedPatchBase(ptf.patch().poly(), ptf.mapperPtr_()) | |
| : nullptr | |
| ) | |
| {} | |
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | |
| template<class Type> | |
| void Foam::mappedValueFvPatchField<Type>::map | |
| ( | |
| const fvPatchField<Type>& ptf, | |
| const fieldMapper& mapper | |
| ) | |
| { | |
| fixedValueFvPatchField<Type>::map(ptf, mapper); | |
| if (mapperPtr_.valid()) | |
| { | |
| mapperPtr_->clearOut(false); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::mappedValueFvPatchField<Type>::reset | |
| ( | |
| const fvPatchField<Type>& ptf | |
| ) | |
| { | |
| fixedValueFvPatchField<Type>::reset(ptf); | |
| if (mapperPtr_.valid()) | |
| { | |
| mapperPtr_->clearOut(false); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::mappedValueFvPatchField<Type>::updateCoeffs() | |
| { | |
| if (this->updated()) | |
| { | |
| return; | |
| } | |
| this->operator==(mappedValues(nbrPatchField())); | |
| fixedValueFvPatchField<Type>::updateCoeffs(); | |
| } | |
| template<class Type> | |
| void Foam::mappedValueFvPatchField<Type>::write(Ostream& os) const | |
| { | |
| fvPatchField<Type>::write(os); | |
| writeEntryIfDifferent | |
| ( | |
| os, | |
| "field", | |
| internalField().name(), | |
| fieldName_ | |
| ); | |
| if (setAverage_) | |
| { | |
| writeEntry(os, "average", average_); | |
| } | |
| if (mapperPtr_.valid()) | |
| { | |
| mapperPtr_->write(os); | |
| } | |
| writeEntry(os, "value", *this); | |
| } | |
| // ************************************************************************* // | |