35 #include <boost/core/ignore_unused.hpp>
40 #define EPSILON 0.000001
42 #define CROSS(dest, v1, v2){ \
43 dest[0] = v1[1] * v2[2] - v1[2] * v2[1]; \
44 dest[1] = v1[2] * v2[0] - v1[0] * v2[2]; \
45 dest[2] = v1[0] * v2[1] - v1[1] * v2[0];}
47 #define DOT(v1, v2) (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2])
49 #define SUB(dest, v1, v2){ \
50 dest[0] = v1[0] - v2[0]; \
51 dest[1] = v1[1] - v2[1]; \
52 dest[2] = v1[2] - v2[2];}
76 RiemannSolver::RiemannSolver()
77 : m_requiresRotation(false), m_rotStorage(3) {}
81 : m_requiresRotation(false), m_rotStorage(3)
83 boost::ignore_unused(pSession);
117 int nFields = Fwd .size();
118 int nPts = Fwd[0].size();
123 for (
int i = 0; i < 3; ++i)
127 for (
int j = 0; j < nFields; ++j)
173 for (
int i = 0; i < inarray.size(); ++i)
179 for (
int i = 0; i < vecLocs.size(); i++)
181 ASSERTL1(vecLocs[i].size() == normals.size(),
182 "vecLocs[i] element count mismatch");
184 switch (normals.size())
188 const int nq = inarray[0].size();
189 const int vx = (int)vecLocs[i][0];
196 const int nq = inarray[0].size();
197 const int vx = (int)vecLocs[i][0];
198 const int vy = (int)vecLocs[i][1];
203 outarray[vx], 1, outarray[vx], 1);
207 outarray[vy], 1, outarray[vy], 1);
213 const int nq = inarray[0].size();
214 const int vx = (int)vecLocs[i][0];
215 const int vy = (int)vecLocs[i][1];
216 const int vz = (int)vecLocs[i][2];
229 outarray[vx], 1, outarray[vx], 1);
234 outarray[vy], 1, outarray[vy], 1);
239 outarray[vz], 1, outarray[vz], 1);
244 ASSERTL1(
false,
"Invalid space dimension.");
264 for (
int i = 0; i < inarray.size(); ++i)
270 for (
int i = 0; i < vecLocs.size(); i++)
272 ASSERTL1(vecLocs[i].size() == normals.size(),
273 "vecLocs[i] element count mismatch");
275 switch (normals.size())
279 const int nq = normals[0].size();
280 const int vx = (int)vecLocs[i][0];
287 const int nq = normals[0].size();
288 const int vx = (int)vecLocs[i][0];
289 const int vy = (int)vecLocs[i][1];
294 outarray[vx], 1, outarray[vx], 1);
298 outarray[vy], 1, outarray[vy], 1);
304 const int nq = normals[0].size();
305 const int vx = (int)vecLocs[i][0];
306 const int vy = (int)vecLocs[i][1];
307 const int vz = (int)vecLocs[i][2];
313 outarray[vx], 1, outarray[vx], 1);
318 outarray[vy], 1, outarray[vy], 1);
323 outarray[vz], 1, outarray[vz], 1);
328 ASSERTL1(
false,
"Invalid space dimension.");
393 const int nq = normals[0].size();
400 for (i = 0; i < 9; ++i)
404 for (i = 0; i < normals[0].size(); ++i)
408 tn[0] = normals[0][i];
409 tn[1] = normals[1][i];
410 tn[2] = normals[2][i];
413 for (j = 0; j < 9; ++j)
450 x[0] = (from[0] > 0.0)? from[0] : -from[0];
451 x[1] = (from[1] > 0.0)? from[1] : -from[1];
452 x[2] = (from[2] > 0.0)? from[2] : -from[2];
458 x[0] = 1.0; x[1] = x[2] = 0.0;
462 x[2] = 1.0; x[0] = x[1] = 0.0;
469 x[1] = 1.0; x[0] = x[2] = 0.0;
473 x[2] = 1.0; x[0] = x[1] = 0.0;
477 u[0] = x[0] - from[0];
478 u[1] = x[1] - from[1];
479 u[2] = x[2] - from[2];
480 v[0] = x[0] - to [0];
481 v[1] = x[1] - to [1];
482 v[2] = x[2] - to [2];
484 c1 = 2.0 /
DOT(u, u);
485 c2 = 2.0 /
DOT(v, v);
486 c3 = c1 * c2 *
DOT(u, v);
488 for (i = 0; i < 3; i++) {
489 for (j = 0; j < 3; j++) {
490 mat[3*i+j] = - c1 * u[i] * u[j]
506 mat[0] = e + hvx * v[0];
507 mat[1] = hvxy - v[2];
508 mat[2] = hvxz + v[1];
509 mat[3] = hvxy + v[2];
510 mat[4] = e + h * v[1] * v[1];
511 mat[5] = hvyz - v[0];
512 mat[6] = hvxz - v[1];
513 mat[7] = hvyz + v[0];
514 mat[8] = e + hvz * v[2];
532 int nPts = Fwd[0].size();
548 for(
int i=0;i< nDim;i++)
567 boost::ignore_unused(nDim,Fwd,Bwd,normals,FJac,BJac);
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define CROSS(dest, v1, v2)
Provides a generic Factory class.
SOLVER_UTILS_EXPORT bool CheckAuxVec(std::string name)
Determine whether a vector has been defined in m_auxVec.
SOLVER_UTILS_EXPORT void Solve(const int nDim, const Array< OneD, const Array< OneD, NekDouble > > &Fwd, const Array< OneD, const Array< OneD, NekDouble > > &Bwd, Array< OneD, Array< OneD, NekDouble > > &flux)
Perform the Riemann solve given the forwards and backwards spaces.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_rotStorage
Rotation storage.
bool m_requiresRotation
Indicates whether the Riemann solver requires a rotation to be applied to the velocity fields.
virtual SOLVER_UTILS_EXPORT void v_CalcFluxJacobian(const int nDim, const Array< OneD, const Array< OneD, NekDouble > > &Fwd, const Array< OneD, const Array< OneD, NekDouble > > &Bwd, const Array< OneD, const Array< OneD, NekDouble > > &normals, DNekBlkMatSharedPtr &FJac, DNekBlkMatSharedPtr &BJac)
SOLVER_UTILS_EXPORT bool CheckParams(std::string name)
Determine whether a parameter has been defined in m_params.
std::map< std::string, RSScalarFuncType > m_auxScal
Map of auxiliary scalar function types.
SOLVER_UTILS_EXPORT void rotateToNormal(const Array< OneD, const Array< OneD, NekDouble > > &inarray, const Array< OneD, const Array< OneD, NekDouble > > &normals, const Array< OneD, const Array< OneD, NekDouble > > &vecLocs, Array< OneD, Array< OneD, NekDouble > > &outarray)
Rotate a vector field to trace normal.
virtual void v_Solve(const int nDim, const Array< OneD, const Array< OneD, NekDouble > > &Fwd, const Array< OneD, const Array< OneD, NekDouble > > &Bwd, Array< OneD, Array< OneD, NekDouble > > &flux)=0
SOLVER_UTILS_EXPORT void rotateFromNormal(const Array< OneD, const Array< OneD, NekDouble > > &inarray, const Array< OneD, const Array< OneD, NekDouble > > &normals, const Array< OneD, const Array< OneD, NekDouble > > &vecLocs, Array< OneD, Array< OneD, NekDouble > > &outarray)
Rotate a vector field from trace normal.
Array< OneD, Array< OneD, NekDouble > > m_rotMat
Rotation matrices for each trace quadrature point.
SOLVER_UTILS_EXPORT bool CheckScalars(std::string name)
Determine whether a scalar has been defined in m_scalars.
SOLVER_UTILS_EXPORT void CalcFluxJacobian(const int nDim, const Array< OneD, const Array< OneD, NekDouble > > &Fwd, const Array< OneD, const Array< OneD, NekDouble > > &Bwd, DNekBlkMatSharedPtr &FJac, DNekBlkMatSharedPtr &BJac)
Calculate the flux jacobian of Fwd and Bwd.
std::map< std::string, RSVecFuncType > m_vectors
Map of vector function types.
std::map< std::string, RSScalarFuncType > m_scalars
Map of scalar function types.
SOLVER_UTILS_EXPORT bool CheckVectors(std::string name)
Determine whether a vector has been defined in m_vectors.
void FromToRotation(Array< OneD, const NekDouble > &from, Array< OneD, const NekDouble > &to, NekDouble *mat)
A function for creating a rotation matrix that rotates a vector from into another vector to.
SOLVER_UTILS_EXPORT void GenerateRotationMatrices(const Array< OneD, const Array< OneD, NekDouble > > &normals)
Generate rotation matrices for 3D expansions.
SOLVER_UTILS_EXPORT bool CheckAuxScal(std::string name)
Determine whether a scalar has been defined in m_auxScal.
SOLVER_UTILS_EXPORT RiemannSolver()
std::map< std::string, RSParamFuncType > m_params
Map of parameter function types.
std::map< std::string, RSVecFuncType > m_auxVec
Map of auxiliary vector function types.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Vvtvm(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvm (vector times vector plus vector): z = w*x - y
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector):
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)