VectorSpaces and MatrixSpaces: Added construction from and assignment to zero

This commit is contained in:
Henry Weller
2016-03-22 08:25:50 +00:00
parent 0f0e4a0c38
commit e6e687b67d
22 changed files with 203 additions and 62 deletions

View File

@ -35,10 +35,10 @@ inline Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::MatrixSpace()
template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
inline Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::MatrixSpace
(
const Foam::zero z
const Foam::zero
)
:
MatrixSpace::vsType(z)
MatrixSpace::vsType(Zero)
{}
@ -257,7 +257,7 @@ inline Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>
Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::identity()
{
StaticAssert(Nrows == Ncols);
msType result((Foam::zero()));
msType result(Zero);
for (direction i=0; i<Ncols; ++i)
{
@ -327,7 +327,7 @@ inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::operator()
) const
{
#ifdef FULLDEBUG
if (i < 0 || i > Nrows-1 || j < 0 || j > Ncols-1)
if (i > Nrows-1 || j > Ncols-1)
{
FatalErrorInFunction
<< "indices out of range"
@ -347,7 +347,7 @@ inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::operator()
)
{
#ifdef FULLDEBUG
if (i < 0 || i > Nrows-1 || j < 0 || j > Ncols-1)
if (i > Nrows-1 || j > Ncols-1)
{
FatalErrorInFunction
<< "indices out of range"
@ -417,10 +417,10 @@ operator()(const direction i, const direction j)
template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
inline void Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::operator=
(
const Foam::zero z
const Foam::zero
)
{
MatrixSpace::vsType::operator=(z);
MatrixSpace::vsType::operator=(Zero);
}
@ -552,10 +552,7 @@ inline typename typeOfInnerProduct<Cmpt, Form1, Form2>::type operator&
{
StaticAssert(Ncols1 == Nrows2);
typename typeOfInnerProduct<Cmpt, Form1, Form2>::type result
(
(Foam::zero())
);
typename typeOfInnerProduct<Cmpt, Form1, Form2>::type result(Zero);
for (direction i=0; i<Nrows1; ++i)
{
@ -579,10 +576,7 @@ inline typename typeOfInnerProduct<Cmpt, Form, VSForm>::type operator&
const VectorSpace<VSForm, Cmpt, Ncols>& v
)
{
typename typeOfInnerProduct<Cmpt, Form, VSForm>::type result
(
(Foam::zero())
);
typename typeOfInnerProduct<Cmpt, Form, VSForm>::type result(Zero);
for (direction i=0; i<Nrows; ++i)
{

View File

@ -31,9 +31,9 @@ inline Foam::RowVector<Cmpt>::RowVector()
template<class Cmpt>
inline Foam::RowVector<Cmpt>::RowVector(const Foam::zero z)
inline Foam::RowVector<Cmpt>::RowVector(const Foam::zero)
:
RowVector::msType(z)
RowVector::msType(Zero)
{}
@ -44,7 +44,7 @@ inline Foam::RowVector<Cmpt>::RowVector
const MatrixSpace<RowVector<Cmpt2>, Cmpt2, 1, 3>& ms
)
:
MatrixSpace<RowVector<Cmpt>, Cmpt, 1, 3>(ms)
RowVector::msType(ms)
{}
@ -65,7 +65,7 @@ inline Foam::RowVector<Cmpt>::RowVector
template<class Cmpt>
inline Foam::RowVector<Cmpt>::RowVector(Istream& is)
:
MatrixSpace<RowVector<Cmpt>, Cmpt, 1, 3>(is)
RowVector::msType(is)
{}
@ -112,9 +112,9 @@ inline Cmpt& Foam::RowVector<Cmpt>::z()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::RowVector<Cmpt>::operator=(const Foam::zero z)
inline void Foam::RowVector<Cmpt>::operator=(const Foam::zero)
{
RowVector::msType::operator=(z);
RowVector::msType::operator=(Zero);
}

View File

@ -82,6 +82,9 @@ public:
//- Construct null
inline SphericalTensor();
//- Construct initialized to zero
inline explicit SphericalTensor(const Foam::zero);
//- Construct given VectorSpace
template<class Cmpt2>
inline SphericalTensor
@ -106,6 +109,12 @@ public:
//- Transpose
inline const SphericalTensor<Cmpt>& T() const;
// Member Operators
//- Assignment to zero
inline void operator=(const Foam::zero);
};

View File

@ -32,6 +32,13 @@ inline Foam::SphericalTensor<Cmpt>::SphericalTensor()
{}
template<class Cmpt>
inline Foam::SphericalTensor<Cmpt>::SphericalTensor(const Foam::zero)
:
SphericalTensor::vsType(Zero)
{}
template<class Cmpt>
template<class Cmpt2>
inline Foam::SphericalTensor<Cmpt>::SphericalTensor
@ -39,7 +46,7 @@ inline Foam::SphericalTensor<Cmpt>::SphericalTensor
const VectorSpace<SphericalTensor<Cmpt2>, Cmpt2, 1>& vs
)
:
VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(vs)
SphericalTensor::vsType(vs)
{}
@ -53,7 +60,7 @@ inline Foam::SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
template<class Cmpt>
inline Foam::SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
:
VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
SphericalTensor::vsType(is)
{}
@ -81,6 +88,15 @@ Foam::SphericalTensor<Cmpt>::T() const
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SphericalTensor<Cmpt>::operator=(const Foam::zero)
{
SphericalTensor::vsType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -78,6 +78,9 @@ public:
//- Construct null
inline SphericalTensor2D();
//- Construct initialized to zero
inline explicit SphericalTensor2D(const Foam::zero);
//- Construct given VectorSpace
inline SphericalTensor2D
(
@ -97,6 +100,12 @@ public:
inline const Cmpt& ii() const;
inline Cmpt& ii();
// Member Operators
//- Assignment to zero
inline void operator=(const Foam::zero);
};

View File

@ -32,13 +32,20 @@ inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D()
{}
template<class Cmpt>
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(const Foam::zero)
:
SphericalTensor2D::vsType(Zero)
{}
template<class Cmpt>
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D
(
const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
)
:
VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(vs)
SphericalTensor2D::vsType(vs)
{}
@ -52,7 +59,7 @@ inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
template<class Cmpt>
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
:
VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
SphericalTensor2D::vsType(is)
{}
@ -72,6 +79,15 @@ inline Cmpt& Foam::SphericalTensor2D<Cmpt>::ii()
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SphericalTensor2D<Cmpt>::operator=(const Foam::zero)
{
SphericalTensor2D::vsType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -82,6 +82,9 @@ public:
//- Construct null
inline SymmTensor();
//- Construct initialized to zero
inline explicit SymmTensor(const Foam::zero);
//- Construct given VectorSpace of the same rank
template<class Cmpt2>
inline SymmTensor(const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>&);
@ -125,6 +128,9 @@ public:
// Member Operators
//- Assignment to zero
inline void operator=(const Foam::zero);
//- Construct given SphericalTensor
inline void operator=(const SphericalTensor<Cmpt>&);
};

View File

@ -33,6 +33,13 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor()
{}
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor(const Foam::zero)
:
SymmTensor::vsType(Zero)
{}
template<class Cmpt>
template<class Cmpt2>
inline Foam::SymmTensor<Cmpt>::SymmTensor
@ -40,7 +47,7 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor
const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>& vs
)
:
VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>(vs)
SymmTensor::vsType(vs)
{}
@ -70,7 +77,7 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor(Istream& is)
:
VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>(is)
SymmTensor::vsType(is)
{}
@ -157,7 +164,7 @@ inline const Foam::SymmTensor<Cmpt>& Foam::SymmTensor<Cmpt>::T() const
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
@ -168,6 +175,13 @@ inline void Foam::SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st)
}
template<class Cmpt>
inline void Foam::SymmTensor<Cmpt>::operator=(const Foam::zero)
{
SymmTensor::vsType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -82,6 +82,9 @@ public:
//- Construct null
inline SymmTensor2D();
//- Construct initialized to zero
inline explicit SymmTensor2D(const Foam::zero);
//- Construct given VectorSpace
inline SymmTensor2D(const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>&);
@ -117,6 +120,9 @@ public:
// Member Operators
//- Assignment to zero
inline void operator=(const Foam::zero);
//- Construct given SphericalTensor2D
inline void operator=(const SphericalTensor2D<Cmpt>&);
};

View File

@ -33,13 +33,20 @@ inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D()
{}
template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(const Foam::zero)
:
SymmTensor2D::vsType(Zero)
{}
template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D
(
const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs
)
:
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(vs)
SymmTensor2D::vsType(vs)
{}
@ -66,7 +73,7 @@ inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D
template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is)
:
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(is)
SymmTensor2D::vsType(is)
{}
@ -117,7 +124,7 @@ inline const Foam::SymmTensor2D<Cmpt>& Foam::SymmTensor2D<Cmpt>::T() const
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SymmTensor2D<Cmpt>::operator=
@ -130,6 +137,13 @@ inline void Foam::SymmTensor2D<Cmpt>::operator=
}
template<class Cmpt>
inline void Foam::SymmTensor2D<Cmpt>::operator=(const Foam::zero)
{
SymmTensor2D::vsType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -197,6 +197,9 @@ public:
//- Assign to a triad
inline void operator=(const Vector<Vector<Cmpt>>&);
//- Assignment to zero
inline void operator=(const Foam::zero);
};

