ENH: add iterators to VectorSpace (#1265)

- this adds support for various STL operations including

    * sorting, filling, find min/max element etc.
    * for-range iteration

STYLE: use constexpr for VectorSpace rank
This commit is contained in:
Mark Olesen
2019-04-04 17:14:27 +02:00
committed by Andrew Heather
parent f3670521cd
commit 1c4e32fb6a
17 changed files with 201 additions and 106 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,6 +31,7 @@ Description
#include "vector.H" #include "vector.H"
#include "IOstreams.H" #include "IOstreams.H"
#include <algorithm>
using namespace Foam; using namespace Foam;
@ -74,6 +75,18 @@ void doTest(vector& vec1, vector& vec2)
} }
template<class VecSpace>
void testIterator(const VecSpace& vs)
{
Info<< "size: " << vs.size() << " for:";
for (const auto& val : vs)
{
Info<< " " << val;
}
Info<< nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
@ -89,8 +102,21 @@ int main(int argc, char *argv[])
vector vec2(0.5, 0.51, -0.5); vector vec2(0.5, 0.51, -0.5);
doTest(vec1, vec2); doTest(vec1, vec2);
testIterator(vec1);
testIterator(vec2);
// Use STL algorithm(s)
std::sort(vec2.begin(), vec2.end());
Info<< "sorted: " << vec2 << nl;
std::random_shuffle(vec2.begin(), vec2.end());
Info<< "shuffled: " << vec2 << nl;
} }
Info<< "\nEnd\n" << nl;
return 0; return 0;
} }

View File

@ -67,7 +67,7 @@ public:
// Member constants // Member constants
//- Rank of BarycentricTensor is 2 //- Rank of BarycentricTensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
//- Component labeling enumeration //- Component labeling enumeration

View File

@ -67,7 +67,7 @@ public:
// Member constants // Member constants
//- Rank of DiagTensor is 2 //- Rank of DiagTensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
//- Component labeling enumeration //- Component labeling enumeration

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2016 OpenFOAM Foundation | Copyright (C) 2016 OpenFOAM Foundation
@ -68,20 +68,20 @@ public:
// Member constants // Member constants
static const direction mRows = Mrows; static constexpr direction mRows = Mrows;
static const direction nCols = Ncols; static constexpr direction nCols = Ncols;
// Static member functions // Static member functions
//- Return the number of rows //- Return the number of rows
static direction m() static direction m() noexcept
{ {
return Mrows; return Mrows;
} }
//- Return the number of columns //- Return the number of columns
static direction n() static direction n() noexcept
{ {
return Ncols; return Ncols;
} }

View File

