Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Nektar::SolverUtils::RiemannSolver Class Referenceabstract

The RiemannSolver class provides an abstract interface under which solvers for various Riemann problems can be implemented. More...

#include <RiemannSolver.h>

Inheritance diagram for Nektar::SolverUtils::RiemannSolver:
[legend]

Public Member Functions

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.
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetScalar (std::string name, FuncPointerT func, ObjectPointerT obj)
 
void SetScalar (std::string name, RSScalarFuncType fp)
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetVector (std::string name, FuncPointerT func, ObjectPointerT obj)
 
void SetVector (std::string name, RSVecFuncType fp)
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetParam (std::string name, FuncPointerT func, ObjectPointerT obj)
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetUpdateNormalsFlag (FuncPointerT func, ObjectPointerT obj)
 
void SetALEFlag (bool &ALE)
 
void SetParam (std::string name, RSParamFuncType fp)
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetAuxScal (std::string name, FuncPointerT func, ObjectPointerT obj)
 
template<typename FuncPointerT , typename ObjectPointerT >
void SetAuxVec (std::string name, FuncPointerT func, ObjectPointerT obj)
 
void SetAuxVec (std::string name, RSVecFuncType fp)
 
std::map< std::string, RSScalarFuncType > & GetScalars ()
 
std::map< std::string, RSVecFuncType > & GetVectors ()
 
std::map< std::string, RSParamFuncType > & GetParams ()
 
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.
 
SOLVER_UTILS_EXPORT void ResetRotMatrix (void)
 

Public Attributes

int m_spacedim
 

Protected Member Functions

SOLVER_UTILS_EXPORT RiemannSolver ()
 
SOLVER_UTILS_EXPORT RiemannSolver (const LibUtilities::SessionReaderSharedPtr &pSession)
 
virtual SOLVER_UTILS_EXPORT ~RiemannSolver ()
 
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 GenerateRotationMatrices (const Array< OneD, const Array< OneD, NekDouble > > &normals)
 Generate rotation matrices for 3D expansions.
 
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 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.
 
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.
 
SOLVER_UTILS_EXPORT bool CheckScalars (std::string name)
 Determine whether a scalar has been defined in m_scalars.
 
SOLVER_UTILS_EXPORT bool CheckVectors (std::string name)
 Determine whether a vector has been defined in m_vectors.
 
SOLVER_UTILS_EXPORT bool CheckParams (std::string name)
 Determine whether a parameter has been defined in m_params.
 
SOLVER_UTILS_EXPORT bool CheckAuxScal (std::string name)
 Determine whether a scalar has been defined in m_auxScal.
 
SOLVER_UTILS_EXPORT bool CheckAuxVec (std::string name)
 Determine whether a vector has been defined in m_auxVec.
 
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)
 

Protected Attributes

bool m_requiresRotation
 Indicates whether the Riemann solver requires a rotation to be applied to the velocity fields.
 
std::map< std::string, RSScalarFuncTypem_scalars
 Map of scalar function types.
 
std::map< std::string, RSVecFuncTypem_vectors
 Map of vector function types.
 
std::map< std::string, RSParamFuncTypem_params
 Map of parameter function types.
 
std::map< std::string, RSScalarFuncTypem_auxScal
 Map of auxiliary scalar function types.
 
std::map< std::string, RSVecFuncTypem_auxVec
 Map of auxiliary vector function types.
 
std::function< bool()> m_updateNormals
 Function of normals updated flag.
 
Array< OneD, Array< OneD, NekDouble > > m_rotMat
 Rotation matrices for each trace quadrature point.
 
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_rotStorage
 Rotation storage.
 
bool m_ALESolver = false
 Flag if using the ALE formulation.
 

Detailed Description

The RiemannSolver class provides an abstract interface under which solvers for various Riemann problems can be implemented.

Definition at line 58 of file RiemannSolver.h.

Constructor & Destructor Documentation

◆ RiemannSolver() [1/2]

Nektar::SolverUtils::RiemannSolver::RiemannSolver ( )
protected

