mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: retrieve tensor diagonal directly instead of via diagTensor
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,7 +92,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct initialized to zero
|
||||
inline DiagTensor(const Foam::zero);
|
||||
inline DiagTensor(Foam::zero);
|
||||
|
||||
//- Construct given VectorSpace
|
||||
template<class Cmpt2>
|
||||
@ -123,6 +123,9 @@ public:
|
||||
|
||||
// Diagonal access and manipulation
|
||||
|
||||
//- Extract the diagonal as a vector
|
||||
inline Vector<Cmpt> diag() const;
|
||||
|
||||
//- The L2-norm squared of the diagonal
|
||||
inline scalar diagSqr() const;
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,9 +32,9 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::DiagTensor<Cmpt>::DiagTensor(const Foam::zero)
|
||||
inline Foam::DiagTensor<Cmpt>::DiagTensor(Foam::zero)
|
||||
:
|
||||
VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>(Zero)
|
||||
VectorSpace<DiagTensor<Cmpt>, Cmpt, 3>(Foam::zero{})
|
||||
{}
|
||||
|
||||
|
||||
@ -81,6 +81,13 @@ inline Foam::DiagTensor<Cmpt>::DiagTensor(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::Vector<Cmpt> Foam::DiagTensor<Cmpt>::diag() const
|
||||
{
|
||||
return Vector<Cmpt>(this->xx(), this->yy(), this->zz());
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::scalar Foam::DiagTensor<Cmpt>::diagSqr() const
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,7 +94,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct initialized to zero
|
||||
inline SymmTensor(const Foam::zero);
|
||||
inline SymmTensor(Foam::zero);
|
||||
|
||||
//- Construct given VectorSpace of the same rank
|
||||
template<class Cmpt2>
|
||||
@ -234,6 +234,12 @@ public:
|
||||
inline scalar diagSqr() const;
|
||||
|
||||
|
||||
// Characteristics
|
||||
|
||||
//- Is identity tensor?
|
||||
inline bool is_identity(const scalar tol = ROOTVSMALL) const;
|
||||
|
||||
|
||||
// Tensor Operations
|
||||
|
||||
//- Return non-Hermitian transpose
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,9 +31,9 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::SymmTensor<Cmpt>::SymmTensor(const Foam::zero)
|
||||
inline Foam::SymmTensor<Cmpt>::SymmTensor(Foam::zero)
|
||||
:
|
||||
SymmTensor::vsType(Zero)
|
||||
SymmTensor::vsType(Foam::zero{})
|
||||
{}
|
||||
|
||||
|
||||
@ -238,6 +238,21 @@ inline Foam::scalar Foam::SymmTensor<Cmpt>::diagSqr() const
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline bool Foam::SymmTensor<Cmpt>::is_identity(const scalar tol) const
|
||||
{
|
||||
return
|
||||
(
|
||||
Foam::mag(xx() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(yy() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(zz() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(xy()) < tol
|
||||
&& Foam::mag(xz()) < tol
|
||||
&& Foam::mag(yz()) < tol
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Cmpt Foam::SymmTensor<Cmpt>::det() const
|
||||
{
|
||||
|
||||
@ -410,12 +410,12 @@ inline bool Foam::Tensor<Cmpt>::is_identity(const scalar tol) const
|
||||
{
|
||||
return
|
||||
(
|
||||
mag(xx() - pTraits<Cmpt>::one) < tol
|
||||
&& mag(yy() - pTraits<Cmpt>::one) < tol
|
||||
&& mag(zz() - pTraits<Cmpt>::one) < tol
|
||||
&& mag(xy()) < tol && mag(xz()) < tol
|
||||
&& mag(yx()) < tol && mag(yz()) < tol
|
||||
&& mag(zx()) < tol && mag(zy()) < tol
|
||||
Foam::mag(xx() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(yy() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(zz() - pTraits<Cmpt>::one) < tol
|
||||
&& Foam::mag(xy()) < tol && Foam::mag(xz()) < tol
|
||||
&& Foam::mag(yx()) < tol && Foam::mag(yz()) < tol
|
||||
&& Foam::mag(zx()) < tol && Foam::mag(zy()) < tol
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ License
|
||||
#include "wedgeFaPatchField.H"
|
||||
#include "transformField.H"
|
||||
#include "symmTransform.H"
|
||||
#include "diagTensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -138,10 +137,9 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::wedgeFaPatchField<Type>::snGradTransformDiag() const
|
||||
{
|
||||
const diagTensor diagT =
|
||||
0.5*diag(I - refCast<const wedgeFaPatch>(this->patch()).faceT());
|
||||
const auto& rot = refCast<const wedgeFaPatch>(this->patch()).faceT();
|
||||
|
||||
const vector diagV(diagT.xx(), diagT.yy(), diagT.zz());
|
||||
const vector diagV = 0.5*(I - rot).diag();
|
||||
|
||||
return tmp<Field<Type>>::New
|
||||
(
|
||||
|
||||
@ -155,9 +155,7 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::symmetryPlaneFvPatchField<Type>::snGradTransformDiag() const
|
||||
{
|
||||
vector nHat(symmetryPlanePatch_.n());
|
||||
|
||||
const vector diag(mag(nHat.x()), mag(nHat.y()), mag(nHat.z()));
|
||||
const vector diag(cmptMag(symmetryPlanePatch_.n()));
|
||||
|
||||
return tmp<Field<Type>>::New
|
||||
(
|
||||
|
||||
@ -30,7 +30,6 @@ License
|
||||
#include "wedgeFvPatchField.H"
|
||||
#include "transformField.H"
|
||||
#include "symmTransform.H"
|
||||
#include "diagTensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -152,10 +151,9 @@ template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::wedgeFvPatchField<Type>::snGradTransformDiag() const
|
||||
{
|
||||
const diagTensor diagT =
|
||||
0.5*diag(I - refCast<const wedgeFvPatch>(this->patch()).cellT());
|
||||
const auto& rot = refCast<const wedgeFvPatch>(this->patch()).cellT();
|
||||
|
||||
const vector diagV(diagT.xx(), diagT.yy(), diagT.zz());
|
||||
const vector diagV = 0.5*(I - rot).diag();
|
||||
|
||||
return tmp<Field<Type>>::New
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user