@ -345,7 +345,7 @@ inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator()
) const ) const
{ {
#ifdef FULLDEBUG #ifdef FULLDEBUG
if (i > Mrows-1 || j > Ncols-1) if (i >= Mrows || j >= Ncols)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "indices out of range" << "indices out of range"
@ -365,7 +365,7 @@ inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator()
) )
{ {
#ifdef FULLDEBUG #ifdef FULLDEBUG
if (i > Mrows-1 || j > Ncols-1) if (i >= Mrows || j >= Ncols)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "indices out of range" << "indices out of range"

View File

@ -65,7 +65,7 @@ public:
// Member constants // Member constants
//- Rank of SphericalTensor is 2 //- Rank of SphericalTensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -61,7 +61,7 @@ public:
// Member constants // Member constants
//- Rank of SphericalTensor2D is 2 //- Rank of SphericalTensor2D is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -67,7 +67,7 @@ public:
// Member constants // Member constants
//- Rank of SymmTensor is 2 //- Rank of SymmTensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -67,7 +67,7 @@ public:
// Member constants // Member constants
//- Rank of SymmTensor2D is 2 //- Rank of SymmTensor2D is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -53,8 +53,9 @@ See also
namespace Foam namespace Foam
{ {
template<class Cmpt> // Forward Declarations
class SymmTensor; template<class Cmpt> class SymmTensor;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Tensor Declaration Class Tensor Declaration
@ -75,7 +76,7 @@ public:
// Member constants // Member constants
//- Rank of Tensor is 2 //- Rank of Tensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -70,7 +70,7 @@ public:
// Member constants // Member constants
//- Rank of Tensor2D is 2 //- Rank of Tensor2D is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members

View File

@ -72,7 +72,7 @@ public:
// Member constants // Member constants
//- Rank of Vector is 1 //- Rank of Vector is 1
static const direction rank = 1; static constexpr direction rank = 1;
//- Component labeling enumeration //- Component labeling enumeration

View File

@ -65,7 +65,7 @@ public:
// Member constants // Member constants
//- Rank of Vector2D is 1 //- Rank of Vector2D is 1
static const direction rank = 1; static constexpr direction rank = 1;
//- Component labeling enumeration //- Component labeling enumeration

View File

@ -38,18 +38,15 @@ Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
Istream& is Istream& is
) )
{ {
// Read beginning of VectorSpace<Cmpt> is.readBegin("VectorSpace");
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
for (direction i=0; i<Ncmpts; i++) for (direction i=0; i<Ncmpts; i++)
{ {
is >> v_[i]; is >> v_[i];
} }
// Read end of VectorSpace<Cmpt> is.readEnd("VectorSpace");
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
} }
@ -64,7 +61,7 @@ Foam::word Foam::name
buf << '(' << vs.v_[0]; buf << '(' << vs.v_[0];
for (direction i=1; i<Ncmpts; i++) for (direction i=1; i<Ncmpts; ++i)
{ {
buf << ',' << vs.v_[i]; buf << ',' << vs.v_[i];
} }
@ -84,18 +81,15 @@ Foam::Istream& Foam::operator>>
VectorSpace<Form, Cmpt, Ncmpts>& vs VectorSpace<Form, Cmpt, Ncmpts>& vs
) )
{ {
// Read beginning of VectorSpace<Cmpt, Ncmpts> is.readBegin("VectorSpace");
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
for (direction i=0; i<Ncmpts; i++) for (direction i=0; i<Ncmpts; i++)
{ {
is >> vs.v_[i]; is >> vs.v_[i];
} }
// Read end of VectorSpace<Cmpt, Ncmpts> is.readEnd("VectorSpace");
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check(FUNCTION_NAME); is.check(FUNCTION_NAME);
return is; return is;
@ -111,7 +105,7 @@ Foam::Ostream& Foam::operator<<
{ {
os << token::BEGIN_LIST << vs.v_[0]; os << token::BEGIN_LIST << vs.v_[0];
for (direction i=1; i<Ncmpts; i++) for (direction i=1; i<Ncmpts; ++i)
{ {
os << token::SPACE << vs.v_[i]; os << token::SPACE << vs.v_[i];
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -89,23 +89,23 @@ public:
typedef Cmpt cmptType; typedef Cmpt cmptType;
// Static constants // Static Constants
//- Dimensionality of space //- Dimensionality of space
static const direction dim = 3; static constexpr direction dim = 3;
//- Number of components in this vector space //- Number of components in this vector space
static const direction nComponents = Ncmpts; static constexpr direction nComponents = Ncmpts;
// VectorSpace currently defaults to a column-vector // VectorSpace currently defaults to a column-vector
// This will be removed when column-vector is introduced // This will be removed when column-vector is introduced
// as a specialization // as a specialization
static const direction mRows = Ncmpts; static constexpr direction mRows = Ncmpts;
static const direction nCols = 1; static constexpr direction nCols = 1;
// Static data members // Static Data Members
static const char* const typeName; static const char* const typeName;
static const char* const componentNames[]; static const char* const componentNames[];
@ -120,11 +120,7 @@ public:
// Sub-Block Classes // Sub-Block Classes
//- Const sub-block type //- Const sub-block type
template template<class SubVector, direction BStart>
<
class SubVector,
direction BStart
>
class ConstBlock class ConstBlock
{ {
const vsType& vs_; const vsType& vs_;
@ -158,12 +154,12 @@ public:
inline VectorSpace(const Foam::zero); inline VectorSpace(const Foam::zero);
//- Construct from Istream //- Construct from Istream
VectorSpace(Istream&); VectorSpace(Istream& is);
//- Construct as copy //- Copy construct
inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>&); inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>& vs);
//- Construct as copy of a VectorSpace with the same size //- Copy construct of a VectorSpace with the same size
template<class Form2, class Cmpt2> template<class Form2, class Cmpt2>
inline explicit VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&); inline explicit VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&);
@ -171,7 +167,7 @@ public:
// Member Functions // Member Functions
//- Return the number of elements in the VectorSpace = Ncmpts. //- Return the number of elements in the VectorSpace = Ncmpts.
inline static direction size(); inline static constexpr direction size();
inline const Cmpt& component(const direction) const; inline const Cmpt& component(const direction) const;
inline Cmpt& component(const direction); inline Cmpt& component(const direction);
@ -200,6 +196,39 @@ public:
inline void operator/=(const scalar); inline void operator/=(const scalar);
// Iterators
//- Random access iterator for traversing VectorSpace
typedef Cmpt* iterator;
//- Random access iterator for traversing VectorSpace
typedef const Cmpt* const_iterator;
// Random access iterator (non-const)
//- Return an iterator to begin of VectorSpace
inline iterator begin();
//- Return an iterator to end of UListVectorSpace
inline iterator end();
// Random access iterator (const)
//- Return const_iterator to begin of VectorSpace
inline const_iterator cbegin() const;
//- Return const_iterator to end of VectorSpace
inline const_iterator cend() const;
//- Return const_iterator to begin of VectorSpace
inline const_iterator begin() const;
//- Return const_iterator to end of VectorSpace
inline const_iterator end() const;
// IOstream Operators // IOstream Operators
friend Istream& operator>> <Form, Cmpt, Ncmpts> friend Istream& operator>> <Form, Cmpt, Ncmpts>

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -31,27 +31,23 @@ License
#include "ops.H" #include "ops.H"
#include <type_traits> #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace() inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
{} {}
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero) inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero)
{ {
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, Zero, eqOp<Cmpt>()); VectorSpaceOps<Ncmpts,0>::eqOpS(*this, Zero, eqOp<Cmpt>());
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
( (
const VectorSpace<Form, Cmpt, Ncmpts>& vs const VectorSpace<Form, Cmpt, Ncmpts>& vs
) )
@ -60,9 +56,9 @@ inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
template<class Form2, class Cmpt2> template<class Form2, class Cmpt2>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
( (
const VectorSpace<Form2, Cmpt2, Ncmpts>& vs const VectorSpace<Form2, Cmpt2, Ncmpts>& vs
) )
@ -71,10 +67,10 @@ inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
template<class SubVector, direction BStart> template<class SubVector, Foam::direction BStart>
inline inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>
VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>::ConstBlock ::ConstBlock
( (
const vsType& vs const vsType& vs
) )
@ -91,15 +87,15 @@ VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>::ConstBlock
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline direction VectorSpace<Form, Cmpt, Ncmpts>::size() inline constexpr Foam::direction Foam::VectorSpace<Form, Cmpt, Ncmpts>::size()
{ {
return Ncmpts; return Ncmpts;
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component inline const Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
( (
const direction d const direction d
) const ) const
@ -117,8 +113,8 @@ inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component inline Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
( (
const direction d const direction d
) )
@ -136,8 +132,8 @@ inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::component inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
( (
Cmpt& c, Cmpt& c,
const direction d const direction d
@ -156,8 +152,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::component
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::replace inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::replace
( (
const direction d, const direction d,
const Cmpt& c const Cmpt& c
@ -176,8 +172,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::replace
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Form VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s) inline Form Foam::VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
{ {
Form v; Form v;
VectorSpaceOps<Ncmpts,0>::eqOpS(v, s, eqOp<Cmpt>()); VectorSpaceOps<Ncmpts,0>::eqOpS(v, s, eqOp<Cmpt>());
@ -185,20 +181,64 @@ inline Form VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
template<class SubVector, direction BStart> template<class SubVector, Foam::direction BStart>
inline const typename VectorSpace<Form, Cmpt, Ncmpts>::template inline const typename Foam::VectorSpace<Form, Cmpt, Ncmpts>::template
ConstBlock<SubVector, BStart> ConstBlock<SubVector, BStart>
VectorSpace<Form, Cmpt, Ncmpts>::block() const Foam::VectorSpace<Form, Cmpt, Ncmpts>::block() const
{ {
return *this; return *this;
} }
// * * * * * * * * * * * * * * * * Iterator * * * * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
{
return (v_ + Ncmpts);
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin() const
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend() const
{
return (v_ + Ncmpts);
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin() const
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() const
{
return (v_ + Ncmpts);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[] inline const Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator[]
( (
const direction d const direction d
) const ) const
@ -216,8 +256,8 @@ inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[] inline Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator[]
( (
const direction d const direction d
) )
@ -235,10 +275,10 @@ inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
template<class SubVector, direction BStart> template<class SubVector, Foam::direction BStart>
inline const Cmpt& inline const Cmpt&
VectorSpace<Form, Cmpt, Ncmpts>:: Foam::VectorSpace<Form, Cmpt, Ncmpts>::
ConstBlock<SubVector, BStart>::operator[] ConstBlock<SubVector, BStart>::operator[]
( (
const direction d const direction d
@ -257,10 +297,10 @@ ConstBlock<SubVector, BStart>::operator[]
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
template<class SubVector, direction BStart> template<class SubVector, Foam::direction BStart>
inline const Cmpt& inline const Cmpt&
VectorSpace<Form, Cmpt, Ncmpts>:: Foam::VectorSpace<Form, Cmpt, Ncmpts>::
ConstBlock<SubVector, BStart>::operator() ConstBlock<SubVector, BStart>::operator()
( (
const direction i, const direction i,
@ -275,7 +315,7 @@ ConstBlock<SubVector, BStart>::operator()
<< abort(FatalError); << abort(FatalError);
} }
if (j != 0) if (j)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "index " << j << " != 0" << "index " << j << " != 0"
@ -287,8 +327,8 @@ ConstBlock<SubVector, BStart>::operator()
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator= inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator=
( (
const VectorSpace<Form, Cmpt, Ncmpts>& vs const VectorSpace<Form, Cmpt, Ncmpts>& vs
) )
@ -297,8 +337,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator+= inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator+=
( (
const VectorSpace<Form, Cmpt, Ncmpts>& vs const VectorSpace<Form, Cmpt, Ncmpts>& vs
) )
@ -307,8 +347,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator+=
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator-= inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator-=
( (
const VectorSpace<Form, Cmpt, Ncmpts>& vs const VectorSpace<Form, Cmpt, Ncmpts>& vs
) )
@ -317,15 +357,15 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator-=
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=(const Foam::zero) inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator=(const Foam::zero)
{ {
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>()); VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator*= inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator*=
( (
const scalar s const scalar s
) )
@ -334,8 +374,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator*=
} }
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, Foam::direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator/= inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator/=
( (
const scalar s const scalar s
) )
@ -344,6 +384,11 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator/=
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, direction Ncmpts>

View File

@ -74,7 +74,7 @@ public:
// Member constants // Member constants
//- Rank of Tensor is 2 //- Rank of Tensor is 2
static const direction rank = 2; static constexpr direction rank = 2;
// Static data members // Static data members