Definition at line 74 of file RiemannSolver.cpp.

75{
76}
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.

◆ RiemannSolver() [2/2]

Nektar::SolverUtils::RiemannSolver::RiemannSolver ( const LibUtilities::SessionReaderSharedPtr pSession)
protected

Definition at line 78 of file RiemannSolver.cpp.

81{
82}

◆ ~RiemannSolver()

virtual SOLVER_UTILS_EXPORT Nektar::SolverUtils::RiemannSolver::~RiemannSolver ( )
inlineprotectedvirtual

Definition at line 181 of file RiemannSolver.h.

181{};

Member Function Documentation

◆ CalcFluxJacobian()

void Nektar::SolverUtils::RiemannSolver::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.

Parameters
FwdForwards trace space.
BwdBackwards trace space.
fluxResultant flux along trace space.

Definition at line 539 of file RiemannSolver.cpp.

543{
544 int nPts = Fwd[0].size();
545
547 {
548 ASSERTL1(CheckVectors("N"), "N not defined.");
549 ASSERTL1(CheckAuxVec("vecLocs"), "vecLocs not defined.");
550 const Array<OneD, const Array<OneD, NekDouble>> normals =
551 m_vectors["N"]();
552 const Array<OneD, const Array<OneD, NekDouble>> vecLocs =
553 m_auxVec["vecLocs"]();
554
555 v_CalcFluxJacobian(nDim, Fwd, Bwd, normals, FJac, BJac);
556 }
557 else
558 {
559 Array<OneD, Array<OneD, NekDouble>> normals(nDim);
560 for (int i = 0; i < nDim; i++)
561 {
562 normals[i] = Array<OneD, NekDouble>(nPts, 0.0);
563 }
564 Vmath::Fill(nPts, 1.0, normals[0], 1);
565
566 v_CalcFluxJacobian(nDim, Fwd, Bwd, normals, FJac, BJac);
567 }
568}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
SOLVER_UTILS_EXPORT bool CheckAuxVec(std::string name)
Determine whether a vector has been defined in m_auxVec.
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)
std::map< std::string, RSVecFuncType > m_vectors
Map of vector function types.
SOLVER_UTILS_EXPORT bool CheckVectors(std::string name)
Determine whether a vector has been defined in m_vectors.
std::map< std::string, RSVecFuncType > m_auxVec
Map of auxiliary vector function types.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:54

References ASSERTL1, CheckAuxVec(), CheckVectors(), Vmath::Fill(), m_auxVec, m_requiresRotation, m_vectors, and v_CalcFluxJacobian().

◆ CheckAuxScal()

bool Nektar::SolverUtils::RiemannSolver::CheckAuxScal ( std::string  name)
protected

Determine whether a scalar has been defined in m_auxScal.

Parameters
nameScalar name.

Definition at line 379 of file RiemannSolver.cpp.

380{
381 return m_auxScal.find(name) != m_auxScal.end();
382}
std::map< std::string, RSScalarFuncType > m_auxScal
Map of auxiliary scalar function types.

References m_auxScal.

◆ CheckAuxVec()

bool Nektar::SolverUtils::RiemannSolver::CheckAuxVec ( std::string  name)
protected

Determine whether a vector has been defined in m_auxVec.

Parameters
nameVector name.

Definition at line 389 of file RiemannSolver.cpp.

390{
391 return m_auxVec.find(name) != m_auxVec.end();
392}

References m_auxVec.

Referenced by CalcFluxJacobian(), and Solve().

◆ CheckParams()

bool Nektar::SolverUtils::RiemannSolver::CheckParams ( std::string  name)
protected

Determine whether a parameter has been defined in m_params.

Parameters
nameParameter name.

Definition at line 369 of file RiemannSolver.cpp.

370{
371 return m_params.find(name) != m_params.end();
372}
std::map< std::string, RSParamFuncType > m_params
Map of parameter function types.

References m_params.

Referenced by Nektar::UpwindPulseSolver::RiemannSolverUpwind().

