Download data/src/generic/genericFvFields/genericFvPatchField/genericFvPatchField.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 18.5 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/generic/genericFvFields/genericFvPatchField/genericFvPatchField.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/generic/genericFvFields/genericFvPatchField/genericFvPatchField.C
-
curl -L -o genericFvPatchField.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/generic/genericFvFields/genericFvPatchField/genericFvPatchField.C
18.5 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/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // | |
| namespace Foam | |
| { | |
| template<class Type> | |
| bool insertUniformTypeField | |
| ( | |
| const scalarList& components, | |
| const word& keyword, | |
| const label size, | |
| HashPtrTable<Field<Type>>& typeFields | |
| ) | |
| { | |
| if (components.size() != Type::nComponents) | |
| { | |
| return false; | |
| } | |
| Type t; | |
| forAll(t, i) | |
| { | |
| t[i] = components[i]; | |
| } | |
| typeFields.insert(keyword, new Field<Type>(size, t)); | |
| return true; | |
| } | |
| template<> | |
| bool insertUniformTypeField | |
| ( | |
| const scalarList& components, | |
| const word& keyword, | |
| const label size, | |
| HashPtrTable<Field<scalar>>& typeFields | |
| ) | |
| { | |
| return false; | |
| } | |
| } | |
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | |
| template<class Type> | |
| Foam::genericFvPatchField<Type>::genericFvPatchField | |
| ( | |
| const fvPatch& p, | |
| const DimensionedField<Type, fvMesh>& iF, | |
| const dictionary& dict | |
| ) | |
| : | |
| genericFieldBase(dict.lookup("type")), | |
| calculatedFvPatchField<Type>(p, iF, dict, false), | |
| dict_(dict), | |
| valuePresent_(false) | |
| { | |
| if (dict_.found("value")) | |
| { | |
| valuePresent_ = true; | |
| calculatedFvPatchField<Type>::operator= | |
| ( | |
| Field<Type>("value", iF.dimensions(), dict_, p.size()) | |
| ); | |
| } | |
| else | |
| { | |
| Info<< "\n Cannot find 'value' entry" | |
| << " for patch " << this->patch().name() | |
| << " of field " << this->internalField().name() | |
| << " for generic patch field with actual type " | |
| << actualTypeName() << nl | |
| << " in file " << this->internalField().objectPath() << nl | |
| << " Extrapolating the internal field to the patch." | |
| << endl; | |
| calculatedFvPatchField<Type>::operator=(this->patchInternalField()); | |
| } | |
| forAllConstIter(dictionary, dict_, iter) | |
| { | |
| if (iter().keyword() != "type" && iter().keyword() != "value") | |
| { | |
| if | |
| ( | |
| iter().isStream() | |
| && iter().stream().size() | |
| ) | |
| { | |
| ITstream& is = iter().stream(); | |
| // Read first token | |
| token firstToken(is); | |
| if | |
| ( | |
| firstToken.isWord() | |
| && firstToken.wordToken() == "nonuniform" | |
| ) | |
| { | |
| token fieldToken(is); | |
| if (!fieldToken.isCompound()) | |
| { | |
| if | |
| ( | |
| fieldToken.isLabel() | |
| && fieldToken.labelToken() == 0 | |
| ) | |
| { | |
| scalarFields_.insert | |
| ( | |
| iter().keyword(), | |
| new scalarField(0) | |
| ); | |
| } | |
| else | |
| { | |
| FatalIOErrorInFunction(dict) | |
| << "\n token following 'nonuniform' " | |
| "is not a compound" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " | |
| << this->internalField().name() | |
| << " in file " | |
| << this->internalField().objectPath() | |
| << exit(FatalIOError); | |
| } | |
| } | |
| FOR_ALL_FIELD_TYPES(ReadTypeField) | |
| else | |
| { | |
| FatalIOErrorInFunction(dict) | |
| << "\n compound " << fieldToken.compoundToken() | |
| << " not supported" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " | |
| << this->internalField().name() | |
| << " in file " | |
| << this->internalField().objectPath() | |
| << exit(FatalIOError); | |
| } | |
| } | |
| else if | |
| ( | |
| firstToken.isWord() | |
| && firstToken.wordToken() == "uniform" | |
| ) | |
| { | |
| token fieldToken(is); | |
| if (!fieldToken.isPunctuation()) | |
| { | |
| scalarFields_.insert | |
| ( | |
| iter().keyword(), | |
| new scalarField | |
| ( | |
| this->size(), | |
| fieldToken.number() | |
| ) | |
| ); | |
| } | |
| else | |
| { | |
| // Read as a scalarList | |
| is.putBack(fieldToken); | |
| scalarList l(is); | |
| if (!(0 FOR_ALL_FIELD_TYPES(InsertUniformTypeField))) | |
| { | |
| FatalIOErrorInFunction(dict) | |
| << "\n unrecognised native type " << l | |
| << "\n on patch " << this->patch().name() | |
| << " of field " | |
| << this->internalField().name() | |
| << " in file " | |
| << this->internalField().objectPath() | |
| << exit(FatalIOError); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| template<class Type> | |
| Foam::genericFvPatchField<Type>::genericFvPatchField | |
| ( | |
| const genericFvPatchField<Type>& ptf, | |
| const fvPatch& p, | |
| const DimensionedField<Type, fvMesh>& iF, | |
| const fieldMapper& mapper | |
| ) | |
| : | |
| genericFieldBase(ptf), | |
| calculatedFvPatchField<Type>(ptf, p, iF, mapper), | |
| dict_(ptf.dict_), | |
| valuePresent_(ptf.valuePresent_) | |
| { | |
| FOR_ALL_FIELD_TYPES(MapTypeFields); | |
| } | |
| template<class Type> | |
| Foam::genericFvPatchField<Type>::genericFvPatchField | |
| ( | |
| const genericFvPatchField<Type>& ptf, | |
| const DimensionedField<Type, fvMesh>& iF | |
| ) | |
| : | |
| genericFieldBase(ptf), | |
| calculatedFvPatchField<Type>(ptf, iF), | |
| dict_(ptf.dict_), | |
| valuePresent_(ptf.valuePresent_) | |
| FOR_ALL_FIELD_TYPES(CopyTypeFields) | |
| {} | |
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | |
| template<class Type> | |
| void Foam::genericFvPatchField<Type>::map | |
| ( | |
| const fvPatchField<Type>& ptf, | |
| const fieldMapper& mapper | |
| ) | |
| { | |
| calculatedFvPatchField<Type>::map(ptf, mapper); | |
| const genericFvPatchField<Type>& dptf = | |
| refCast<const genericFvPatchField<Type>>(ptf); | |
| FOR_ALL_FIELD_TYPES(MapTypeFields); | |
| } | |
| template<class Type> | |
| void Foam::genericFvPatchField<Type>::reset | |
| ( | |
| const fvPatchField<Type>& ptf | |
| ) | |
| { | |
| calculatedFvPatchField<Type>::reset(ptf); | |
| const genericFvPatchField<Type>& dptf = | |
| refCast<const genericFvPatchField<Type>>(ptf); | |
| FOR_ALL_FIELD_TYPES(ResetTypeFields); | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::Field<Type>> | |
| Foam::genericFvPatchField<Type>::valueInternalCoeffs | |
| ( | |
| const tmp<scalarField>& | |
| ) const | |
| { | |
| FatalErrorInFunction | |
| << "cannot be called for a genericFvPatchField" | |
| " (actual type " << actualTypeName() << ")" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " << this->internalField().name() | |
| << " in file " << this->internalField().objectPath() | |
| << "\n You are probably trying to solve for a field with a " | |
| "generic boundary condition." | |
| << abort(FatalError); | |
| return *this; | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::Field<Type>> | |
| Foam::genericFvPatchField<Type>::valueBoundaryCoeffs | |
| ( | |
| const tmp<scalarField>& | |
| ) const | |
| { | |
| FatalErrorInFunction | |
| << "cannot be called for a genericFvPatchField" | |
| " (actual type " << actualTypeName() << ")" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " << this->internalField().name() | |
| << " in file " << this->internalField().objectPath() | |
| << "\n You are probably trying to solve for a field with a " | |
| "generic boundary condition." | |
| << abort(FatalError); | |
| return *this; | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::Field<Type>> | |
| Foam::genericFvPatchField<Type>::gradientInternalCoeffs() const | |
| { | |
| FatalErrorInFunction | |
| << "cannot be called for a genericFvPatchField" | |
| " (actual type " << actualTypeName() << ")" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " << this->internalField().name() | |
| << " in file " << this->internalField().objectPath() | |
| << "\n You are probably trying to solve for a field with a " | |
| "generic boundary condition." | |
| << abort(FatalError); | |
| return *this; | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::Field<Type>> | |
| Foam::genericFvPatchField<Type>::gradientBoundaryCoeffs() const | |
| { | |
| FatalErrorInFunction | |
| << "cannot be called for a genericFvPatchField" | |
| " (actual type " << actualTypeName() << ")" | |
| << "\n on patch " << this->patch().name() | |
| << " of field " << this->internalField().name() | |
| << " in file " << this->internalField().objectPath() | |
| << "\n You are probably trying to solve for a field with a " | |
| "generic boundary condition." | |
| << abort(FatalError); | |
| return *this; | |
| } | |
| template<class Type> | |
| void Foam::genericFvPatchField<Type>::write(Ostream& os) const | |
| { | |
| writeEntry(os, "type", actualTypeName()); | |
| forAllConstIter(dictionary, dict_, iter) | |
| { | |
| if (iter().keyword() != "type" && iter().keyword() != "value") | |
| { | |
| if | |
| ( | |
| iter().isStream() | |
| && iter().stream().size() | |
| && iter().stream()[0].isWord() | |
| && iter().stream()[0].wordToken() == "nonuniform" | |
| ) | |
| { | |
| if (false) {} FOR_ALL_FIELD_TYPES(WriteTypeFieldEntry) | |
| } | |
| else | |
| { | |
| iter().write(os); | |
| } | |
| } | |
| } | |
| if (valuePresent_) | |
| { | |
| writeEntry(os, "value", *this); | |
| } | |
| } | |
| // ************************************************************************* // | |