6#include "AMReX_SPACE.H"
7#include "AMReX_Vector.H"
8#include "AMReX_BLassert.H"
9#include "AMReX_Geometry.H"
10#include "AMReX_IndexType.H"
11#include <eigen3/Eigen/Core>
12#include <eigen3/Eigen/Geometry>
13#include <eigen3/Eigen/SVD>
14#include <AMReX_REAL.H>
19using Vector = Eigen::Matrix<amrex::Real,AMREX_SPACEDIM,1>;
21using Covector = Eigen::Matrix<amrex::Real,1,AMREX_SPACEDIM>;
22using Matrix = Eigen::Matrix<amrex::Real,AMREX_SPACEDIM,AMREX_SPACEDIM>;
24using iMatrix = Eigen::Matrix<int,AMREX_SPACEDIM,AMREX_SPACEDIM>;
46 : Eigen::Quaterniond() {}
48 : Eigen::Quaterniond(
w,
x,
y,
z) {}
50 : Eigen::Quaterniond(R) {}
52 : Eigen::Quaterniond(q.
w(),q.
x(),q.
y(),q.
z()) {}
57 w() = rhs.w();
x() = rhs.x();
y() = rhs.y();
z() = rhs.z();
63 w() += rhs.w();
x() += rhs.x();
y() += rhs.y();
z() += rhs.z();
80 ret.w() =
b.w()*alpha;
ret.x() =
b.x()*alpha;
ret.y() =
b.y()*alpha;
ret.z() =
b.z()*alpha;
87 ret.w() =
b.w()*alpha;
ret.x() =
b.x()*alpha;
ret.y() =
b.y()*alpha;
ret.z() =
b.z()*alpha;
94 ret.w() = a.w()+
b.w();
ret.x() = a.x()+
b.x();
ret.y() = a.y()+
b.y();
ret.z() = a.z()+
b.z();
102 ret.w() = a.w()-
b.w();
ret.x() = a.x()-
b.x();
ret.y() = a.y()-
b.y();
ret.z() = a.z()-
b.z();
109 if (
fabs((a.w() -
b.w())/(a.w()+a.w())) > 1E-8)
return false;
110 if (
fabs((a.x() -
b.x())/(a.x()+a.x())) > 1E-8)
return false;
111 if (
fabs((a.y() -
b.y())/(a.y()+a.y())) > 1E-8)
return false;
112 if (
fabs((a.z() -
b.z())/(a.z()+a.z())) > 1E-8)
return false;
123 if (
ixType == amrex::IndexType::TheNodeType())
125 return Vector(AMREX_D_DECL(
126 geom.ProbLo()[0] + ((amrex::Real)(
i)) * geom.CellSize()[0],
127 geom.ProbLo()[1] + ((amrex::Real)(
j)) * geom.CellSize()[1],
128 geom.ProbLo()[2] + ((amrex::Real)(
k)) * geom.CellSize()[2]));
130 else if (
ixType == amrex::IndexType::TheCellType())
132 return Vector(AMREX_D_DECL(
133 geom.ProbLo()[0] + ((amrex::Real)(
i) + 0.5) * geom.CellSize()[0],
134 geom.ProbLo()[1] + ((amrex::Real)(
j) + 0.5) * geom.CellSize()[1],
135 geom.ProbLo()[2] + ((amrex::Real)(
k) + 0.5) * geom.CellSize()[2]));
137 return Set::Vector::Zero();
145 if (
xmin)
N(0) = -1.0;
146 else if (
xmax)
N(0) = 1.0;
148 if (
ymin)
N(1) = -1.0;
149 else if (
ymax)
N(1) = 1.0;
152 if (
zmin)
N(2) = -1.0;
153 else if (
zmax)
N(2) = 1.0;
162 size(0) = geom.ProbHi()[0] - geom.ProbLo()[0];
164 size(1) = geom.ProbHi()[1] - geom.ProbLo()[1];
167 size(2) = geom.ProbHi()[2] - geom.ProbLo()[2];
177 if (
ixType == amrex::IndexType::TheNodeType())
179 return Vector(AMREX_D_DECL(
180 geom.ProbLo()[0] + ((amrex::Real)(
i)) * geom.CellSize()[0],
181 geom.ProbLo()[1] + ((amrex::Real)(
j)) * geom.CellSize()[1],
182 geom.ProbLo()[2] + ((amrex::Real)(
k)) * geom.CellSize()[2]));
184 else if (
ixType == amrex::IndexType::TheCellType())
186 return Vector(AMREX_D_DECL(
187 geom.ProbLo()[0] + ((amrex::Real)(
i) + 0.5) * geom.CellSize()[0],
188 geom.ProbLo()[1] + ((amrex::Real)(
j) + 0.5) * geom.CellSize()[1],
189 geom.ProbLo()[2] + ((amrex::Real)(
k) + 0.5) * geom.CellSize()[2]));
191 return Set::Vector::Zero();
196template<
int dim,
int sym>
AMREX_FORCE_INLINE void operator+=(const Quaternion &rhs)
friend Quaternion operator-(const Quaternion a, const Quaternion b)
friend Quaternion operator*(const Set::Scalar alpha, const Quaternion b)
Quaternion(const Eigen::Matrix3d &R)
friend Quaternion operator+(const Quaternion a, const Quaternion b)
AMREX_FORCE_INLINE void operator=(const Eigen::Quaterniond &rhs)
friend bool operator==(const Quaternion a, const Quaternion b)
Quaternion(Set::Scalar w, Set::Scalar x, Set::Scalar y, Set::Scalar z)
Quaternion(Eigen::Quaterniond &q)
A collection of data types and symmetry-reduced data structures.
Eigen::Matrix< int, AMREX_SPACEDIM, AMREX_SPACEDIM > iMatrix
AMREX_FORCE_INLINE Quaternion operator-(const Quaternion a, const Quaternion b)
AMREX_FORCE_INLINE Vector Volume(const int &i, const int &j, const int &k, const amrex::Geometry &geom, const amrex::IndexType &ixType)
Eigen::Matrix< amrex::Real, 1, AMREX_SPACEDIM > Covector
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
AMREX_FORCE_INLINE Vector Position(const int &i, const int &j, const int &k, const amrex::Geometry &geom, const amrex::IndexType &ixType)
AMREX_FORCE_INLINE bool operator==(const Quaternion a, const Quaternion b)
AMREX_FORCE_INLINE Quaternion operator+(const Quaternion a, const Quaternion b)
AMREX_FORCE_INLINE Set::Matrix3d expand(const Set::Matrix &in)
AMREX_FORCE_INLINE Vector Size(const amrex::Geometry &geom)
AMREX_FORCE_INLINE Vector Normal(AMREX_D_DECL(bool xmin, bool ymin, bool zmin), AMREX_D_DECL(bool xmax, bool ymax, bool zmax))
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, AMREX_SPACEDIM > Matrix
AMREX_FORCE_INLINE Set::Matrix reduce(const Set::Matrix3d &in)
AMREX_FORCE_INLINE Quaternion operator*(const Set::Scalar alpha, const Quaternion b)
std::ostream & operator<<(std::ostream &os, const Matrix4< dim, sym > &b)