◆ CheckScalars()

bool Nektar::SolverUtils::RiemannSolver::CheckScalars ( std::string  name)
protected

Determine whether a scalar has been defined in m_scalars.

Parameters
nameScalar name.

Definition at line 349 of file RiemannSolver.cpp.

350{
351 return m_scalars.find(name) != m_scalars.end();
352}
std::map< std::string, RSScalarFuncType > m_scalars
Map of scalar function types.

References m_scalars.

Referenced by Nektar::SolverUtils::UpwindSolver::v_Solve(), and Nektar::UpwindPulseSolver::v_Solve().

◆ CheckVectors()

bool Nektar::SolverUtils::RiemannSolver::CheckVectors ( std::string  name)
protected

Determine whether a vector has been defined in m_vectors.

Parameters
nameVector name.

Definition at line 359 of file RiemannSolver.cpp.

360{
361 return m_vectors.find(name) != m_vectors.end();
362}

References m_vectors.

Referenced by CalcFluxJacobian(), Nektar::AcousticSolver::GetRotBasefield(), Solve(), and Nektar::RoeSolverSIMD::v_Solve().

◆ FromToRotation()

void Nektar::SolverUtils::RiemannSolver::FromToRotation ( Array< OneD, const NekDouble > &  from,
Array< OneD, const NekDouble > &  to,
NekDouble mat 
)
protected

A function for creating a rotation matrix that rotates a vector from into another vector to.

Authors: Tomas Möller, John Hughes "Efficiently Building a Matrix to Rotate One Vector to Another" Journal of Graphics Tools, 4(4):1-4, 1999

Parameters
fromNormalised 3-vector to rotate from.
toNormalised 3-vector to rotate to.
outResulting 3x3 rotation matrix (row-major order).

Definition at line 442 of file RiemannSolver.cpp.

445{
446 NekDouble v[3];
447 NekDouble e, h, f;
448
449 CROSS(v, from, to);
450 e = DOT(from, to);
451 f = (e < 0) ? -e : e;
452 if (f > 1.0 - EPSILON)
453 {
454 NekDouble u[3], v[3];
455 NekDouble x[3];
456 NekDouble c1, c2, c3;
457 int i, j;
458
459 x[0] = (from[0] > 0.0) ? from[0] : -from[0];
460 x[1] = (from[1] > 0.0) ? from[1] : -from[1];
461 x[2] = (from[2] > 0.0) ? from[2] : -from[2];
462
463 if (x[0] < x[1])
464 {
465 if (x[0] < x[2])
466 {
467 x[0] = 1.0;
468 x[1] = x[2] = 0.0;
469 }
470 else
471 {
472 x[2] = 1.0;
473 x[0] = x[1] = 0.0;
474 }
475 }
476 else
477 {
478 if (x[1] < x[2])
479 {
480 x[1] = 1.0;
481 x[0] = x[2] = 0.0;
482 }
483 else
484 {
485 x[2] = 1.0;
486 x[0] = x[1] = 0.0;
487 }
488 }
489
490 u[0] = x[0] - from[0];
491 u[1] = x[1] - from[1];
492 u[2] = x[2] - from[2];
493 v[0] = x[0] - to[0];
494 v[1] = x[1] - to[1];
495 v[2] = x[2] - to[2];
496
497 c1 = 2.0 / DOT(u, u);
498 c2 = 2.0 / DOT(v, v);
499 c3 = c1 * c2 * DOT(u, v);
500
501 for (i = 0; i < 3; i++)
502 {
503 for (j = 0; j < 3; j++)
504 {
505 mat[3 * i + j] =
506 -c1 * u[i] * u[j] - c2 * v[i] * v[j] + c3 * v[i] * u[j];
507 }
508 mat[i + 3 * i] += 1.0;
509 }
510 }
511 else
512 {
513 NekDouble hvx, hvz, hvxy, hvxz, hvyz;
514 h = 1.0 / (1.0 + e);
515 hvx = h * v[0];
516 hvz = h * v[2];
517 hvxy = hvx * v[1];
518 hvxz = hvx * v[2];
519 hvyz = hvz * v[1];
520 mat[0] = e + hvx * v[0];
521 mat[1] = hvxy - v[2];
522 mat[2] = hvxz + v[1];
523 mat[3] = hvxy + v[2];
524 mat[4] = e + h * v[1] * v[1];
525 mat[5] = hvyz - v[0];
526 mat[6] = hvxz - v[1];
527 mat[7] = hvyz + v[0];
528 mat[8] = e + hvz * v[2];
529 }
530}
#define EPSILON
#define CROSS(dest, v1, v2)
#define DOT(v1, v2)

