29 #include <type_traits> 67 this->v_[XX] = st.
ii(); this->v_[XY] =
Zero; this->v_[XZ] =
Zero;
68 this->v_[YX] =
Zero; this->v_[YY] = st.
ii(); this->v_[YZ] =
Zero;
69 this->v_[ZX] =
Zero; this->v_[ZY] =
Zero; this->v_[ZZ] = st.
ii();
76 this->v_[XX] = st.
xx(); this->v_[XY] = st.
xy(); this->v_[XZ] = st.
xz();
77 this->v_[YX] = st.
xy(); this->v_[YY] = st.
yy(); this->v_[YZ] = st.
yz();
78 this->v_[ZX] = st.
xz(); this->v_[ZY] = st.
yz(); this->v_[ZZ] = st.
zz();
89 Tensor<Cmpt>(vecs.
x(), vecs.
y(), vecs.z(), transposed)
116 const Cmpt txx,
const Cmpt txy,
const Cmpt txz,
117 const Cmpt tyx,
const Cmpt tyy,
const Cmpt tyz,
118 const Cmpt tzx,
const Cmpt tzy,
const Cmpt tzz
121 this->v_[XX] = txx; this->v_[XY] = txy; this->v_[XZ] = txz;
122 this->v_[YX] = tyx; this->v_[YY] = tyy; this->v_[YZ] = tyz;
123 this->v_[ZX] = tzx; this->v_[ZY] = tzy; this->v_[ZZ] = tzz;
130 template<
class, Foam::direction, Foam::direction>
class Block2,
155 return Vector<Cmpt>(this->v_[XX], this->v_[XY], this->v_[XZ]);
162 return Vector<Cmpt>(this->v_[YX], this->v_[YY], this->v_[YZ]);
169 return Vector<Cmpt>(this->v_[ZX], this->v_[ZY], this->v_[ZZ]);
176 return Vector<Cmpt>(this->v_[XX], this->v_[YX], this->v_[ZX]);
183 return Vector<Cmpt>(this->v_[XY], this->v_[YY], this->v_[ZY]);
190 return Vector<Cmpt>(this->v_[XZ], this->v_[YZ], this->v_[ZZ]);
195 template<Foam::direction Idx>
198 if (Idx == 0)
return cx();
199 else if (Idx == 1)
return cy();
200 else if (Idx == 2)
return cz();
202 static_assert(Idx < 3,
"Invalid column access");
212 case 0:
return cx();
break;
213 case 1:
return cy();
break;
214 case 2:
return cz();
break;
225 template<Foam::direction Idx>
228 if (Idx == 0)
return x();
229 else if (Idx == 1)
return y();
230 else if (Idx == 2)
return z();
232 static_assert(Idx < 3,
"Invalid row access");
242 case 0:
return x();
break;
243 case 1:
return y();
break;
244 case 2:
return z();
break;
255 template<Foam::direction Idx>
260 this->v_[XX] = v.
x();
261 this->v_[YX] = v.
y();
262 this->v_[ZX] = v.
z();
266 this->v_[XY] = v.
x();
267 this->v_[YY] = v.
y();
268 this->v_[ZY] = v.
z();
272 this->v_[XZ] = v.
x();
273 this->v_[YZ] = v.
y();
274 this->v_[ZZ] = v.
z();
277 static_assert(Idx < 3,
"Invalid column access");
282 template<Foam::direction Idx>
287 this->v_[XX] = v.
x(); this->v_[XY] = v.
y(); this->v_[XZ] = v.
z();
291 this->v_[YX] = v.
x(); this->v_[YY] = v.
y(); this->v_[YZ] = v.
z();
295 this->v_[ZX] = v.
x(); this->v_[ZY] = v.
y(); this->v_[ZZ] = v.
z();
298 static_assert(Idx < 3,
"Invalid row access");
310 this->v_[XX] =
x.x(); this->v_[XY] =
y.x(); this->v_[XZ] = z.
x();
311 this->v_[YX] =
x.y(); this->v_[YY] =
y.y(); this->v_[YZ] = z.
y();
312 this->v_[ZX] =
x.z(); this->v_[ZY] =
y.z(); this->v_[ZZ] = z.
z();
324 this->v_[XX] =
x.x(); this->v_[XY] =
x.y(); this->v_[XZ] =
x.z();
325 this->v_[YX] =
y.x(); this->v_[YY] =
y.y(); this->v_[YZ] =
y.z();
326 this->v_[ZX] = z.
x(); this->v_[ZY] = z.
y(); this->v_[ZZ] = z.
z();
339 case 0: col<0>(v);
break;
340 case 1: col<1>(v);
break;
341 case 2: col<2>(v);
break;
353 const Vector<Cmpt>& v
358 case 0: row<0>(v);
break;
359 case 1: row<1>(v);
break;
360 case 2: row<2>(v);
break;
371 return Vector<Cmpt>(this->v_[XX], this->v_[YY], this->v_[ZZ]);
378 this->v_[XX] = v.
x(); this->v_[YY] = v.
y(); this->v_[ZZ] = v.
z();
390 &&
mag(xy()) < tol &&
mag(xz()) < tol
391 &&
mag(yx()) < tol &&
mag(yz()) < tol
392 &&
mag(zx()) < tol &&
mag(zy()) < tol
454 *
this = this->inner(t);
459 template<
class Cmpt2>
472 this->v_[XX] = st.
ii(); this->v_[XY] =
Zero; this->v_[XZ] =
Zero;
473 this->v_[YX] =
Zero; this->v_[YY] = st.
ii(); this->v_[YZ] =
Zero;
474 this->v_[ZX] =
Zero; this->v_[ZY] =
Zero; this->v_[ZZ] = st.
ii();
481 this->v_[XX] = st.
xx(); this->v_[XY] = st.
xy(); this->v_[XZ] = st.
xz();
482 this->v_[YX] = st.
xy(); this->v_[YY] = st.
yy(); this->v_[YZ] = st.
yz();
483 this->v_[ZX] = st.
xz(); this->v_[ZY] = st.
yz(); this->v_[ZZ] = st.
zz();
490 this->v_[XX] =
tr.x().x();
491 this->v_[XY] =
tr.x().y();
492 this->v_[XZ] =
tr.x().z();
494 this->v_[YX] =
tr.y().x();
495 this->v_[YY] =
tr.y().y();
496 this->v_[YZ] =
tr.y().z();
498 this->v_[ZX] =
tr.z().x();
499 this->v_[ZY] =
tr.z().y();
500 this->v_[ZZ] =
tr.z().z();
515 return t.
xx() + t.
yy() + t.
zz();
536 t.
xx(), 0.5*(t.
xy() + t.
yx()), 0.5*(t.
xz() + t.
zx()),
537 t.
yy(), 0.5*(t.
yz() + t.
zy()),
545 inline SymmTensor<Cmpt>
twoSymm(
const Tensor<Cmpt>& t)
549 2*t.xx(), (t.xy() + t.yx()), (t.xz() + t.zx()),
550 2*t.yy(), (t.yz() + t.zy()),
558 inline Tensor<Cmpt>
skew(
const Tensor<Cmpt>& t)
562 Zero, 0.5*(t.xy() - t.yx()), 0.5*(t.xz() - t.zx()),
563 0.5*(t.yx() - t.xy()),
Zero, 0.5*(t.yz() - t.zy()),
564 0.5*(t.zx() - t.xz()), 0.5*(t.zy() - t.yz()),
Zero 571 inline const Tensor<Cmpt>&
skew(
const SymmTensor<Cmpt>& st)
595 inline Cmpt
det(
const Tensor<Cmpt>& t)
599 t.xx()*t.yy()*t.zz() + t.xy()*t.yz()*t.zx()
600 + t.xz()*t.yx()*t.zy() - t.xx()*t.yz()*t.zy()
601 - t.xy()*t.yx()*t.zz() - t.xz()*t.yy()*t.zx()
629 inline Tensor<Cmpt>
inv(
const Tensor<Cmpt>& t,
const Cmpt dett)
632 if (
mag(dett) < VSMALL)
635 <<
"Tensor is not invertible due to the (almost) zero determinant:" 636 <<
" Tensor = " << t <<
nl 637 <<
" det(Tensor) = " << dett
642 return cof(t).
T()/dett;
676 t.xx()*t.yy() + t.yy()*t.zz() + t.xx()*t.zz()
677 - t.xy()*t.yx() - t.yz()*t.zy() - t.xz()*t.zx()
699 st1.
ii() + t2.
xx(), t2.
xy(), t2.
xz(),
700 t2.
yx(), st1.
ii() + t2.
yy(), t2.
yz(),
701 t2.
zx(), t2.
zy(), st1.
ii() + t2.
zz()
713 t1.
xx() + st2.
ii(), t1.
xy(), t1.
xz(),
714 t1.
yx(), t1.
yy() + st2.
ii(), t1.
yz(),
715 t1.
zx(), t1.
zy(), t1.
zz() + st2.
ii()
727 st1.
xx() + t2.
xx(), st1.
xy() + t2.
xy(), st1.
xz() + t2.
xz(),
728 st1.
xy() + t2.
yx(), st1.
yy() + t2.
yy(), st1.
yz() + t2.
yz(),
729 st1.
xz() + t2.
zx(), st1.
yz() + t2.
zy(), st1.
zz() + t2.
zz()
737 operator+(
const Tensor<Cmpt>& t1,
const SymmTensor<Cmpt>& st2)
741 t1.xx() + st2.xx(), t1.xy() + st2.xy(), t1.xz() + st2.xz(),
742 t1.yx() + st2.xy(), t1.yy() + st2.yy(), t1.yz() + st2.yz(),
743 t1.zx() + st2.xz(), t1.zy() + st2.yz(), t1.zz() + st2.zz()
751 operator-(
const SphericalTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
755 st1.ii() - t2.xx(), -t2.xy(), -t2.xz(),
756 -t2.yx(), st1.ii() - t2.yy(), -t2.yz(),
757 -t2.zx(), -t2.zy(), st1.ii() - t2.zz()
765 operator-(
const Tensor<Cmpt>& t1,
const SphericalTensor<Cmpt>& st2)
769 t1.xx() - st2.ii(), t1.xy(), t1.xz(),
770 t1.yx(), t1.yy() - st2.ii(), t1.yz(),
771 t1.zx(), t1.zy(), t1.zz() - st2.ii()
779 operator-(
const SymmTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
783 st1.xx() - t2.xx(), st1.xy() - t2.xy(), st1.xz() - t2.xz(),
784 st1.xy() - t2.yx(), st1.yy() - t2.yy(), st1.yz() - t2.yz(),
785 st1.xz() - t2.zx(), st1.yz() - t2.zy(), st1.zz() - t2.zz()
793 operator-(
const Tensor<Cmpt>& t1,
const SymmTensor<Cmpt>& st2)
797 t1.xx() - st2.xx(), t1.xy() - st2.xy(), t1.xz() - st2.xz(),
798 t1.yx() - st2.xy(), t1.yy() - st2.yy(), t1.yz() - st2.yz(),
799 t1.zx() - st2.xz(), t1.zy() - st2.yz(), t1.zz() - st2.zz()
814 inline Tensor<Cmpt>
operator*(
const Vector<Cmpt>& v)
827 inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>
::type 828 operator/(
const Vector<Cmpt>& v,
const Tensor<Cmpt>& t)
844 <<
" is not divisible due to a zero value in Cmpt:" 871 operator&(
const SphericalTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
875 st1.ii()*t2.xx(), st1.ii()*t2.xy(), st1.ii()*t2.xz(),
876 st1.ii()*t2.yx(), st1.ii()*t2.yy(), st1.ii()*t2.yz(),
877 st1.ii()*t2.zx(), st1.ii()*t2.zy(), st1.ii()*t2.zz()
885 operator&(
const Tensor<Cmpt>& t1,
const SphericalTensor<Cmpt>& st2)
889 t1.xx()*st2.ii(), t1.xy()*st2.ii(), t1.xz()*st2.ii(),
890 t1.yx()*st2.ii(), t1.yy()*st2.ii(), t1.yz()*st2.ii(),
891 t1.zx()*st2.ii(), t1.zy()*st2.ii(), t1.zz()*st2.ii()
899 operator&(
const SymmTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
903 st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx(),
904 st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy(),
905 st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz(),
907 st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx(),
908 st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy(),
909 st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz(),
911 st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx(),
912 st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy(),
913 st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
921 operator&(
const Tensor<Cmpt>& t1,
const SymmTensor<Cmpt>& st2)
925 t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz(),
926 t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz(),
927 t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz(),
929 t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz(),
930 t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz(),
931 t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz(),
933 t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz(),
934 t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz(),
935 t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
942 #if defined(__GNUC__) && !defined(__clang__) 944 __attribute__((optimize(
"no-tree-vectorize")))
951 t.
xx()*v.
x() + t.
xy()*v.
y() + t.
xz()*v.
z(),
952 t.
yx()*v.
x() + t.
yy()*v.
y() + t.
yz()*v.
z(),
953 t.
zx()*v.
x() + t.
zy()*v.
y() + t.
zz()*v.
z()
965 v.
x()*t.
xx() + v.
y()*t.
yx() + v.
z()*t.
zx(),
966 v.
x()*t.
xy() + v.
y()*t.
yy() + v.
z()*t.
zy(),
967 v.
x()*t.
xz() + v.
y()*t.
yz() + v.
z()*t.
zz()
975 operator&&(
const SphericalTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
977 return (st1.ii()*t2.xx() + st1.ii()*t2.yy() + st1.ii()*t2.zz());
986 return (t1.
xx()*st2.
ii() + t1.
yy()*st2.
ii() + t1.
zz()*st2.
ii());
993 operator&&(
const SymmTensor<Cmpt>& st1,
const Tensor<Cmpt>& t2)
997 st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
998 st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
999 st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
1005 template<
class Cmpt>
1007 operator&&(
const Tensor<Cmpt>& t1,
const SymmTensor<Cmpt>& st2)
1011 t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
1012 t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
1013 t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
1019 template<
class Cmpt>
1020 inline typename outerProduct<Vector<Cmpt>, Vector<Cmpt>>
::type 1021 operator*(
const Vector<Cmpt>& v1,
const Vector<Cmpt>& v2)
1025 v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
1026 v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
1027 v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
1034 template<
class Cmpt>
1035 class typeOfSum<SphericalTensor<Cmpt>, Tensor<Cmpt>>
1039 typedef Tensor<Cmpt>
type;
1043 template<
class Cmpt>
1044 class typeOfSum<Tensor<Cmpt>, SphericalTensor<Cmpt>>
1048 typedef Tensor<Cmpt>
type;
1052 template<
class Cmpt>
1061 template<
class Cmpt>
1070 template<
class Cmpt>
1071 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt>>
1075 typedef Tensor<Cmpt>
type;
1079 template<
class Cmpt>
1088 template<
class Cmpt>
1089 class innerProduct<SymmTensor<Cmpt>, Tensor<Cmpt>>
1093 typedef Tensor<Cmpt>
type;
1097 template<
class Cmpt>
1098 class innerProduct<Tensor<Cmpt>, SymmTensor<Cmpt>>
1102 typedef Tensor<Cmpt>
type;
Cmpt invariantII(const SymmTensor< Cmpt > &st)
Return the 2nd invariant of a SymmTensor.
Cmpt tr(const Tensor< Cmpt > &t)
Return the trace of a Tensor.
const Cmpt & xz() const noexcept
Vector< Cmpt > cx() const
Extract vector for column 0.
A templated (3 x 3) symmetric tensor of objects of <T>, effectively containing 6 elements, derived from VectorSpace.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Cmpt & yx() const noexcept
dimensionedTensor skew(const dimensionedTensor &dt)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
Vector< Cmpt > cz() const
Extract vector for column 2.
Tensor< Cmpt > T() const
Return non-Hermitian transpose.
Vector< Cmpt > x() const
Extract vector for row 0.
A traits class, which is primarily used for primitives.
const Cmpt & xy() const noexcept
dimensionSet operator &&(const dimensionSet &ds1, const dimensionSet &ds2)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
Vector< Cmpt > y() const
Extract vector for row 1.
const Cmpt & y() const noexcept
Access to the vector y component.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
SphericalTensor< Cmpt > sph(const DiagTensor< Cmpt > &dt)
Return the spherical part of a DiagTensor as a SphericalTensor.
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Tensor()=default
Default construct.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
const Cmpt & zz() const noexcept
A templated (3 x 3) diagonal tensor of objects of <T>, effectively containing 1 element, derived from VectorSpace.
Vector< Cmpt > z() const
Extract vector for row 2.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const Cmpt & yz() const noexcept
const Cmpt & xx() const noexcept
const Cmpt & yy() const noexcept
void cols(const Vector< Cmpt > &x, const Vector< Cmpt > &y, const Vector< Cmpt > &z)
Set column values.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Vector< Cmpt > col() const
Extract vector for given column: compile-time check of index.
tmp< faMatrix< Type > > operator*(const areaScalarField::Internal &, const faMatrix< Type > &)
bool is_identity(const scalar tol=ROOTVSMALL) const
Is identity tensor?
Cmpt invariantIII(const SymmTensor< Cmpt > &st)
Return the 3rd invariant of a SymmTensor.
const Cmpt & zx() const noexcept
const Cmpt & ii() const noexcept
const Cmpt & xx() const noexcept
void rows(const Vector< Cmpt > &x, const Vector< Cmpt > &y, const Vector< Cmpt > &z)
Set row values.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
errorManip< error > abort(error &err)
tmp< faMatrix< Type > > operator-(const faMatrix< Type > &)
Unary negation.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross-product operators.
const Cmpt & x() const noexcept
Access to the vector x component.
dimensioned< Type > T() const
Return transpose.
const Cmpt & zy() const noexcept
Tensor< Cmpt > schur(const Tensor< Cmpt > &t2) const
Schur-product of this with another Tensor.
Tensor & operator=(const Tensor &)=default
Copy assignment.
const Cmpt & z() const noexcept
Access to the vector z component.
Tensor< Cmpt > inv() const
Return inverse.
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
Vector< Cmpt > diag() const
Extract the diagonal as a vector.
const Cmpt & yy() const noexcept
const Cmpt & zz() const noexcept
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< GeometricField< Type, faPatchField, areaMesh > > operator &(const faMatrix< Type > &, const DimensionedField< Type, areaMesh > &)
const dimensionedScalar c
Speed of light in a vacuum.
Cmpt invariantI(const SymmTensor< Cmpt > &st)
Return the 1st invariant of a SymmTensor.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
void operator &=(const Tensor< Cmpt > &t)
Assign inner-product of this with another Tensor.
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const Cmpt & xz() const noexcept
Tensor< Cmpt > inner(const Tensor< Cmpt > &t2) const
Inner-product of this with another Tensor.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) - 2 >::type type
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
Vector< Cmpt > cy() const
Extract vector for column 1.
static const Tensor< Cmpt > zero
const Cmpt & xy() const noexcept
static constexpr const zero Zero
Global zero (0)
Vector< Cmpt > row() const
Extract vector for given row: compile-time check of index.
const Cmpt & yz() const noexcept