MatrixSymmetric.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef MECURYDPM_MATRIXSYMMETRIC_H
27 #define MECURYDPM_MATRIXSYMMETRIC_H
28 
29 #include <cmath>
30 #include <sstream>
31 #include "Matrix.h"
32 
37 {
38 public:
42  Mdouble XX, XY, XZ, YY, YZ, ZZ;
43 
47  explicit operator Matrix3D() const;
48 
53 
58 
62  void setZero();
63 
67  Mdouble trace() const;
68 
73 
78 
83 
88 
92  friend Vec3D operator*(const MatrixSymmetric3D& A, const Vec3D& b);
93 
98 
103 
107  friend std::ostream& operator<<(std::ostream& os, const MatrixSymmetric3D& A);
108 
112  friend std::istream& operator>>(std::istream& is, MatrixSymmetric3D& A);
113 
118 
123 
128 
133 
137  static MatrixSymmetric3D sqrt(const MatrixSymmetric3D& A);
138 
142  static MatrixSymmetric3D selfDyadic(const Vec3D& a);
143 
147  static MatrixSymmetric3D symmetrisedDyadic(const Vec3D& a, const Vec3D& b);
148 
153 
157  MatrixSymmetric3D inverse() const;
158 
162  static Mdouble determinant(const MatrixSymmetric3D& A);
163 
168 };
169 
170 #endif
@ A
Definition: StatisticsVector.h:42
Implementation of a 3D matrix.
Definition: Matrix.h:38
Implementation of a 3D symmetric matrix.
Definition: MatrixSymmetric.h:37
MatrixSymmetric3D operator-(const MatrixSymmetric3D &A) const
Matrix substraction.
Definition: MatrixSymmetric.cc:100
MatrixSymmetric3D & operator+=(const MatrixSymmetric3D &A)
Matrix addition.
Definition: MatrixSymmetric.cc:189
Mdouble ZZ
Definition: MatrixSymmetric.h:42
MatrixSymmetric3D & operator/=(Mdouble a)
Scalar division.
Definition: MatrixSymmetric.cc:221
static MatrixSymmetric3D square(const MatrixSymmetric3D &A)
Calculates the pointwise square.
Definition: MatrixSymmetric.cc:238
friend std::ostream & operator<<(std::ostream &os, const MatrixSymmetric3D &A)
Add elements to an ostream.
Definition: MatrixSymmetric.cc:166
Mdouble YY
Definition: MatrixSymmetric.h:42
void setZero()
Sets all elements to zero.
Definition: MatrixSymmetric.cc:70
static MatrixSymmetric3D symmetrisedDyadic(const Vec3D &a, const Vec3D &b)
Calculates the symmetrised dyadic product of two Vec3D: .
Definition: MatrixSymmetric.cc:277
MatrixSymmetric3D()
Default constructor.
Definition: MatrixSymmetric.cc:42
static MatrixSymmetric3D sqrt(const MatrixSymmetric3D &A)
Calculates the pointwise square root.
Definition: MatrixSymmetric.cc:250
MatrixSymmetric3D operator/(Mdouble a) const
Scalar division.
Definition: MatrixSymmetric.cc:155
MatrixSymmetric3D & operator-=(const MatrixSymmetric3D &A)
Matrix substraction.
Definition: MatrixSymmetric.cc:205
friend std::istream & operator>>(std::istream &is, MatrixSymmetric3D &A)
Add elements to an istream.
Definition: MatrixSymmetric.cc:178
MatrixSymmetric3D operator+(const MatrixSymmetric3D &A) const
Matrix addition.
Definition: MatrixSymmetric.cc:90
MatrixSymmetric3D getCylindricalTensorField(const Vec3D &p) const
Returns the matrix in cylindrical coordinates.
Definition: MatrixSymmetric.cc:326
friend Vec3D operator*(const MatrixSymmetric3D &A, const Vec3D &b)
Vector multiplication.
Definition: MatrixSymmetric.cc:132
static MatrixSymmetric3D selfDyadic(const Vec3D &a)
Calculates the dyadic product of a Vec3D with itself: .
Definition: MatrixSymmetric.cc:263
MatrixSymmetric3D inverse() const
Computes the inverse of a matrix; exits if the inverse doesn't exist.
Definition: MatrixSymmetric.cc:298
Mdouble XZ
Definition: MatrixSymmetric.h:42
Mdouble XY
Definition: MatrixSymmetric.h:42
Mdouble trace() const
Returns the MEAN of the diagonal elements (i.e. the trace divided by three).
Definition: MatrixSymmetric.cc:80
Mdouble XX
The six distinctive matrix elements.
Definition: MatrixSymmetric.h:42
static Mdouble determinant(const MatrixSymmetric3D &A)
Computes the determinant of a matrix.
Definition: MatrixSymmetric.cc:313
Mdouble YZ
Definition: MatrixSymmetric.h:42
Definition: Vector.h:51