References CROSS, DOT, and EPSILON.

Referenced by GenerateRotationMatrices().

◆ GenerateRotationMatrices()

void Nektar::SolverUtils::RiemannSolver::GenerateRotationMatrices ( const Array< OneD, const Array< OneD, NekDouble > > &  normals)
protected

Generate rotation matrices for 3D expansions.

Definition at line 397 of file RiemannSolver.cpp.

399{
400 Array<OneD, NekDouble> xdir(3, 0.0);
401 Array<OneD, NekDouble> tn(3);
402 NekDouble tmp[9];
403 const int nq = normals[0].size();
404 int i, j;
405 xdir[0] = 1.0;
406
407 // Allocate storage for rotation matrices.
408 m_rotMat = Array<OneD, Array<OneD, NekDouble>>(9);
409
410 for (i = 0; i < 9; ++i)
411 {
412 m_rotMat[i] = Array<OneD, NekDouble>(nq);
413 }
414 for (i = 0; i < normals[0].size(); ++i)
415 {
416 // Generate matrix which takes us from (1,0,0) vector to trace
417 // normal.
418 tn[0] = normals[0][i];
419 tn[1] = normals[1][i];
420 tn[2] = normals[2][i];
421 FromToRotation(tn, xdir, tmp);
422
423 for (j = 0; j < 9; ++j)
424 {
425 m_rotMat[j][i] = tmp[j];
426 }
427 }
428}
Array< OneD, Array< OneD, NekDouble > > m_rotMat
Rotation matrices for each trace quadrature point.
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.

References FromToRotation(), and m_rotMat.

Referenced by rotateToNormal(), and Nektar::RoeSolverSIMD::v_Solve().

◆ GetParams()

std::map< std::string, RSParamFuncType > & Nektar::SolverUtils::RiemannSolver::GetParams ( )
inline

Definition at line 137 of file RiemannSolver.h.

138 {
139 return m_params;
140 }

References m_params.

◆ GetScalars()

std::map< std::string, RSScalarFuncType > & Nektar::SolverUtils::RiemannSolver::GetScalars ( )
inline

Definition at line 127 of file RiemannSolver.h.

128 {
129 return m_scalars;
130 }

References m_scalars.

◆ GetVectors()

std::map< std::string, RSVecFuncType > & Nektar::SolverUtils::RiemannSolver::GetVectors ( )
inline

Definition at line 132 of file RiemannSolver.h.

133 {
134 return m_vectors;
135 }

References m_vectors.

◆ ResetRotMatrix()

SOLVER_UTILS_EXPORT void Nektar::SolverUtils::RiemannSolver::ResetRotMatrix ( void  )
inline

Definition at line 149 of file RiemannSolver.h.

150 {
152 }
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray

References m_rotMat, and Nektar::NullNekDoubleArrayOfArray.

◆ rotateFromNormal()

void Nektar::SolverUtils::RiemannSolver::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 
)
protected

Rotate a vector field from trace normal.

This function performs a rotation of the triad of vector components provided in inarray so that the first component aligns with the Cartesian components; it performs the inverse operation of RiemannSolver::rotateToNormal.

Definition at line 275 of file RiemannSolver.cpp.