View File

@ -33,9 +33,9 @@ inline Foam::Tensor<Cmpt>::Tensor()
template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor(const Foam::zero z)
inline Foam::Tensor<Cmpt>::Tensor(const Foam::zero)
:
Tensor::msType(z)
Tensor::msType(Zero)
{}
@ -329,7 +329,7 @@ inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::T() const
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::Tensor<Cmpt>::operator&=(const Tensor<Cmpt>& t)
@ -400,6 +400,13 @@ inline void Foam::Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt>>& tr)
}
template<class Cmpt>
inline void Foam::Tensor<Cmpt>::operator=(const Foam::zero)
{
Tensor::msType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -85,6 +85,9 @@ public:
//- Construct null
inline Tensor2D();
//- Construct initialized to zero
inline explicit Tensor2D(const Foam::zero);
//- Construct given VectorSpace
inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
@ -142,6 +145,9 @@ public:
//- Copy SphericalTensor2D
inline void operator=(const SphericalTensor2D<Cmpt>&);
//- Assignment to zero
inline void operator=(const Foam::zero);
};

View File

@ -30,13 +30,20 @@ inline Foam::Tensor2D<Cmpt>::Tensor2D()
{}
template<class Cmpt>
inline Foam::Tensor2D<Cmpt>::Tensor2D(const Foam::zero)
:
Tensor2D::msType(Zero)
{}
template<class Cmpt>
inline Foam::Tensor2D<Cmpt>::Tensor2D
(
const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs
)
:
VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(vs)
Tensor2D::msType(vs)
{}
@ -83,7 +90,7 @@ inline Foam::Tensor2D<Cmpt>::Tensor2D
template<class Cmpt>
inline Foam::Tensor2D<Cmpt>::Tensor2D(Istream& is)
:
VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(is)
Tensor2D::msType(is)
{}
@ -181,6 +188,15 @@ inline void Foam::Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::Tensor2D<Cmpt>::operator=(const Foam::zero)
{
Tensor2D::msType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -31,9 +31,9 @@ inline Foam::Vector<Cmpt>::Vector()
template<class Cmpt>
inline Foam::Vector<Cmpt>::Vector(const Foam::zero z)
inline Foam::Vector<Cmpt>::Vector(const Foam::zero)
:
Vector::vsType(z)
Vector::vsType(Zero)
{}
@ -44,7 +44,7 @@ inline Foam::Vector<Cmpt>::Vector
const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs
)
:
VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs)
Vector::vsType(vs)
{}
@ -65,7 +65,7 @@ inline Foam::Vector<Cmpt>::Vector
template<class Cmpt>
inline Foam::Vector<Cmpt>::Vector(Istream& is)
:
VectorSpace<Vector<Cmpt>, Cmpt, 3>(is)
Vector::vsType(is)
{}
@ -124,9 +124,9 @@ inline const Foam::Vector<Cmpt>& Foam::Vector<Cmpt>::centre
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::Vector<Cmpt>::operator=(const Foam::zero z)
inline void Foam::Vector<Cmpt>::operator=(const Foam::zero)
{
VectorSpace<Vector<Cmpt>, Cmpt, 3>::operator=(z);
Vector::vsType::operator=(Zero);
}

