ENH: reduce duplicate code for float/double Vector/Tensor

STYLE: pass value not reference to pTraits for basic types

STYLE: add solveVector typedef to vector.H
This commit is contained in:
Mark Olesen
2022-03-07 13:10:32 +01:00
parent 42fe95a6a9
commit bd37f0b441
53 changed files with 365 additions and 792 deletions

View File

@ -72,23 +72,17 @@ primitives/SphericalTensor/sphericalTensor/sphericalTensor.C
primitives/SphericalTensor/labelSphericalTensor/labelSphericalTensor.C
primitives/SymmTensor/labelSymmTensor/labelSymmTensor.C
primitives/SymmTensor/symmTensor/symmTensor.C
primitives/Tensor/labelTensor/labelTensor.C
primitives/Tensor/tensor/tensor.C
primitives/Tensor/floats/floatTensors.C
primitives/Tensor/floats/tensor.C
primitives/Tensor/ints/labelTensor.C
primitives/Tensor/lists/sphericalTensorList.C
primitives/Tensor/lists/symmTensorList.C
primitives/Tensor/lists/tensorList.C
primitives/Vector/complexVector/complexVector.C
#if !defined(WM_DP)
primitives/Vector/doubleVector/doubleVector.C
primitives/Tensor/doubleTensor/doubleTensor.C
#endif
#if !defined(WM_SP) && !defined(WM_SPDP)
primitives/Vector/floatVector/floatVector.C
primitives/Tensor/floatTensor/floatTensor.C
#endif
primitives/Vector/labelVector/labelVector.C
primitives/Vector/vector/vector.C
primitives/Vector/complex/complexVector.C
primitives/Vector/floats/floatVectors.C
primitives/Vector/ints/labelVector.C
primitives/Vector/lists/vectorList.C
primitives/Vector/lists/vectorIOList.C
primitives/Vector/lists/vectorListIOList.C

View File