280{
281 for (int i = 0; i < inarray.size(); ++i)
282 {
283 Vmath::Vcopy(inarray[i].size(), inarray[i], 1, outarray[i], 1);
284 }
285
286 for (int i = 0; i < vecLocs.size(); i++)
287 {
288 ASSERTL1(vecLocs[i].size() == normals.size(),
289 "vecLocs[i] element count mismatch");
290
291 switch (normals.size())
292 {
293 case 1:
294 { // do nothing
295 const int nq = normals[0].size();
296 const int vx = (int)vecLocs[i][0];
297 Vmath::Vmul(nq, inarray[vx], 1, normals[0], 1, outarray[vx], 1);
298 break;
299 }
300 case 2:
301 {
302 const int nq = normals[0].size();
303 const int vx = (int)vecLocs[i][0];
304 const int vy = (int)vecLocs[i][1];
305
306 Vmath::Vmul(nq, inarray[vy], 1, normals[1], 1, outarray[vx], 1);
307 Vmath::Vvtvm(nq, inarray[vx], 1, normals[0], 1, outarray[vx], 1,
308 outarray[vx], 1);
309 Vmath::Vmul(nq, inarray[vx], 1, normals[1], 1, outarray[vy], 1);
310 Vmath::Vvtvp(nq, inarray[vy], 1, normals[0], 1, outarray[vy], 1,
311 outarray[vy], 1);
312 break;
313 }
314
315 case 3:
316 {
317 const int nq = normals[0].size();
318 const int vx = (int)vecLocs[i][0];
319 const int vy = (int)vecLocs[i][1];
320 const int vz = (int)vecLocs[i][2];
321
322 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[0], 1, inarray[vy],
323 1, m_rotMat[3], 1, outarray[vx], 1);
324 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[6], 1, outarray[vx],
325 1, outarray[vx], 1);
326 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[1], 1, inarray[vy],
327 1, m_rotMat[4], 1, outarray[vy], 1);
328 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[7], 1, outarray[vy],
329 1, outarray[vy], 1);
330 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[2], 1, inarray[vy],
331 1, m_rotMat[5], 1, outarray[vz], 1);
332 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[8], 1, outarray[vz],
333 1, outarray[vz], 1);
334 break;
335 }
336
337 default:
338 ASSERTL1(false, "Invalid space dimension.");
339 break;
340 }
341 }
342}
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.
Definition Vmath.hpp:72
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
Definition Vmath.hpp:366
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 minus vector): z = w*x - y
Definition Vmath.hpp:381
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):
Definition Vmath.hpp:439
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References ASSERTL1, m_rotMat, Vmath::Vcopy(), Vmath::Vmul(), Vmath::Vvtvm(), Vmath::Vvtvp(), and Vmath::Vvtvvtp().

Referenced by Solve().

◆ rotateToNormal()

void Nektar::SolverUtils::RiemannSolver::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 
)
protected

Rotate a vector field to trace normal.

This function performs a rotation of a vector so that the first component aligns with the trace normal direction.

The vectors components are stored in inarray. Their locations must be specified in the "vecLocs" array. vecLocs[0] contains the locations of the first vectors components, vecLocs[1] those of the second and so on.

In 2D, this is accomplished through the transform:

\[ (u_x, u_y) = (n_x u_x + n_y u_y, -n_x v_x + n_y v_y) \]

In 3D, we generate a (non-unique) transformation using RiemannSolver::fromToRotation.

Definition at line 180 of file RiemannSolver.cpp.