View File

@ -75,6 +75,9 @@ public:
//- Construct null
inline Vector2D();
//- Construct initialized to zero
inline explicit Vector2D(const Foam::zero);
//- Construct given VectorSpace
inline Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>&);
@ -100,6 +103,12 @@ public:
//- Perp dot product (dot product with perpendicular vector)
inline scalar perp(const Vector2D<Cmpt>& b) const;
// Member Operators
//- Assignment to zero
inline void operator=(const Foam::zero);
};

View File

@ -30,13 +30,20 @@ inline Foam::Vector2D<Cmpt>::Vector2D()
{}
template<class Cmpt>
inline Foam::Vector2D<Cmpt>::Vector2D(const Foam::zero)
:
Vector2D::vsType(Zero)
{}
template<class Cmpt>
inline Foam::Vector2D<Cmpt>::Vector2D
(
const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>& vs
)
:
VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(vs)
Vector2D::vsType(vs)
{}
@ -51,7 +58,7 @@ inline Foam::Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy)
template<class Cmpt>
inline Foam::Vector2D<Cmpt>::Vector2D(Istream& is)
:
VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(is)
Vector2D::vsType(is)
{}
@ -83,6 +90,15 @@ inline Cmpt& Foam::Vector2D<Cmpt>::y()
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::Vector2D<Cmpt>::operator=(const Foam::zero)
{
Vector2D::vsType::operator=(Zero);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam

View File

@ -42,9 +42,9 @@ inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero z)
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero)
{
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, Zero, eqOp<Cmpt>());
}

