MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
DgSysEqnAcousticPerturb< nDim > Class Template Reference

#include <dgcartesiansyseqnacousticperturb.h>

Inheritance diagram for DgSysEqnAcousticPerturb< nDim >:
[legend]
Collaboration diagram for DgSysEqnAcousticPerturb< nDim >:
[legend]

Classes

struct  CV
 

Public Member Functions

 DgSysEqnAcousticPerturb (MInt solverId)
 Constructor calls parent constructor & loads all necessary properties for this equation. More...
 
void calcInitialCondition (const MFloat t, const MFloat *x, MFloat *const nodeVars, MFloat *u) const
 Calculate the initial condition for a certain point in space. More...
 
void calcFlux (const MFloat *const nodeVars, const MFloat *const q, const MInt noNodes1D, MFloat *const flux) const
 Calculates the physical fluxes in all dimensions for all integrations points within a cell. More...
 
void calcSource (const MFloat *const nodeVars, const MFloat *const u, const MInt noNodes1D, const MFloat t, const MFloat *const x, MFloat *const src) const
 Calculates the source terms for all integration points within a cell. More...
 
void calcSpongeSource (const MFloat *nodeVars, const MFloat *u, const MInt noNodes1D, const MFloat *eta, MFloat *src) const
 Calculates the sponge source terms for all integration points within a cell. More...
 
MFloat getTimeStep (const MFloat *nodeVars, const MFloat *const u, const MInt noNodes1D, const MFloat invJacobian, const MInt sbpMode) const
 Calculate the time step for an explicit time stepping scheme for a given element. More...
 