185{
186 for (int i = 0; i < inarray.size(); ++i)
187 {
188 Vmath::Vcopy(inarray[i].size(), inarray[i], 1, outarray[i], 1);
189 }
190
191 for (int i = 0; i < vecLocs.size(); i++)
192 {
193 ASSERTL1(vecLocs[i].size() == normals.size(),
194 "vecLocs[i] element count mismatch");
195
196 switch (normals.size())
197 {
198 case 1:
199 { // do nothing
200 const int nq = inarray[0].size();
201 const int vx = (int)vecLocs[i][0];
202 Vmath::Vmul(nq, inarray[vx], 1, normals[0], 1, outarray[vx], 1);
203 break;
204 }
205 case 2:
206 {
207 const int nq = inarray[0].size();
208 const int vx = (int)vecLocs[i][0];
209 const int vy = (int)vecLocs[i][1];
210
211 Vmath::Vmul(nq, inarray[vx], 1, normals[0], 1, outarray[vx], 1);
212 Vmath::Vvtvp(nq, inarray[vy], 1, normals[1], 1, outarray[vx], 1,
213 outarray[vx], 1);
214 Vmath::Vmul(nq, inarray[vx], 1, normals[1], 1, outarray[vy], 1);
215 Vmath::Vvtvm(nq, inarray[vy], 1, normals[0], 1, outarray[vy], 1,
216 outarray[vy], 1);
217 break;
218 }
219
220 case 3:
221 {
222 const int nq = inarray[0].size();
223 const int vx = (int)vecLocs[i][0];
224 const int vy = (int)vecLocs[i][1];
225 const int vz = (int)vecLocs[i][2];
226
227 if (m_ALESolver)
228 {
229 // Generate matrices if they don't already exist.
230 if (m_rotMat.size() == 0 || m_updateNormals())
231 {
233 }
234 }
235 else
236 {
237 // Generate matrices if they don't already exist.
238 if (m_rotMat.size() == 0)
239 {
241 }
242 }
243
244 // Apply rotation matrices.
245 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[0], 1, inarray[vy],
246 1, m_rotMat[1], 1, outarray[vx], 1);
247 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[2], 1, outarray[vx],
248 1, outarray[vx], 1);
249 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[3], 1, inarray[vy],
250 1, m_rotMat[4], 1, outarray[vy], 1);
251 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[5], 1, outarray[vy],
252 1, outarray[vy], 1);
253 Vmath::Vvtvvtp(nq, inarray[vx], 1, m_rotMat[6], 1, inarray[vy],
254 1, m_rotMat[7], 1, outarray[vz], 1);
255 Vmath::Vvtvp(nq, inarray[vz], 1, m_rotMat[8], 1, outarray[vz],
256 1, outarray[vz], 1);
257 break;
258 }
259
260 default:
261 ASSERTL1(false, "Invalid space dimension.");
262 break;
263 }
264 }
265}
std::function< bool()> m_updateNormals
Function of normals updated flag.
SOLVER_UTILS_EXPORT void GenerateRotationMatrices(const Array< OneD, const Array< OneD, NekDouble > > &normals)
Generate rotation matrices for 3D expansions.
bool m_ALESolver
Flag if using the ALE formulation.

References ASSERTL1, GenerateRotationMatrices(), m_ALESolver, m_rotMat, m_updateNormals, Vmath::Vcopy(), Vmath::Vmul(), Vmath::Vvtvm(), Vmath::Vvtvp(), and Vmath::Vvtvvtp().

Referenced by Nektar::AcousticSolver::GetRotBasefield(), and Solve().

◆ SetALEFlag()

void Nektar::SolverUtils::RiemannSolver::SetALEFlag ( bool &  ALE)
inline

Definition at line 100 of file RiemannSolver.h.

101 {
102 m_ALESolver = ALE;
103 }

References m_ALESolver.

