mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: added access to get/set a Tensor diagonal
This commit is contained in:
committed by
Andrew Heather
parent
7b42931a7b
commit
b465592ee2
@ -41,7 +41,7 @@ SourceFiles
|
|||||||
#define SymmTensor_H
|
#define SymmTensor_H
|
||||||
|
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
#include "VectorSpace.H"
|
#include "Vector.H"
|
||||||
#include "SphericalTensor.H"
|
#include "SphericalTensor.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -104,12 +104,12 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
SymmTensor(Istream&);
|
inline SymmTensor(Istream&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Component access
|
||||||
|
|
||||||
inline const Cmpt& xx() const;
|
inline const Cmpt& xx() const;
|
||||||
inline const Cmpt& xy() const;
|
inline const Cmpt& xy() const;
|
||||||
@ -125,6 +125,18 @@ public:
|
|||||||
inline Cmpt& yz();
|
inline Cmpt& yz();
|
||||||
inline Cmpt& zz();
|
inline Cmpt& zz();
|
||||||
|
|
||||||
|
|
||||||
|
// Diagonal access.
|
||||||
|
|
||||||
|
//- Extract the diagonal as a vector
|
||||||
|
inline Vector<Cmpt> diag() const;
|
||||||
|
|
||||||
|
//- Set values of the diagonal
|
||||||
|
inline void diag(const Vector<Cmpt>& v);
|
||||||
|
|
||||||
|
|
||||||
|
// Tensor Operations
|
||||||
|
|
||||||
//- Transpose
|
//- Transpose
|
||||||
inline const SymmTensor<Cmpt>& T() const;
|
inline const SymmTensor<Cmpt>& T() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -25,7 +25,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "Vector.H"
|
|
||||||
#include "Tensor.H"
|
#include "Tensor.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -159,6 +158,20 @@ inline Cmpt& Foam::SymmTensor<Cmpt>::zz()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Foam::Vector<Cmpt> Foam::SymmTensor<Cmpt>::diag() const
|
||||||
|
{
|
||||||
|
return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline void Foam::SymmTensor<Cmpt>::diag(const Vector<Cmpt>& v)
|
||||||
|
{
|
||||||
|
this->v_[XX] = v.x(); this->v_[YY] = v.y(); this->v_[ZZ] = v.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Cmpt>
|
template<class Cmpt>
|
||||||
inline const Foam::SymmTensor<Cmpt>& Foam::SymmTensor<Cmpt>::T() const
|
inline const Foam::SymmTensor<Cmpt>& Foam::SymmTensor<Cmpt>::T() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,7 +41,7 @@ SourceFiles
|
|||||||
#define SymmTensor2D_H
|
#define SymmTensor2D_H
|
||||||
|
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
#include "VectorSpace.H"
|
#include "Vector2D.H"
|
||||||
#include "SphericalTensor2D.H"
|
#include "SphericalTensor2D.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
SymmTensor2D(Istream&);
|
inline SymmTensor2D(Istream&);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -117,6 +117,16 @@ public:
|
|||||||
inline Cmpt& xy();
|
inline Cmpt& xy();
|
||||||
inline Cmpt& yy();
|
inline Cmpt& yy();
|
||||||
|
|
||||||
|
|
||||||
|
// Diagonal access.
|
||||||
|
|
||||||
|
//- Extract the diagonal as a vector
|
||||||
|
inline Vector2D<Cmpt> diag() const;
|
||||||
|
|
||||||
|
//- Set values of the diagonal
|
||||||
|
inline void diag(const Vector2D<Cmpt>& v);
|
||||||
|
|
||||||
|
|
||||||
//- Transpose
|
//- Transpose
|
||||||
inline const SymmTensor2D<Cmpt>& T() const;
|
inline const SymmTensor2D<Cmpt>& T() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -25,7 +25,6 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "Vector2D.H"
|
|
||||||
#include "Tensor2D.H"
|
#include "Tensor2D.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -119,6 +118,20 @@ inline Cmpt& Foam::SymmTensor2D<Cmpt>::yy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Foam::Vector2D<Cmpt> Foam::SymmTensor2D<Cmpt>::diag() const
|
||||||
|
{
|
||||||
|
return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline void Foam::SymmTensor2D<Cmpt>::diag(const Vector2D<Cmpt>& v)
|
||||||
|
{
|
||||||
|
this->v_[XX] = v.x(); this->v_[YY] = v.y();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Cmpt>
|
template<class Cmpt>
|
||||||
inline const Foam::SymmTensor2D<Cmpt>& Foam::SymmTensor2D<Cmpt>::T() const
|
inline const Foam::SymmTensor2D<Cmpt>& Foam::SymmTensor2D<Cmpt>::T() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -229,9 +229,14 @@ public:
|
|||||||
// Runtime check of row index.
|
// Runtime check of row index.
|
||||||
inline void row(const direction r, const Vector<Cmpt>& v);
|
inline void row(const direction r, const Vector<Cmpt>& v);
|
||||||
|
|
||||||
//- Return vector for given row (0,1,2)
|
|
||||||
// Runtime check of row index.
|
// Diagonal access.
|
||||||
inline Vector<Cmpt> vectorComponent(const direction cmpt) const;
|
|
||||||
|
//- Extract the diagonal as a vector
|
||||||
|
inline Vector<Cmpt> diag() const;
|
||||||
|
|
||||||
|
//- Set values of the diagonal
|
||||||
|
inline void diag(const Vector<Cmpt>& v);
|
||||||
|
|
||||||
|
|
||||||
// Tensor Operations
|
// Tensor Operations
|
||||||
@ -269,6 +274,16 @@ public:
|
|||||||
|
|
||||||
//- Assign to a triad of row vectors
|
//- Assign to a triad of row vectors
|
||||||
inline void operator=(const Vector<Vector<Cmpt>>&);
|
inline void operator=(const Vector<Vector<Cmpt>>&);
|
||||||
|
|
||||||
|
|
||||||
|
// Housekeeping
|
||||||
|
|
||||||
|
//- Deprecated(2018-12) Return vector for given row (0,1)
|
||||||
|
// \deprecated(2018-12) use row() method
|
||||||
|
Vector<Cmpt> vectorComponent(const direction cmpt) const
|
||||||
|
{
|
||||||
|
return row(cmpt);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -460,12 +460,16 @@ inline void Foam::Tensor<Cmpt>::row(const direction r, const Vector<Cmpt>& v)
|
|||||||
|
|
||||||
|
|
||||||
template<class Cmpt>
|
template<class Cmpt>
|
||||||
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::vectorComponent
|
inline Foam::Vector<Cmpt> Foam::Tensor<Cmpt>::diag() const
|
||||||
(
|
|
||||||
const direction cmpt
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return row(cmpt);
|
return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline void Foam::Tensor<Cmpt>::diag(const Vector<Cmpt>& v)
|
||||||
|
{
|
||||||
|
this->v_[XX] = v.x(); this->v_[YY] = v.y(); this->v_[ZZ] = v.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -185,9 +185,14 @@ public:
|
|||||||
// Runtime check of row index.
|
// Runtime check of row index.
|
||||||
inline void row(const direction r, const Vector2D<Cmpt>& v);
|
inline void row(const direction r, const Vector2D<Cmpt>& v);
|
||||||
|
|
||||||
//- Return vector for given row (0,1)
|
|
||||||
// Runtime check of row index.
|
// Diagonal access.
|
||||||
inline Vector2D<Cmpt> vectorComponent(const direction cmpt) const;
|
|
||||||
|
//- Extract the diagonal as a vector
|
||||||
|
inline Vector2D<Cmpt> diag() const;
|
||||||
|
|
||||||
|
//- Set values of the diagonal
|
||||||
|
inline void diag(const Vector2D<Cmpt>& v);
|
||||||
|
|
||||||
|
|
||||||
// Tensor Operations
|
// Tensor Operations
|
||||||
@ -209,6 +214,16 @@ public:
|
|||||||
|
|
||||||
//- Copy assign from SphericalTensor2D
|
//- Copy assign from SphericalTensor2D
|
||||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||||
|
|
||||||
|
|
||||||
|
// Housekeeping
|
||||||
|
|
||||||
|
//- Deprecated(2018-12) Return vector for given row (0,1)
|
||||||
|
// \deprecated(2018-12) use row() method
|
||||||
|
Vector2D<Cmpt> vectorComponent(const direction cmpt) const
|
||||||
|
{
|
||||||
|
return row(cmpt);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -305,12 +305,16 @@ inline void Foam::Tensor2D<Cmpt>::row
|
|||||||
|
|
||||||
|
|
||||||
template<class Cmpt>
|
template<class Cmpt>
|
||||||
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::vectorComponent
|
inline Foam::Vector2D<Cmpt> Foam::Tensor2D<Cmpt>::diag() const
|
||||||
(
|
|
||||||
const direction cmpt
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
return row(cmpt);
|
return Vector2D<Cmpt>(this->v_[XX], this->v_[YY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline void Foam::Tensor2D<Cmpt>::diag(const Vector2D<Cmpt>& v)
|
||||||
|
{
|
||||||
|
this->v_[XX] = v.x(); this->v_[YY] = v.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user