diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index d0e703cfd1..881ca47c7a 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -90,8 +90,8 @@ primitives/Vector/lists/vectorListIOList.C primitives/Tensor2D/tensor2D/tensor2D.C primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C -primitives/Vector2D/labelVector2D/labelVector2D.C -primitives/Vector2D/vector2D/vector2D.C +primitives/Vector2D/floats/vector2D.C +primitives/Vector2D/ints/labelVector2D.C primitives/complex/complex.C primitives/globalIndexAndTransform/globalIndexAndTransform.C diff --git a/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C b/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C index 66b58892fc..59dc1035d8 100644 --- a/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C +++ b/src/OpenFOAM/primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C @@ -69,13 +69,13 @@ const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::min template<> const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::rootMax ( - labelSphericalTensor::uniform(sqrt(scalar(labelMax))) + labelSphericalTensor::uniform(::sqrt(double(labelMax))) ); template<> const Foam::labelSphericalTensor Foam::labelSphericalTensor::vsType::rootMin ( - labelSphericalTensor::uniform(-sqrt(scalar(labelMax))) + labelSphericalTensor::uniform(-::sqrt(double(labelMax))) ); template<> diff --git a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C index df06cb3a5e..0cdd46292f 100644 --- a/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C +++ b/src/OpenFOAM/primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C @@ -67,13 +67,13 @@ const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::min template<> const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::rootMax ( - labelSymmTensor::uniform(sqrt(scalar(labelMax))) + labelSymmTensor::uniform(::sqrt(double(labelMax))) ); template<> const Foam::labelSymmTensor Foam::labelSymmTensor::vsType::rootMin ( - labelSymmTensor::uniform(-sqrt(scalar(labelMax))) + labelSymmTensor::uniform(-::sqrt(double(labelMax))) ); template<> diff --git a/src/OpenFOAM/primitives/Tensor/ints/labelTensor.C b/src/OpenFOAM/primitives/Tensor/ints/labelTensor.C index 3adc0c66cf..1c3541d935 100644 --- a/src/OpenFOAM/primitives/Tensor/ints/labelTensor.C +++ b/src/OpenFOAM/primitives/Tensor/ints/labelTensor.C @@ -68,13 +68,13 @@ const Foam::labelTensor Foam::labelTensor::vsType::min template<> const Foam::labelTensor Foam::labelTensor::vsType::rootMax ( - labelTensor::uniform(sqrt(scalar(labelMax))) + labelTensor::uniform(::sqrt(double(labelMax))) ); template<> const Foam::labelTensor Foam::labelTensor::vsType::rootMin ( - labelTensor::uniform(-sqrt(scalar(labelMax))) + labelTensor::uniform(-::sqrt(double(labelMax))) ); template<> diff --git a/src/OpenFOAM/primitives/Vector/Vector.H b/src/OpenFOAM/primitives/Vector/Vector.H index a254b9e855..053865a2a8 100644 --- a/src/OpenFOAM/primitives/Vector/Vector.H +++ b/src/OpenFOAM/primitives/Vector/Vector.H @@ -171,7 +171,7 @@ public: inline Vector cross(const Vector& v2) const; - // Comparision Operations + // Comparison Operations //- Lexicographically compare \em a and \em b with order (x:y:z) static inline bool less_xyz diff --git a/src/OpenFOAM/primitives/Vector/VectorI.H b/src/OpenFOAM/primitives/Vector/VectorI.H index 4c33803f65..7ce8d60118 100644 --- a/src/OpenFOAM/primitives/Vector/VectorI.H +++ b/src/OpenFOAM/primitives/Vector/VectorI.H @@ -170,7 +170,7 @@ Foam::Vector::cross(const Vector& v2) const } -// * * * * * * * * * * * * * Comparision Operations * * * * * * * * * * * * // +// * * * * * * * * * * * * * Comparison Operations * * * * * * * * * * * * * // template inline bool diff --git a/src/OpenFOAM/primitives/Vector/ints/labelVector.C b/src/OpenFOAM/primitives/Vector/ints/labelVector.C index c98aba46e7..6513f5eb3b 100644 --- a/src/OpenFOAM/primitives/Vector/ints/labelVector.C +++ b/src/OpenFOAM/primitives/Vector/ints/labelVector.C @@ -32,47 +32,54 @@ License template<> const char* const Foam::labelVector::vsType::typeName = "labelVector"; -template<> -const char* const Foam::labelVector::vsType::componentNames[] = -{ - "x", "y", "z" -}; +#undef defineTraits +#define defineTraits(Type, Prefix) \ + \ + template<> \ + const char* const Foam::Vector::vsType::componentNames[] = \ + { \ + "x", "y", "z" \ + }; \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::zero \ + ( \ + Vector::uniform(0) \ + ); \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::one \ + ( \ + Vector::uniform(1) \ + ); \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::max \ + ( \ + Vector::uniform(Prefix##Max) \ + ); \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::min \ + ( \ + Vector::uniform(-Prefix##Max) \ + ); \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::rootMax \ + ( \ + Vector::uniform(::sqrt(double(Prefix##Max))) \ + ); \ + \ + template<> \ + const Foam::Vector Foam::Vector::vsType::rootMin \ + ( \ + Vector::uniform(-::sqrt(double(Prefix##Max))) \ + ); -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 Foam::labelVector Foam::labelVector::vsType::rootMax -( - labelVector::uniform(sqrt(scalar(labelMax))) -); - -template<> -const Foam::labelVector Foam::labelVector::vsType::rootMin -( - labelVector::uniform(-sqrt(scalar(labelMax))) -); +defineTraits(Foam::label, label); +#undef defineTraits // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector/ints/labelVector.H b/src/OpenFOAM/primitives/Vector/ints/labelVector.H index d04f62e7bd..b6ac6ec0ef 100644 --- a/src/OpenFOAM/primitives/Vector/ints/labelVector.H +++ b/src/OpenFOAM/primitives/Vector/ints/labelVector.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef labelVector_H -#define labelVector_H +#ifndef Foam_labelVector_H +#define Foam_labelVector_H #include "label.H" #include "Vector.H" diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2D.H b/src/OpenFOAM/primitives/Vector2D/Vector2D.H index 2e807e22b6..01ad98d2f6 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2D.H @@ -153,6 +153,23 @@ public: const Vector2D& b, const scalar tol = 1e-10 ) const; + + + // Comparison Operations + + //- Lexicographically compare \em a and \em b with order (x:y) + static inline bool less_xy + ( + const Vector2D& a, + const Vector2D& b + ); + + //- Lexicographically compare \em a and \em b with order (y:x) + static inline bool less_yx + ( + const Vector2D& a, + const Vector2D& b + ); }; diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H index 1877bce271..bdd677986f 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H @@ -126,12 +126,38 @@ Foam::Vector2D::removeCollinear(const Vector2D& unitVec) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Comparison Operations * * * * * * * * * * * * * // + +template +inline bool +Foam::Vector2D::less_xy(const Vector2D& a, const Vector2D& b) +{ + return + ( + (a.x() < b.x()) + || (!(b.x() < a.x()) && (a.y() < b.y())) + ); +} + + +template +inline bool +Foam::Vector2D::less_yx(const Vector2D& a, const Vector2D& b) +{ + return + ( + (a.y() < b.y()) + || (!(b.y() < a.y()) && (a.x() < b.x())) + ); +} + + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template inline Cmpt operator&(const Vector2D& v1, const Vector2D& v2) diff --git a/src/OpenFOAM/primitives/Vector2D/floats/vector2D.C b/src/OpenFOAM/primitives/Vector2D/floats/vector2D.C new file mode 100644 index 0000000000..dd0e46429e --- /dev/null +++ b/src/OpenFOAM/primitives/Vector2D/floats/vector2D.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "vector2D.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +#if defined(WM_DP) + +template<> +const char* const Foam::Vector2D::vsType::typeName = "floatVector2D"; + +template<> +const char* const Foam::Vector2D::vsType::typeName = "vector2D"; + +#else + +// WM_SP, WM_SPDP +template<> +const char* const Foam::Vector2D::vsType::typeName = "vector2D"; + +template<> +const char* const Foam::Vector2D::vsType::typeName = "doubleVector2D"; + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#undef defineTraits +#define defineTraits(Type, Prefix) \ + \ + template<> \ + const char* const Foam::Vector2D::vsType::componentNames[] = \ + { \ + "x", "y" \ + }; \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::zero \ + ( \ + Vector2D::uniform(0) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::one \ + ( \ + Vector2D::uniform(1) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::max \ + ( \ + Vector2D::uniform(Prefix##VGREAT) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::min \ + ( \ + Vector2D::uniform(-Prefix##VGREAT) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::rootMax \ + ( \ + Vector2D::uniform(Prefix##ROOTVGREAT) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::rootMin \ + ( \ + Vector2D::uniform(-Prefix##ROOTVGREAT) \ + ); + + +defineTraits(float, floatScalar); +defineTraits(double, doubleScalar); + +#undef defineTraits + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H b/src/OpenFOAM/primitives/Vector2D/floats/vector2D.H similarity index 84% rename from src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H rename to src/OpenFOAM/primitives/Vector2D/floats/vector2D.H index b620ca5b59..870408c606 100644 --- a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/floats/vector2D.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef vector2D_H -#define vector2D_H +#ifndef Foam_vector2D_H +#define Foam_vector2D_H #include "scalar.H" #include "Vector2D.H" @@ -48,6 +48,15 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +//! \class Foam::floatVector2D +//! \brief A Vector2D of values with float precision +typedef Vector2D floatVector2D; + +//! \class Foam::doubleVector2D +//! \brief A Vector2D of values with double precision +typedef Vector2D doubleVector2D; + +// With float or double precision (depending on compilation) typedef Vector2D vector2D; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.C b/src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.C new file mode 100644 index 0000000000..86836ba48b --- /dev/null +++ b/src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.C @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2019 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "labelVector2D.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<> +const char* const Foam::labelVector2D::vsType::typeName = "labelVector2D"; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#undef defineTraits +#define defineTraits(Type, Prefix) \ + \ + template<> \ + const char* const Foam::Vector2D::vsType::componentNames[] = \ + { \ + "x", "y" \ + }; \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::zero \ + ( \ + Vector2D::uniform(0) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::one \ + ( \ + Vector2D::uniform(1) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::max \ + ( \ + Vector2D::uniform(Prefix##Max) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::min \ + ( \ + Vector2D::uniform(-Prefix##Max) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::rootMax \ + ( \ + Vector2D::uniform(::sqrt(double(Prefix##Max))) \ + ); \ + \ + template<> \ + const Foam::Vector2D Foam::Vector2D::vsType::rootMin \ + ( \ + Vector2D::uniform(-::sqrt(double(Prefix##Max))) \ + ); + + +defineTraits(Foam::label, label); + +#undef defineTraits + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H b/src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.H similarity index 97% rename from src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H rename to src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.H index fae937db0f..56345fb659 100644 --- a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/ints/labelVector2D.H @@ -34,8 +34,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef labelVector2D_H -#define labelVector2D_H +#ifndef Foam_labelVector2D_H +#define Foam_labelVector2D_H #include "label.H" #include "Vector2D.H" diff --git a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C b/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C deleted file mode 100644 index 4b44f83275..0000000000 --- a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C +++ /dev/null @@ -1,75 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "labelVector2D.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<> -const char* const Foam::labelVector2D::vsType::typeName = "labelVector2D"; - -template<> -const char* const Foam::labelVector2D::vsType::componentNames[] = { "x", "y" }; - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::zero -( - labelVector2D::uniform(0) -); - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::one -( - labelVector2D::uniform(1) -); - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::max -( - labelVector2D::uniform(labelMax) -); - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::min -( - labelVector2D::uniform(-labelMax) -); - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::rootMax -( - labelVector2D::uniform(sqrt(scalar(labelMax))) -); - -template<> -const Foam::labelVector2D Foam::labelVector2D::vsType::rootMin -( - labelVector2D::uniform(-sqrt(scalar(labelMax))) -); - - -// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C b/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C deleted file mode 100644 index a8e3eda22d..0000000000 --- a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.C +++ /dev/null @@ -1,78 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Description - Vector2D of scalars. - -\*---------------------------------------------------------------------------*/ - -#include "vector2D.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<> -const char* const Foam::vector2D::vsType::typeName = "vector2D"; - -template<> -const char* const Foam::vector2D::vsType::componentNames[] = {"x", "y"}; - -template<> -const Foam::vector2D Foam::vector2D::vsType::vsType::zero -( - vector2D::uniform(0) -); - -template<> -const Foam::vector2D Foam::vector2D::vsType::one -( - vector2D::uniform(1) -); - -template<> -const Foam::vector2D Foam::vector2D::vsType::max -( - vector2D::uniform(VGREAT) -); - -template<> -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) -); - - -// ************************************************************************* //