◆ SetAuxScal()

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetAuxScal ( std::string  name,
FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 111 of file RiemannSolver.h.

112 {
113 m_auxScal[name] = std::bind(func, obj);
114 }

References m_auxScal.

◆ SetAuxVec() [1/2]

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetAuxVec ( std::string  name,
FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 117 of file RiemannSolver.h.

118 {
119 m_auxVec[name] = std::bind(func, obj);
120 }

References m_auxVec.

◆ SetAuxVec() [2/2]

void Nektar::SolverUtils::RiemannSolver::SetAuxVec ( std::string  name,
RSVecFuncType  fp 
)
inline

Definition at line 122 of file RiemannSolver.h.

123 {
124 m_auxVec[name] = fp;
125 }

References m_auxVec.

◆ SetParam() [1/2]

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetParam ( std::string  name,
FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 89 of file RiemannSolver.h.

90 {
91 m_params[name] = std::bind(func, obj);
92 }

References m_params.

◆ SetParam() [2/2]

void Nektar::SolverUtils::RiemannSolver::SetParam ( std::string  name,
RSParamFuncType  fp 
)
inline

Definition at line 105 of file RiemannSolver.h.

106 {
107 m_params[name] = fp;
108 }

References m_params.

◆ SetScalar() [1/2]

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetScalar ( std::string  name,
FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 67 of file RiemannSolver.h.

68 {
69 m_scalars[name] = std::bind(func, obj);
70 }

References m_scalars.

◆ SetScalar() [2/2]

void Nektar::SolverUtils::RiemannSolver::SetScalar ( std::string  name,
RSScalarFuncType  fp 
)
inline

Definition at line 72 of file RiemannSolver.h.

73 {
74 m_scalars[name] = fp;
75 }

References m_scalars.

◆ SetUpdateNormalsFlag()

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetUpdateNormalsFlag ( FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 95 of file RiemannSolver.h.

96 {
97 m_updateNormals = std::bind(func, obj);
98 }

References m_updateNormals.

◆ SetVector() [1/2]

template<typename FuncPointerT , typename ObjectPointerT >
void Nektar::SolverUtils::RiemannSolver::SetVector ( std::string  name,
FuncPointerT  func,
ObjectPointerT  obj 
)
inline

Definition at line 78 of file RiemannSolver.h.

79 {
80 m_vectors[name] = std::bind(func, obj);
81 }

References m_vectors.

◆ SetVector() [2/2]

void Nektar::SolverUtils::RiemannSolver::SetVector ( std::string  name,
RSVecFuncType  fp 
)
inline

Definition at line 83 of file RiemannSolver.h.

84 {
85 m_vectors[name] = fp;
86 }

References m_vectors.

◆ Solve()

void Nektar::SolverUtils::RiemannSolver::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.

This routine calls the virtual function v_Solve to perform the Riemann solve. If the flag m_requiresRotation is set, then the velocity field is rotated to the normal direction to perform dimensional splitting, and the resulting fluxes are rotated back to the Cartesian directions before being returned. For the Rotation to work, the normal vectors "N" and the location of the vector components in Fwd "vecLocs"must be set via the SetAuxVec() method.

Parameters
FwdForwards trace space.
BwdBackwards trace space.
fluxResultant flux along trace space.

Definition at line 100 of file RiemannSolver.cpp.

104{
106 {
107 ASSERTL1(CheckVectors("N"), "N not defined.");
108 ASSERTL1(CheckAuxVec("vecLocs"), "vecLocs not defined.");
109 const Array<OneD, const Array<OneD, NekDouble>> normals =
110 m_vectors["N"]();
111 const Array<OneD, const Array<OneD, NekDouble>> vecLocs =
112 m_auxVec["vecLocs"]();
113
114 int nFields = Fwd.size();
115 int nPts = Fwd[0].size();
116
117 if (m_rotStorage[0].size() != nFields ||
118 m_rotStorage[0][0].size() != nPts)
119 {
120 for (int i = 0; i < 3; ++i)
121 {
122 m_rotStorage[i] = Array<OneD, Array<OneD, NekDouble>>(nFields);
123 for (int j = 0; j < nFields; ++j)
124 {
125 m_rotStorage[i][j] = Array<OneD, NekDouble>(nPts);
126 }
127 }
128 }
129
130 rotateToNormal(Fwd, normals, vecLocs, m_rotStorage[0]);
131 rotateToNormal(Bwd, normals, vecLocs, m_rotStorage[1]);
132
134 rotateFromNormal(m_rotStorage[2], normals, vecLocs, flux);
135
136 // Attempt to subtract (\vec{U}\vec{vg})\dot n for ALE
137 if (m_ALESolver)
138 {
139 auto vgt = m_vectors["vgt"]();
140 auto N = m_vectors["N"]();
141 for (int i = 0; i < flux.size(); ++i)
142 {
143 for (int j = 0; j < flux[i].size(); ++j)
144 {
145 NekDouble tmp = 0;
146 for (int k = 0; k < nDim; ++k)
147 {
148 tmp += N[k][j] * vgt[k][j];
149 }
150 flux[i][j] -= 0.5 * (Fwd[i][j] + Bwd[i][j]) * tmp;
151 }
152 }
153 }
154 }
155 else
156 {
157 v_Solve(nDim, Fwd, Bwd, flux);
158 }
159}
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.

References ASSERTL1, CheckAuxVec(), CheckVectors(), m_ALESolver, m_auxVec, m_requiresRotation, m_rotStorage, m_vectors, rotateFromNormal(), rotateToNormal(), and v_Solve().

◆ v_CalcFluxJacobian()

void Nektar::SolverUtils::RiemannSolver::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 
)
protectedvirtual

Definition at line 570 of file RiemannSolver.cpp.

577{
578 NEKERROR(ErrorUtil::efatal, "v_CalcFluxJacobian not specified.");
579}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...

References Nektar::ErrorUtil::efatal, and NEKERROR.

Referenced by CalcFluxJacobian().

◆ v_Solve()

virtual void Nektar::SolverUtils::RiemannSolver::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 
)
protectedpure virtual

Member Data Documentation

◆ m_ALESolver

bool Nektar::SolverUtils::RiemannSolver::m_ALESolver = false
protected

Flag if using the ALE formulation.

Definition at line 175 of file RiemannSolver.h.

Referenced by rotateToNormal(), SetALEFlag(), and Solve().

◆ m_auxScal

std::map<std::string, RSScalarFuncType> Nektar::SolverUtils::RiemannSolver::m_auxScal
protected

Map of auxiliary scalar function types.

Definition at line 165 of file RiemannSolver.h.

Referenced by CheckAuxScal(), and SetAuxScal().

◆ m_auxVec

std::map<std::string, RSVecFuncType> Nektar::SolverUtils::RiemannSolver::m_auxVec
protected

Map of auxiliary vector function types.

Definition at line 167 of file RiemannSolver.h.

Referenced by CalcFluxJacobian(), CheckAuxVec(), SetAuxVec(), SetAuxVec(), and Solve().

◆ m_params

std::map<std::string, RSParamFuncType> Nektar::SolverUtils::RiemannSolver::m_params
protected

◆ m_requiresRotation

bool Nektar::SolverUtils::RiemannSolver::m_requiresRotation
protected

◆ m_rotMat

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::RiemannSolver::m_rotMat
protected

Rotation matrices for each trace quadrature point.

Definition at line 171 of file RiemannSolver.h.

Referenced by GenerateRotationMatrices(), ResetRotMatrix(), rotateFromNormal(), rotateToNormal(), and Nektar::RoeSolverSIMD::v_Solve().

◆ m_rotStorage

Array<OneD, Array<OneD, Array<OneD, NekDouble> > > Nektar::SolverUtils::RiemannSolver::m_rotStorage
protected

Rotation storage.

Definition at line 173 of file RiemannSolver.h.

Referenced by Solve().

◆ m_scalars

std::map<std::string, RSScalarFuncType> Nektar::SolverUtils::RiemannSolver::m_scalars
protected

◆ m_spacedim

int Nektar::SolverUtils::RiemannSolver::m_spacedim

Definition at line 142 of file RiemannSolver.h.

◆ m_updateNormals

std::function<bool()> Nektar::SolverUtils::RiemannSolver::m_updateNormals
protected

Function of normals updated flag.

Definition at line 169 of file RiemannSolver.h.

Referenced by rotateToNormal(), and SetUpdateNormalsFlag().

◆ m_vectors

std::map<std::string, RSVecFuncType> Nektar::SolverUtils::RiemannSolver::m_vectors
protected