void calcRiemann (const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
 Calculates the numerical flux at a surface given two states (left and right). More...
 
void calcRiemannLaxFriedich (const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
 Calculate Riemann flux using the local Lax-Friedrichs flux scheme. More...
 
void calcRiemannRoe (const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
 
void primToCons (const MFloat *prim, MFloat *cons) const
 Calculates a set of conservative variables from a set of primitive variables. More...
 
void consToPrim (const MFloat *cons, MFloat *prim) const
 Calculates a set of primitive variables from a set of conservative variables. More...
 
void getDefaultNodeVars (MFloat *const nodeVars) const
 Return the default node variables. More...
 
void getDefaultNodeVarsBody (MFloat *const nodeVars) const
 Return the default node variables inside a body. More...
 
MBool extendNodeVar (const MInt varId) const
 Return if the given node variable should be extended. More...
 
void calcRiemannRoe (const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
 
void calcRiemannRoe (const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
 
- Public Member Functions inherited from DgSysEqn< nDim, DgSysEqnAcousticPerturb< nDim > >
MFloat cfl () const
 
MFloat cflScaled (const MInt polyDeg) const
 

Private Member Functions

void calcFlux1D (const MFloat *const nodeVars, const MFloat *const q, const MInt noNodes1D, const MInt dirId, MFloat *const flux) const
 Calculates the physical fluxes in dimension dirId for all integrations points on an element face. More...
 
MFloat cflFactor (const MInt polyDeg) const
 
const MString s_consVarNames []
 
const MString s_primVarNames []
 
const MString s_nodeVarNames []
 
const MString s_consVarNames []
 
const MString s_primVarNames []
 
const MString s_nodeVarNames []
 

Private Attributes

std::array< MFloat, nDim > m_meanVelocity
 
MFloat m_meanDensity
 
MFloat m_meanSpeedOfSound
 
MBool m_constantSpeedOfSound = false
 
MFloat m_spongePressureInfy
 
MFloat m_spongeSigma
 
MBool m_compressibleSourceTerm = true
 
MString m_dgIntegrationMethod
 
MInt m_dgTimeIntegrationScheme
 
std::array< std::array< MFloat, s_maxPolyDeg+1 >, 2 > m_cflFactor
 

Static Private Attributes

static const MString s_sysEqnName = "DG_SYSEQN_ACOUSTICPERTURB"
 
static const MInt s_noVariables = nDim + 1
 
static const MString s_consVarNames [s_noVariables]
 
static const MString s_primVarNames [s_noVariables]
 
static const MInt s_noNodeVars = 2 * nDim + 2
 
static const MBool s_hasTimeDependentNodeVars = false
 
static const MString s_nodeVarNames [s_noNodeVars]
 
static const MInt s_maxPolyDeg = 31
 

Friends

class DgSysEqn< nDim, DgSysEqnAcousticPerturb >
 

Additional Inherited Members

- Static Public Member Functions inherited from DgSysEqn< nDim, DgSysEqnAcousticPerturb< nDim > >
static constexpr MInt noVars ()
 
static constexpr MInt noNodeVars ()
 
static constexpr MBool hasTimeDependentNodeVars ()
 
static const MStringsysEqnName ()
 
static const MStringconsVarNames (MInt i)
 
static const MStringprimVarNames (MInt i)
 
static const MStringnodeVarNames (MInt i)
 
- Public Attributes inherited from DgSysEqn< nDim, DgSysEqnAcousticPerturb< nDim > >
MInt m_initialCondition
 
MFloat m_initialNumberWaves
 
MInt m_sourceTerm
 
MInt m_riemannSolver
 
- Protected Member Functions inherited from DgSysEqn< nDim, DgSysEqnAcousticPerturb< nDim > >
 DgSysEqn (MInt solverId)
 
- Protected Attributes inherited from DgSysEqn< nDim, DgSysEqnAcousticPerturb< nDim > >
const MInt m_solverId
 

Detailed Description

template<MInt nDim>
class DgSysEqnAcousticPerturb< nDim >

Definition at line 27 of file dgcartesiansyseqnacousticperturb.h.

Constructor & Destructor Documentation

◆ DgSysEqnAcousticPerturb()

template<MInt nDim>
DgSysEqnAcousticPerturb< nDim >::DgSysEqnAcousticPerturb ( MInt  solverId)
explicit
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]solverIdCurrent solver id.

Definition at line 164 of file dgcartesiansyseqnacousticperturb.h.

Member Function Documentation

◆ calcFlux()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcFlux ( const MFloat *const  nodeVars,
const MFloat *const  q,
const MInt  noNodes1D,
MFloat *const  flux 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]qPointer to solution variables (size: noNodes1D^nDim*noVars)).
[in]noNodes1DNumber of nodes 1D in the cell.
[out]fluxCalculated flux (size: noNodes1D^nDim*noVars*nDim)).

Definition at line 827 of file dgcartesiansyseqnacousticperturb.h.

830 {
831 // TRACE();
832
833 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
834 const MFloatTensor U(const_cast<MFloat*>(q), noNodes1D, noNodes1D, noNodes1D3, s_noVariables);
835 const MFloatTensor U0(const_cast<MFloat*>(nodeVars), noNodes1D, noNodes1D, noNodes1D3, s_noNodeVars);
836 MFloatTensor f(flux, noNodes1D, noNodes1D, noNodes1D3, nDim, s_noVariables);
837
838 // The following flux equations are calculated here (if 2D, consider all
839 // z-components to be zero; for an incompressible case: cBar=1, rhoBar=1):
840
841 // Flux in x-direction:
842 // f_x(CV[u]) = u*uBar + v*vBar + w*wBar + p/rhoBar
843 // f_x(CV[v]) = 0
844 // f_x(CV[w]) = 0
845 // f_x(CV[p]) = rhoBar*cBar^2*u + uBar*p
846
847 // Flux in y-direction:
848 // f_y(CV[u]) = 0
849 // f_y(CV[v]) = u*uBar + v*vBar + w*wBar + p/rhoBar
850 // f_y(CV[w]) = 0
851 // f_y(CV[p]) = rhoBar*cBar^2*v + vBar*p
852
853 // Flux in z-direction:
854 // f_z(CV[u]) = 0
855 // f_z(CV[v]) = 0
856 // f_z(CV[w]) = u*uBar + v*vBar + w*wBar + p/rhoBar
857 // f_z(CV[p]) = rhoBar*cBar^2*w + wBar*p
858
859 for(MInt i = 0; i < noNodes1D; i++) {
860 for(MInt j = 0; j < noNodes1D; j++) {
861 for(MInt k = 0; k < noNodes1D3; k++) {
862 for(MInt d = 0; d < nDim; d++) {
863 // Momentum fluxes
864 for(MInt fd = 0; fd < nDim; fd++) {
865 f(i, j, k, d, CV::UU[fd]) = 0.0;
866 }
867 f(i, j, k, d, CV::UU[d]) = std::inner_product(&U0(i, j, k, CV::UU0[0]),
868 &U0(i, j, k, CV::UU0[0]) + nDim,
869 &U(i, j, k, CV::UU[0]),
870 U(i, j, k, CV::P) / U0(i, j, k, CV::RHO0));
871
872 // Energy flux
873 f(i, j, k, d, CV::P) = U0(i, j, k, CV::RHO0) * POW2(U0(i, j, k, CV::C0)) * U(i, j, k, CV::UU[d])
874 + U0(i, j, k, CV::UU0[d]) * U(i, j, k, CV::P);
875 }
876 }
877 }
878 }
879}
constexpr Real POW2(const Real x)
Definition: functions.h:119
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
static constexpr const MInt UU0[nDim]
static constexpr const MInt UU[nDim]

◆ calcFlux1D()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcFlux1D ( const MFloat *const  nodeVars,
const MFloat *const  q,
const MInt  noNodes1D,
const MInt  dirId,
MFloat *const  flux 
) const
private
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]qPointer to solution variables (size: noNodes1D^(nDim-1)*noVars)).
[in]noNodes1DNumber of nodes 1D in the cell.
[in]dirIdOrientation of the face (0 - x, 1 - y, 2 - z).
[out]fluxCalculated flux (size: noNodes1D^(nDim-1)*noVars)).

Definition at line 896 of file dgcartesiansyseqnacousticperturb.h.

