Commit 93285d5f authored by Henry Weller's avatar Henry Weller
Browse files

src/OpenFOAM/primitives: Moved the standard static data members for vector and...

src/OpenFOAM/primitives: Moved the standard static data members for vector and tensor types into VectorSpace

This simplifies the code easing maintenance and the addition of other
VectorSpace types.
parent 8a93701e
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -58,6 +58,10 @@ class DiagTensor
public:
//- Equivalent type of labels used for valid component indexing
typedef DiagTensor<label> labelType;
// Member constants
enum
......@@ -66,16 +70,6 @@ public:
};
// Static data members
static const char* const typeName;
static const char* componentNames[];
static const DiagTensor zero;
static const DiagTensor one;
static const DiagTensor max;
static const DiagTensor min;
//- Component labeling enumeration
enum components { XX, YY, ZZ };
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -26,21 +26,16 @@ License
#include "SphericalTensor.H"
#include "SymmTensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline DiagTensor<Cmpt>::DiagTensor()
inline Foam::DiagTensor<Cmpt>::DiagTensor()
{}
template<class Cmpt>
template<class Cmpt2>
inline DiagTensor<Cmpt>::DiagTensor
inline Foam::DiagTensor<Cmpt>::DiagTensor
(
const VectorSpace<DiagTensor<Cmpt2>, Cmpt2, 3>& vs
)
......@@ -50,7 +45,7 @@ inline DiagTensor<Cmpt>::DiagTensor
template<class Cmpt>
inline DiagTensor<Cmpt>::DiagTensor
inline Foam::DiagTensor<Cmpt>::DiagTensor
(
const Cmpt& vxx,
const Cmpt& vyy,
......@@ -64,7 +59,7 @@ inline DiagTensor<Cmpt>::DiagTensor
template<class Cmpt>
inline DiagTensor<Cmpt>::DiagTensor(Istream& is)
inline Foam::DiagTensor<Cmpt>::DiagTensor(Istream& is)
:
VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>(is)
{}
......@@ -73,43 +68,48 @@ inline DiagTensor<Cmpt>::DiagTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& DiagTensor<Cmpt>::xx() const
inline const Cmpt& Foam::DiagTensor<Cmpt>::xx() const
{
return this->v_[XX];
}
template<class Cmpt>
inline const Cmpt& DiagTensor<Cmpt>::yy() const
inline const Cmpt& Foam::DiagTensor<Cmpt>::yy() const
{
return this->v_[YY];
}
template<class Cmpt>
inline const Cmpt& DiagTensor<Cmpt>::zz() const
inline const Cmpt& Foam::DiagTensor<Cmpt>::zz() const
{
return this->v_[ZZ];
}
template<class Cmpt>
inline Cmpt& DiagTensor<Cmpt>::xx()
inline Cmpt& Foam::DiagTensor<Cmpt>::xx()
{
return this->v_[XX];
}
template<class Cmpt>
inline Cmpt& DiagTensor<Cmpt>::yy()
inline Cmpt& Foam::DiagTensor<Cmpt>::yy()
{
return this->v_[YY];
}
template<class Cmpt>
inline Cmpt& DiagTensor<Cmpt>::zz()
inline Cmpt& Foam::DiagTensor<Cmpt>::zz()
{
return this->v_[ZZ];
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
template<class Cmpt>
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,34 +28,52 @@ Description
#include "diagTensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const diagTensor::typeName = "diagTensor";
const char* const Foam::diagTensor::vsType::typeName = "diagTensor";
template<>
const char* diagTensor::componentNames[] = {"xx", "yy", "zz"};
const char* const Foam::diagTensor::vsType::componentNames[] =
{
"xx", "yy", "zz"
};
template<>
const diagTensor diagTensor::zero(0, 0, 0);
const Foam::diagTensor Foam::diagTensor::vsType::vsType::zero
(
diagTensor::uniform(0)
);
template<>
const diagTensor diagTensor::one(1, 1, 1);
const Foam::diagTensor Foam::diagTensor::vsType::one
(
diagTensor::uniform(1)
);
template<>
const diagTensor diagTensor::max(VGREAT, VGREAT, VGREAT);
const Foam::diagTensor Foam::diagTensor::vsType::max
(
diagTensor::uniform(VGREAT)
);
template<>
const diagTensor diagTensor::min(-VGREAT, -VGREAT, -VGREAT);
const Foam::diagTensor Foam::diagTensor::vsType::min
(
diagTensor::uniform(-VGREAT)
);
template<>
const Foam::diagTensor Foam::diagTensor::vsType::rootMax
(
diagTensor::uniform(ROOTVGREAT)
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
const Foam::diagTensor Foam::diagTensor::vsType::rootMin
(
diagTensor::uniform(-ROOTVGREAT)
);
} // End namespace Foam
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -38,7 +38,7 @@ const Scalar pTraits<Scalar>::max = ScalarVGREAT;
const Scalar pTraits<Scalar>::rootMin = -ScalarROOTVGREAT;
const Scalar pTraits<Scalar>::rootMax = ScalarROOTVGREAT;
const char* pTraits<Scalar>::componentNames[] = { "" };
const char* const pTraits<Scalar>::componentNames[] = { "" };
pTraits<Scalar>::pTraits(const Scalar& p)
:
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -65,7 +65,7 @@ public:
// Static data members
static const char* const typeName;
static const char* componentNames[];
static const char* const componentNames[];
static const Scalar zero;
static const Scalar one;
static const Scalar max;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -70,12 +70,6 @@ public:
// Static data members
static const char* const typeName;
static const char* componentNames[];
static const SphericalTensor zero;
static const SphericalTensor one;
static const SphericalTensor max;
static const SphericalTensor min;
static const SphericalTensor I;
static const SphericalTensor oneThirdI;
static const SphericalTensor twoThirdsI;
......
......@@ -25,21 +25,16 @@ License
#include "Vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline SphericalTensor<Cmpt>::SphericalTensor()
inline Foam::SphericalTensor<Cmpt>::SphericalTensor()
{}
template<class Cmpt>
template<class Cmpt2>
inline SphericalTensor<Cmpt>::SphericalTensor
inline Foam::SphericalTensor<Cmpt>::SphericalTensor
(
const VectorSpace<SphericalTensor<Cmpt2>, Cmpt2, 1>& vs
)
......@@ -49,14 +44,14 @@ inline SphericalTensor<Cmpt>::SphericalTensor
template<class Cmpt>
inline SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
inline Foam::SphericalTensor<Cmpt>::SphericalTensor(const Cmpt& stii)
{
this->v_[II] = stii;
}
template<class Cmpt>
inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
inline Foam::SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
:
VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>(is)
{}
......@@ -65,26 +60,32 @@ inline SphericalTensor<Cmpt>::SphericalTensor(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& SphericalTensor<Cmpt>::ii() const
inline const Cmpt& Foam::SphericalTensor<Cmpt>::ii() const
{
return this->v_[II];
}
template<class Cmpt>
inline Cmpt& SphericalTensor<Cmpt>::ii()
inline Cmpt& Foam::SphericalTensor<Cmpt>::ii()
{
return this->v_[II];
}
template<class Cmpt>
inline const SphericalTensor<Cmpt>& SphericalTensor<Cmpt>::T() const
inline const Foam::SphericalTensor<Cmpt>&
Foam::SphericalTensor<Cmpt>::T() const
{
return *this;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
//- Inner-product between two spherical tensors
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,31 +25,59 @@ License
#include "labelSphericalTensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* const Foam::labelSphericalTensor::vsType::typeName
(
"labelSphericalTensor"
);
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::labelSphericalTensor::vsType::componentNames[] =
{
"ii"
};
template<>
const char* const labelSphericalTensor::typeName = "labelSphericalTensor";
const Foam::labelSphericalTensor
Foam::labelSphericalTensor::vsType::vsType::zero
(
labelSphericalTensor::uniform(0)
);
template<>
const char* labelSphericalTensor::componentNames[] = {"ii"};
const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::one
(
labelSphericalTensor::uniform(1)
);
template<>
const labelSphericalTensor labelSphericalTensor::zero(0);
const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::max
(
labelSphericalTensor::uniform(labelMax)
);
template<>
const labelSphericalTensor labelSphericalTensor::one(1);
const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::min
(
labelSphericalTensor::uniform(-labelMax)
);
template<>
const labelSphericalTensor labelSphericalTensor::I(1);
const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::rootMax
(
labelSphericalTensor::uniform(sqrt(scalar(labelMax)))
);
template<>
const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::rootMin
(
labelSphericalTensor::uniform(-sqrt(scalar(labelMax)))
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
const Foam::labelSphericalTensor Foam::labelSphericalTensor::I(1);
} // End namespace Foam
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,42 +25,57 @@ License
#include "sphericalTensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const sphericalTensor::typeName = "sphericalTensor";
const char* const Foam::sphericalTensor::vsType::typeName = "sphericalTensor";
template<>
const char* sphericalTensor::componentNames[] = {"ii"};
const char* const Foam::sphericalTensor::vsType::componentNames[] = {"ii"};
template<>
const sphericalTensor sphericalTensor::zero(0);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::zero
(
sphericalTensor::uniform(0)
);
template<>
const sphericalTensor sphericalTensor::one(1);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::one
(
sphericalTensor::uniform(1)
);
template<>
const sphericalTensor sphericalTensor::max(VGREAT);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::max
(
sphericalTensor::uniform(VGREAT)
);
template<>
const sphericalTensor sphericalTensor::min(-VGREAT);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::min
(
sphericalTensor::uniform(-VGREAT)
);
template<>
const sphericalTensor sphericalTensor::I(1);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::rootMax
(
sphericalTensor::uniform(ROOTVGREAT)
);
template<>
const sphericalTensor sphericalTensor::oneThirdI(1.0/3.0);
const Foam::sphericalTensor Foam::sphericalTensor::vsType::rootMin
(
sphericalTensor::uniform(-ROOTVGREAT)
);
template<>
const sphericalTensor sphericalTensor::twoThirdsI(2.0/3.0);
const Foam::sphericalTensor Foam::sphericalTensor::I(1);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
const Foam::sphericalTensor Foam::sphericalTensor::oneThirdI(1.0/3.0);
} // End namespace Foam
template<>
const Foam::sphericalTensor Foam::sphericalTensor::twoThirdsI(2.0/3.0);
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -66,12 +66,6 @@ public:
// Static data members
static const char* const typeName;
static const char* componentNames[];
static const SphericalTensor2D zero;
static const SphericalTensor2D one;
static const SphericalTensor2D max;
static const SphericalTensor2D min;
static const SphericalTensor2D I;
static const SphericalTensor2D oneThirdI;
static const SphericalTensor2D twoThirdsI;
......
......@@ -25,22 +25,15 @@ License
#include "Vector2D.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null
template<class Cmpt>
inline SphericalTensor2D<Cmpt>::SphericalTensor2D()
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D()
{}
// Construct given VectorSpace
template<class Cmpt>
inline SphericalTensor2D<Cmpt>::SphericalTensor2D
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D
(
const VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>& vs
)
......@@ -49,17 +42,15 @@ inline SphericalTensor2D<Cmpt>::SphericalTensor2D
{}
// Construct given three Cmpts
template<class Cmpt>
inline SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(const Cmpt& stii)
{
this->v_[II] = stii;
}
// Construct from Istream
template<class Cmpt>
inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
:
VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>(is)
{}
......@@ -68,19 +59,24 @@ inline SphericalTensor2D<Cmpt>::SphericalTensor2D(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Cmpt>
inline const Cmpt& SphericalTensor2D<Cmpt>::ii() const
inline const Cmpt& Foam::SphericalTensor2D<Cmpt>::ii() const
{
return this->v_[II];