mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: SymmTensor2D class
This commit is contained in:
@ -56,6 +56,7 @@ primitives/Vector/lists/vectorListIOList.C
|
||||
|
||||
primitives/Tensor2D/tensor2D/tensor2D.C
|
||||
primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C
|
||||
primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C
|
||||
primitives/Vector2D/vector2D/vector2D.C
|
||||
|
||||
primitives/complex/complex.C
|
||||
|
||||
147
src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H
Normal file
147
src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2D.H
Normal file
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
Class
|
||||
Foam::SymmTensor2D
|
||||
|
||||
Description
|
||||
Templated 2D symmetric tensor derived from VectorSpace adding construction
|
||||
from 4 components, element access using xx(), xy() etc. member functions
|
||||
and the inner-product (dot-product) and outer-product of two Vectors
|
||||
(tensor-product) operators.
|
||||
|
||||
SourceFiles
|
||||
SymmTensor2DI.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SymmTensor2D_H
|
||||
#define SymmTensor2D_H
|
||||
|
||||
#include "VectorSpace.H"
|
||||
#include "SphericalTensor2D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SymmTensor2D Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Cmpt>
|
||||
class SymmTensor2D
|
||||
:
|
||||
public VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Equivalent type of labels used for valid component indexing
|
||||
typedef SymmTensor2D<label> labelType;
|
||||
|
||||
|
||||
// Member constants
|
||||
|
||||
enum
|
||||
{
|
||||
rank = 2 // Rank of SymmTensor2D is 2
|
||||
};
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
static const char* componentNames[];
|
||||
|
||||
static const SymmTensor2D zero;
|
||||
static const SymmTensor2D one;
|
||||
static const SymmTensor2D max;
|
||||
static const SymmTensor2D min;
|
||||
static const SymmTensor2D I;
|
||||
|
||||
|
||||
//- Component labeling enumeration
|
||||
enum components { XX, XY, YY };
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline SymmTensor2D();
|
||||
|
||||
//- Construct given VectorSpace
|
||||
inline SymmTensor2D(const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>&);
|
||||
|
||||
//- Construct given SphericalTensor
|
||||
inline SymmTensor2D(const SphericalTensor2D<Cmpt>&);
|
||||
|
||||
//- Construct given the three components
|
||||
inline SymmTensor2D
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy,
|
||||
const Cmpt tyy
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
SymmTensor2D(Istream&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
inline const Cmpt& xx() const;
|
||||
inline const Cmpt& xy() const;
|
||||
inline const Cmpt& yy() const;
|
||||
|
||||
inline Cmpt& xx();
|
||||
inline Cmpt& xy();
|
||||
inline Cmpt& yy();
|
||||
|
||||
//- Transpose
|
||||
inline const SymmTensor2D<Cmpt>& T() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Construct given SphericalTensor2D
|
||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Include inline implementations
|
||||
#include "SymmTensor2DI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
503
src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H
Normal file
503
src/OpenFOAM/primitives/SymmTensor2D/SymmTensor2DI.H
Normal file
@ -0,0 +1,503 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "Vector2D.H"
|
||||
#include "Tensor2D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D()
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D
|
||||
(
|
||||
const VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>& vs
|
||||
)
|
||||
:
|
||||
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(vs)
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
this->v_[YY] = st.ii();
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D
|
||||
(
|
||||
const Cmpt txx, const Cmpt txy,
|
||||
const Cmpt tyy
|
||||
)
|
||||
{
|
||||
this->v_[XX] = txx; this->v_[XY] = txy;
|
||||
this->v_[YY] = tyy;
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>::SymmTensor2D(Istream& is)
|
||||
:
|
||||
VectorSpace<SymmTensor2D<Cmpt>, Cmpt, 3>(is)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::xx() const
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::xy() const
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline const Cmpt& SymmTensor2D<Cmpt>::yy() const
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::xx()
|
||||
{
|
||||
return this->v_[XX];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::xy()
|
||||
{
|
||||
return this->v_[XY];
|
||||
}
|
||||
|
||||
template <class Cmpt>
|
||||
inline Cmpt& SymmTensor2D<Cmpt>::yy()
|
||||
{
|
||||
return this->v_[YY];
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline const SymmTensor2D<Cmpt>& SymmTensor2D<Cmpt>::T() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline void SymmTensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.ii(); this->v_[XY] = 0;
|
||||
this->v_[YY] = st.ii();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||
|
||||
//- Inner-product between two symmetric tensors
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*st2.xx() + st1.xy()*st2.xy(),
|
||||
st1.xx()*st2.xy() + st1.xy()*st2.yy(),
|
||||
|
||||
st1.xy()*st2.xx() + st1.yy()*st2.xy(),
|
||||
st1.xy()*st2.xy() + st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a symmetric tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*st2.xx() + 2*st1.xy()*st2.xy()
|
||||
+ st1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a symmetric tensor and a vector
|
||||
template <class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st, const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
st.xx()*v.x() + st.xy()*v.y(),
|
||||
st.xy()*v.x() + st.yy()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a vector and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Vector2D<Cmpt>
|
||||
operator&(const Vector2D<Cmpt>& v, const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return Vector2D<Cmpt>
|
||||
(
|
||||
v.x()*st.xx() + v.y()*st.xy(),
|
||||
v.x()*st.xy() + v.y()*st.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Cmpt magSqr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
magSqr(st.xx()) + 2*magSqr(st.xy())
|
||||
+ magSqr(st.yy())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the trace of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt tr(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st.xx() + st.yy();
|
||||
}
|
||||
|
||||
|
||||
//- Return the spherical part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SphericalTensor2D<Cmpt> sph(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return (1.0/2.0)*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the symmetric part of a symmetric tensor, i.e. itself
|
||||
template <class Cmpt>
|
||||
inline const SymmTensor2D<Cmpt>& symm(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
//- Return twice the symmetric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> twoSymm(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return 2*st;
|
||||
}
|
||||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> dev(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor2D<Cmpt>::oneThirdI*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the deviatoric part of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> dev2(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return st - SphericalTensor2D<Cmpt>::twoThirdsI*tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the determinant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt det(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
st.xx()*st.yy() - st.xy()*st.xy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the cofactor symmetric tensor of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> cof(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st.yy(), -st.xy(),
|
||||
st.xx()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a symmetric tensor give the determinant
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st, const Cmpt detst)
|
||||
{
|
||||
return cof(st)/detst;
|
||||
}
|
||||
|
||||
|
||||
//- Return the inverse of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> inv(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return inv(st, det(st));
|
||||
}
|
||||
|
||||
|
||||
//- Return the 1st invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt invariantI(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return tr(st);
|
||||
}
|
||||
|
||||
|
||||
//- Return the 2nd invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt invariantII(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return
|
||||
(
|
||||
0.5*sqr(tr(st))
|
||||
- 0.5*
|
||||
(
|
||||
st.xx()*st.xx() + st.xy()*st.xy()
|
||||
+ st.xy()*st.xy() + st.yy()*st.yy()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Return the 3rd invariant of a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt invariantIII(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
return det(st);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator+(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii() + st2.xx(), st2.xy(),
|
||||
spt1.ii() + st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator+(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() + spt2.ii(), st1.xy(),
|
||||
st1.yy() + spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator-(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii() - st2.xx(), -st2.xy(),
|
||||
spt1.ii() - st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator-(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() - spt2.ii(), st1.xy(),
|
||||
st1.yy() - spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a spherical symmetric tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator&(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
spt1.ii()*st2.xx(), spt1.ii()*st2.xy(),
|
||||
spt1.ii()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*spt2.ii(), st1.xy()*spt2.ii(),
|
||||
st1.yy()*spt2.ii()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a symmetric tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SphericalTensor2D<Cmpt>& spt1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return(spt1.ii()*st2.xx() + spt1.ii()*st2.yy());
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const SphericalTensor2D<Cmpt>& spt2)
|
||||
{
|
||||
return(st1.xx()*spt2.ii() + st1.yy()*spt2.ii());
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline SymmTensor2D<Cmpt> sqr(const Vector2D<Cmpt>& v)
|
||||
{
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
v.x()*v.x(), v.x()*v.y(),
|
||||
v.y()*v.y()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class outerProduct<SymmTensor2D<Cmpt>, Cmpt>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class outerProduct<Cmpt, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, Vector2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Vector2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<Vector2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Vector2D<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SphericalTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SymmTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SphericalTensor2D<Cmpt>, SymmTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
template<class Cmpt>
|
||||
class innerProduct<SymmTensor2D<Cmpt>, SphericalTensor2D<Cmpt> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef SymmTensor2D<Cmpt> type;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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 "symmTensor2D.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const char* const symmTensor2D::typeName = "symmTensor2D";
|
||||
|
||||
template<>
|
||||
const char* symmTensor2D::componentNames[] =
|
||||
{
|
||||
"xx", "xy",
|
||||
"yy"
|
||||
};
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::zero
|
||||
(
|
||||
0, 0,
|
||||
0
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::one
|
||||
(
|
||||
1, 1,
|
||||
1
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::max
|
||||
(
|
||||
VGREAT, VGREAT,
|
||||
VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::min
|
||||
(
|
||||
-VGREAT, -VGREAT,
|
||||
-VGREAT
|
||||
);
|
||||
|
||||
template<>
|
||||
const symmTensor2D symmTensor2D::I
|
||||
(
|
||||
1, 0,
|
||||
1
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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::symmTensor2D
|
||||
|
||||
Description
|
||||
SymmTensor2D of scalars.
|
||||
|
||||
SourceFiles
|
||||
symmTensor2D.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef symmTensor2D_H
|
||||
#define symmTensor2D_H
|
||||
|
||||
#include "SymmTensor2D.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef SymmTensor2D<scalar> symmTensor2D;
|
||||
|
||||
//- Data associated with symmTensor2D type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<symmTensor2D>() {return true;}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,6 +46,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Cmpt>
|
||||
class SymmTensor2D;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Tensor2D Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -90,6 +93,9 @@ public:
|
||||
//- Construct given VectorSpace
|
||||
inline Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>&);
|
||||
|
||||
//- Construct given SymmTensor2D
|
||||
inline Tensor2D(const SymmTensor2D<Cmpt>&);
|
||||
|
||||
//- Construct given SphericalTensor2D
|
||||
inline Tensor2D(const SphericalTensor2D<Cmpt>&);
|
||||
|
||||
@ -136,6 +142,9 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Copy SymmTensor2D
|
||||
inline void operator=(const SymmTensor2D<Cmpt>&);
|
||||
|
||||
//- Copy SphericalTensor2D
|
||||
inline void operator=(const SphericalTensor2D<Cmpt>&);
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -42,6 +42,14 @@ inline Tensor2D<Cmpt>::Tensor2D(const VectorSpace<Tensor2D<Cmpt>, Cmpt, 4>& vs)
|
||||
{}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
|
||||
this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>::Tensor2D(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
@ -159,6 +167,14 @@ inline Tensor2D<Cmpt> Tensor2D<Cmpt>::T() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline void Tensor2D<Cmpt>::operator=(const SymmTensor2D<Cmpt>& st)
|
||||
{
|
||||
this->v_[XX] = st.xx(); this->v_[XY] = st.xy();
|
||||
this->v_[YX] = st.xy(); this->v_[YY] = st.yy();
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline void Tensor2D<Cmpt>::operator=(const SphericalTensor2D<Cmpt>& st)
|
||||
{
|
||||
@ -240,23 +256,23 @@ inline SphericalTensor2D<Cmpt> sph(const Tensor2D<Cmpt>& t)
|
||||
|
||||
//- Return the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt> symm(const Tensor2D<Cmpt>& t)
|
||||
inline SymmTensor2D<Cmpt> symm(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
t.xx(), 0.5*(t.xy() + t.yx()),
|
||||
0.5*(t.yx() + t.xy()), t.yy()
|
||||
t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
//- Return the twice the symmetric part of a tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt> twoSymm(const Tensor2D<Cmpt>& t)
|
||||
inline SymmTensor2D<Cmpt> twoSymm(const Tensor2D<Cmpt>& t)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
return SymmTensor2D<Cmpt>
|
||||
(
|
||||
t.xx() + t.xx(), t.xy() + t.yx(),
|
||||
t.yx() + t.xy(), t.yy() + t.yy()
|
||||
t.yy() + t.yy()
|
||||
);
|
||||
}
|
||||
|
||||
@ -356,7 +372,7 @@ inline Cmpt invariantIII(const Tensor2D<Cmpt>& t)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * Mixed Tensor SphericalTensor Operators * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
@ -455,6 +471,114 @@ operator&&(const Tensor2D<Cmpt>& t1, const SphericalTensor2D<Cmpt>& st2)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * Mixed Tensor SymmTensor Operators * * * * * * * * * * //
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() + t2.xx(), st1.xy() + t2.xy(),
|
||||
st1.xy() + t2.yx(), st1.yy() + t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator+(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() + st2.xx(), t1.xy() + st2.xy(),
|
||||
t1.yx() + st2.xy(), t1.yy() + st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx() - t2.xx(), st1.xy() - t2.xy(),
|
||||
st1.xy() - t2.yx(), st1.yy() - t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator-(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx() - st2.xx(), t1.xy() - st2.xy(),
|
||||
t1.yx() - st2.xy(), t1.yy() - st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
st1.xx()*t2.xx() + st1.xy()*t2.yx(),
|
||||
st1.xx()*t2.xy() + st1.xy()*t2.yy(),
|
||||
|
||||
st1.xy()*t2.xx() + st1.yy()*t2.yx(),
|
||||
st1.xy()*t2.xy() + st1.yy()*t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Inner-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
inline Tensor2D<Cmpt>
|
||||
operator&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx()*st2.xx() + t1.xy()*st2.xy(),
|
||||
t1.xx()*st2.xy() + t1.xy()*st2.yy(),
|
||||
|
||||
t1.yx()*st2.xx() + t1.yy()*st2.xy(),
|
||||
t1.yx()*st2.xy() + t1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a spherical tensor and a tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const SymmTensor2D<Cmpt>& st1, const Tensor2D<Cmpt>& t2)
|
||||
{
|
||||
return
|
||||
(
|
||||
st1.xx()*t2.xx() + st1.xy()*t2.xy()
|
||||
+ st1.xy()*t2.yx() + st1.yy()*t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Double-dot-product between a tensor and a spherical tensor
|
||||
template <class Cmpt>
|
||||
inline Cmpt
|
||||
operator&&(const Tensor2D<Cmpt>& t1, const SymmTensor2D<Cmpt>& st2)
|
||||
{
|
||||
return
|
||||
(
|
||||
t1.xx()*st2.xx() + t1.xy()*st2.xy()
|
||||
+ t1.yx()*st2.xy() + t1.yy()*st2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
class typeOfSum<SphericalTensor2D<Cmpt>, Tensor2D<Cmpt> >
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user