900 {
901 // TRACE();
902
903 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
904 const MFloatTensor U(const_cast<MFloat*>(q), noNodes1D, noNodes1D3, s_noVariables);
905 const MFloatTensor U0(const_cast<MFloat*>(nodeVars), noNodes1D, noNodes1D3, s_noNodeVars);
906 MFloatTensor f(flux, noNodes1D, noNodes1D3, s_noVariables);
907
908 for(MInt i = 0; i < noNodes1D; i++) {
909 for(MInt j = 0; j < noNodes1D3; j++) {
910 // Momentum fluxes
911 for(MInt d = 0; d < nDim; d++) {
912 if(d == dirId) {
913 f(i, j, CV::UU[d]) = std::inner_product(&U0(i, j, CV::UU0[0]),
914 &U0(i, j, CV::UU0[0]) + nDim,
915 &U(i, j, CV::UU[0]),
916 U(i, j, CV::P) / U0(i, j, CV::RHO0));
917 } else {
918 f(i, j, CV::UU[d]) = 0.0;
919 }
920 }
921
922 // Energy flux
923 f(i, j, CV::P) = U0(i, j, CV::RHO0) * POW2(U0(i, j, CV::C0)) * U(i, j, CV::UU[dirId])
924 + U0(i, j, CV::UU0[dirId]) * U(i, j, CV::P);
925 }
926 }
927}

