39 #define EPSILON 0.000001
41 #define CROSS(dest, v1, v2){ \
42 dest[0] = v1[1] * v2[2] - v1[2] * v2[1]; \
43 dest[1] = v1[2] * v2[0] - v1[0] * v2[2]; \
44 dest[2] = v1[0] * v2[1] - v1[1] * v2[0];}
46 #define DOT(v1, v2) (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2])
48 #define SUB(dest, v1, v2){ \
49 dest[0] = v1[0] - v2[0]; \
50 dest[1] = v1[1] - v2[1]; \
51 dest[2] = v1[2] - v2[2];}
66 Loki::NoDestroy > Type;
67 return Type::Instance();
77 RiemannSolver::RiemannSolver() : m_requiresRotation(false),
101 const Array<
OneD,
const Array<OneD, NekDouble> > &Fwd,
102 const Array<
OneD,
const Array<OneD, NekDouble> > &Bwd,
103 Array<
OneD, Array<OneD, NekDouble> > &flux)
109 const Array<OneD, const Array<OneD, NekDouble> > normals =
111 const Array<OneD, const Array<OneD, NekDouble> > vecLocs =
114 int nFields = Fwd .num_elements();
115 int nPts = Fwd[0].num_elements();
120 for (
int i = 0; i < 3; ++i)
123 Array<OneD, Array<OneD, NekDouble> >(nFields);
124 for (
int j = 0; j < nFields; ++j)
163 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
164 const Array<
OneD,
const Array<OneD, NekDouble> > &normals,
165 const Array<
OneD,
const Array<OneD, NekDouble> > &vecLocs,
166 Array<
OneD, Array<OneD, NekDouble> > &outarray)
168 for (
int i = 0; i < inarray.num_elements(); ++i)
174 for (
int i = 0; i < vecLocs.num_elements(); i++)
176 ASSERTL1(vecLocs[i].num_elements() == normals.num_elements(),
177 "vecLocs[i] element count mismatch");
179 switch (normals.num_elements())
187 const int nq = inarray[0].num_elements();
188 const int vx = (int)vecLocs[i][0];
189 const int vy = (int)vecLocs[i][1];
194 outarray[vx], 1, outarray[vx], 1);
198 outarray[vy], 1, outarray[vy], 1);
204 const int nq = inarray[0].num_elements();
205 const int vx = (int)vecLocs[i][0];
206 const int vy = (int)vecLocs[i][1];
207 const int vz = (int)vecLocs[i][2];
220 outarray[vx], 1, outarray[vx], 1);
225 outarray[vy], 1, outarray[vy], 1);
230 outarray[vz], 1, outarray[vz], 1);
235 ASSERTL1(
false,
"Invalid space dimension.");
250 const Array<
OneD,
const Array<OneD, NekDouble> > &inarray,
251 const Array<
OneD,
const Array<OneD, NekDouble> > &normals,
252 const Array<
OneD,
const Array<OneD, NekDouble> > &vecLocs,
253 Array<
OneD, Array<OneD, NekDouble> > &outarray)
255 for (
int i = 0; i < inarray.num_elements(); ++i)
261 for (
int i = 0; i < vecLocs.num_elements(); i++)
263 ASSERTL1(vecLocs[i].num_elements() == normals.num_elements(),
264 "vecLocs[i] element count mismatch");
266 switch (normals.num_elements())
274 const int nq = normals[0].num_elements();
275 const int vx = (int)vecLocs[i][0];
276 const int vy = (int)vecLocs[i][1];
281 outarray[vx], 1, outarray[vx], 1);
285 outarray[vy], 1, outarray[vy], 1);
291 const int nq = normals[0].num_elements();
292 const int vx = (int)vecLocs[i][0];
293 const int vy = (int)vecLocs[i][1];
294 const int vz = (int)vecLocs[i][2];
300 outarray[vx], 1, outarray[vx], 1);
305 outarray[vy], 1, outarray[vy], 1);
310 outarray[vz], 1, outarray[vz], 1);
315 ASSERTL1(
false,
"Invalid space dimension.");
390 const Array<
OneD,
const Array<OneD, NekDouble> > &normals)
392 Array<OneD, NekDouble> xdir(3,0.0);
393 Array<OneD, NekDouble> tn (3);
395 const int nq = normals[0].num_elements();
400 m_rotMat = Array<OneD, Array<OneD, NekDouble> >(9);
402 for (i = 0; i < 9; ++i)
404 m_rotMat[i] = Array<OneD, NekDouble>(nq);
406 for (i = 0; i < normals[0].num_elements(); ++i)
410 tn[0] = normals[0][i];
411 tn[1] = normals[1][i];
412 tn[2] = normals[2][i];
415 for (j = 0; j < 9; ++j)
435 Array<OneD, const NekDouble> &from,
436 Array<OneD, const NekDouble> &to,
452 x[0] = (from[0] > 0.0)? from[0] : -from[0];
453 x[1] = (from[1] > 0.0)? from[1] : -from[1];
454 x[2] = (from[2] > 0.0)? from[2] : -from[2];
460 x[0] = 1.0; x[1] = x[2] = 0.0;
464 x[2] = 1.0; x[0] = x[1] = 0.0;
471 x[1] = 1.0; x[0] = x[2] = 0.0;
475 x[2] = 1.0; x[0] = x[1] = 0.0;
479 u[0] = x[0] - from[0];
480 u[1] = x[1] - from[1];
481 u[2] = x[2] - from[2];
482 v[0] = x[0] - to [0];
483 v[1] = x[1] - to [1];
484 v[2] = x[2] - to [2];
486 c1 = 2.0 /
DOT(u, u);
487 c2 = 2.0 /
DOT(v, v);
488 c3 = c1 * c2 *
DOT(u, v);
490 for (i = 0; i < 3; i++) {
491 for (j = 0; j < 3; j++) {
492 mat[3*i+j] = - c1 * u[i] * u[j]
508 mat[0] = e + hvx * v[0];
509 mat[1] = hvxy - v[2];
510 mat[2] = hvxz + v[1];
511 mat[3] = hvxy + v[2];
512 mat[4] = e + h * v[1] * v[1];
513 mat[5] = hvyz - v[0];
514 mat[6] = hvxz - v[1];
515 mat[7] = hvyz + v[0];
516 mat[8] = e + hvz * v[2];