View File

@ -33,10 +33,10 @@ inline Foam::CompactSpatialTensor<Cmpt>::CompactSpatialTensor()
template<class Cmpt>
inline Foam::CompactSpatialTensor<Cmpt>::CompactSpatialTensor
(
const Foam::zero z
const Foam::zero
)
:
CompactSpatialTensor::msType(z)
CompactSpatialTensor::msType(Zero)
{}
@ -97,9 +97,9 @@ inline Foam::CompactSpatialTensor<Cmpt>::CompactSpatialTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::CompactSpatialTensor<Cmpt>::operator=(const Foam::zero z)
inline void Foam::CompactSpatialTensor<Cmpt>::operator=(const Foam::zero)
{
CompactSpatialTensor::msType::operator=(z);
CompactSpatialTensor::msType::operator=(Zero);
}

View File

@ -33,10 +33,10 @@ inline Foam::CompactSpatialTensorT<Cmpt>::CompactSpatialTensorT()
template<class Cmpt>
inline Foam::CompactSpatialTensorT<Cmpt>::CompactSpatialTensorT
(
const Foam::zero z
const Foam::zero
)
:
CompactSpatialTensorT::msType(z)
CompactSpatialTensorT::msType(Zero)
{}
@ -97,9 +97,9 @@ inline Foam::CompactSpatialTensorT<Cmpt>::CompactSpatialTensorT(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::CompactSpatialTensorT<Cmpt>::operator=(const Foam::zero z)
inline void Foam::CompactSpatialTensorT<Cmpt>::operator=(const Foam::zero)
{
CompactSpatialTensorT::msType::operator=(z);
CompactSpatialTensorT::msType::operator=(Zero);
}

View File

@ -33,9 +33,9 @@ inline Foam::SpatialTensor<Cmpt>::SpatialTensor()
template<class Cmpt>
inline Foam::SpatialTensor<Cmpt>::SpatialTensor(const Foam::zero z)
inline Foam::SpatialTensor<Cmpt>::SpatialTensor(const Foam::zero)
:
SpatialTensor::msType(z)
SpatialTensor::msType(Zero)
{}
@ -136,9 +136,9 @@ inline Foam::SpatialTensor<Cmpt>::SpatialTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SpatialTensor<Cmpt>::operator=(const Foam::zero z)
inline void Foam::SpatialTensor<Cmpt>::operator=(const Foam::zero)
{
SpatialTensor::msType::operator=(z);
SpatialTensor::msType::operator=(Zero);
}

View File

@ -31,9 +31,9 @@ inline Foam::SpatialVector<Cmpt>::SpatialVector()
template<class Cmpt>
inline Foam::SpatialVector<Cmpt>::SpatialVector(const Foam::zero z)
inline Foam::SpatialVector<Cmpt>::SpatialVector(const Foam::zero)
:
SpatialVector::vsType(z)
SpatialVector::vsType(Zero)
{}
@ -206,9 +206,9 @@ const Foam::SpatialVector<Cmpt>& Foam::SpatialVector<Cmpt>::dual::v() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Cmpt>
inline void Foam::SpatialVector<Cmpt>::operator=(const Foam::zero z)
inline void Foam::SpatialVector<Cmpt>::operator=(const Foam::zero)
{
SpatialVector::vsType::operator=(z);
SpatialVector::vsType::operator=(Zero);
}