From 93285d5fe197d64db9e467c03fec88e10e9b666e Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Tue, 8 Mar 2016 10:57:41 +0000 Subject: [PATCH] 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. --- .../primitives/DiagTensor/DiagTensor.H | 16 ++-- .../primitives/DiagTensor/DiagTensorI.H | 32 +++---- .../DiagTensor/diagTensor/diagTensor.C | 46 +++++++--- src/OpenFOAM/primitives/Scalar/Scalar.C | 4 +- src/OpenFOAM/primitives/Scalar/Scalar.H | 4 +- .../SphericalTensor/SphericalTensor.H | 8 +- .../SphericalTensor/SphericalTensorI.H | 25 +++--- .../labelSphericalTensor.C | 52 ++++++++--- .../sphericalTensor/sphericalTensor.C | 49 +++++++---- .../SphericalTensor2D/SphericalTensor2D.H | 8 +- .../SphericalTensor2D/SphericalTensor2DI.H | 26 +++--- .../sphericalTensor2D/sphericalTensor2D.C | 56 ++++++++---- .../primitives/SymmTensor/SymmTensor.H | 9 +- .../primitives/SymmTensor/SymmTensorI.H | 47 +++++----- .../labelSymmTensor/labelSymmTensor.C | 55 ++++++++---- .../SymmTensor/symmTensor/symmTensor.C | 53 ++++++------ .../primitives/SymmTensor2D/SymmTensor2D.H | 9 +- .../primitives/SymmTensor2D/SymmTensor2DI.H | 39 +++++---- .../SymmTensor2D/symmTensor2D/symmTensor2D.C | 49 ++++++----- src/OpenFOAM/primitives/Tensor/Tensor.H | 7 -- src/OpenFOAM/primitives/Tensor/TensorI.H | 86 ++++++++++--------- .../Tensor/labelTensor/labelTensor.C | 75 +++++++++------- .../primitives/Tensor/tensor/tensor.C | 77 +++++++---------- src/OpenFOAM/primitives/Tensor2D/Tensor2D.H | 13 ++- src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H | 52 +++++------ .../primitives/Tensor2D/tensor2D/tensor2D.C | 36 +++++--- src/OpenFOAM/primitives/Vector/Vector.H | 14 +-- src/OpenFOAM/primitives/Vector/VectorI.H | 47 +++++----- .../Vector/complexVector/complexVector.C | 47 ++++++---- .../Vector/floatVector/floatVector.C | 49 ++++++----- .../Vector/labelVector/labelVector.C | 53 +++++++++--- .../primitives/Vector/vector/vector.C | 26 ++---- src/OpenFOAM/primitives/Vector2D/Vector2D.H | 16 ++-- src/OpenFOAM/primitives/Vector2D/Vector2DI.H | 33 ++++--- .../primitives/Vector2D/vector2D/vector2D.C | 44 +++++++--- .../primitives/VectorSpace/VectorSpace.H | 23 ++++- .../primitives/VectorSpace/VectorSpaceI.H | 16 ++-- src/OpenFOAM/primitives/bools/bool/bool.C | 4 +- src/OpenFOAM/primitives/bools/bool/bool.H | 4 +- src/OpenFOAM/primitives/ints/int32/int32.C | 4 +- src/OpenFOAM/primitives/ints/int32/int32.H | 4 +- src/OpenFOAM/primitives/ints/int64/int64.C | 4 +- src/OpenFOAM/primitives/ints/int64/int64.H | 4 +- src/OpenFOAM/primitives/ints/uint32/uint32.C | 4 +- src/OpenFOAM/primitives/ints/uint32/uint32.H | 4 +- src/OpenFOAM/primitives/ints/uint64/uint64.C | 4 +- src/OpenFOAM/primitives/ints/uint64/uint64.H | 4 +- src/OpenFOAM/primitives/triad/triad.C | 61 ++++++------- src/OpenFOAM/primitives/triad/triad.H | 8 +- 49 files changed, 766 insertions(+), 644 deletions(-) diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H index 2d64825ed77..0a2138cea44 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H @@ -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 }; diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H index 63497e7a246..49ed7b8998e 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H @@ -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> diff --git a/src/OpenFOAM/primitives/DiagTensor/diagTensor/diagTensor.C b/src/OpenFOAM/primitives/DiagTensor/diagTensor/diagTensor.C index f5fe69dedc3..bcc9c1af3df 100644 --- a/src/OpenFOAM/primitives/DiagTensor/diagTensor/diagTensor.C +++ b/src/OpenFOAM/primitives/DiagTensor/diagTensor/diagTensor.C @@ -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 // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.C b/src/OpenFOAM/primitives/Scalar/Scalar.C index 05db9a2d80d..0a3e09b0b18 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.C +++ b/src/OpenFOAM/primitives/Scalar/Scalar.C @@ -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) : diff --git a/src/OpenFOAM/primitives/Scalar/Scalar.H b/src/OpenFOAM/primitives/Scalar/Scalar.H index c25a92b2097..54b8ec57850 100644 --- a/src/OpenFOAM/primitives/Scalar/Scalar.H +++ b/src/OpenFOAM/primitives/Scalar/Scalar.H @@ -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; diff --git a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H index a2bb56e3f4c..cd16d3026eb 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H +++ b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensor.H @@ -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; diff --git a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H index c22f5478950..409b3961b29 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H +++ b/src/OpenFOAM/primitives/SphericalTensor/SphericalTensorI.H @@ -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 diff --git a/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C b/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C index 59f01c61925..c7ce40447fd 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C +++ b/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C @@ -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 // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SphericalTensor/sphericalTensor/sphericalTensor.C b/src/OpenFOAM/primitives/SphericalTensor/sphericalTensor/sphericalTensor.C index b5d3bc59fc8..826fb0cc222 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/sphericalTensor/sphericalTensor.C +++ b/src/OpenFOAM/primitives/SphericalTensor/sphericalTensor/sphericalTensor.C @@ -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); // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H index 0ecae53a584..474777c1c3d 100644 --- a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H +++ b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2D.H @@ -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; diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H index 18bf88f0a56..9a8b6daff73 100644 --- a/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H +++ b/src/OpenFOAM/primitives/SphericalTensor2D/SphericalTensor2DI.H @@ -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]; } template<class Cmpt> -inline Cmpt& SphericalTensor2D<Cmpt>::ii() +inline Cmpt& Foam::SphericalTensor2D<Cmpt>::ii() { return this->v_[II]; } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // //- Inner-product between two spherical tensors diff --git a/src/OpenFOAM/primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C b/src/OpenFOAM/primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C index c8c597f32c9..538e9d437f3 100644 --- a/src/OpenFOAM/primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C +++ b/src/OpenFOAM/primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C @@ -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,64 @@ License #include "sphericalTensor2D.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const sphericalTensor2D::typeName = "sphericalTensor2D"; +const char* const Foam::sphericalTensor2D::vsType::typeName +( + "sphericalTensor2D" +); template<> -const char* sphericalTensor2D::componentNames[] = {"ii"}; +const char* const Foam::sphericalTensor2D::vsType::componentNames[] = +{ + "ii" +}; template<> -const sphericalTensor2D sphericalTensor2D::zero(0); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::vsType::zero +( + sphericalTensor2D::uniform(0) +); template<> -const sphericalTensor2D sphericalTensor2D::one(1); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::one +( + sphericalTensor2D::uniform(1) +); template<> -const sphericalTensor2D sphericalTensor2D::max(VGREAT); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::max +( + sphericalTensor2D::uniform(VGREAT) +); template<> -const sphericalTensor2D sphericalTensor2D::min(-VGREAT); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::min +( + sphericalTensor2D::uniform(-VGREAT) +); template<> -const sphericalTensor2D sphericalTensor2D::I(1); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::rootMax +( + sphericalTensor2D::uniform(ROOTVGREAT) +); template<> -const sphericalTensor2D sphericalTensor2D::oneThirdI(1.0/3.0); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::vsType::rootMin +( + sphericalTensor2D::uniform(-ROOTVGREAT) +); template<> -const sphericalTensor2D sphericalTensor2D::twoThirdsI(2.0/3.0); +const Foam::sphericalTensor2D Foam::sphericalTensor2D::I(1); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::sphericalTensor2D Foam::sphericalTensor2D::oneThirdI(1.0/3.0); + +template<> +const Foam::sphericalTensor2D Foam::sphericalTensor2D::twoThirdsI(2.0/3.0); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H index afa1dbb622f..952536ac8cc 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensor.H @@ -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 @@ -72,13 +72,6 @@ public: // Static data members - static const char* const typeName; - static const char* componentNames[]; - - static const SymmTensor zero; - static const SymmTensor one; - static const SymmTensor max; - static const SymmTensor min; static const SymmTensor I; diff --git a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H index b0e64c90091..6caa6aec265 100644 --- a/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H +++ b/src/OpenFOAM/primitives/SymmTensor/SymmTensorI.H @@ -26,21 +26,16 @@ License #include "Vector.H" #include "Tensor.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Cmpt> -inline SymmTensor<Cmpt>::SymmTensor() +inline Foam::SymmTensor<Cmpt>::SymmTensor() {} template<class Cmpt> template<class Cmpt2> -inline SymmTensor<Cmpt>::SymmTensor +inline Foam::SymmTensor<Cmpt>::SymmTensor ( const VectorSpace<SymmTensor<Cmpt2>, Cmpt2, 6>& vs ) @@ -50,7 +45,7 @@ inline SymmTensor<Cmpt>::SymmTensor template<class Cmpt> -inline SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st) +inline Foam::SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0; @@ -59,7 +54,7 @@ inline SymmTensor<Cmpt>::SymmTensor(const SphericalTensor<Cmpt>& st) template<class Cmpt> -inline SymmTensor<Cmpt>::SymmTensor +inline Foam::SymmTensor<Cmpt>::SymmTensor ( const Cmpt txx, const Cmpt txy, const Cmpt txz, const Cmpt tyy, const Cmpt tyz, @@ -73,7 +68,7 @@ inline SymmTensor<Cmpt>::SymmTensor template<class Cmpt> -inline SymmTensor<Cmpt>::SymmTensor(Istream& is) +inline Foam::SymmTensor<Cmpt>::SymmTensor(Istream& is) : VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>(is) {} @@ -82,81 +77,81 @@ inline SymmTensor<Cmpt>::SymmTensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::xx() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::xx() const { return this->v_[XX]; } template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::xy() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::xy() const { return this->v_[XY]; } template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::xz() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::xz() const { return this->v_[XZ]; } template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::yy() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::yy() const { return this->v_[YY]; } template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::yz() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::yz() const { return this->v_[YZ]; } template<class Cmpt> -inline const Cmpt& SymmTensor<Cmpt>::zz() const +inline const Cmpt& Foam::SymmTensor<Cmpt>::zz() const { return this->v_[ZZ]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::xx() +inline Cmpt& Foam::SymmTensor<Cmpt>::xx() { return this->v_[XX]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::xy() +inline Cmpt& Foam::SymmTensor<Cmpt>::xy() { return this->v_[XY]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::xz() +inline Cmpt& Foam::SymmTensor<Cmpt>::xz() { return this->v_[XZ]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::yy() +inline Cmpt& Foam::SymmTensor<Cmpt>::yy() { return this->v_[YY]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::yz() +inline Cmpt& Foam::SymmTensor<Cmpt>::yz() { return this->v_[YZ]; } template<class Cmpt> -inline Cmpt& SymmTensor<Cmpt>::zz() +inline Cmpt& Foam::SymmTensor<Cmpt>::zz() { return this->v_[ZZ]; } template<class Cmpt> -inline const SymmTensor<Cmpt>& SymmTensor<Cmpt>::T() const +inline const Foam::SymmTensor<Cmpt>& Foam::SymmTensor<Cmpt>::T() const { return *this; } @@ -165,7 +160,7 @@ inline const SymmTensor<Cmpt>& SymmTensor<Cmpt>::T() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline void SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) +inline void Foam::SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0; @@ -173,6 +168,10 @@ inline void SymmTensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C index 0e5deb2705e..ea20917f261 100644 --- a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C +++ b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C @@ -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,18 +25,13 @@ License #include "labelSymmTensor.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const labelSymmTensor::typeName = "labelSymmTensor"; +const char* const Foam::labelSymmTensor::vsType::typeName = "labelSymmTensor"; template<> -const char* labelSymmTensor::componentNames[] = +const char* const Foam::labelSymmTensor::vsType::componentNames[] = { "xx", "xy", "xz", "yy", "yz", @@ -44,24 +39,48 @@ const char* labelSymmTensor::componentNames[] = }; template<> -const labelSymmTensor labelSymmTensor::zero +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::vsType::zero ( - 0, 0, 0, - 0, 0, - 0 + labelSymmTensor::uniform(0) ); template<> -const labelSymmTensor labelSymmTensor::one +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::one ( - 1, 1, 1, - 1, 1, - 1 + labelSymmTensor::uniform(1) +); + +template<> +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::max +( + labelSymmTensor::uniform(labelMax) ); +template<> +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::min +( + labelSymmTensor::uniform(-labelMax) +); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::rootMax +( + labelSymmTensor::uniform(sqrt(scalar(labelMax))) +); + +template<> +const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::rootMin +( + labelSymmTensor::uniform(-sqrt(scalar(labelMax))) +); + +template<> +const Foam::labelSymmTensor Foam::labelSymmTensor::I +( + 1, 0, 0, + 1, 0, + 1 +); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SymmTensor/symmTensor/symmTensor.C b/src/OpenFOAM/primitives/SymmTensor/symmTensor/symmTensor.C index 22f2b9eb8db..cc5b6975e0c 100644 --- a/src/OpenFOAM/primitives/SymmTensor/symmTensor/symmTensor.C +++ b/src/OpenFOAM/primitives/SymmTensor/symmTensor/symmTensor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,18 +25,13 @@ License #include "symmTensor.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const symmTensor::typeName = "symmTensor"; +const char* const Foam::symmTensor::vsType::typeName = "symmTensor"; template<> -const char* symmTensor::componentNames[] = +const char* const Foam::symmTensor::vsType::componentNames[] = { "xx", "xy", "xz", "yy", "yz", @@ -44,39 +39,43 @@ const char* symmTensor::componentNames[] = }; template<> -const symmTensor symmTensor::zero +const Foam::symmTensor Foam::symmTensor::vsType::vsType::zero ( - 0, 0, 0, - 0, 0, - 0 + symmTensor::uniform(0) ); template<> -const symmTensor symmTensor::one +const Foam::symmTensor Foam::symmTensor::vsType::one ( - 1, 1, 1, - 1, 1, - 1 + symmTensor::uniform(1) +); + +template<> +const Foam::symmTensor Foam::symmTensor::vsType::max +( + symmTensor::uniform(VGREAT) ); template<> -const symmTensor symmTensor::max +const Foam::symmTensor Foam::symmTensor::vsType::min ( - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, - VGREAT + symmTensor::uniform(-VGREAT) ); template<> -const symmTensor symmTensor::min +const Foam::symmTensor Foam::symmTensor::vsType::rootMax ( - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, - -VGREAT + symmTensor::uniform(ROOTVGREAT) ); template<> -const symmTensor symmTensor::I +const Foam::symmTensor Foam::symmTensor::vsType::rootMin +( + symmTensor::uniform(-ROOTVGREAT) +); + +template<> +const Foam::symmTensor Foam::symmTensor::I ( 1, 0, 0, 1, 0, @@ -84,8 +83,4 @@ const symmTensor symmTensor::I ); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H index 550e9bfec07..1d747caa2d0 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H @@ -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 @@ -72,13 +72,6 @@ public: // Static data members - static const char* const typeName; - static const char* componentNames[]; - - static const SymmTensor2D zero; - static const SymmTensor2D one; - static const SymmTensor2D max; - static const SymmTensor2D min; static const SymmTensor2D I; diff --git a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H index 2212a6f13d0..674a6a6975f 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H +++ b/src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H @@ -26,20 +26,15 @@ License #include "Vector2D.H" #include "Tensor2D.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Cmpt> -inline SymmTensor2D<Cmpt>::SymmTensor2D() +inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D() {} template<class Cmpt> -inline SymmTensor2D<Cmpt>::SymmTensor2D +inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D ( const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs ) @@ -49,7 +44,7 @@ inline SymmTensor2D<Cmpt>::SymmTensor2D template<class Cmpt> -inline SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st) +inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YY] = st.ii(); @@ -57,7 +52,7 @@ inline SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st) template<class Cmpt> -inline SymmTensor2D<Cmpt>::SymmTensor2D +inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D ( const Cmpt txx, const Cmpt txy, const Cmpt tyy @@ -69,7 +64,7 @@ inline SymmTensor2D<Cmpt>::SymmTensor2D template<class Cmpt> -inline SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is) +inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is) : VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(is) {} @@ -78,45 +73,45 @@ inline SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline const Cmpt& SymmTensor2D<Cmpt>::xx() const +inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xx() const { return this->v_[XX]; } template<class Cmpt> -inline const Cmpt& SymmTensor2D<Cmpt>::xy() const +inline const Cmpt& Foam::SymmTensor2D<Cmpt>::xy() const { return this->v_[XY]; } template<class Cmpt> -inline const Cmpt& SymmTensor2D<Cmpt>::yy() const +inline const Cmpt& Foam::SymmTensor2D<Cmpt>::yy() const { return this->v_[YY]; } template<class Cmpt> -inline Cmpt& SymmTensor2D<Cmpt>::xx() +inline Cmpt& Foam::SymmTensor2D<Cmpt>::xx() { return this->v_[XX]; } template<class Cmpt> -inline Cmpt& SymmTensor2D<Cmpt>::xy() +inline Cmpt& Foam::SymmTensor2D<Cmpt>::xy() { return this->v_[XY]; } template<class Cmpt> -inline Cmpt& SymmTensor2D<Cmpt>::yy() +inline Cmpt& Foam::SymmTensor2D<Cmpt>::yy() { return this->v_[YY]; } template<class Cmpt> -inline const SymmTensor2D<Cmpt>& SymmTensor2D<Cmpt>::T() const +inline const Foam::SymmTensor2D<Cmpt>& Foam::SymmTensor2D<Cmpt>::T() const { return *this; } @@ -125,13 +120,21 @@ inline const SymmTensor2D<Cmpt>& SymmTensor2D<Cmpt>::T() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline void SymmTensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st) +inline void Foam::SymmTensor2D<Cmpt>::operator= +( + const SphericalTensor2D<Cmpt>& st +) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YY] = st.ii(); } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // //- Inner-product between two symmetric tensors diff --git a/src/OpenFOAM/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C b/src/OpenFOAM/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C index 32f6d9ca6a2..f2d870261ba 100644 --- a/src/OpenFOAM/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C +++ b/src/OpenFOAM/primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C @@ -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 @@ -25,61 +25,60 @@ License #include "symmTensor2D.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const symmTensor2D::typeName = "symmTensor2D"; +const char* const Foam::symmTensor2D::vsType::typeName = "symmTensor2D"; template<> -const char* symmTensor2D::componentNames[] = +const char* const Foam::symmTensor2D::vsType::componentNames[] = { "xx", "xy", "yy" }; template<> -const symmTensor2D symmTensor2D::zero +const Foam::symmTensor2D Foam::symmTensor2D::vsType::vsType::zero ( - 0, 0, - 0 + symmTensor2D::uniform(0) ); template<> -const symmTensor2D symmTensor2D::one +const Foam::symmTensor2D Foam::symmTensor2D::vsType::one ( - 1, 1, - 1 + symmTensor2D::uniform(1) ); template<> -const symmTensor2D symmTensor2D::max +const Foam::symmTensor2D Foam::symmTensor2D::vsType::max ( - VGREAT, VGREAT, - VGREAT + symmTensor2D::uniform(VGREAT) ); template<> -const symmTensor2D symmTensor2D::min +const Foam::symmTensor2D Foam::symmTensor2D::vsType::min ( - -VGREAT, -VGREAT, - -VGREAT + symmTensor2D::uniform(-VGREAT) ); template<> -const symmTensor2D symmTensor2D::I +const Foam::symmTensor2D Foam::symmTensor2D::vsType::rootMax ( - 1, 0, - 1 + symmTensor2D::uniform(ROOTVGREAT) ); +template<> +const Foam::symmTensor2D Foam::symmTensor2D::vsType::rootMin +( + symmTensor2D::uniform(-ROOTVGREAT) +); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::symmTensor2D Foam::symmTensor2D::I +( + 1, 0, + 1 +); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Tensor/Tensor.H b/src/OpenFOAM/primitives/Tensor/Tensor.H index 0d0ba7e04dd..9cd83fd09b0 100644 --- a/src/OpenFOAM/primitives/Tensor/Tensor.H +++ b/src/OpenFOAM/primitives/Tensor/Tensor.H @@ -75,13 +75,6 @@ public: // Static data members - static const char* const typeName; - static const char* componentNames[]; - - static const Tensor zero; - static const Tensor one; - static const Tensor max; - static const Tensor min; static const Tensor I; diff --git a/src/OpenFOAM/primitives/Tensor/TensorI.H b/src/OpenFOAM/primitives/Tensor/TensorI.H index 85b33a4952b..35bfdef0c46 100644 --- a/src/OpenFOAM/primitives/Tensor/TensorI.H +++ b/src/OpenFOAM/primitives/Tensor/TensorI.H @@ -25,28 +25,26 @@ License #include "SymmTensor.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Cmpt> -inline Tensor<Cmpt>::Tensor() +inline Foam::Tensor<Cmpt>::Tensor() {} template<class Cmpt> template<class Cmpt2> -inline Tensor<Cmpt>::Tensor(const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs) +inline Foam::Tensor<Cmpt>::Tensor +( + const VectorSpace<Tensor<Cmpt2>, Cmpt2, 9>& vs +) : VectorSpace<Tensor<Cmpt>, Cmpt, 9>(vs) {} template<class Cmpt> -inline Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st) +inline Foam::Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0; @@ -55,7 +53,7 @@ inline Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st) template<class Cmpt> -inline Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st) +inline Foam::Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st) { this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz(); this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz(); @@ -64,7 +62,7 @@ inline Tensor<Cmpt>::Tensor(const SymmTensor<Cmpt>& st) template<class Cmpt> -inline Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt>>& tr) +inline Foam::Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt>>& tr) { this->v_[XX] = tr.x().x(); this->v_[XY] = tr.x().y(); @@ -81,7 +79,7 @@ inline Tensor<Cmpt>::Tensor(const Vector<Vector<Cmpt>>& tr) template<class Cmpt> -inline Tensor<Cmpt>::Tensor +inline Foam::Tensor<Cmpt>::Tensor ( const Vector<Cmpt>& x, const Vector<Cmpt>& y, @@ -95,7 +93,7 @@ inline Tensor<Cmpt>::Tensor template<class Cmpt> -inline Tensor<Cmpt>::Tensor +inline Foam::Tensor<Cmpt>::Tensor ( const Cmpt txx, const Cmpt txy, const Cmpt txz, const Cmpt tyx, const Cmpt tyy, const Cmpt tyz, @@ -109,7 +107,7 @@ inline Tensor<Cmpt>::Tensor template<class Cmpt> -inline Tensor<Cmpt>::Tensor(Istream& is) +inline Foam::Tensor<Cmpt>::Tensor(Istream& is) : VectorSpace<Tensor<Cmpt>, Cmpt, 9>(is) {} @@ -118,28 +116,31 @@ inline Tensor<Cmpt>::Tensor(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline Vector<Cmpt> Tensor<Cmpt>::x() const +inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::x() const { return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]); } template<class Cmpt> -inline Vector<Cmpt> Tensor<Cmpt>::y() const +inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::y() const { return Vector<Cmpt>(this->v_[YX], this->v_[YY], this->v_[YZ]); } template<class Cmpt> -inline Vector<Cmpt> Tensor<Cmpt>::z() const +inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::z() const { return Vector<Cmpt>(this->v_[ZX], this->v_[ZY], this->v_[ZZ]); } template<class Cmpt> -inline Vector<Cmpt> Tensor<Cmpt>::vectorComponent(const direction cmpt) const +inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::vectorComponent +( + const direction cmpt +) const { switch (cmpt) { @@ -157,133 +158,133 @@ inline Vector<Cmpt> Tensor<Cmpt>::vectorComponent(const direction cmpt) const template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::xx() const +inline const Cmpt& Foam::Tensor<Cmpt>::xx() const { return this->v_[XX]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::xy() const +inline const Cmpt& Foam::Tensor<Cmpt>::xy() const { return this->v_[XY]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::xz() const +inline const Cmpt& Foam::Tensor<Cmpt>::xz() const { return this->v_[XZ]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::yx() const +inline const Cmpt& Foam::Tensor<Cmpt>::yx() const { return this->v_[YX]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::yy() const +inline const Cmpt& Foam::Tensor<Cmpt>::yy() const { return this->v_[YY]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::yz() const +inline const Cmpt& Foam::Tensor<Cmpt>::yz() const { return this->v_[YZ]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::zx() const +inline const Cmpt& Foam::Tensor<Cmpt>::zx() const { return this->v_[ZX]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::zy() const +inline const Cmpt& Foam::Tensor<Cmpt>::zy() const { return this->v_[ZY]; } template<class Cmpt> -inline const Cmpt& Tensor<Cmpt>::zz() const +inline const Cmpt& Foam::Tensor<Cmpt>::zz() const { return this->v_[ZZ]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::xx() +inline Cmpt& Foam::Tensor<Cmpt>::xx() { return this->v_[XX]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::xy() +inline Cmpt& Foam::Tensor<Cmpt>::xy() { return this->v_[XY]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::xz() +inline Cmpt& Foam::Tensor<Cmpt>::xz() { return this->v_[XZ]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::yx() +inline Cmpt& Foam::Tensor<Cmpt>::yx() { return this->v_[YX]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::yy() +inline Cmpt& Foam::Tensor<Cmpt>::yy() { return this->v_[YY]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::yz() +inline Cmpt& Foam::Tensor<Cmpt>::yz() { return this->v_[YZ]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::zx() +inline Cmpt& Foam::Tensor<Cmpt>::zx() { return this->v_[ZX]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::zy() +inline Cmpt& Foam::Tensor<Cmpt>::zy() { return this->v_[ZY]; } template<class Cmpt> -inline Cmpt& Tensor<Cmpt>::zz() +inline Cmpt& Foam::Tensor<Cmpt>::zz() { return this->v_[ZZ]; } template<class Cmpt> -inline Tensor<Cmpt> Tensor<Cmpt>::T() const +inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::T() const { return Tensor<Cmpt> ( @@ -297,7 +298,7 @@ inline Tensor<Cmpt> Tensor<Cmpt>::T() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline void Tensor<Cmpt>::operator&=(const Tensor<Cmpt>& t) +inline void Foam::Tensor<Cmpt>::operator&=(const Tensor<Cmpt>& t) { *this = ( @@ -320,7 +321,7 @@ inline void Tensor<Cmpt>::operator&=(const Tensor<Cmpt>& t) template<class Cmpt> -inline void Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) +inline void Foam::Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); this->v_[YZ] = 0; @@ -329,7 +330,7 @@ inline void Tensor<Cmpt>::operator=(const SphericalTensor<Cmpt>& st) template<class Cmpt> -inline void Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st) +inline void Foam::Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st) { this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[XZ] = st.xz(); this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); this->v_[YZ] = st.yz(); @@ -338,7 +339,7 @@ inline void Tensor<Cmpt>::operator=(const SymmTensor<Cmpt>& st) template<class Cmpt> -inline void Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt>>& tr) +inline void Foam::Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt>>& tr) { this->v_[XX] = tr.x().x(); this->v_[XY] = tr.x().y(); @@ -354,6 +355,11 @@ inline void Tensor<Cmpt>::operator=(const Vector<Vector<Cmpt>>& tr) } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // template<class Cmpt> diff --git a/src/OpenFOAM/primitives/Tensor/labelTensor/labelTensor.C b/src/OpenFOAM/primitives/Tensor/labelTensor/labelTensor.C index 4274e78a3e4..4f15ceda59f 100644 --- a/src/OpenFOAM/primitives/Tensor/labelTensor/labelTensor.C +++ b/src/OpenFOAM/primitives/Tensor/labelTensor/labelTensor.C @@ -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,35 +28,52 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam +template<> +const char* const Foam::labelTensor::vsType::typeName = "labelTensor"; + +template<> +const char* const Foam::labelTensor::vsType::componentNames[] = { - template<> - const char* const Foam::labelTensor::typeName = "labelTensor"; - - template<> - const char* Foam::labelTensor::componentNames[] = - { - "xx", "xy", "xz", - "yx", "yy", "yz", - "zx", "zy", "zz" - }; - - template<> - const Foam::labelTensor Foam::labelTensor::zero - ( - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 - ); - - template<> - const Foam::labelTensor Foam::labelTensor::one - ( - 1, 1, 1, - 1, 1, 1, - 1, 1, 1 - ); -} + "xx", "xy", "xz", + "yx", "yy", "yz", + "zx", "zy", "zz" +}; + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::zero +( + labelTensor::uniform(0) +); + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::one +( + labelTensor::uniform(1) +); + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::max +( + labelTensor::uniform(labelMax) +); + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::min +( + labelTensor::uniform(-labelMax) +); + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::rootMax +( + labelTensor::uniform(sqrt(scalar(labelMax))) +); + +template<> +const Foam::labelTensor Foam::labelTensor::vsType::rootMin +( + labelTensor::uniform(-sqrt(scalar(labelMax))) +); // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C index fd636a2529a..cadbef6a9b3 100644 --- a/src/OpenFOAM/primitives/Tensor/tensor/tensor.C +++ b/src/OpenFOAM/primitives/Tensor/tensor/tensor.C @@ -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 @@ -30,59 +30,42 @@ using namespace Foam::constant::mathematical; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam +template<> +const char* const Foam::tensor::vsType::typeName = "tensor"; + +template<> +const char* const Foam::tensor::vsType::componentNames[] = { - template<> - const char* const tensor::typeName = "tensor"; + "xx", "xy", "xz", + "yx", "yy", "yz", + "zx", "zy", "zz" +}; - template<> - const char* tensor::componentNames[] = - { - "xx", "xy", "xz", - "yx", "yy", "yz", - "zx", "zy", "zz" - }; +template<> +const Foam::tensor Foam::tensor::vsType::zero(tensor::uniform(0)); - template<> - const tensor tensor::zero - ( - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 - ); +template<> +const Foam::tensor Foam::tensor::vsType::one(tensor::uniform(1)); - template<> - const tensor tensor::one - ( - 1, 1, 1, - 1, 1, 1, - 1, 1, 1 - ); +template<> +const Foam::tensor Foam::tensor::vsType::max(tensor::uniform(VGREAT)); - template<> - const tensor tensor::max - ( - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT, - VGREAT, VGREAT, VGREAT - ); +template<> +const Foam::tensor Foam::tensor::vsType::min(tensor::uniform(-VGREAT)); - template<> - const tensor tensor::min - ( - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT, - -VGREAT, -VGREAT, -VGREAT - ); +template<> +const Foam::tensor Foam::tensor::vsType::rootMax(tensor::uniform(ROOTVGREAT)); - template<> - const tensor tensor::I - ( - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 - ); -} +template<> +const Foam::tensor Foam::tensor::vsType::rootMin(tensor::uniform(-ROOTVGREAT)); + +template<> +const Foam::tensor Foam::tensor::I +( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 +); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H index ac49d74d53a..bc1f3906e56 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2D.H @@ -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 @@ -61,6 +61,10 @@ class Tensor2D public: + //- Equivalent type of labels used for valid component indexing + typedef Tensor2D<label> labelType; + + // Member constants enum @@ -71,13 +75,6 @@ public: // Static data members - static const char* const typeName; - static const char* componentNames[]; - - static const Tensor2D zero; - static const Tensor2D one; - static const Tensor2D max; - static const Tensor2D min; static const Tensor2D I; diff --git a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H index 230ebe70052..bc68f00ad3e 100644 --- a/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H +++ b/src/OpenFOAM/primitives/Tensor2D/Tensor2DI.H @@ -23,27 +23,25 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D() +inline Foam::Tensor2D<Cmpt>::Tensor2D() {} template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs) +inline Foam::Tensor2D<Cmpt>::Tensor2D +( + const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs +) : VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(vs) {} template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st) +inline Foam::Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st) { this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); @@ -51,7 +49,7 @@ inline Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st) template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st) +inline Foam::Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); @@ -59,7 +57,7 @@ inline Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st) template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D +inline Foam::Tensor2D<Cmpt>::Tensor2D ( const Vector2D<Cmpt>& x, const Vector2D<Cmpt>& y @@ -71,7 +69,7 @@ inline Tensor2D<Cmpt>::Tensor2D template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D +inline Foam::Tensor2D<Cmpt>::Tensor2D ( const Cmpt txx, const Cmpt txy, const Cmpt tyx, const Cmpt tyy @@ -83,7 +81,7 @@ inline Tensor2D<Cmpt>::Tensor2D template<class Cmpt> -inline Tensor2D<Cmpt>::Tensor2D(Istream& is) +inline Foam::Tensor2D<Cmpt>::Tensor2D(Istream& is) : VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>(is) {} @@ -92,70 +90,70 @@ inline Tensor2D<Cmpt>::Tensor2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline Vector2D<Cmpt> Tensor2D<Cmpt>::x() const +inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::x() const { return Vector2D<Cmpt>(this->v_[XX], this->v_[XY]); } template<class Cmpt> -inline Vector2D<Cmpt> Tensor2D<Cmpt>::y() const +inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::y() const { return Vector2D<Cmpt>(this->v_[YX], this->v_[YY]); } template<class Cmpt> -inline const Cmpt& Tensor2D<Cmpt>::xx() const +inline const Cmpt& Foam::Tensor2D<Cmpt>::xx() const { return this->v_[XX]; } template<class Cmpt> -inline const Cmpt& Tensor2D<Cmpt>::xy() const +inline const Cmpt& Foam::Tensor2D<Cmpt>::xy() const { return this->v_[XY]; } template<class Cmpt> -inline const Cmpt& Tensor2D<Cmpt>::yx() const +inline const Cmpt& Foam::Tensor2D<Cmpt>::yx() const { return this->v_[YX]; } template<class Cmpt> -inline const Cmpt& Tensor2D<Cmpt>::yy() const +inline const Cmpt& Foam::Tensor2D<Cmpt>::yy() const { return this->v_[YY]; } template<class Cmpt> -inline Cmpt& Tensor2D<Cmpt>::xx() +inline Cmpt& Foam::Tensor2D<Cmpt>::xx() { return this->v_[XX]; } template<class Cmpt> -inline Cmpt& Tensor2D<Cmpt>::xy() +inline Cmpt& Foam::Tensor2D<Cmpt>::xy() { return this->v_[XY]; } template<class Cmpt> -inline Cmpt& Tensor2D<Cmpt>::yx() +inline Cmpt& Foam::Tensor2D<Cmpt>::yx() { return this->v_[YX]; } template<class Cmpt> -inline Cmpt& Tensor2D<Cmpt>::yy() +inline Cmpt& Foam::Tensor2D<Cmpt>::yy() { return this->v_[YY]; } template<class Cmpt> -inline Tensor2D<Cmpt> Tensor2D<Cmpt>::T() const +inline Foam::Tensor2D<Cmpt> Foam::Tensor2D<Cmpt>::T() const { return Tensor2D<Cmpt> ( @@ -168,7 +166,7 @@ inline Tensor2D<Cmpt> Tensor2D<Cmpt>::T() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline void Tensor2D<Cmpt>::operator=(const SymmTensor2D<Cmpt>& st) +inline void Foam::Tensor2D<Cmpt>::operator=(const SymmTensor2D<Cmpt>& st) { this->v_[XX] = st.xx(); this->v_[XY] = st.xy(); this->v_[YX] = st.xy(); this->v_[YY] = st.yy(); @@ -176,13 +174,17 @@ inline void Tensor2D<Cmpt>::operator=(const SymmTensor2D<Cmpt>& st) template<class Cmpt> -inline void Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st) +inline void Foam::Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st) { this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[YX] = 0; this->v_[YY] = st.ii(); } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C index 96ff1a31943..36f97252558 100644 --- a/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C +++ b/src/OpenFOAM/primitives/Tensor2D/tensor2D/tensor2D.C @@ -28,41 +28,49 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const Foam::tensor2D::typeName = "tensor2D"; +const char* const Foam::tensor2D::vsType::typeName = "tensor2D"; template<> -const char* Foam::tensor2D::componentNames[] = +const char* const Foam::tensor2D::vsType::componentNames[] = { "xx", "xy", "yx", "yy" }; template<> -const Foam::tensor2D Foam::tensor2D::zero +const Foam::tensor2D Foam::tensor2D::vsType::vsType::zero ( - 0, 0, - 0, 0 + tensor2D::uniform(0) ); template<> -const Foam::tensor2D Foam::tensor2D::one +const Foam::tensor2D Foam::tensor2D::vsType::one ( - 1, 1, - 1, 1 + tensor2D::uniform(1) ); template<> -const Foam::tensor2D Foam::tensor2D::max +const Foam::tensor2D Foam::tensor2D::vsType::max ( - VGREAT, VGREAT, - VGREAT, VGREAT + tensor2D::uniform(VGREAT) ); template<> -const Foam::tensor2D Foam::tensor2D::min +const Foam::tensor2D Foam::tensor2D::vsType::min ( - -VGREAT, -VGREAT, - -VGREAT, -VGREAT + tensor2D::uniform(-VGREAT) +); + +template<> +const Foam::tensor2D Foam::tensor2D::vsType::rootMax +( + tensor2D::uniform(ROOTVGREAT) +); + +template<> +const Foam::tensor2D Foam::tensor2D::vsType::rootMin +( + tensor2D::uniform(-ROOTVGREAT) ); template<> diff --git a/src/OpenFOAM/primitives/Vector/Vector.H b/src/OpenFOAM/primitives/Vector/Vector.H index b79dd8d6f7e..e4ba4c1feda 100644 --- a/src/OpenFOAM/primitives/Vector/Vector.H +++ b/src/OpenFOAM/primitives/Vector/Vector.H @@ -74,18 +74,6 @@ public: }; - // Static data members - - static const char* const typeName; - static const char* componentNames[]; - static const Vector zero; - static const Vector one; - static const Vector max; - static const Vector min; - static const Vector rootMax; - static const Vector rootMin; - - //- Component labeling enumeration enum components { X, Y, Z }; @@ -127,7 +115,7 @@ public: // Member Operators - inline void operator=(const scalar); + inline void operator=(const Foam::zero); }; diff --git a/src/OpenFOAM/primitives/Vector/VectorI.H b/src/OpenFOAM/primitives/Vector/VectorI.H index 31330574610..4d598dea368 100644 --- a/src/OpenFOAM/primitives/Vector/VectorI.H +++ b/src/OpenFOAM/primitives/Vector/VectorI.H @@ -23,28 +23,31 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Cmpt> -inline Vector<Cmpt>::Vector() +inline Foam::Vector<Cmpt>::Vector() {} template<class Cmpt> template<class Cmpt2> -inline Vector<Cmpt>::Vector(const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs) +inline Foam::Vector<Cmpt>::Vector +( + const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs +) : VectorSpace<Vector<Cmpt>, Cmpt, 3>(vs) {} template<class Cmpt> -inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz) +inline Foam::Vector<Cmpt>::Vector +( + const Cmpt& vx, + const Cmpt& vy, + const Cmpt& vz +) { this->v_[X] = vx; this->v_[Y] = vy; @@ -53,7 +56,7 @@ inline Vector<Cmpt>::Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz) template<class Cmpt> -inline Vector<Cmpt>::Vector(Istream& is) +inline Foam::Vector<Cmpt>::Vector(Istream& is) : VectorSpace<Vector<Cmpt>, Cmpt, 3>(is) {} @@ -62,38 +65,38 @@ inline Vector<Cmpt>::Vector(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline const Cmpt& Vector<Cmpt>::x() const +inline const Cmpt& Foam::Vector<Cmpt>::x() const { return this->v_[X]; } template<class Cmpt> -inline const Cmpt& Vector<Cmpt>::y() const +inline const Cmpt& Foam::Vector<Cmpt>::y() const { return this->v_[Y]; } template<class Cmpt> -inline const Cmpt& Vector<Cmpt>::z() const +inline const Cmpt& Foam::Vector<Cmpt>::z() const { return this->v_[Z]; } template<class Cmpt> -inline Cmpt& Vector<Cmpt>::x() +inline Cmpt& Foam::Vector<Cmpt>::x() { return this->v_[X]; } template<class Cmpt> -inline Cmpt& Vector<Cmpt>::y() +inline Cmpt& Foam::Vector<Cmpt>::y() { return this->v_[Y]; } template<class Cmpt> -inline Cmpt& Vector<Cmpt>::z() +inline Cmpt& Foam::Vector<Cmpt>::z() { return this->v_[Z]; } @@ -102,7 +105,7 @@ inline Cmpt& Vector<Cmpt>::z() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline const Vector<Cmpt>& Vector<Cmpt>::centre +inline const Foam::Vector<Cmpt>& Foam::Vector<Cmpt>::centre ( const Foam::List<Vector<Cmpt>>& )const @@ -114,17 +117,19 @@ inline const Vector<Cmpt>& Vector<Cmpt>::centre // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class Cmpt> -inline void Vector<Cmpt>::operator= -( - const scalar s -) +inline void Foam::Vector<Cmpt>::operator=(const Foam::zero z) { - VectorSpace<Vector<Cmpt>, Cmpt, 3>::operator=(s); + VectorSpace<Vector<Cmpt>, Cmpt, 3>::operator=(z); } // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + template<class Cmpt> inline typename innerProduct<Vector<Cmpt>, Vector<Cmpt>>::type operator&(const Vector<Cmpt>& v1, const Vector<Cmpt>& v2) diff --git a/src/OpenFOAM/primitives/Vector/complexVector/complexVector.C b/src/OpenFOAM/primitives/Vector/complexVector/complexVector.C index 7e5d04144be..f3241df6961 100644 --- a/src/OpenFOAM/primitives/Vector/complexVector/complexVector.C +++ b/src/OpenFOAM/primitives/Vector/complexVector/complexVector.C @@ -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,37 +28,52 @@ Description #include "complexVector.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<> +const char* const Foam::complexVector::vsType::typeName = "complexVector"; -namespace Foam +template<> +const char* const Foam::complexVector::vsType::componentNames[] = { + "x", "y", "z" +}; -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +template<> +const Foam::complexVector Foam::complexVector::vsType::zero +( + complexVector::uniform(complex(0, 0)) +); template<> -const char* const complexVector::typeName = "complexVector"; +const Foam::complexVector Foam::complexVector::vsType::one +( + complexVector::uniform(complex(1, 1)) +); template<> -const char* complexVector::componentNames[] = {"x", "y", "z"}; +const Foam::complexVector Foam::complexVector::vsType::max +( + complexVector::uniform(complex(VGREAT, VGREAT)) +); template<> -const complexVector complexVector::zero +const Foam::complexVector Foam::complexVector::vsType::min ( - complex(0, 0), - complex(0, 0), - complex(0, 0) + complexVector::uniform(complex(-VGREAT, -VGREAT)) ); template<> -const complexVector complexVector::one +const Foam::complexVector Foam::complexVector::vsType::rootMax ( - complex(1, 1), - complex(1, 1), - complex(1, 1) + complexVector::uniform(complex(ROOTVGREAT, ROOTVGREAT)) ); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::complexVector Foam::complexVector::vsType::rootMin +( + complexVector::uniform(complex(-ROOTVGREAT, -ROOTVGREAT)) +); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector/floatVector/floatVector.C b/src/OpenFOAM/primitives/Vector/floatVector/floatVector.C index d88ac70f1f4..13ab567ba41 100644 --- a/src/OpenFOAM/primitives/Vector/floatVector/floatVector.C +++ b/src/OpenFOAM/primitives/Vector/floatVector/floatVector.C @@ -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,43 +28,52 @@ Description #include "floatVector.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const floatVector::typeName = "floatVector"; +const char* const Foam::floatVector::vsType::typeName = "floatVector"; template<> -const char* floatVector::componentNames[] = {"x", "y", "z"}; +const char* const Foam::floatVector::vsType::componentNames[] = +{ + "x", "y", "z" +}; template<> -const floatVector floatVector::zero(0, 0, 0); +const Foam::floatVector Foam::floatVector::vsType::zero +( + floatVector::uniform(0) +); template<> -const floatVector floatVector::one(1, 1, 1); +const Foam::floatVector Foam::floatVector::vsType::one +( + floatVector::uniform(1) +); template<> -const floatVector floatVector::max +const Foam::floatVector Foam::floatVector::vsType::max ( - floatScalarVGREAT, - floatScalarVGREAT, - floatScalarVGREAT + floatVector::uniform(floatScalarVGREAT) ); template<> -const floatVector floatVector::min +const Foam::floatVector Foam::floatVector::vsType::min ( - -floatScalarVGREAT, - -floatScalarVGREAT, - -floatScalarVGREAT + floatVector::uniform(-floatScalarVGREAT) ); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::floatVector Foam::floatVector::vsType::rootMax +( + floatVector::uniform(floatScalarROOTVGREAT) +); + +template<> +const Foam::floatVector Foam::floatVector::vsType::rootMin +( + floatVector::uniform(-floatScalarROOTVGREAT) +); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector/labelVector/labelVector.C b/src/OpenFOAM/primitives/Vector/labelVector/labelVector.C index 248f6601def..231c3a69ef1 100644 --- a/src/OpenFOAM/primitives/Vector/labelVector/labelVector.C +++ b/src/OpenFOAM/primitives/Vector/labelVector/labelVector.C @@ -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 @@ -27,19 +27,50 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam +template<> +const char* const Foam::labelVector::vsType::typeName = "labelVector"; + +template<> +const char* const Foam::labelVector::vsType::componentNames[] = { - template<> - const char* const Foam::labelVector::typeName = "labelVector"; + "x", "y", "z" +}; + +template<> +const Foam::labelVector Foam::labelVector::vsType::zero +( + labelVector::uniform(0) +); + +template<> +const Foam::labelVector Foam::labelVector::vsType::one +( + labelVector::uniform(1) +); + +template<> +const Foam::labelVector Foam::labelVector::vsType::max +( + labelVector::uniform(labelMax) +); + +template<> +const Foam::labelVector Foam::labelVector::vsType::min +( + labelVector::uniform(-labelMax) +); - template<> - const char* Foam::labelVector::componentNames[] = {"x", "y", "z"}; +template<> +const Foam::labelVector Foam::labelVector::vsType::rootMax +( + labelVector::uniform(sqrt(scalar(labelMax))) +); - template<> - const Foam::labelVector Foam::labelVector::zero(0, 0, 0); +template<> +const Foam::labelVector Foam::labelVector::vsType::rootMin +( + labelVector::uniform(-sqrt(scalar(labelMax))) +); - template<> - const Foam::labelVector Foam::labelVector::one(1, 1, 1); -} // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector/vector/vector.C b/src/OpenFOAM/primitives/Vector/vector/vector.C index 40b6e79c31a..646f34c35de 100644 --- a/src/OpenFOAM/primitives/Vector/vector/vector.C +++ b/src/OpenFOAM/primitives/Vector/vector/vector.C @@ -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 @@ -28,39 +28,31 @@ Description #include "vector.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const vector::typeName = "vector"; +const char* const Foam::vector::vsType::typeName = "vector"; template<> -const char* vector::componentNames[] = {"x", "y", "z"}; +const char* const Foam::vector::vsType::componentNames[] = {"x", "y", "z"}; template<> -const vector vector::zero(0, 0, 0); +const Foam::vector Foam::vector::vsType::vsType::zero(vector::uniform(0)); template<> -const vector vector::one(1, 1, 1); +const Foam::vector Foam::vector::vsType::one(vector::uniform(1)); template<> -const vector vector::max(VGREAT, VGREAT, VGREAT); +const Foam::vector Foam::vector::vsType::max(vector::uniform(VGREAT)); template<> -const vector vector::min(-VGREAT, -VGREAT, -VGREAT); +const Foam::vector Foam::vector::vsType::min(vector::uniform(-VGREAT)); template<> -const vector vector::rootMax(ROOTVGREAT, ROOTVGREAT, ROOTVGREAT); +const Foam::vector Foam::vector::vsType::rootMax(vector::uniform(ROOTVGREAT)); template<> -const vector vector::rootMin(-ROOTVGREAT, -ROOTVGREAT, -ROOTVGREAT); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +const Foam::vector Foam::vector::vsType::rootMin(vector::uniform(-ROOTVGREAT)); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2D.H b/src/OpenFOAM/primitives/Vector2D/Vector2D.H index e63fbad951b..ca77ed8ce10 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2D.H @@ -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 @@ -56,6 +56,10 @@ class Vector2D public: + //- Equivalent type of labels used for valid component indexing + typedef Vector2D<label> labelType; + + // Member constants enum @@ -64,16 +68,6 @@ public: }; - // Static data members - - static const char* const typeName; - static const char* componentNames[]; - static const Vector2D zero; - static const Vector2D one; - static const Vector2D max; - static const Vector2D min; - - //- Component labeling enumeration enum components { X, Y }; diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H index b3e5f6c63a5..8ccf067c26e 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H @@ -23,39 +23,33 @@ License \*---------------------------------------------------------------------------*/ -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct null template<class Cmpt> -inline Vector2D<Cmpt>::Vector2D() +inline Foam::Vector2D<Cmpt>::Vector2D() {} -// Construct given VectorSpace template<class Cmpt> -inline Vector2D<Cmpt>::Vector2D(const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>& vs) +inline Foam::Vector2D<Cmpt>::Vector2D +( + const VectorSpace<Vector2D<Cmpt>, Cmpt, 2>& vs +) : VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(vs) {} -// Construct given three Cmpts template<class Cmpt> -inline Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy) +inline Foam::Vector2D<Cmpt>::Vector2D(const Cmpt& vx, const Cmpt& vy) { this->v_[X] = vx; this->v_[Y] = vy; } -// Construct from Istream template<class Cmpt> -inline Vector2D<Cmpt>::Vector2D(Istream& is) +inline Foam::Vector2D<Cmpt>::Vector2D(Istream& is) : VectorSpace<Vector2D<Cmpt>, Cmpt, 2>(is) {} @@ -64,31 +58,36 @@ inline Vector2D<Cmpt>::Vector2D(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Cmpt> -inline const Cmpt& Vector2D<Cmpt>::x() const +inline const Cmpt& Foam::Vector2D<Cmpt>::x() const { return this->v_[X]; } template<class Cmpt> -inline const Cmpt& Vector2D<Cmpt>::y() const +inline const Cmpt& Foam::Vector2D<Cmpt>::y() const { return this->v_[Y]; } template<class Cmpt> -inline Cmpt& Vector2D<Cmpt>::x() +inline Cmpt& Foam::Vector2D<Cmpt>::x() { return this->v_[X]; } template<class Cmpt> -inline Cmpt& Vector2D<Cmpt>::y() +inline Cmpt& Foam::Vector2D<Cmpt>::y() { return this->v_[Y]; } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // template<class Cmpt> diff --git a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C b/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C index e773e19608e..4a73dada31b 100644 --- a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C +++ b/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C @@ -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,33 +28,49 @@ Description #include "vector2D.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const vector2D::typeName = "vector2D"; +const char* const Foam::vector2D::vsType::typeName = "vector2D"; template<> -const char* vector2D::componentNames[] = {"x", "y"}; +const char* const Foam::vector2D::vsType::componentNames[] = {"x", "y"}; template<> -const vector2D vector2D::zero(0, 0); +const Foam::vector2D Foam::vector2D::vsType::vsType::zero +( + vector2D::uniform(0) +); template<> -const vector2D vector2D::one(1, 1); +const Foam::vector2D Foam::vector2D::vsType::one +( + vector2D::uniform(1) +); template<> -const vector2D vector2D::max(VGREAT, VGREAT); +const Foam::vector2D Foam::vector2D::vsType::max +( + vector2D::uniform(VGREAT) +); template<> -const vector2D vector2D::min(-VGREAT, -VGREAT); +const Foam::vector2D Foam::vector2D::vsType::min +( + vector2D::uniform(-VGREAT) +); -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +const Foam::vector2D Foam::vector2D::vsType::rootMax +( + vector2D::uniform(ROOTVGREAT) +); + +template<> +const Foam::vector2D Foam::vector2D::vsType::rootMin +( + vector2D::uniform(-ROOTVGREAT) +); -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H index 05822b0fb86..2d650f43ae5 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpace.H @@ -42,6 +42,7 @@ SourceFiles #include "direction.H" #include "scalar.H" #include "word.H" +#include "zero.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,6 +78,13 @@ class VectorSpace public: + //- The components of this vector space + Cmpt v_[nCmpt]; + + + //- VectorSpace type + typedef VectorSpace<Form, Cmpt, nCmpt> vsType; + //- Component type typedef Cmpt cmptType; @@ -92,8 +100,14 @@ public: // Static data members - //- The components of this vector space - Cmpt v_[nCmpt]; + static const char* const typeName; + static const char* const componentNames[]; + static const Form zero; + static const Form one; + static const Form max; + static const Form min; + static const Form rootMax; + static const Form rootMin; // Constructors @@ -123,6 +137,9 @@ public: inline void component(Cmpt&, const direction) const; inline void replace(const direction, const Cmpt&); + //- Return a VectorSpace with all elements = s + inline static Form uniform(const Cmpt& s); + // Member Operators @@ -133,7 +150,7 @@ public: inline void operator+=(const VectorSpace<Form, Cmpt, nCmpt>&); inline void operator-=(const VectorSpace<Form, Cmpt, nCmpt>&); - inline void operator=(const scalar); + inline void operator=(const Foam::zero); inline void operator*=(const scalar); inline void operator/=(const scalar); diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H index 846c6e7f56c..e1c88e61d86 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H @@ -148,6 +148,15 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::replace } +template<class Form, class Cmpt, int nCmpt> +inline Form VectorSpace<Form, Cmpt, nCmpt>::uniform(const Cmpt& s) +{ + Form v; + VectorSpaceOps<nCmpt,0>::eqOpS(v, s, eqOp<Cmpt>()); + return v; +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class Form, class Cmpt, int nCmpt> @@ -219,12 +228,9 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::operator-= template<class Form, class Cmpt, int nCmpt> -inline void VectorSpace<Form, Cmpt, nCmpt>::operator= -( - const scalar s -) +inline void VectorSpace<Form, Cmpt, nCmpt>::operator=(const Foam::zero) { - VectorSpaceOps<nCmpt,0>::eqOpS(*this, s, eqOp<Cmpt>()); + VectorSpaceOps<nCmpt,0>::eqOpS(*this, 0, eqOp<Cmpt>()); } diff --git a/src/OpenFOAM/primitives/bools/bool/bool.C b/src/OpenFOAM/primitives/bools/bool/bool.C index 5969cadcea3..267a8c16111 100644 --- a/src/OpenFOAM/primitives/bools/bool/bool.C +++ b/src/OpenFOAM/primitives/bools/bool/bool.C @@ -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 @@ -31,7 +31,7 @@ const char* const Foam::pTraits<bool>::typeName = "bool"; const bool Foam::pTraits<bool>::zero = false; const bool Foam::pTraits<bool>::one = true; -const char* Foam::pTraits<bool>::componentNames[] = { "" }; +const char* const Foam::pTraits<bool>::componentNames[] = { "" }; Foam::pTraits<bool>::pTraits(const bool& p) : diff --git a/src/OpenFOAM/primitives/bools/bool/bool.H b/src/OpenFOAM/primitives/bools/bool/bool.H index a7de5ecf469..b1638ec0541 100644 --- a/src/OpenFOAM/primitives/bools/bool/bool.H +++ b/src/OpenFOAM/primitives/bools/bool/bool.H @@ -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 @@ -84,7 +84,7 @@ public: // Static data members static const char* const typeName; - static const char* componentNames[]; + static const char* const componentNames[]; static const bool zero; static const bool one; diff --git a/src/OpenFOAM/primitives/ints/int32/int32.C b/src/OpenFOAM/primitives/ints/int32/int32.C index 4883be46d52..4a209fc50b9 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32.C +++ b/src/OpenFOAM/primitives/ints/int32/int32.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ const int32_t Foam::pTraits<int32_t>::max = INT32_MAX; const int32_t Foam::pTraits<int32_t>::rootMin = pTraits<int32_t>::min; const int32_t Foam::pTraits<int32_t>::rootMax = pTraits<int32_t>::max; -const char* Foam::pTraits<int32_t>::componentNames[] = { "" }; +const char* const Foam::pTraits<int32_t>::componentNames[] = { "" }; Foam::pTraits<int32_t>::pTraits(const int32_t& p) : diff --git a/src/OpenFOAM/primitives/ints/int32/int32.H b/src/OpenFOAM/primitives/ints/int32/int32.H index 694bfb57f74..0602a8e3458 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32.H +++ b/src/OpenFOAM/primitives/ints/int32/int32.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -102,7 +102,7 @@ public: // Static data members static const char* const typeName; - static const char* componentNames[]; + static const char* const componentNames[]; static const int32_t zero; static const int32_t one; static const int32_t min; diff --git a/src/OpenFOAM/primitives/ints/int64/int64.C b/src/OpenFOAM/primitives/ints/int64/int64.C index 5b58fad539b..f182c9d2760 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64.C +++ b/src/OpenFOAM/primitives/ints/int64/int64.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ const int64_t Foam::pTraits<int64_t>::max = INT64_MAX; const int64_t Foam::pTraits<int64_t>::rootMin = pTraits<int64_t>::min; const int64_t Foam::pTraits<int64_t>::rootMax = pTraits<int64_t>::max; -const char* Foam::pTraits<int64_t>::componentNames[] = { "" }; +const char* const Foam::pTraits<int64_t>::componentNames[] = { "" }; Foam::pTraits<int64_t>::pTraits(const int64_t& p) : diff --git a/src/OpenFOAM/primitives/ints/int64/int64.H b/src/OpenFOAM/primitives/ints/int64/int64.H index 38cd1057860..6006321a288 100644 --- a/src/OpenFOAM/primitives/ints/int64/int64.H +++ b/src/OpenFOAM/primitives/ints/int64/int64.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ public: // Static data members static const char* const typeName; - static const char* componentNames[]; + static const char* const componentNames[]; static const int64_t zero; static const int64_t one; static const int64_t min; diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32.C b/src/OpenFOAM/primitives/ints/uint32/uint32.C index 2ffe5445dc4..c195b355a45 100644 --- a/src/OpenFOAM/primitives/ints/uint32/uint32.C +++ b/src/OpenFOAM/primitives/ints/uint32/uint32.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ const uint32_t Foam::pTraits<uint32_t>::max = INT32_MAX; const uint32_t Foam::pTraits<uint32_t>::rootMin = pTraits<uint32_t>::min; const uint32_t Foam::pTraits<uint32_t>::rootMax = pTraits<uint32_t>::max; -const char* Foam::pTraits<uint32_t>::componentNames[] = { "" }; +const char* const Foam::pTraits<uint32_t>::componentNames[] = { "" }; Foam::pTraits<uint32_t>::pTraits(const uint32_t& p) : diff --git a/src/OpenFOAM/primitives/ints/uint32/uint32.H b/src/OpenFOAM/primitives/ints/uint32/uint32.H index 3b0ad01c7a2..9c2a3b6833d 100644 --- a/src/OpenFOAM/primitives/ints/uint32/uint32.H +++ b/src/OpenFOAM/primitives/ints/uint32/uint32.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ public: // Static data members static const char* const typeName; - static const char* componentNames[]; + static const char* const componentNames[]; static const uint32_t zero; static const uint32_t one; static const uint32_t min; diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64.C b/src/OpenFOAM/primitives/ints/uint64/uint64.C index 63fd8b31942..b099c4b4e03 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64.C +++ b/src/OpenFOAM/primitives/ints/uint64/uint64.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ const uint64_t Foam::pTraits<uint64_t>::max = INT64_MAX; const uint64_t Foam::pTraits<uint64_t>::rootMin = pTraits<uint64_t>::min; const uint64_t Foam::pTraits<uint64_t>::rootMax = pTraits<uint64_t>::max; -const char* Foam::pTraits<uint64_t>::componentNames[] = { "" }; +const char* const Foam::pTraits<uint64_t>::componentNames[] = { "" }; Foam::pTraits<uint64_t>::pTraits(const uint64_t& p) : diff --git a/src/OpenFOAM/primitives/ints/uint64/uint64.H b/src/OpenFOAM/primitives/ints/uint64/uint64.H index dc196594626..2d2e31f802f 100644 --- a/src/OpenFOAM/primitives/ints/uint64/uint64.H +++ b/src/OpenFOAM/primitives/ints/uint64/uint64.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ public: // Static data members static const char* const typeName; - static const char* componentNames[]; + static const char* const componentNames[]; static const uint64_t zero; static const uint64_t one; static const uint64_t min; diff --git a/src/OpenFOAM/primitives/triad/triad.C b/src/OpenFOAM/primitives/triad/triad.C index 8bb2f7cd73c..f73e82f4d4b 100644 --- a/src/OpenFOAM/primitives/triad/triad.C +++ b/src/OpenFOAM/primitives/triad/triad.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,73 +29,60 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - template<> -const char* const triad::Vector<vector>::typeName = "triad"; +const char* const Foam::triad::vsType::typeName = "triad"; template<> -const char* triad::Vector<vector>::componentNames[] = {"x", "y", "z"}; +const char* const Foam::triad::vsType::componentNames[] = {"x", "y", "z"}; -const triad triad::zero +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::zero ( - vector(0, 0, 0), - vector(0, 0, 0), - vector(0, 0, 0) + triad::uniform(vector::uniform(0)) ); -const triad triad::one +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::one ( - vector(1, 1, 1), - vector(1, 1, 1), - vector(1, 1, 1) + triad::uniform(vector::uniform(1)) ); -const triad triad::max +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::max ( - vector(VGREAT, VGREAT, VGREAT), - vector(VGREAT, VGREAT, VGREAT), - vector(VGREAT, VGREAT, VGREAT) + triad::uniform(vector::uniform(VGREAT)) ); -const triad triad::min +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::min ( - vector(-VGREAT, -VGREAT, -VGREAT), - vector(-VGREAT, -VGREAT, -VGREAT), - vector(-VGREAT, -VGREAT, -VGREAT) + triad::uniform(vector::uniform(-VGREAT)) ); -const triad triad::rootMax +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::rootMax ( - vector(ROOTVGREAT, ROOTVGREAT, ROOTVGREAT), - vector(ROOTVGREAT, ROOTVGREAT, ROOTVGREAT), - vector(ROOTVGREAT, ROOTVGREAT, ROOTVGREAT) + triad::uniform(vector::uniform(ROOTVGREAT)) ); -const triad triad::rootMin +template<> +const Foam::Vector<Foam::vector> Foam::triad::vsType::rootMin ( - vector(-ROOTVGREAT, -ROOTVGREAT, -ROOTVGREAT), - vector(-ROOTVGREAT, -ROOTVGREAT, -ROOTVGREAT), - vector(-ROOTVGREAT, -ROOTVGREAT, -ROOTVGREAT) + triad::uniform(vector::uniform(-ROOTVGREAT)) ); -const triad triad::I +const Foam::triad Foam::triad::I ( vector(1, 0, 0), vector(0, 1, 0), vector(0, 0, 1) ); -const triad triad::unset +const Foam::triad Foam::triad::unset ( - vector(VGREAT, VGREAT, VGREAT), - vector(VGREAT, VGREAT, VGREAT), - vector(VGREAT, VGREAT, VGREAT) + triad::uniform(vector::uniform(VGREAT)) ); -} - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/triad/triad.H b/src/OpenFOAM/primitives/triad/triad.H index 8755b60bc13..abe8ad0d27f 100644 --- a/src/OpenFOAM/primitives/triad/triad.H +++ b/src/OpenFOAM/primitives/triad/triad.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -96,12 +96,6 @@ public: // Static data members - static const triad zero; - static const triad one; - static const triad max; - static const triad min; - static const triad rootMax; - static const triad rootMin; static const triad I; static const triad unset; -- GitLab