Nektar++
UpwindPulseSolver.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: UpwindPulseSolver.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// License for the specific language governing rights and limitations under
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included
22// in all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32// Description: Upwind pulse Riemann solver.
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
38namespace Nektar
39{
42 "UpwindPulse", UpwindPulseSolver::create, "UpwindPulseSolver");
43
46 : RiemannSolver(pSession), m_session(pSession)
47{
48}
49
50/**
51 * Calculates the third term of the weak form (1): numerical flux
52 * at boundary \f$ \left[ \mathbf{\psi}^{\delta} \cdot \{
53 * \mathbf{F}^u - \mathbf{F}(\mathbf{U}^{\delta}) \}
54 * \right]_{x_e^l}^{x_eû} \f$
55 */
57 [[maybe_unused]] const int nDim,
58 const Array<OneD, const Array<OneD, NekDouble>> &Fwd,
59 const Array<OneD, const Array<OneD, NekDouble>> &Bwd,
61{
62 int i;
63 int nTracePts = Fwd[0].size();
64
65 ASSERTL1(CheckScalars("A0"), "A0 not defined.");
66 const Array<OneD, NekDouble> &A0 = m_scalars["A0"]();
67
68 ASSERTL1(CheckScalars("beta"), "beta not defined.");
69 const Array<OneD, NekDouble> &beta = m_scalars["beta"]();
70
71 const Array<OneD, NekDouble> &alpha = m_scalars["alpha"]();
72
73 ASSERTL1(CheckScalars("N"), "N not defined.");
74 const Array<OneD, NekDouble> &N = m_scalars["N"]();
75
76 for (i = 0; i < nTracePts; ++i)
77 {
78 RiemannSolverUpwind(Fwd[0][i], Fwd[1][i], Bwd[0][i], Bwd[1][i],
79 flux[0][i], flux[1][i], A0[i], beta[i], N[i],
80 alpha[i]);
81 }
82}
83
84/**
85 * Riemann solver for upwinding at an interface between two
86 * elements. Uses the characteristic variables for calculating
87 * the upwinded state \f$(A_u, u_u)\f$ from the left
88 * \f$(A_L, u_L)\f$ and right state \f$(A_R, u_R)\f$. Returns the
89 * upwinded flux $\mathbf{F}^u$ needed for the weak formulation
90 * (1). Details can be found in "Pulse wave propagation in the
91 * human vascular system", section 3.3
92 *
93 */
95 NekDouble AR, NekDouble uR,
96 NekDouble &Aflux, NekDouble &uflux,
98 NekDouble n, NekDouble alpha)
99{
100 NekDouble W1 = 0.0;
101 NekDouble W2 = 0.0;
102 NekDouble IL = 0.0;
103 NekDouble IR = 0.0;
104 NekDouble Au = 0.0;
105 NekDouble uu = 0.0;
106 NekDouble cL = 0.0;
107 NekDouble cR = 0.0;
108 NekDouble P = 0.0;
109
110 ASSERTL1(CheckParams("rho"), "rho not defined.");
111 NekDouble rho = m_params["rho"]();
112 NekDouble nDomains = m_params["domains"]();
113
114 m_nVariables = m_session->GetVariables().size();
115
116 m_vessels =
118
119 if (m_session->DefinesSolverInfo("PressureArea"))
120 {
122 m_session->GetSolverInfo("PressureArea"), m_vessels, m_session);
123 }
124 else
125 {
127 "Beta", m_vessels, m_session);
128 }
129
130 // Compute the wave speeds to check dynamics are sub-sonic
131 m_pressureArea->GetC(cL, beta, AL, A0, alpha);
132 m_pressureArea->GetC(cR, beta, AR, A0, alpha);
133 ASSERTL1(fabs(cL + cR) > fabs(uL + uR), "Conditions are not sub-sonic");
134
135 /*
136 Calculate the characteristics. The use of the normal here allows
137 for the definition of the characteristics (and hence the left
138 and right state) to be inverted if n is in the -ve
139 x-direction. This means we end up with the positive
140 defintion of the flux which has to therefore be multiplied
141 by the normal at the end of the method. This is a bit of a
142 mind twister but is efficient from a coding perspective.
143 */
144 m_pressureArea->GetCharIntegral(IL, beta, AL, A0, alpha);
145 m_pressureArea->GetCharIntegral(IR, beta, AR, A0, alpha);
146 W1 = uL + n * IL;
147 W2 = uR - n * IR;
148
149 // Calculate conservative variables from characteristics
150 m_pressureArea->GetAFromChars(Au, n * W1, n * W2, beta, A0, alpha);
151 m_pressureArea->GetUFromChars(uu, W1, W2);
152
153 // Pressure for the energy flux
154 m_pressureArea->GetPressure(P, beta, Au, A0, 0, 0, alpha);
155
156 // Compute the fluxes multiplied by the normal
157 Aflux = Au * uu * n;
158 uflux = (uu * uu / 2 + P / rho) * n;
159}
160
161} // namespace Nektar
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:143
The RiemannSolver class provides an abstract interface under which solvers for various Riemann proble...
Definition: RiemannSolver.h:58
SOLVER_UTILS_EXPORT bool CheckParams(std::string name)
Determine whether a parameter has been defined in m_params.
SOLVER_UTILS_EXPORT bool CheckScalars(std::string name)
Determine whether a scalar has been defined in m_scalars.
std::map< std::string, RSScalarFuncType > m_scalars
Map of scalar function types.
std::map< std::string, RSParamFuncType > m_params
Map of parameter function types.
LibUtilities::SessionReaderSharedPtr m_session
static std::string solverName
void RiemannSolverUpwind(NekDouble AL, NekDouble uL, NekDouble AR, NekDouble uR, NekDouble &Aflux, NekDouble &uflux, NekDouble A0, NekDouble beta, NekDouble n, NekDouble alpha=0.5)
UpwindPulseSolver(const LibUtilities::SessionReaderSharedPtr &pSession)
PulseWavePressureAreaSharedPtr m_pressureArea
static RiemannSolverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
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) override
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:59
@ P
Monomial polynomials .
Definition: BasisType.h:62
RiemannSolverFactory & GetRiemannSolverFactory()
PressureAreaFactory & GetPressureAreaFactory()
double NekDouble