/*---------------------------------------------------------------------------*\ ========= | \\ / 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 . \*---------------------------------------------------------------------------*/ #include "SubField.H" #include "expressionAssert.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template inline Foam::SubField::SubField ( const SubList& list ) : SubList(list) {} template inline Foam::SubField::SubField ( const UList& list ) : SubList(list, list.size()) {} template inline Foam::SubField::SubField ( const UList& list, const label subSize ) : SubList(list, subSize) {} template inline Foam::SubField::SubField ( const UList& list, const label subSize, const label startIndex ) : SubList(list, subSize, startIndex) {} template inline Foam::SubField::SubField ( const SubField& sfield ) : tmp>::refCount(), SubList(sfield) {} template inline Foam::SubField::SubField ( SubField& sfield, bool reuse ) : tmp>::refCount(), SubList(sfield) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template inline Foam::tmp::cmptType>> Foam::SubField::component ( const direction d ) const { return (reinterpret_cast&>(*this)).component(d); } template inline Foam::tmp> Foam::SubField::T() const { return (reinterpret_cast&>(*this)).T(); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template inline void Foam::SubField::operator=(const SubField& rhs) { SubList::operator=(rhs); } template inline void Foam::SubField::operator=(const UList& rhs) { SubList::operator=(rhs); } template inline void Foam::SubField::operator=(const tmp>& rhs) { SubList::operator=(rhs()); } template inline void Foam::SubField::operator=(const Type& rhs) { SubList::operator=(rhs); } template inline void Foam::SubField::operator=(const zero) { SubList::operator=(Zero); } template template void Foam::SubField::operator=(const Expression& e) { #ifdef FULLDEBUG expression::assertSameAllContainerProperty ( *this, e ); #endif std::copy(expression::begin(e), expression::end(e), this->begin()); } #define COMPUTED_ASSIGNMENT(TYPE, op) \ \ template \ void Foam::SubField::operator op(const UList& f) \ { \ forAll(*this, i) \ { \ this->operator[](i) op f[i]; \ } \ } \ \ template \ void Foam::SubField::operator op(const tmp>& tf) \ { \ operator op(tf()); \ tf.clear(); \ } \ \ template \ void Foam::SubField::operator op(const TYPE& t) \ { \ forAll(*this, i) \ { \ this->operator[](i) op t; \ } \ } COMPUTED_ASSIGNMENT(Type, +=) COMPUTED_ASSIGNMENT(Type, -=) COMPUTED_ASSIGNMENT(scalar, *=) COMPUTED_ASSIGNMENT(scalar, /=) #undef COMPUTED_ASSIGNMENT template template inline void Foam::SubField::operator= ( const VectorSpace& rhs ) { forAll(rhs, i) { this->operator[](i) = rhs[i]; } } // ************************************************************************* //