ENH: declare generated methods for vector-space, primitives

- make read construct from Istream explicit

BUG: sph(const SymmTensor2D<Cmpt>&)

- had incorrect constant, but the 2D routines still need more attention
 (#1575)
This commit is contained in:
Mark Olesen
2020-01-27 15:54:30 +01:00
committed by Andrew Heather
parent 6953760460
commit 4ecc6ccfca
47 changed files with 500 additions and 403 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,7 +74,7 @@ class pTraits<List<T>>
public:
typedef label cmptType;
pTraits(Istream& is)
explicit pTraits(Istream& is)
:
List<T>(is)
{}
@ -87,7 +88,7 @@ class pTraits<UList<T>>
public:
typedef label cmptType;
pTraits(Istream& is)
explicit pTraits(Istream& is)
:
UList<T>(is)
{}
@ -101,7 +102,7 @@ class pTraits<Field<T>>
public:
typedef label cmptType;
pTraits(Istream& is)
explicit pTraits(Istream& is)
:
Field<T>(is)
{}
@ -115,7 +116,7 @@ class pTraits<face>
public:
typedef label cmptType;
pTraits(Istream& is)
explicit pTraits(Istream& is)
:
face(is)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,11 +58,13 @@ class Barycentric
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Barycentric<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Barycentric<label> labelType;
// Member constants
// Member Constants
//- Rank of Barycentric is 1
static constexpr direction rank = 1;
@ -72,15 +74,18 @@ public:
enum components { A, B, C, D };
// Constructors
// Generated Methods
//- Construct null
inline Barycentric();
//- Default construct
Barycentric() = default;
// Constructors
//- Construct initialized to zero
inline Barycentric(const Foam::zero);
//- Construct given four components
//- Construct from components
inline Barycentric
(
const Cmpt& va,

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Barycentric<Cmpt>::Barycentric()
{}
template<class Cmpt>
inline Foam::Barycentric<Cmpt>::Barycentric(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,11 +61,13 @@ class BarycentricTensor
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Tensor<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Tensor<label> labelType;
// Member constants
// Member Constants
//- Rank of BarycentricTensor is 2
static constexpr direction rank = 2;
@ -75,16 +77,19 @@ public:
enum components { XA, XB, XC, XD, YA, YB, YC, YD, ZA, ZB, ZC, ZD };
// Generated Methods
//- Default construct
BarycentricTensor() = default;
// Constructors
//- Construct null
BarycentricTensor();
//- Construct initialised to zero
BarycentricTensor(const Foam::zero);
inline BarycentricTensor(const Foam::zero);
//- Construct given three barycentric components (rows)
BarycentricTensor
inline BarycentricTensor
(
const Barycentric<Cmpt>& x,
const Barycentric<Cmpt>& y,
@ -92,7 +97,7 @@ public:
);
//- Construct given four vector components (columns)
BarycentricTensor
inline BarycentricTensor
(
const Vector<Cmpt>& a,
const Vector<Cmpt>& b,

View File

@ -27,11 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::BarycentricTensor<Cmpt>::BarycentricTensor()
{}
template<class Cmpt>
inline Foam::BarycentricTensor<Cmpt>::BarycentricTensor(const Foam::zero)
:

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,7 +31,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::barycentric barycentric01
static inline Foam::barycentric barycentric01Impl
(
Foam::scalar s,
Foam::scalar t,
@ -71,13 +72,11 @@ Foam::barycentric barycentric01
Foam::barycentric Foam::barycentric01(Random& rndGen)
{
return
::barycentric01
(
rndGen.sample01<scalar>(),
rndGen.sample01<scalar>(),
rndGen.sample01<scalar>()
);
const scalar s(rndGen.sample01<scalar>());
const scalar t(rndGen.sample01<scalar>());
const scalar u(rndGen.sample01<scalar>());
return barycentric01Impl(s, t, u);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,11 +58,13 @@ class Barycentric2D
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Barycentric2D<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Barycentric2D<label> labelType;
// Member constants
// Member Constants
//- Rank of Barycentric2D is 1
static constexpr direction rank = 1;
@ -72,15 +74,18 @@ public:
enum components { A, B, C };
// Constructors
// Generated Methods: copy construct/assignment
//- Construct null
inline Barycentric2D();
//- Default construct
Barycentric2D() = default;
// Constructors
//- Construct initialized to zero
inline Barycentric2D(const Foam::zero);
//- Construct given four components
//- Construct from components
inline Barycentric2D
(
const Cmpt& va,
@ -109,7 +114,6 @@ public:
//- True if any coordinates are negative
inline bool outside() const;
};

View File

@ -28,11 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Barycentric2D<Cmpt>::Barycentric2D()
{}
template<class Cmpt>
inline Foam::Barycentric2D<Cmpt>::Barycentric2D(const Foam::zero)
:

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,7 +31,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::barycentric2D barycentric2D01
static inline Foam::barycentric2D barycentric2D01Impl
(
Foam::scalar s,
Foam::scalar t
@ -53,12 +54,10 @@ Foam::barycentric2D barycentric2D01
Foam::barycentric2D Foam::barycentric2D01(Random& rndGen)
{
return
::barycentric2D01
(
rndGen.sample01<scalar>(),
rndGen.sample01<scalar>()
);
const scalar s(rndGen.sample01<scalar>());
const scalar t(rndGen.sample01<scalar>());
return barycentric2D01Impl(s, t);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,14 +58,15 @@ class DiagTensor
:
public VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef DiagTensor<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef DiagTensor<label> labelType;
// Member constants
// Member Constants
//- Rank of DiagTensor is 2
static constexpr direction rank = 2;
@ -75,10 +76,19 @@ public:
enum components { XX, YY, ZZ };
// Constructors
// Generated Methods
//- Construct null
inline DiagTensor();
//- Default construct
DiagTensor() = default;
//- Copy construct
DiagTensor(const DiagTensor&) = default;
//- Copy assignment
DiagTensor& operator=(const DiagTensor&) = default;
// Constructors
//- Construct initialized to zero
inline DiagTensor(const Foam::zero);
@ -91,7 +101,7 @@ public:
inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz);
//- Construct from Istream
inline DiagTensor(Istream&);
inline explicit DiagTensor(Istream& is);
// Member Functions

View File

@ -30,11 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::DiagTensor<Cmpt>::DiagTensor()
{}
template<class Cmpt>
inline Foam::DiagTensor<Cmpt>::DiagTensor(const Foam::zero)
:
@ -289,7 +284,10 @@ inline Cmpt tr(const DiagTensor<Cmpt>& dt)
template<class Cmpt>
inline SphericalTensor<Cmpt> sph(const DiagTensor<Cmpt>& dt)
{
return 0.5*tr(dt);
return SphericalTensor<Cmpt>
(
1.0/3.0*tr(dt)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,34 +60,35 @@ class MatrixSpace
:
public VectorSpace<Form, Cmpt, Mrows*Ncols>
{
public:
//- MatrixSpace type
typedef MatrixSpace<Form, Cmpt, Mrows, Ncols> msType;
// Typedefs
//- MatrixSpace type
typedef MatrixSpace<Form, Cmpt, Mrows, Ncols> msType;
// Member constants
// Member Constants
static constexpr direction mRows = Mrows;
static constexpr direction nCols = Ncols;
// Static member functions
// Static Member Functions
//- Return the number of rows
//- The number of rows
static direction m() noexcept
{
return Mrows;
}
//- Return the number of columns
//- The number of columns
static direction n() noexcept
{
return Ncols;
}
//- Return the identity matrix for square matrix spaces
//- An identity matrix for square matrix-spaces
inline static msType identity();
@ -149,13 +150,13 @@ public:
static const direction mRows = SubTensor::mRows;
static const direction nCols = SubTensor::nCols;
//- Return the number of rows in the block
//- The number of rows in the block
static direction m()
{
return mRows;
}
//- Return the number of columns in the block
//- The number of columns in the block
static direction n()
{
return nCols;
@ -199,10 +200,13 @@ public:
};
// Constructors
// Generated Methods
//- Construct null
inline MatrixSpace();
//- Default construct
MatrixSpace() = default;
// Constructors
//- Construct initialized to zero
inline MatrixSpace(const Foam::zero);
@ -227,7 +231,7 @@ public:
);
//- Construct from Istream
MatrixSpace(Istream&);
explicit MatrixSpace(Istream& is);
// Member Functions

View File

@ -29,11 +29,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::MatrixSpace()
{}
template<class Form, class Cmpt, Foam::direction Mrows, Foam::direction Ncols>
inline Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::MatrixSpace
(

View File

@ -70,18 +70,19 @@ class pTraits<Scalar>
public:
//- Component type
typedef Scalar cmptType;
// Typedefs
//- Magnitude type
typedef Scalar magType;
//- Component type
typedef Scalar cmptType;
//- Equivalent type of labels used for valid component indexing
typedef label labelType;
//- Magnitude type
typedef Scalar magType;
//- Equivalent type of labels used for valid component indexing
typedef label labelType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -93,7 +94,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -108,11 +109,11 @@ public:
// Constructors
//- Construct from primitive
//- Copy construct from primitive
explicit pTraits(const Scalar& val);
//- Construct from Istream
pTraits(Istream& is);
//- Read construct from Istream
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,20 +57,21 @@ class SphericalTensor
:
public VectorSpace<SphericalTensor<Cmpt>, Cmpt, 1>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef SphericalTensor<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef SphericalTensor<label> labelType;
// Member constants
// Member Constants
//- Rank of SphericalTensor is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const SphericalTensor I;
static const SphericalTensor oneThirdI;
@ -81,10 +82,19 @@ public:
enum components { II };
// Constructors
// Generated Methods
//- Construct null
inline SphericalTensor();
//- Default construct
SphericalTensor() = default;
//- Copy construct
SphericalTensor(const SphericalTensor&) = default;
//- Copy assignment
SphericalTensor& operator=(const SphericalTensor&) = default;
// Constructors
//- Construct initialized to zero
inline SphericalTensor(const Foam::zero);
@ -97,10 +107,10 @@ public:
);
//- Construct given the component
inline SphericalTensor(const Cmpt& tii);
inline explicit SphericalTensor(const Cmpt& tii);
//- Construct from Istream
inline SphericalTensor(Istream&);
inline explicit SphericalTensor(Istream& is);
// Member Functions
@ -111,7 +121,7 @@ public:
inline Cmpt& ii();
//- Transpose
//- Transpose (no-op)
inline const SphericalTensor<Cmpt>& T() const;
};

View File

@ -29,11 +29,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SphericalTensor<Cmpt>::SphericalTensor()
{}
template<class Cmpt>
inline Foam::SphericalTensor<Cmpt>::SphericalTensor(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,16 +57,21 @@ class SphericalTensor2D
:
public VectorSpace<SphericalTensor2D<Cmpt>, Cmpt, 1>
{
public:
// Member constants
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef SphericalTensor2D<label> labelType;
// Member Constants
//- Rank of SphericalTensor2D is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const SphericalTensor2D I;
static const SphericalTensor2D oneThirdI;
@ -77,10 +82,19 @@ public:
enum components { II };
// Constructors
// Generated Methods
//- Construct null
inline SphericalTensor2D();
//- Default construct
SphericalTensor2D() = default;
//- Copy construct
SphericalTensor2D(const SphericalTensor2D&) = default;
//- Copy assignment
SphericalTensor2D& operator=(const SphericalTensor2D&) = default;
// Constructors
//- Construct initialized to zero
inline SphericalTensor2D(const Foam::zero);
@ -92,10 +106,10 @@ public:
);
//- Construct given the component
inline SphericalTensor2D(const Cmpt& tii);
inline explicit SphericalTensor2D(const Cmpt& tii);
//- Construct from Istream
inline SphericalTensor2D(Istream&);
inline explicit SphericalTensor2D(Istream& is);
// Member Functions

View File

@ -29,11 +29,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D()
{}
template<class Cmpt>
inline Foam::SphericalTensor2D<Cmpt>::SphericalTensor2D(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,20 +59,21 @@ class SymmTensor
:
public VectorSpace<SymmTensor<Cmpt>, Cmpt, 6>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef SymmTensor<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef SymmTensor<label> labelType;
// Member constants
// Member Constants
//- Rank of SymmTensor is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const SymmTensor I;
@ -81,10 +82,19 @@ public:
enum components { XX, XY, XZ, YY, YZ, ZZ };
// Constructors
// Generated Methods
//- Construct null
inline SymmTensor();
//- Default construct
SymmTensor() = default;
//- Copy construct
SymmTensor(const SymmTensor&) = default;
//- Copy assignment
SymmTensor& operator=(const SymmTensor&) = default;
// Constructors
//- Construct initialized to zero
inline SymmTensor(const Foam::zero);
@ -105,7 +115,7 @@ public:
);
//- Construct from Istream
inline SymmTensor(Istream&);
inline explicit SymmTensor(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,11 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor()
{}
template<class Cmpt>
inline Foam::SymmTensor<Cmpt>::SymmTensor(const Foam::zero)
:
@ -56,9 +51,9 @@ inline Foam::SymmTensor<Cmpt>::SymmTensor
template<class Cmpt>
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;
this->v_[ZZ] = st.ii();
this->v_[XX] = st.ii(); this->v_[XY] = 0; this->v_[XZ] = 0;
this->v_[YY] = st.ii(); this->v_[YZ] = 0;
this->v_[ZZ] = st.ii();
}
@ -313,7 +308,10 @@ inline Cmpt tr(const SymmTensor<Cmpt>& st)
template<class Cmpt>
inline SphericalTensor<Cmpt> sph(const SymmTensor<Cmpt>& st)
{
return (1.0/3.0)*tr(st);
return SphericalTensor<Cmpt>
(
(1.0/3.0)*tr(st)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,20 +59,21 @@ class SymmTensor2D
:
public VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef SymmTensor2D<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef SymmTensor2D<label> labelType;
// Member constants
// Member Constants
//- Rank of SymmTensor2D is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const SymmTensor2D I;
@ -81,10 +82,19 @@ public:
enum components { XX, XY, YY };
// Constructors
// Generated Methods
//- Construct null
inline SymmTensor2D();
//- Default construct
SymmTensor2D() = default;
//- Copy construct
SymmTensor2D(const SymmTensor2D&) = default;
//- Copy assignment
SymmTensor2D& operator=(const SymmTensor2D&) = default;
// Constructors
//- Construct initialized to zero
inline SymmTensor2D(const Foam::zero);
@ -103,7 +113,7 @@ public:
);
//- Construct from Istream
inline SymmTensor2D(Istream&);
inline explicit SymmTensor2D(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,11 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D()
{}
template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(const Foam::zero)
:
@ -56,7 +51,7 @@ template<class Cmpt>
inline Foam::SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st)
{
this->v_[XX] = st.ii(); this->v_[XY] = 0;
this->v_[YY] = st.ii();
this->v_[YY] = st.ii();
}
@ -252,7 +247,10 @@ inline Cmpt tr(const SymmTensor2D<Cmpt>& st)
template<class Cmpt>
inline SphericalTensor2D<Cmpt> sph(const SymmTensor2D<Cmpt>& st)
{
return (1.0/2.0)*tr(st);
return SphericalTensor2D<Cmpt>
(
0.5*tr(st)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -67,20 +67,21 @@ class Tensor
:
public MatrixSpace<Tensor<Cmpt>, Cmpt, 3, 3>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Tensor<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Tensor<label> labelType;
// Member constants
// Member Constants
//- Rank of Tensor is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const Tensor I;
@ -89,10 +90,19 @@ public:
enum components { XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ };
// Constructors
// Generated Methods
//- Construct null
inline Tensor();
//- Default construct
Tensor() = default;
//- Copy construct
Tensor(const Tensor&) = default;
//- Copy assignment
Tensor& operator=(const Tensor&) = default;
// Constructors
//- Construct initialized to zero
inline Tensor(const Foam::zero);
@ -150,7 +160,7 @@ public:
);
//- Construct from Istream
inline Tensor(Istream& is);
inline explicit Tensor(Istream& is);
// Member Functions

View File

@ -30,11 +30,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor()
{}
template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor(const Foam::zero)
:
@ -66,12 +61,10 @@ inline Foam::Tensor<Cmpt>::Tensor
template<class Cmpt>
inline Foam::Tensor<Cmpt>::Tensor(const SphericalTensor<Cmpt>& st)
:
Tensor::msType(Zero)
{
this->v_[XX] = st.ii();
this->v_[YY] = st.ii();
this->v_[ZZ] = st.ii();
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;
this->v_[ZX] = 0; this->v_[ZY] = 0; this->v_[ZZ] = st.ii();
}
@ -706,7 +699,10 @@ inline Cmpt tr(const Tensor<Cmpt>& t)
template<class Cmpt>
inline SphericalTensor<Cmpt> sph(const Tensor<Cmpt>& t)
{
return (1.0/3.0)*tr(t);
return SphericalTensor<Cmpt>
(
(1.0/3.0)*tr(t)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,20 +61,21 @@ class Tensor2D
:
public VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Tensor2D<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Tensor2D<label> labelType;
// Member constants
// Member Constants
//- Rank of Tensor2D is 2
static constexpr direction rank = 2;
// Static data members
// Static Data Members
static const Tensor2D I;
@ -82,11 +83,18 @@ public:
//- Component labeling enumeration
enum components { XX, XY, YX, YY };
// Generated Methods
//- Construct null
//- Default construct
Tensor2D() = default;
//- Copy construct
Tensor2D(const Tensor2D&) = default;
//- Copy assignment
Tensor2D& operator=(const Tensor2D&) = default;
// Constructors
@ -117,7 +125,7 @@ public:
);
//- Construct from Istream
inline Tensor2D(Istream&);
inline explicit Tensor2D(Istream& is);
// Member Functions

View File

@ -55,11 +55,9 @@ inline Foam::Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st)
template<class Cmpt>
inline Foam::Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st)
:
Tensor2D::vsType(Zero)
{
this->v_[XX] = st.ii();
this->v_[YY] = st.ii();
this->v_[XX] = st.ii(); this->v_[XY] = 0;
this->v_[YX] = 0; this->v_[YY] = st.ii();
}
@ -467,7 +465,10 @@ inline Cmpt tr(const Tensor2D<Cmpt>& t)
template<class Cmpt>
inline SphericalTensor2D<Cmpt> sph(const Tensor2D<Cmpt>& t)
{
return 0.5*tr(t);
return SphericalTensor2D<Cmpt>
(
0.5*tr(t)
);
}

View File

@ -64,14 +64,15 @@ class Vector
:
public VectorSpace<Vector<Cmpt>, Cmpt, 3>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Vector<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Vector<label> labelType;
// Member constants
// Member Constants
//- Rank of Vector is 1
static constexpr direction rank = 1;
@ -81,10 +82,19 @@ public:
enum components { X, Y, Z };
// Constructors
// Generated Methods
//- Construct null
inline Vector();
//- Default construct
Vector() = default;
//- Copy construct
Vector(const Vector&) = default;
//- Copy assignment
Vector& operator=(const Vector&) = default;
// Constructors
//- Construct initialized to zero
inline Vector(const Foam::zero);
@ -97,7 +107,7 @@ public:
inline Vector(const Cmpt& vx, const Cmpt& vy, const Cmpt& vz);
//- Construct from Istream
inline Vector(Istream& is);
inline explicit Vector(Istream& is);
// Member Functions
@ -130,7 +140,6 @@ public:
(
const Foam::List<Vector<Cmpt>>&
) const;
};

View File

@ -28,11 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Vector<Cmpt>::Vector()
{}
template<class Cmpt>
inline Foam::Vector<Cmpt>::Vector(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,14 +57,15 @@ class Vector2D
:
public VectorSpace<Vector2D<Cmpt>, Cmpt, 2>
{
public:
//- Equivalent type of labels used for valid component indexing
typedef Vector2D<label> labelType;
// Typedefs
//- Equivalent type of labels used for valid component indexing
typedef Vector2D<label> labelType;
// Member constants
// Member Constants
//- Rank of Vector2D is 1
static constexpr direction rank = 1;
@ -74,10 +75,19 @@ public:
enum components { X, Y };
// Constructors
// Generated Methods
//- Construct null
inline Vector2D();
//- Default construct
Vector2D() = default;
//- Copy construct
Vector2D(const Vector2D&) = default;
//- Copy assignment
Vector2D& operator=(const Vector2D&) = default;
// Constructors
//- Construct initialized to zero
inline Vector2D(const Foam::zero);
@ -89,7 +99,7 @@ public:
inline Vector2D(const Cmpt& vx, const Cmpt& vy);
//- Construct from Istream
inline Vector2D(Istream& is);
inline explicit Vector2D(Istream& is);
// Member Functions
@ -113,7 +123,6 @@ public:
//- Perp dot product (dot product with perpendicular vector)
inline scalar perp(const Vector2D<Cmpt>& b) const;
};

View File

@ -28,11 +28,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Cmpt>
inline Foam::Vector2D<Cmpt>::Vector2D()
{}
template<class Cmpt>
inline Foam::Vector2D<Cmpt>::Vector2D(const Foam::zero)
:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
template<class Form, class Cmpt, direction Ncmpts> class VectorSpace;
@ -149,17 +149,17 @@ public:
};
// Constructors
// Generated Methods
//- Construct null
inline VectorSpace();
//- Default construct
VectorSpace() = default;
// Constructors
//- Construct initialized to zero
inline VectorSpace(const Foam::zero);
//- Construct from Istream
VectorSpace(Istream& is);
//- Copy construct
inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>& vs);
@ -167,11 +167,17 @@ public:
template<class Form2, class Cmpt2>
inline explicit VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&);
//- Construct from Istream
explicit VectorSpace(Istream& is);
// Member Functions
//- Return the number of elements in the VectorSpace = Ncmpts.
inline static constexpr direction size();
//- The number of elements in the VectorSpace = Ncmpts.
static constexpr direction size() noexcept
{
return Ncmpts;
}
inline const Cmpt& component(const direction) const;
inline Cmpt& component(const direction);
@ -255,7 +261,7 @@ public:
};
// * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
//- A word representation of a VectorSpace
template<class Form, class Cmpt, direction Ncmpts>

View File

@ -32,14 +32,8 @@ License
#include "ops.H"
#include <type_traits>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
{}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero)
{
@ -88,13 +82,6 @@ inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline constexpr Foam::direction Foam::VectorSpace<Form, Cmpt, Ncmpts>::size()
{
return Ncmpts;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,11 +43,10 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class Istream;
class Ostream;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Istream& operator>>(Istream& is, bool& b);
Ostream& operator<<(Ostream& os, const bool b);
@ -72,14 +71,16 @@ class pTraits<bool>
public:
//- Component type
typedef bool cmptType;
// Typedefs
//- Magnitude type
typedef bool magType;
//- Component type
typedef bool cmptType;
//- Magnitude type
typedef bool magType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -91,7 +92,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -101,11 +102,11 @@ public:
// Constructors
//- Construct from primitive
//- Copy construct from primitive
explicit pTraits(const bool& p);
//- Construct from Istream
pTraits(Istream& is);
//- Read construct from Istream
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -90,14 +90,26 @@ class complex
public:
// Generated Methods
//- Copy construct
complex(const complex&) = default;
//- Copy assignment
complex& operator=(const complex&) = default;
//- Move construct
complex(complex&&) = default;
//- Move assignment
complex& operator=(complex&&) = default;
// Constructors
//- Construct null as zero-initialized
//- Default construct, as zero-initialized
inline constexpr complex() noexcept;
//- Default copy constructor
complex(const complex&) = default;
//- Construct zero-initialized from zero class
inline constexpr complex(const Foam::zero) noexcept;
@ -173,9 +185,6 @@ public:
}
//- Copy assignment
inline void operator=(const complex& c);
//- Assign zero
inline void operator=(const Foam::zero);
@ -250,14 +259,16 @@ class pTraits<complex>
public:
//- Component type
typedef complex cmptType;
// Typedefs
//- Magnitude type
typedef scalar magType;
//- Component type
typedef complex cmptType;
//- Equivalent type of labels used for valid component indexing
typedef label labelType;
//- Magnitude type
typedef scalar magType;
//- Equivalent type of labels used for valid component indexing
typedef label labelType;
// Member Constants
@ -287,11 +298,11 @@ public:
// Constructors
//- Construct from primitive
//- Copy construct from primitive
explicit pTraits(const complex& val);
//- Construct from Istream
pTraits(Istream& is);
//- Read construct from Istream
explicit pTraits(Istream& is);
// Member Functions

View File

@ -116,13 +116,6 @@ inline Foam::complex Foam::complex::conjugate() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::complex::operator=(const complex& c)
{
re = c.re;
im = c.im;
}
inline void Foam::complex::operator=(const Foam::zero)
{
re = 0;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,7 +52,6 @@ namespace Foam
{
// Forward Declarations
class vectorTensorTransform;
Istream& operator>>(Istream& is, vectorTensorTransform&);
Ostream& operator<<(Ostream& os, const vectorTensorTransform& C);
@ -63,7 +63,7 @@ Ostream& operator<<(Ostream& os, const vectorTensorTransform& C);
class vectorTensorTransform
{
// private data
// Private Data
//- Translation vector
vector t_;
@ -79,7 +79,7 @@ class vectorTensorTransform
public:
// Static data members
// Static Data
static const char* const typeName;
@ -88,13 +88,30 @@ public:
static const vectorTensorTransform I;
// Generated Methods
//- Copy construct
vectorTensorTransform(const vectorTensorTransform&) = default;
//- Copy assignment
vectorTensorTransform&
operator=(const vectorTensorTransform&) = default;
//- Move construct
vectorTensorTransform(vectorTensorTransform&&) = default;
//- Move assignment
vectorTensorTransform&
operator=(vectorTensorTransform&&) = default;
// Constructors
//- Construct null
//- Default construct - no translation, identity rotation.
inline vectorTensorTransform();
//- Construct given a translation vector, rotation tensor and
// hasR bool
//- hasR bool
inline vectorTensorTransform
(
const vector& t,
@ -103,18 +120,18 @@ public:
);
//- Construct a pure translation vectorTensorTransform given a
// translation vector
//- translation vector
inline explicit vectorTensorTransform(const vector& t);
//- Construct a pure rotation vectorTensorTransform given a
// rotation tensor
//- rotation tensor
inline explicit vectorTensorTransform(const tensor& R);
//- Construct from Istream
vectorTensorTransform(Istream&);
explicit vectorTensorTransform(Istream&);
// Member functions
// Member Functions
// Access
@ -151,11 +168,11 @@ public:
tmp<Field<Type>> transform(const Field<Type>&) const;
// Member operators
// Member Operators
inline void operator=(const vectorTensorTransform&);
inline void operator&=(const vectorTensorTransform&);
//- Assign translation
inline void operator=(const vector&);
inline void operator+=(const vector&);
inline void operator-=(const vector&);
@ -164,7 +181,7 @@ public:
inline void operator&=(const tensor&);
// IOstream operators
// IOstream Operators
friend Istream& operator>>(Istream& is, vectorTensorTransform&);

View File

@ -173,17 +173,6 @@ inline Foam::pointField Foam::vectorTensorTransform::invTransformPosition
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::vectorTensorTransform::operator=
(
const vectorTensorTransform& tr
)
{
t_ = tr.t_;
R_ = tr.R_;
hasR_ = tr.hasR_;
}
inline void Foam::vectorTensorTransform::operator&=
(
const vectorTensorTransform& tr

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,7 +47,6 @@ SourceFiles
#include "pTraits.H"
#include "direction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -139,14 +138,16 @@ class pTraits<int32_t>
public:
//- Component type
typedef int32_t cmptType;
// Typedefs
//- Magnitude type
typedef int32_t magType;
//- Component type
typedef int32_t cmptType;
//- Magnitude type
typedef int32_t magType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -158,7 +159,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -176,7 +177,7 @@ public:
explicit pTraits(const int32_t& val);
//- Read construct from Istream
pTraits(Istream& is);
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -137,14 +137,16 @@ class pTraits<int64_t>
public:
//- Component type
typedef int64_t cmptType;
// Typedefs
//- Magnitude type
typedef int64_t magType;
//- Component type
typedef int64_t cmptType;
//- Magnitude type
typedef int64_t magType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -156,7 +158,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -174,7 +176,7 @@ public:
explicit pTraits(const int64_t& val);
//- Read construct from Istream
pTraits(Istream& is);
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -127,11 +127,13 @@ class pTraits<uint32_t>
public:
//- Component type
typedef uint32_t cmptType;
// Typedefs
//- Component type
typedef uint32_t cmptType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -143,7 +145,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -161,7 +163,7 @@ public:
explicit pTraits(const uint32_t& val);
//- Read construct from Istream
pTraits(Istream& is);
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -136,11 +136,13 @@ class pTraits<uint64_t>
public:
//- Component type
typedef uint64_t cmptType;
// Typedefs
//- Component type
typedef uint64_t cmptType;
// Member constants
// Member Constants
//- Dimensionality of space
static constexpr direction dim = 3;
@ -152,7 +154,7 @@ public:
static constexpr direction nComponents = 1;
// Static data members
// Static Data Members
static const char* const typeName;
static const char* const componentNames[];
@ -170,7 +172,7 @@ public:
explicit pTraits(const uint64_t& val);
//- Read construct from Istream
pTraits(Istream& is);
explicit pTraits(Istream& is);
// Member Functions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,6 +44,7 @@ Description
namespace Foam
{
// Forward Declarations
class Istream;
/*---------------------------------------------------------------------------*\
@ -54,19 +56,18 @@ class pTraits
:
public PrimitiveType
{
public:
// Constructors
//- Construct from primitive
pTraits(const PrimitiveType& p)
//- Copy construct from primitive
explicit pTraits(const PrimitiveType& p)
:
PrimitiveType(p)
{}
//- Construct from Istream
pTraits(Istream& is)
explicit pTraits(Istream& is)
:
PrimitiveType(is)
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -127,10 +127,25 @@ public:
static const quaternion I;
// Constructors
// Generated Methods
//- Construct null
inline quaternion();
//- Default construct
quaternion() = default;
//- Copy construct
quaternion(const quaternion&) = default;
//- Copy assignment
quaternion& operator=(const quaternion&) = default;
//- Move construct
quaternion(quaternion&&) = default;
//- Move assignment
quaternion& operator=(quaternion&&) = default;
// Constructors
//- Construct zero initialized
inline quaternion(const Foam::zero);
@ -193,7 +208,7 @@ public:
inline quaternion normalized() const;
// Edit
// Edit
//- Scalar part of the quaternion ( = cos(theta/2) for rotation)
inline scalar& w();
@ -205,7 +220,7 @@ public:
inline void normalize();
// Transform
// Transform
//- Rotate the given vector
inline vector transform(const vector& v) const;
@ -222,16 +237,15 @@ public:
// Member Operators
inline void operator=(const quaternion& q);
inline void operator+=(const quaternion& q);
inline void operator-=(const quaternion& q);
inline void operator*=(const quaternion& q);
inline void operator/=(const quaternion& q);
//- Change scalar portion
//- Change scalar portion only
inline void operator=(const scalar s);
//- Change vector portion
//- Change vector portion only
inline void operator=(const vector& v);
inline void operator*=(const scalar s);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,13 +28,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::quaternion::quaternion()
{}
inline Foam::quaternion::quaternion(const Foam::zero)
:
w_(Zero),
w_(0),
v_(Zero)
{}
@ -585,12 +581,6 @@ inline Foam::vector Foam::quaternion::eulerAngles
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::quaternion::operator=(const quaternion& q)
{
w_ = q.w_;
v_ = q.v_;
}
inline void Foam::quaternion::operator+=(const quaternion& q)
{
w_ += q.w_;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,17 +33,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const Foam::septernion::typeName = "septernion";
const Foam::septernion Foam::septernion::zero
(
vector(0, 0, 0),
quaternion(0, vector(0, 0, 0))
);
const Foam::septernion Foam::septernion::zero(Zero);
const Foam::septernion Foam::septernion::I
(
vector(0, 0, 0),
quaternion(1, vector(0, 0, 0))
vector(Zero),
quaternion(scalar(1))
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::septernion::septernion(Istream& is)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,7 +77,7 @@ class septernion
public:
// Static data members
// Static Data
static const char* const typeName;
@ -85,10 +85,28 @@ public:
static const septernion I;
// Generated Methods
//- Default construct
septernion() = default;
//- Copy construct
septernion(const septernion&) = default;
//- Copy assignment
septernion& operator=(const septernion&) = default;
//- Move construct
septernion(septernion&&) = default;
//- Move assignment
septernion& operator=(septernion&&) = default;
// Constructors
//- Construct null
inline septernion();
//- Construct zero initialized
inline septernion(const Foam::zero);
//- Construct given a translation vector and rotation quaternion
inline septernion(const vector& t, const quaternion& r);
@ -103,24 +121,24 @@ public:
inline explicit septernion(const spatialTransform& st);
//- Construct from Istream
septernion(Istream&);
explicit septernion(Istream& is);
// Member functions
// Member Functions
// Access
// Access
inline const vector& t() const;
inline const quaternion& r() const;
// Edit
// Edit
inline vector& t();
inline quaternion& r();
// Transform
// Transform
//- Transform the given coordinate point
inline vector transformPoint(const vector& v) const;
@ -129,9 +147,8 @@ public:
inline vector invTransformPoint(const vector& v) const;
// Member operators
// Member Operators
inline void operator=(const septernion&);
inline void operator*=(const septernion&);
inline void operator=(const vector&);
@ -146,7 +163,7 @@ public:
inline void operator/=(const scalar);
// IOstream operators
// IOstream Operators
friend Istream& operator>>(Istream& is, septernion&);
friend Ostream& operator<<(Ostream& os, const septernion& C);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,27 +28,34 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::septernion::septernion()
inline Foam::septernion::septernion(const Foam::zero)
:
t_(Zero),
r_(Zero)
{}
inline Foam::septernion::septernion(const vector& t, const quaternion& r)
:
t_(t),
r_(r)
{}
inline Foam::septernion::septernion(const vector& t)
:
t_(t),
r_(quaternion::I)
{}
inline Foam::septernion::septernion(const quaternion& r)
:
t_(Zero),
r_(r)
{}
inline Foam::septernion::septernion(const spatialTransform& st)
:
t_(st.r()),
@ -95,12 +103,6 @@ inline Foam::vector Foam::septernion::invTransformPoint(const vector& v) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void Foam::septernion::operator=(const septernion& tr)
{
t_ = tr.t_;
r_ = tr.r_;
}
inline void Foam::septernion::operator*=(const septernion& tr)
{
t_ = tr.t() + tr.r().invTransform(t_);
@ -114,11 +116,13 @@ inline void Foam::septernion::operator=(const vector& t)
r_ = quaternion::I;
}
inline void Foam::septernion::operator+=(const vector& t)
{
t_ += t;
}
inline void Foam::septernion::operator-=(const vector& t)
{
t_ -= t;
@ -131,12 +135,14 @@ inline void Foam::septernion::operator=(const quaternion& r)
r_ = r;
}
inline void Foam::septernion::operator*=(const quaternion& r)
{
t_ = r.invTransform(t_);
r_ *= r;
}
inline void Foam::septernion::operator/=(const quaternion& r)
{
t_ = r.transform(t_);