@ -58,8 +58,6 @@ void Foam::primitiveMeshTools::makeFaceCentresAndAreas
}
else
{
typedef Vector<solveScalar> solveVector;
solveVector sumN = Zero;
solveScalar sumA = 0.0;
solveVector sumAc = Zero;
@ -112,8 +110,6 @@ void Foam::primitiveMeshTools::makeCellCentresAndVols
scalarField& cellVols_s
)
{
typedef Vector<solveScalar> solveVector;
PrecisionAdaptor<solveVector, vector> tcellCtrs(cellCtrs_s, false);
PrecisionAdaptor<solveScalar, scalar> tcellVols(cellVols_s, false);
Field<solveVector>& cellCtrs = tcellCtrs.ref();
@ -591,8 +587,6 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::faceFlatness
tmp<scalarField> tfaceFlatness(new scalarField(mesh.nFaces(), 1.0));
scalarField& faceFlatness = tfaceFlatness.ref();
typedef Vector<solveScalar> solveVector;
forAll(fcs, facei)
{
const face& f = fcs[facei];

View File

@ -47,12 +47,6 @@ const Scalar pTraits<Scalar>::vsmall = ScalarVSMALL;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pTraits<Scalar>::pTraits(const Scalar& val) noexcept
:
p_(val)
{}
pTraits<Scalar>::pTraits(Istream& is)
{
is >> p_;

View File

@ -110,7 +110,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const Scalar& val) noexcept;
explicit pTraits(Scalar val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -1,88 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "doubleTensor.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::doubleTensor::vsType::typeName = "doubleTensor";
template<>
const char* const Foam::doubleTensor::vsType::componentNames[] =
{
"xx", "xy", "xz",
"yx", "yy", "yz",
"zx", "zy", "zz"
};
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::zero
(
doubleTensor::uniform(0)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::one
(
doubleTensor::uniform(1)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::max
(
doubleTensor::uniform(doubleScalarVGREAT)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::min
(
doubleTensor::uniform(-doubleScalarVGREAT)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::rootMax
(
doubleTensor::uniform(doubleScalarROOTVGREAT)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::vsType::rootMin
(
doubleTensor::uniform(-doubleScalarROOTVGREAT)
);
template<>
const Foam::doubleTensor Foam::doubleTensor::I
(
1, 0, 0,
0, 1, 0,
0, 0, 1
);
// ************************************************************************* //

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-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 <http://www.gnu.org/licenses/>.
Typedef
Foam::doubleTensor
Description
A Tensor of double precision values
SourceFiles
doubleTensor.C
\*---------------------------------------------------------------------------*/
#ifndef doubleTensor_H
#define doubleTensor_H
#include "Tensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef Tensor<double> doubleTensor;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,88 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "floatTensor.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::floatTensor::vsType::typeName = "floatTensor";
template<>
const char* const Foam::floatTensor::vsType::componentNames[] =
{
"xx", "xy", "xz",
"yx", "yy", "yz",
"zx", "zy", "zz"
};
template<>
const Foam::floatTensor Foam::floatTensor::vsType::zero
(
floatTensor::uniform(0)
);
template<>
const Foam::floatTensor Foam::floatTensor::vsType::one
(
floatTensor::uniform(1)
);
template<>
const Foam::floatTensor Foam::floatTensor::vsType::max
(
floatTensor::uniform(floatScalarVGREAT)
);
template<>
const Foam::floatTensor Foam::floatTensor::vsType::min
(
floatTensor::uniform(-floatScalarVGREAT)
);
template<>
const Foam::floatTensor Foam::floatTensor::vsType::rootMax
(
floatTensor::uniform(floatScalarROOTVGREAT)
);
template<>
const Foam::floatTensor Foam::floatTensor::vsType::rootMin
(
floatTensor::uniform(-floatScalarROOTVGREAT)
);
template<>
const Foam::floatTensor Foam::floatTensor::I
(
1, 0, 0,
0, 1, 0,
0, 0, 1
);
// ************************************************************************* //

View File

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
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 <http://www.gnu.org/licenses/>.
Typedef
Foam::floatTensor
Description
A Tensor of float precision values
SourceFiles
floatTensor.C
\*---------------------------------------------------------------------------*/
#ifndef floatTensor_H
#define floatTensor_H
#include "Tensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef Tensor<float> floatTensor;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,10 @@
// Compatibility include
#ifndef doubleTensor_H
#define doubleTensor_H
#include "tensor.H"
#endif
// ************************************************************************* //

View File

@ -0,0 +1,10 @@
// Compatibility include
#ifndef floatTensor_H
#define floatTensor_H
#include "tensor.H"
#endif
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2018-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "tensor.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#if defined(WM_DP)
template<>
const char* const Foam::Tensor<float>::vsType::typeName = "floatTensor";
template<>
const char* const Foam::Tensor<double>::vsType::typeName = "tensor";
#else
// WM_SP, WM_SPDP
template<>
const char* const Foam::Tensor<float>::vsType::typeName = "tensor";
template<>
const char* const Foam::Tensor<double>::vsType::typeName = "doubleTensor";
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#undef defineTraits
#define defineTraits(Type, Prefix) \
\
template<> \
const char* const Foam::Tensor<Type>::vsType::componentNames[] = \
{ \
"xx", "xy", "xz", \
"yx", "yy", "yz", \
"zx", "zy", "zz" \
}; \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::zero \
( \
Tensor<Type>::uniform(0) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::one \
( \
Tensor<Type>::uniform(1) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::max \
( \
Tensor<Type>::uniform(Prefix##VGREAT) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::min \
( \
Tensor<Type>::uniform(-Prefix##VGREAT) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::rootMax \
( \
Tensor<Type>::uniform(Prefix##ROOTVGREAT) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::vsType::rootMin \
( \
Tensor<Type>::uniform(-Prefix##ROOTVGREAT) \
); \
\
template<> \
const Foam::Tensor<Type> Foam::Tensor<Type>::I \
( \
1, 0, 0, \
0, 1, 0, \
0, 0, 1 \
); \
defineTraits(float, floatScalar);
defineTraits(double, doubleScalar);
#undef defineTraits
// ************************************************************************* //

View File

@ -32,46 +32,6 @@ License
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::tensor::vsType::typeName = "tensor";
template<>
const char* const Foam::tensor::vsType::componentNames[] =
{
"xx", "xy", "xz",
"yx", "yy", "yz",
"zx", "zy", "zz"
};
template<>
const Foam::tensor Foam::tensor::vsType::zero(tensor::uniform(0));
template<>
const Foam::tensor Foam::tensor::vsType::one(tensor::uniform(1));
template<>
const Foam::tensor Foam::tensor::vsType::max(tensor::uniform(VGREAT));
template<>
const Foam::tensor Foam::tensor::vsType::min(tensor::uniform(-VGREAT));
template<>
const Foam::tensor Foam::tensor::vsType::rootMax(tensor::uniform(ROOTVGREAT));
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
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::Vector<Foam::complex> Foam::eigenValues(const tensor& T)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,11 +24,11 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Class
Foam::tensor
Description
Tensor of scalars, i.e. Tensor<scalar>.
Tensor of scalars, i.e. Tensor\<scalar\>.
Analytical functions for the computation of complex eigenvalues and
complex eigenvectors from a given tensor.
@ -37,12 +37,13 @@ See also
Test-Tensor.C
SourceFiles
floatTensors.C
tensor.C
\*---------------------------------------------------------------------------*/
#ifndef tensor_H
#define tensor_H
#ifndef Foam_tensor_H
#define Foam_tensor_H
#include "Tensor.H"
#include "vector.H"
@ -57,9 +58,19 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//! \class Foam::floatTensor
//! \brief A Tensor of values with float precision
typedef Tensor<float> floatTensor;
//! \class Foam::doubleTensor
//! \brief A Tensor of values with double precision
typedef Tensor<double> doubleTensor;
// With float or double precision (depending on compilation)
typedef Tensor<scalar> tensor;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
//- Return complex eigenvalues of a given tensor
// \param T tensor

View File

@ -1,78 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "doubleVector.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::doubleVector::vsType::typeName = "doubleVector";
template<>
const char* const Foam::doubleVector::vsType::componentNames[] =
{
"x", "y", "z"
};
template<>
const Foam::doubleVector Foam::doubleVector::vsType::zero
(
doubleVector::uniform(0)
);
template<>
const Foam::doubleVector Foam::doubleVector::vsType::one
(
doubleVector::uniform(1)
);
template<>
const Foam::doubleVector Foam::doubleVector::vsType::max
(
doubleVector::uniform(doubleScalarVGREAT)
);
template<>
const Foam::doubleVector Foam::doubleVector::vsType::min
(
doubleVector::uniform(-doubleScalarVGREAT)
);
template<>
const Foam::doubleVector Foam::doubleVector::vsType::rootMax
(
doubleVector::uniform(doubleScalarROOTVGREAT)
);
template<>
const Foam::doubleVector Foam::doubleVector::vsType::rootMin
(
doubleVector::uniform(-doubleScalarROOTVGREAT)
);
// ************************************************************************* //

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-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 <http://www.gnu.org/licenses/>.
Typedef
Foam::doubleVector
Description
A Vector of values with double precision.
SourceFiles
doubleVector.C
\*---------------------------------------------------------------------------*/
#ifndef doubleVector_H
#define doubleVector_H
#include "Vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef Vector<double> doubleVector;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "floatVector.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::floatVector::vsType::typeName = "floatVector";
template<>
const char* const Foam::floatVector::vsType::componentNames[] =
{
"x", "y", "z"
};
template<>
const Foam::floatVector Foam::floatVector::vsType::zero
(
floatVector::uniform(0)
);
template<>
const Foam::floatVector Foam::floatVector::vsType::one
(
floatVector::uniform(1)
);
template<>
const Foam::floatVector Foam::floatVector::vsType::max
(
floatVector::uniform(floatScalarVGREAT)
);
template<>
const Foam::floatVector Foam::floatVector::vsType::min
(
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)
);
// ************************************************************************* //

View File

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
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 <http://www.gnu.org/licenses/>.
Typedef
Foam::floatVector
Description
A Vector of values with float precision.
SourceFiles
floatVector.C
\*---------------------------------------------------------------------------*/
#ifndef floatVector_H
#define floatVector_H
#include "Vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef Vector<float> floatVector;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,10 @@
// Compatibility include
#ifndef doubleVector_H
#define doubleVector_H
#include "vector.H"
#endif
// ************************************************************************* //

View File

@ -0,0 +1,10 @@
// Compatibility include
#ifndef floatVector_H
#define floatVector_H
#include "vector.H"
#endif
// ************************************************************************* //

View File

@ -0,0 +1,115 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "vector.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#if defined(WM_DP)
template<>
const char* const Foam::Vector<float>::vsType::typeName = "floatVector";
template<>
const char* const Foam::Vector<double>::vsType::typeName = "vector";
#else
// WM_SP, WM_SPDP
template<>
const char* const Foam::Vector<float>::vsType::typeName = "vector";
template<>
const char* const Foam::Vector<double>::vsType::typeName = "doubleVector";
// or (TDB):
//
// #if defined(WM_SPDP)
// template<>
// const char* const Foam::Vector<double>::vsType::typeName = "solveVector";
// #else
// template<>
// const char* const Foam::Vector<double>::vsType::typeName = "doubleVector";
// #endif
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#undef defineTraits
#define defineTraits(Type, Prefix) \
\
template<> \
const char* const Foam::Vector<Type>::vsType::componentNames[] = \
{ \
"x", "y", "z" \
}; \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::zero \
( \
Vector<Type>::uniform(0) \
); \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::one \
( \
Vector<Type>::uniform(1) \
); \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::max \
( \
Vector<Type>::uniform(Prefix##VGREAT) \
); \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::min \
( \
Vector<Type>::uniform(-Prefix##VGREAT) \
); \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::rootMax \
( \
Vector<Type>::uniform(Prefix##ROOTVGREAT) \
); \
\
template<> \
const Foam::Vector<Type> Foam::Vector<Type>::vsType::rootMin \
( \
Vector<Type>::uniform(-Prefix##ROOTVGREAT) \
); \
defineTraits(float, floatScalar);
defineTraits(double, doubleScalar);
#undef defineTraits
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,19 +24,20 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Class
Foam::vector
Description
A scalar version of the templated Vector
A Vector of values with scalar precision,
where scalar is float/double depending on the compilation flags.
SourceFiles
vector.C
floatVectors.C
\*---------------------------------------------------------------------------*/
#ifndef vector_H
#define vector_H
#ifndef Foam_vector_H
#define Foam_vector_H
#include "scalar.H"
#include "Vector.H"
@ -48,8 +49,22 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//! \class Foam::floatVector
//! \brief A Vector of values with float precision
typedef Vector<float> floatVector;
//! \class Foam::doubleVector
//! \brief A Vector of values with double precision
typedef Vector<double> doubleVector;
// With float or double precision (depending on compilation)
typedef Vector<scalar> vector;
// With float or double precision (depending on compilation)
typedef Vector<solveScalar> solveVector;
// Traits
template<class Type>

View File

@ -1,60 +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 <http://www.gnu.org/licenses/>.
Description
Vector of scalars.
\*---------------------------------------------------------------------------*/
#include "vector.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::vector::vsType::typeName = "vector";
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(VGREAT));
template<>
const Foam::vector Foam::vector::vsType::min(vector::uniform(-VGREAT));
template<>
const Foam::vector Foam::vector::vsType::rootMax(vector::uniform(ROOTVGREAT));
template<>
const Foam::vector Foam::vector::vsType::rootMin(vector::uniform(-ROOTVGREAT));
// ************************************************************************* //

View File

@ -42,12 +42,6 @@ const bool Foam::pTraits<bool>::one = true;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<bool>::pTraits(const bool& p) noexcept
:
p_(p)
{}
Foam::pTraits<bool>::pTraits(Istream& is)
{
is >> p_;

View File

@ -109,7 +109,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const bool& p) noexcept;
explicit pTraits(bool val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -36,12 +36,6 @@ const char* const Foam::pTraits<char>::typeName = "char";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<char>::pTraits(const char p) noexcept
:
p_(p)
{}
Foam::pTraits<char>::pTraits(Istream& is)
{
is >> p_;

View File

@ -103,7 +103,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const char p) noexcept;
explicit pTraits(char val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -51,11 +51,7 @@ const Foam::complex Foam::pTraits<Foam::complex>::rootMax
);
Foam::pTraits<Foam::complex>::pTraits(const complex& val)
:
p_(val)
{}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<Foam::complex>::pTraits(Istream& is)
{
@ -63,8 +59,6 @@ Foam::pTraits<Foam::complex>::pTraits(Istream& is)
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::complex::complex(Istream& is)
{
is >> *this;

View File

@ -299,7 +299,11 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const complex& val);
explicit pTraits(const complex& val)
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -42,11 +42,6 @@ const int32_t Foam::pTraits<int32_t>::rootMax = pTraits<int32_t>::max;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<int32_t>::pTraits(const int32_t& val) noexcept
:
p_(val)
{}
Foam::pTraits<int32_t>::pTraits(Istream& is)
{
is >> p_;

View File

@ -175,7 +175,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const int32_t& val) noexcept;
explicit pTraits(int32_t val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -42,12 +42,6 @@ const int64_t Foam::pTraits<int64_t>::rootMax = pTraits<int64_t>::max;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<int64_t>::pTraits(const int64_t& val) noexcept
:
p_(val)
{}
Foam::pTraits<int64_t>::pTraits(Istream& is)
{
is >> p_;

View File

@ -174,7 +174,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const int64_t& val) noexcept;
explicit pTraits(int64_t val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -42,12 +42,6 @@ const uint32_t Foam::pTraits<uint32_t>::rootMax = pTraits<uint32_t>::max;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<uint32_t>::pTraits(const uint32_t& val) noexcept
:
p_(val)
{}
Foam::pTraits<uint32_t>::pTraits(Istream& is)
{
is >> p_;

View File

@ -161,7 +161,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const uint32_t& val) noexcept;
explicit pTraits(uint32_t val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -42,11 +42,6 @@ const uint64_t Foam::pTraits<uint64_t>::rootMax = pTraits<uint64_t>::max;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<uint64_t>::pTraits(const uint64_t& val) noexcept
:
p_(val)
{}
Foam::pTraits<uint64_t>::pTraits(Istream& is)
{
is >> p_;

View File

@ -170,7 +170,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const uint64_t& val) noexcept;
explicit pTraits(uint64_t val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -42,12 +42,6 @@ const uint8_t Foam::pTraits<uint8_t>::rootMax = UINT8_MAX;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pTraits<uint8_t>::pTraits(const uint8_t& val) noexcept
:
p_(val)
{}
Foam::pTraits<uint8_t>::pTraits(Istream& is)
{
is >> p_;

View File

@ -126,7 +126,10 @@ public:
// Constructors
//- Copy construct from primitive
explicit pTraits(const uint8_t& val) noexcept;
explicit pTraits(uint8_t val) noexcept
:
p_(val)
{}
//- Read construct from Istream
explicit pTraits(Istream& is);

View File

@ -36,8 +36,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef pTraits_H
#define pTraits_H
#ifndef Foam_pTraits_H
#define Foam_pTraits_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -32,11 +32,11 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef STLpoint_H
#define STLpoint_H
#ifndef Foam_STLpoint_H
#define Foam_STLpoint_H
#include "point.H"
#include "floatVector.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,39 +49,37 @@ namespace Foam
class STLpoint
:
public floatVector
public Vector<float>
{
public:
// Constructors
//- Construct null
inline STLpoint()
{}
//- Default construct
STLpoint() = default;
//- Construct from single-precision point
inline STLpoint(const Vector<float>& p)
:
floatVector(p)
Vector<float>(p)
{}
//- Construct from double-precision point
inline STLpoint(const Vector<double>& p)
:
floatVector(float(p.x()), float(p.y()), float(p.z()))
Vector<float>(float(p.x()), float(p.y()), float(p.z()))
{}
//- Construct from single-precision components
inline STLpoint(float x, float y, float z)
:
floatVector(x, y, z)
Vector<float>(x, y, z)
{}
//- Construct from double-precision components
inline STLpoint(double x, double y, double z)
:
floatVector(float(x), float(y), float(z))
Vector<float>(float(x), float(y), float(z))
{}

View File

@ -63,8 +63,6 @@ Foam::label Foam::averageNeighbourFvGeometryScheme::clipFaceTet
// Clip correction vector if any triangle becomes too small. Return number
// of correction vectors clipped
typedef Vector<solveScalar> solveVector;
const pointField& p = mesh_.points();
label nClipped = 0;
@ -142,8 +140,6 @@ void Foam::averageNeighbourFvGeometryScheme::makePyrHeights
ownHeight.setSize(mesh_.nFaces());
neiHeight.setSize(mesh_.nInternalFaces());
typedef Vector<solveScalar> solveVector;
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
@ -184,8 +180,6 @@ Foam::label Foam::averageNeighbourFvGeometryScheme::clipPyramids
// Clip correction vector if any pyramid becomes too small. Return number of
// cells clipped
typedef Vector<solveScalar> solveVector;
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
@ -274,8 +268,6 @@ Foam::averageNeighbourFvGeometryScheme::averageNeighbourCentres
const scalarField& faceWeights
) const
{
typedef Vector<solveScalar> solveVector;
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();
@ -386,8 +378,6 @@ Foam::averageNeighbourFvGeometryScheme::averageCentres
const vectorField& faceNormals
) const
{
typedef Vector<solveScalar> solveVector;
const labelList& own = mesh_.faceOwner();
const labelList& nei = mesh_.faceNeighbour();

View File

@ -247,8 +247,6 @@ void Foam::highAspectRatioFvGeometryScheme::makeAverageCentres
<< "calculating weighted average face/cell centre" << endl;
}
typedef Vector<solveScalar> solveVector;
const faceList& fs = mesh.faces();
// Start off from primitiveMesh faceCentres (preserved for triangles)

View File

@ -74,8 +74,6 @@ void Foam::stabilisedFvGeometryScheme::makeFaceCentresAndAreas
// For more complex faces, decompose into triangles
else
{
typedef Vector<solveScalar> solveVector;
// Compute an estimate of the centre as the average of the points
solveVector fCentre = p[f[0]];
for (label pi = 1; pi < nPoints; pi++)