◆ calcInitialCondition()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcInitialCondition ( const MFloat  t,
const MFloat x,
MFloat *const  nodeVars,
MFloat u 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2012-11-28
Parameters
[in]tTime at which the initial condition should be applied.
[in]xA pointer to the node coordinates.
[out]uA pointer to the solution storage.

Note: If you (for some reason) use nodeVariables information to calculate the initial condition for the conservative variables, you also must set the nodeVariables here, otherwise the calcErrorNorms() method of the DG solver procudes faulty results.

Definition at line 397 of file dgcartesiansyseqnacousticperturb.h.

◆ calcRiemann()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcRiemann ( const MFloat nodeVarsL,
const MFloat nodeVarsR,
const MFloat stateL,
const MFloat stateR,
const MInt  noNodes1D,
const MInt  dirId,
MFloat flux 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]nodeVarsLSurface node variables on the left side of the surface (i.e. in -x/-y/-z-direction).
[in]nodeVarsRSurface node variables on the right side of the surface (i.e. in +x/+y/+z-direction).
[in]stateLSurface variables on the left side of the surface (i.e. in -x/-y/-z-direction).
[in]stateRSurface variables on the right side of the surface (i.e. in +x/+y/+z-direction).
[in]noNodes1DNumber of nodes 1D.
[in]dirIdDirection (0 = x-direction, 1 = y-direction, 2 = z-direction).
[out]fluxCalculated Riemann flux (size: noNodes1D^(nDim-1)*noVars).

Definition at line 1423 of file dgcartesiansyseqnacousticperturb.h.

1429 {
1430 // TRACE();
1431
1432 // Solve Riemann problem
1433 switch(this->m_riemannSolver) {
1434 case 0: // local Lax-Friedrichs flux
1435 {
1436 calcRiemannLaxFriedich(nodeVarsL, nodeVarsR, stateL, stateR, noNodes1D, dirId, flux);
1437 break;
1438 }
1439
1440 case 1: // Roe's flux
1441 {
1442 TERMM(1, "Implementation does not work for internal fluxes, see comments");
1443 calcRiemannRoe(nodeVarsL, nodeVarsR, stateL, stateR, noNodes1D, dirId, flux);
1444 break;
1445 }
1446
1447 default:
1448 mTerm(1, AT_, "The specified Riemann solver is not valid!");
1449 break;
1450 }
1451}
void calcRiemannLaxFriedich(const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
Calculate Riemann flux using the local Lax-Friedrichs flux scheme.
void calcRiemannRoe(const MFloat *nodeVarsL, const MFloat *nodeVarsR, const MFloat *stateL, const MFloat *stateR, const MInt noNodes1D, const MInt dirId, MFloat *flux) const
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

◆ calcRiemannLaxFriedich()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcRiemannLaxFriedich ( const MFloat nodeVarsL,
const MFloat nodeVarsR,
const MFloat stateL,
const MFloat stateR,
const MInt  noNodes1D,
const MInt  dirId,
MFloat flux 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2015-03-13

Note: for argument description, see calcRieman(...).

Definition at line 1461 of file dgcartesiansyseqnacousticperturb.h.

1467 {
1468 // TRACE();
1469
1470 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1471 const MFloatTensor uL(const_cast<MFloat*>(stateL), noNodes1D, noNodes1D3, s_noVariables);
1472 const MFloatTensor uR(const_cast<MFloat*>(stateR), noNodes1D, noNodes1D3, s_noVariables);
1473
1474 const MFloatTensor nL(const_cast<MFloat*>(nodeVarsL), noNodes1D, noNodes1D3, s_noNodeVars);
1475 const MFloatTensor nR(const_cast<MFloat*>(nodeVarsR), noNodes1D, noNodes1D3, s_noNodeVars);
1476
1477#ifndef _OPENMP
1478 MFloatScratchSpace maxLambda(noNodes1D, noNodes1D3, AT_, "maxLambda");
1479#else
1480 MFloatTensor maxLambda(noNodes1D, noNodes1D3);
1481#endif
1482
1483 // Calculate maximum eigenvalue
1484 for(MInt i = 0; i < noNodes1D; i++) {
1485 for(MInt j = 0; j < noNodes1D3; j++) {
1486 maxLambda(i, j) = std::max(fabs(nL(i, j, CV::UU0[dirId])) + nL(i, j, CV::C0),
1487 fabs(nR(i, j, CV::UU0[dirId])) + nR(i, j, CV::C0));
1488 }
1489 }
1490
1491#ifndef _OPENMP
1492 MFloatScratchSpace fluxL(noNodes1D, noNodes1D3, s_noVariables, AT_, "fluxL");
1493 MFloatScratchSpace fluxR(noNodes1D, noNodes1D3, s_noVariables, AT_, "fluxR");
1494#else
1495 MFloatTensor fluxL(noNodes1D, noNodes1D3, s_noVariables);
1496 MFloatTensor fluxR(noNodes1D, noNodes1D3, s_noVariables);
1497#endif
1498
1499 // Calculate flux from left and right state
1500 calcFlux1D(nodeVarsL, stateL, noNodes1D, dirId, &fluxL[0]);
1501 calcFlux1D(nodeVarsR, stateR, noNodes1D, dirId, &fluxR[0]);
1502
1503 // Solve Riemann problem
1504 MFloatTensor riemann(flux, noNodes1D, noNodes1D3, s_noVariables);
1505 for(MInt i = 0; i < noNodes1D; i++) {
1506 for(MInt j = 0; j < noNodes1D3; j++) {
1507 for(MInt n = 0; n < s_noVariables; n++) {
1508 riemann(i, j, n) = 0.5 * ((fluxL(i, j, n) + fluxR(i, j, n)) - maxLambda(i, j) * (uR(i, j, n) - uL(i, j, n)));
1509 }
1510 }
1511 }
1512}
void calcFlux1D(const MFloat *const nodeVars, const MFloat *const q, const MInt noNodes1D, const MInt dirId, MFloat *const flux) const
Calculates the physical fluxes in dimension dirId for all integrations points on an element face.
This class is a ScratchSpace.
Definition: scratch.h:758

◆ calcRiemannRoe() [1/3]

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcRiemannRoe ( const MFloat nodeVarsL,
const MFloat nodeVarsR,
const MFloat stateL,
const MFloat stateR,
const MInt  noNodes1D,
const MInt  dirId,
MFloat flux 
) const

◆ calcRiemannRoe() [2/3]

void DgSysEqnAcousticPerturb< 2 >::calcRiemannRoe ( const MFloat nodeVarsL,
const MFloat nodeVarsR,
const MFloat stateL,
const MFloat stateR,
const MInt  noNodes1D,
const MInt  dirId,
MFloat flux 
) const
inline

Definition at line 1532 of file dgcartesiansyseqnacousticperturb.h.

1538 {
1539 // TRACE();
1540
1541 const MInt nDim = 2;
1542 const MFloatTensor uL(const_cast<MFloat*>(stateL), noNodes1D, noVars());
1543 const MFloatTensor uR(const_cast<MFloat*>(stateR), noNodes1D, noVars());
1544 const MFloatTensor nL(const_cast<MFloat*>(nodeVarsL), noNodes1D, noNodeVars());
1545 const MFloatTensor nR(const_cast<MFloat*>(nodeVarsR), noNodes1D, noNodeVars());
1546 MFloatTensor f(flux, noNodes1D, s_noVariables);
1547
1548 // TODO labels:DG use node variables instead
1549 // Define mean flow constants
1550 const MFloat c = 1.0;
1551 const MFloat rho = 1.0;
1552
1553 // Normal direction
1554 const std::array<MInt, nDim> n = {{1 - dirId, dirId}};
1555
1556 // Characteristic boundary conditions
1557 for(MInt i = 0; i < noNodes1D; i++) {
1558 // FIXME labels:DG,totest The following is just a hack and probably does not work when the
1559 // Roe Riemann solver is used for internal fluxes
1560 // Determine mean flow
1561 const std::array<MFloat, nDim> meanVelocity = {
1562 {0.5 * (nL(i, CV::U0) + nR(i, CV::U0)), 0.5 * (nL(i, CV::V0) + nR(i, CV::V0))}};
1563
1564 // Mean flow matrix with simplified transformation matrix
1565 const std::array<MFloat, nDim> um = {
1566 {meanVelocity[0] * n[0] + meanVelocity[1] * n[1], -meanVelocity[0] * n[1] + meanVelocity[1] * n[0]}};
1567
1568 // stateL(vecL) and stateR(vecR) variables multiplied by transformation
1569 // matrix (see reference)
1570 const std::array<MFloat, nDim> vecL = {
1571 {uL(i, CV::UU[0]) * n[0] + uL(i, CV::UU[1]) * n[1], -uL(i, CV::UU[0]) * n[1] + uL(i, CV::UU[1]) * n[0]}};
1572 const std::array<MFloat, nDim> vecR = {
1573 {uR(i, CV::UU[0]) * n[0] + uR(i, CV::UU[1]) * n[1], -uR(i, CV::UU[0]) * n[1] + uR(i, CV::UU[1]) * n[0]}};
1574
1575 // Calculate characteristic waves
1576 // L1 and L2 composite from vecL and vecR
1577 const MFloat L1 = 0.5 * (uR(i, CV::P) + rho * c * (-vecR[0] + um[1] / (um[0] - c) * (-vecR[1])));
1578 const MFloat L2 = 0.5 * (uL(i, CV::P) + rho * c * (vecL[0] + um[1] / (um[0] + c) * vecL[1]));
1579
1580 // Calculate Riemann flux
1581 f(i, CV::P) = (um[0] - c) * (L1) + (um[0] + c) * (L2);
1582 f(i, CV::UU[0]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[0];
1583 f(i, CV::UU[1]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[1];
1584 }
1585}

◆ calcRiemannRoe() [3/3]

void DgSysEqnAcousticPerturb< 3 >::calcRiemannRoe ( const MFloat nodeVarsL,
const MFloat nodeVarsR,
const MFloat stateL,
const MFloat stateR,
const MInt  noNodes1D,
const MInt  dirId,
MFloat flux 
) const
inline

Definition at line 1606 of file dgcartesiansyseqnacousticperturb.h.

1612 {
1613 // TRACE();
1614
1615 const MInt nDim = 3;
1616 const MFloatTensor uL(const_cast<MFloat*>(stateL), noNodes1D, noNodes1D, noVars());
1617 const MFloatTensor uR(const_cast<MFloat*>(stateR), noNodes1D, noNodes1D, noVars());
1618 const MFloatTensor nL(const_cast<MFloat*>(nodeVarsL), noNodes1D, noNodes1D, noNodeVars());
1619 const MFloatTensor nR(const_cast<MFloat*>(nodeVarsR), noNodes1D, noNodes1D, noNodeVars());
1620 MFloatTensor f(flux, noNodes1D, noNodes1D, s_noVariables);
1621
1622 // TODO labels:DG use node variables instead
1623 // Define mean flow constants
1624 const MFloat c = 1.0;
1625 const MFloat rho = 1.0;
1626
1627 // Normal direction
1628 const std::array<MInt, nDim> n = {{dirId == 0 ? 1 : 0, dirId == 1 ? 1 : 0, dirId == 2 ? 1 : 0}};
1629
1630 // Characteristic boundary conditions
1631 // stateL and stateR multiplied by transformation matrix (see reference)
1632 for(MInt i = 0; i < noNodes1D; i++) {
1633 for(MInt j = 0; j < noNodes1D; j++) {
1634 // FIXME labels:DG,totest The following is just a hack and probably does not work when the
1635 // Roe Riemann solver is used for internal fluxes
1636 // Determine mean flow
1637 const std::array<MFloat, nDim> meanVelocity = {{0.5 * (nL(i, j, CV::U0) + nR(i, j, CV::U0)),
1638 0.5 * (nL(i, j, CV::V0) + nR(i, j, CV::V0)),
1639 0.5 * (nL(i, j, CV::W0) + nR(i, j, CV::W0))}};
1640
1641 // Mean flow matrix with transformation matrix (see ref.)
1642 const std::array<MFloat, nDim> um = {{meanVelocity[0] * n[0] + meanVelocity[1] * n[1] + meanVelocity[2] * n[2],
1643 meanVelocity[0] * n[1] + meanVelocity[1] * n[2] + meanVelocity[2] * n[0],
1644 meanVelocity[0] * n[2] + meanVelocity[1] * n[0] + meanVelocity[2] * n[1]}};
1645
1646 const std::array<MFloat, nDim> vecL = {
1647 {uL(i, j, CV::UU[0]) * n[0] + uL(i, j, CV::UU[1]) * n[1] + uL(i, j, CV::UU[2]) * n[2],
1648 uL(i, j, CV::UU[0]) * n[1] + uL(i, j, CV::UU[1]) * n[2] + uL(i, j, CV::UU[2]) * n[0],
1649 uL(i, j, CV::UU[0]) * n[2] + uL(i, j, CV::UU[1]) * n[0] + uL(i, j, CV::UU[2]) * n[1]}};
1650
1651 const std::array<MFloat, nDim> vecR = {
1652 {uR(i, j, CV::UU[0]) * n[0] + uR(i, j, CV::UU[1]) * n[1] + uR(i, j, CV::UU[2]) * n[2],
1653 uR(i, j, CV::UU[0]) * n[1] + uR(i, j, CV::UU[1]) * n[2] + uR(i, j, CV::UU[2]) * n[0],
1654 uR(i, j, CV::UU[0]) * n[2] + uR(i, j, CV::UU[1]) * n[0] + uR(i, j, CV::UU[2]) * n[1]}};
1655
1656 // Calculate characteristic waves
1657 // L1 and L2 composite from vecL and vecR
1658 const MFloat L1 =
1659 0.5
1660 * (uR(i, j, CV::P)
1661 + rho * c * (-vecL[0] + um[1] / (um[0] - c) * (-vecL[1]) + um[2] / (um[0] - c) * (-vecL[2])));
1662 const MFloat L2 =
1663 0.5
1664 * (uL(i, j, CV::P) + rho * c * (vecR[0] + um[1] / (um[0] + c) * vecR[1] + um[2] / (um[0] + c) * (vecR[2])));
1665 // Calculate Riemann flux
1666 f(i, j, CV::P) = (um[0] - c) * (L1) + (um[0] + c) * (L2);
1667 f(i, j, CV::UU[0]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[0];
1668 f(i, j, CV::UU[1]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[1];
1669 f(i, j, CV::UU[2]) = 1 / rho / c * (-1 * ((um[0] - c) * L1) + ((um[0] + c) * L2)) * n[2];
1670 }
1671 }
1672}

◆ calcSource()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcSource ( const MFloat *const  nodeVars,
const MFloat *const  u,
const MInt  noNodes1D,
const MFloat  t,
const MFloat *const  x,
MFloat *const  src 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]uPointer to solution variables (size: noNodes1D^nDim*noVars)).
[in]noNodes1Din the cell.
[in]tCurrent time.
[in]xCoordinates of the integration points of the current cell.
[out]srcPointer to where source terms are stored (size: noNodes1D^nDim*noVars)).

Definition at line 978 of file dgcartesiansyseqnacousticperturb.h.

◆ calcSpongeSource()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::calcSpongeSource ( const MFloat nodeVars,
const MFloat u,
const MInt  noNodes1D,
const MFloat eta,
MFloat src 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]nodeVarsPointer to node variables (size: noNodes1D^nDim*noNodeVars)
[in]uPointer to solution variables (size: noNodes1D^nDim*noVars)).
[in]noNodes1Din the cell.
[in]etaPointer to eta used for the sponge calculations.
[out]srcPointer to where source terms are stored (size: noNodes1D^nDim*noVars)).

Definition at line 1328 of file dgcartesiansyseqnacousticperturb.h.

1329 {
1330 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1331
1332 // gamma = heat capacity ratio for monoatomic gas
1333 MFloat gammaMinusOne = 5.0 / 3.0 - 1.0;
1334 MFloat FgammaMinusOne = 1.0 / gammaMinusOne;
1335
1336 const MFloatTensor spongeEta(const_cast<MFloat*>(eta), noNodes1D, noNodes1D, noNodes1D3);
1337 MFloatTensor uState(const_cast<MFloat*>(u), noNodes1D, noNodes1D, noNodes1D3, s_noVariables);
1338 MFloatTensor spongeSource(src, noNodes1D, noNodes1D, noNodes1D3, s_noVariables);
1339
1340 for(MInt i = 0; i < noNodes1D; i++) {
1341 for(MInt j = 0; j < noNodes1D; j++) {
1342 for(MInt k = 0; k < noNodes1D3; k++) {
1343 MFloat deltaP = (m_spongePressureInfy - uState(i, j, k, CV::P)) * FgammaMinusOne;
1344
1345 spongeSource(i, j, k, CV::P) = m_spongeSigma * spongeEta(i, j, k) * deltaP;
1346 for(MInt l = 0; l < nDim; l++) {
1347 spongeSource(i, j, k, CV::UU[l]) = 0.0;
1348 }
1349 }
1350 }
1351 }
1352}

◆ cflFactor()

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::cflFactor ( const MInt  polyDeg) const
private

Yield an empirically-derived maximum stable CFL number. The user should be able to specify a CFL number of "1.0" in virtually all cases.

Author
Rodrigo Miguez (rodrigo) rodri.nosp@m.go.m.nosp@m.iguez.nosp@m.@rwt.nosp@m.h-aac.nosp@m.hen..nosp@m.de
Date
2018-02-28
Parameters
[in]polyDegPolynomial degree in the cell.
[out]cflfactor obtained from m_cflFactor.

Definition at line 942 of file dgcartesiansyseqnacousticperturb.h.

942 {
943 if(polyDeg > s_maxPolyDeg) {
944 TERMM(1, "Polynomial degree exceeds maximum supported");
945 }
946 // Note: The factor "0.95" is used to avoid numerical instabilities when using the full
947 // cfl factor value.
948
949 const MFloat factor = 0.95 * m_cflFactor[nDim - 2][polyDeg];
950
951 return factor;
952}
std::array< std::array< MFloat, s_maxPolyDeg+1 >, 2 > m_cflFactor

◆ consToPrim()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::consToPrim ( const MFloat cons,
MFloat prim 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]consConservative variable storage (size: noVars).
[out]primPrimitive variable storage (size: noVars).

Definition at line 1686 of file dgcartesiansyseqnacousticperturb.h.

1686 {
1687 // Very easy...
1688 std::copy(cons, cons + s_noVariables, prim);
1689}

◆ extendNodeVar()

template<MInt nDim>
MBool DgSysEqnAcousticPerturb< nDim >::extendNodeVar ( const MInt  varId) const

Definition at line 1744 of file dgcartesiansyseqnacousticperturb.h.

1744 {
1745 // Do not extend...
1746 if(varId == CV::C0) return false; // mean speed of sound ...
1747 for(MInt i = 0; i < nDim; i++) {
1748 if(varId == CV::DC0[i]) { // and its derivatives
1749 return false;
1750 }
1751 }
1752 return true;
1753}
static constexpr const MInt DC0[nDim]

◆ getDefaultNodeVars()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::getDefaultNodeVars ( MFloat *const  nodeVars) const
Author
Ansgar Niemoeller (ansgar) a.nie.nosp@m.moel.nosp@m.ler@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2016-07-30
Parameters
[out]nodeVarsContains the default node variables ordered by CV.

Definition at line 1716 of file dgcartesiansyseqnacousticperturb.h.

1716 {
1717 // Mean velocities
1718 std::copy_n(std::begin(m_meanVelocity), nDim, &nodeVars[CV::UU0[0]]);
1719 // Mean density
1720 nodeVars[CV::RHO0] = m_meanDensity;
1721 // Mean speed of sound
1722 nodeVars[CV::C0] = m_meanSpeedOfSound;
1723 // Derivatives of mean speed of sound, always zero
1724 std::fill_n(&nodeVars[CV::DC0[0]], nDim, 0.0);
1725}
std::array< MFloat, nDim > m_meanVelocity

◆ getDefaultNodeVarsBody()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::getDefaultNodeVarsBody ( MFloat *const  nodeVars) const

Definition at line 1730 of file dgcartesiansyseqnacousticperturb.h.

1730 {
1731 // Mean velocities
1732 std::fill_n(&nodeVars[CV::UU0[0]], nDim, 0.0);
1733 // Mean density
1734 nodeVars[CV::RHO0] = m_meanDensity;
1735 // Mean speed of sound
1736 nodeVars[CV::C0] = m_meanSpeedOfSound;
1737 // Derivatives of mean speed of sound, always zero
1738 std::fill_n(&nodeVars[CV::DC0[0]], nDim, 0.0);
1739}

◆ getTimeStep()

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::getTimeStep ( const MFloat nodeVars,
const MFloat *const  u,
const MInt  noNodes1D,
const MFloat  invJacobian,
const MInt  sbpMode 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]uPointer to element variables.
[in]noNodes1DCurrent number of nodes 1D.
[in]invJacobianInverse Jacobian of element.
Returns
Calculated time step for the element.

Definition at line 1368 of file dgcartesiansyseqnacousticperturb.h.

1372 {
1373 // TRACE();
1374
1375 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
1376 const MFloat inf = std::numeric_limits<MFloat>::infinity();
1377 const MFloatTensor U0(const_cast<MFloat*>(nodeVars), noNodes1D, noNodes1D, noNodes1D3, s_noNodeVars);
1378
1379 MFloat maxLambda[] = {-inf, -inf, -inf};
1380 for(MInt i = 0; i < noNodes1D; i++) {
1381 for(MInt j = 0; j < noNodes1D; j++) {
1382 for(MInt k = 0; k < noNodes1D3; k++) {
1383 for(MInt d = 0; d < nDim; d++) {
1384 maxLambda[d] = std::max(maxLambda[d], fabs(U0(i, j, k, CV::UU0[d])) + U0(i, j, k, CV::C0));
1385 }
1386 }
1387 }
1388 }
1389
1390 MFloat dt;
1391 if(sbpMode) {
1392 dt = this->cfl() * F2 / (invJacobian * std::accumulate(&maxLambda[0], &maxLambda[0] + nDim, F0) * (noNodes1D - 1));
1393 } else {
1394 const MInt polyDeg = noNodes1D - 1;
1395 dt = this->cflScaled(polyDeg) * cflFactor(polyDeg) * F2
1396 / (invJacobian * std::accumulate(&maxLambda[0], &maxLambda[0] + nDim, F0));
1397 }
1398 return dt;
1399}
MFloat cflFactor(const MInt polyDeg) const

◆ primToCons()

template<MInt nDim>
void DgSysEqnAcousticPerturb< nDim >::primToCons ( const MFloat prim,
MFloat cons 
) const
Author
Michael Schlottke (mic) mic@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2013-04-18
Parameters
[in]primPrimitive variable storage (size: noVars).
[out]consConservative variable storage (size: noVars).

Definition at line 1703 of file dgcartesiansyseqnacousticperturb.h.

1703 {
1704 // Very easy...
1705 std::copy(prim, prim + s_noVariables, cons);
1706}

◆ s_consVarNames() [1/2]

const MString DgSysEqnAcousticPerturb< 2 >::s_consVarNames
private

Definition at line 10 of file dgcartesiansyseqnacousticperturb.cpp.

◆ s_consVarNames() [2/2]

const MString DgSysEqnAcousticPerturb< 3 >::s_consVarNames
private

Definition at line 16 of file dgcartesiansyseqnacousticperturb.cpp.

◆ s_nodeVarNames() [1/2]

const MString DgSysEqnAcousticPerturb< 2 >::s_nodeVarNames
private

Definition at line 14 of file dgcartesiansyseqnacousticperturb.cpp.

◆ s_nodeVarNames() [2/2]

const MString DgSysEqnAcousticPerturb< 3 >::s_nodeVarNames
private

Definition at line 20 of file dgcartesiansyseqnacousticperturb.cpp.

◆ s_primVarNames() [1/2]

const MString DgSysEqnAcousticPerturb< 2 >::s_primVarNames
private

Definition at line 12 of file dgcartesiansyseqnacousticperturb.cpp.

◆ s_primVarNames() [2/2]

const MString DgSysEqnAcousticPerturb< 3 >::s_primVarNames
private

Definition at line 18 of file dgcartesiansyseqnacousticperturb.cpp.

Friends And Related Function Documentation

◆ DgSysEqn< nDim, DgSysEqnAcousticPerturb >

template<MInt nDim>
friend class DgSysEqn< nDim, DgSysEqnAcousticPerturb >
friend

Definition at line 1744 of file dgcartesiansyseqnacousticperturb.h.

Member Data Documentation

◆ m_cflFactor

template<MInt nDim>
std::array<std::array<MFloat, s_maxPolyDeg + 1>, 2> DgSysEqnAcousticPerturb< nDim >::m_cflFactor
private

Definition at line 85 of file dgcartesiansyseqnacousticperturb.h.

◆ m_compressibleSourceTerm

template<MInt nDim>
MBool DgSysEqnAcousticPerturb< nDim >::m_compressibleSourceTerm = true
private

Definition at line 81 of file dgcartesiansyseqnacousticperturb.h.

◆ m_constantSpeedOfSound

template<MInt nDim>
MBool DgSysEqnAcousticPerturb< nDim >::m_constantSpeedOfSound = false
private

Definition at line 78 of file dgcartesiansyseqnacousticperturb.h.

◆ m_dgIntegrationMethod

template<MInt nDim>
MString DgSysEqnAcousticPerturb< nDim >::m_dgIntegrationMethod
private

Definition at line 82 of file dgcartesiansyseqnacousticperturb.h.

◆ m_dgTimeIntegrationScheme

template<MInt nDim>
MInt DgSysEqnAcousticPerturb< nDim >::m_dgTimeIntegrationScheme
private

Definition at line 83 of file dgcartesiansyseqnacousticperturb.h.

◆ m_meanDensity

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::m_meanDensity
private

Definition at line 76 of file dgcartesiansyseqnacousticperturb.h.

◆ m_meanSpeedOfSound

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::m_meanSpeedOfSound
private

Definition at line 77 of file dgcartesiansyseqnacousticperturb.h.

◆ m_meanVelocity

template<MInt nDim>
std::array<MFloat, nDim> DgSysEqnAcousticPerturb< nDim >::m_meanVelocity
private

Definition at line 75 of file dgcartesiansyseqnacousticperturb.h.

◆ m_spongePressureInfy

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::m_spongePressureInfy
private

Definition at line 79 of file dgcartesiansyseqnacousticperturb.h.

◆ m_spongeSigma

template<MInt nDim>
MFloat DgSysEqnAcousticPerturb< nDim >::m_spongeSigma
private

Definition at line 80 of file dgcartesiansyseqnacousticperturb.h.

◆ s_consVarNames

template<MInt nDim>
const MString DgSysEqnAcousticPerturb< nDim >::s_consVarNames[s_noVariables]
staticprivate

Definition at line 67 of file dgcartesiansyseqnacousticperturb.h.

◆ s_hasTimeDependentNodeVars

template<MInt nDim>
const MBool DgSysEqnAcousticPerturb< nDim >::s_hasTimeDependentNodeVars = false
staticprivate

Definition at line 72 of file dgcartesiansyseqnacousticperturb.h.

◆ s_maxPolyDeg

template<MInt nDim>
const MInt DgSysEqnAcousticPerturb< nDim >::s_maxPolyDeg = 31
staticprivate

Definition at line 84 of file dgcartesiansyseqnacousticperturb.h.

◆ s_nodeVarNames

template<MInt nDim>
const MString DgSysEqnAcousticPerturb< nDim >::s_nodeVarNames[s_noNodeVars]
staticprivate

Definition at line 73 of file dgcartesiansyseqnacousticperturb.h.

◆ s_noNodeVars

template<MInt nDim>
const MInt DgSysEqnAcousticPerturb< nDim >::s_noNodeVars = 2 * nDim + 2
staticprivate

Definition at line 71 of file dgcartesiansyseqnacousticperturb.h.

◆ s_noVariables

template<MInt nDim>
const MInt DgSysEqnAcousticPerturb< nDim >::s_noVariables = nDim + 1
staticprivate

Definition at line 66 of file dgcartesiansyseqnacousticperturb.h.

◆ s_primVarNames

template<MInt nDim>
const MString DgSysEqnAcousticPerturb< nDim >::s_primVarNames[s_noVariables]
staticprivate

Definition at line 68 of file dgcartesiansyseqnacousticperturb.h.

◆ s_sysEqnName

template<MInt nDim>
const MString DgSysEqnAcousticPerturb< nDim >::s_sysEqnName = "DG_SYSEQN_ACOUSTICPERTURB"
staticprivate

Definition at line 64 of file dgcartesiansyseqnacousticperturb.h.


The documentation for this class was generated from the following file: