Download data/src/finiteVolume/fields/PtrFields/PtrField.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 10.9 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/finiteVolume/fields/PtrFields/PtrField.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/finiteVolume/fields/PtrFields/PtrField.C
-
curl -L -o PtrField.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/finiteVolume/fields/PtrFields/PtrField.C
10.9 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 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/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | |
| template<class Type> | |
| Foam::PtrField<Type>::PtrField() | |
| : | |
| PtrList<Type>() | |
| {} | |
| template<class Type> | |
| Foam::PtrField<Type>::PtrField(const label size) | |
| : | |
| PtrList<Type>(size) | |
| {} | |
| template<class Type> | |
| Foam::PtrField<Type>::PtrField(const PtrField<Type>& f) | |
| : | |
| tmp<PtrField<Type>>::refCount(), | |
| PtrList<Type>(f) | |
| {} | |
| template<class Type> | |
| Foam::PtrField<Type>::PtrField(PtrField<Type>&& f) | |
| : | |
| tmp<PtrField<Type>>::refCount(), | |
| PtrList<Type>(move(f)) | |
| {} | |
| template<class Type> | |
| Foam::PtrField<Type>::PtrField(const tmp<PtrField<Type>>& tf) | |
| : | |
| PtrList<Type>(const_cast<PtrField<Type>&>(tf()), tf.isTmp()) | |
| { | |
| tf.clear(); | |
| } | |
| template<class Type> | |
| template<class ... Args> | |
| Foam::PtrField<Type>::PtrField(const PtrField<Type>& f, const Args& ... args) | |
| : | |
| PtrList<Type>(f, args ...) | |
| {} | |
| template<class Type> | |
| template<class ... Args> | |
| Foam::PtrField<Type>::PtrField(const PtrList<Type>& f, const Args& ... args) | |
| : | |
| PtrList<Type>(f, args ...) | |
| {} | |
| template<class Type> | |
| template<class Expression, class ... Args, class> | |
| Foam::PtrField<Type>::PtrField(const Expression& e, const Args& ... args) | |
| : | |
| PtrList<Type>(expression::getFirst<expression::Size>(e)) | |
| { | |
| expression::assertSameAllContainerProperty<expression::Size>(e); | |
| forAll(*this, i) | |
| { | |
| PtrList<Type>::set | |
| ( | |
| i, | |
| expression::New<Type, true> | |
| ( | |
| expression::access(e, i), | |
| args ... | |
| ).ptr() | |
| ); | |
| } | |
| } | |
| template<class Type> | |
| Foam::tmp<Foam::PtrField<Type>> Foam::PtrField<Type>::clone() const | |
| { | |
| return tmp<PtrField<Type>>(new PtrField<Type>(*this)); | |
| } | |
| template<class Type> | |
| template<class ... Args> | |
| Foam::tmp<Foam::PtrField<Type>> Foam::PtrField<Type>::New | |
| ( | |
| const tmp<PtrField<Type>>& tf, | |
| const Args& ... args | |
| ) | |
| { | |
| if (tf.isTmp()) | |
| { | |
| return tf; | |
| } | |
| else | |
| { | |
| const PtrField<Type>& f = tf(); | |
| tmp<PtrField<Type>> trf | |
| ( | |
| new PtrField<Type>(f.size()) | |
| ); | |
| PtrField<Type>& rf = trf.ref(); | |
| forAll(f, i) | |
| { | |
| rf.set(i, expression::New<Type, true>(f[i], args ...).ptr()); | |
| } | |
| return trf; | |
| } | |
| } | |
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | |
| template<class Type> | |
| void Foam::PtrField<Type>::negate() | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).negate(); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::replace | |
| ( | |
| const direction d, | |
| const PtrField<cmptField>& sf | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).replace(d, sf[i]); | |
| } | |
| } | |
| template<class Type> | |
| template<class Expression, class> | |
| void Foam::PtrField<Type>::replace | |
| ( | |
| const direction d, | |
| const Expression& e | |
| ) | |
| { | |
| expression::assertSameAllContainerProperty<expression::Size> | |
| ( | |
| *this, | |
| e | |
| ); | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).replace(d, expression::access(e, i)); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::replace | |
| ( | |
| const direction d, | |
| const cmptType& s | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).replace(d, s); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::boundLower | |
| ( | |
| const typename PtrField<Type>::pType& lower | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).boundLower(lower); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::boundUpper | |
| ( | |
| const typename PtrField<Type>::pType& upper | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).boundUpper(upper); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::bound | |
| ( | |
| const typename PtrField<Type>::pType& lower, | |
| const typename PtrField<Type>::pType& upper | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i).bound(lower, upper); | |
| } | |
| } | |
| // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // | |
| template<class Type> | |
| void Foam::PtrField<Type>::operator=(const PtrField<Type>& f) | |
| { | |
| if (this == &f) | |
| { | |
| FatalErrorInFunction | |
| << "attempted assignment to self" | |
| << abort(FatalError); | |
| } | |
| forAll(*this, i) | |
| { | |
| this->operator[](i) = f[i]; | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::operator=(PtrField<Type>&& f) | |
| { | |
| if (this == &f) | |
| { | |
| FatalErrorInFunction | |
| << "attempted assignment to self" | |
| << abort(FatalError); | |
| } | |
| PtrList<Type>::operator=(move(f)); | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::operator=(const tmp<PtrField>& tf) | |
| { | |
| if (this == &(tf())) | |
| { | |
| FatalErrorInFunction | |
| << "attempted assignment to self" | |
| << abort(FatalError); | |
| } | |
| PtrField* fieldPtr = tf.ptr(); | |
| PtrList<Type>::transfer(*fieldPtr); | |
| delete fieldPtr; | |
| } | |
| template<class Type> | |
| template<class Expression, class> | |
| void Foam::PtrField<Type>::operator=(const Expression& e) | |
| { | |
| expression::assertSameAllContainerProperty<expression::Size> | |
| ( | |
| *this, | |
| e | |
| ); | |
| forAll(*this, i) | |
| { | |
| this->operator[](i) = expression::access(e, i); | |
| } | |
| } | |
| template<class Type> | |
| void Foam::PtrField<Type>::operator= | |
| ( | |
| const typename PtrField<Type>::pType& t | |
| ) | |
| { | |
| forAll(*this, i) | |
| { | |
| this->operator[](i) = t; | |
| } | |
| } | |
| COMPUTED_ASSIGNMENT(Type, pType_, +=) | |
| COMPUTED_ASSIGNMENT(Type, pType_, -=) | |
| COMPUTED_ASSIGNMENT(cmptField_, pCmptType_, *=) | |
| COMPUTED_ASSIGNMENT(cmptField_, pCmptType_, /=) | |
| // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // | |
| template<class Type> | |
| Foam::Ostream& Foam::operator<<(Ostream& os, const PtrField<Type>& f) | |
| { | |
| os << static_cast<const PtrList<Type>&>(f); | |
| return os; | |
| } | |
| // ************************************************************************* // | |