Alamo
Matrix4_Diagonal.H
Go to the documentation of this file.
1#ifndef SET_MATRIX4_DIAGONAL_H
2#define SET_MATRIX4_DIAGONAL_H
3
4#include "Util/Util.H"
5#include "Base.H"
6
7namespace Set
8{
9template<>
11{
12 Set::Matrix A = Set::Matrix::Ones();
13public:
17 Scalar operator () (const int i, const int j, const int k, const int l) const
18 {
19 if (i == k && j == l) return A(i, j);
20 else return 0.0;
21 }
22 void Randomize()
23 {
24 A = Set::Matrix::Random();
25 }
26 void Print(std::ostream& os)
27 {
28 os << "A = \n" << A;
29 }
31 {
33 zero.A = Set::Matrix::Zero();
34 return zero;
35 }
44
45
46 //AMREX_GPU_HOST_DEVICE void operator = (Matrix4<AMREX_SPACEDIM,Sym::Isotropic> &a) {lambda = a.lambda; mu = a.mu;}
49 //AMREX_GPU_HOST_DEVICE void operator *= (const Matrix4<AMREX_SPACEDIM,Sym::Diagonal> &a) {A *= a.A;}
50 //AMREX_GPU_HOST_DEVICE void operator /= (const Matrix4<AMREX_SPACEDIM,Sym::Diagonal> &a) {A /= a.A;}
51 AMREX_GPU_HOST_DEVICE void operator *= (const Set::Scalar& alpha) { A *= alpha; }
52 AMREX_GPU_HOST_DEVICE void operator /= (const Set::Scalar& alpha) { A /= alpha; }
53
55 {
56 return A.lpNorm<2>();
57 }
58 bool contains_nan() const
59 {
60 if (std::isnan(A.lpNorm<2>())) return true;
61 return false;
62 }
63
64};
67{
69
70 for (int i = 0; i < AMREX_SPACEDIM; i++)
71 {
72 for (int j = 0; j < AMREX_SPACEDIM; j++)
73 {
74 ret(i, j) = a.A(i, j) * b(i, j);
75 }
76 }
77
78 return ret;
79}
80
83{
84 Set::Vector ret = Set::Vector::Zero();
85
86 for (int i = 0; i < AMREX_SPACEDIM; i++)
87 for (int j = 0; j < AMREX_SPACEDIM; j++)
88 ret(i) += a.A(i, j) * b(i, j, j);
89
90 return ret;
91}
128
137
138
139}
140#endif
Matrix< _Scalar, _Rows, _Cols > & operator*=(const amrex::Vector< amrex::Real > &x)
Definition Eigen_Amrex.H:18
AMREX_FORCE_INLINE void operator+=(const OP_CLASS &rhs)
static Matrix4< AMREX_SPACEDIM, Sym::Diagonal > Zero()
AMREX_GPU_HOST_DEVICE Matrix4(Set::Matrix a_A)
A collection of data types and symmetry-reduced data structures.
Definition Base.H:18
AMREX_FORCE_INLINE Quaternion operator-(const Quaternion a, const Quaternion b)
Definition Base.H:100
Sym
Definition Base.H:197
@ Diagonal
Definition Base.H:197
amrex::Real Scalar
Definition Base.H:19
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Matrix4< AMREX_SPACEDIM, Sym::Diagonal > operator/(const Matrix4< AMREX_SPACEDIM, Sym::Diagonal > &a, const Set::Scalar &b)
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:20
AMREX_FORCE_INLINE bool operator==(const Quaternion a, const Quaternion b)
Definition Base.H:108
AMREX_FORCE_INLINE Quaternion operator+(const Quaternion a, const Quaternion b)
Definition Base.H:92
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, AMREX_SPACEDIM > Matrix
Definition Base.H:23
AMREX_FORCE_INLINE Quaternion operator*(const Set::Scalar alpha, const Quaternion b)
Definition Base.H:78