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 
38 namespace 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  const int nDim, const Array<OneD, const Array<OneD, NekDouble>> &Fwd,
58  const Array<OneD, const Array<OneD, NekDouble>> &Bwd,
60 {
61  int i;
62  int nTracePts = Fwd[0].size();
63 
64  ASSERTL1(CheckScalars("A0"), "A0 not defined.");
65  const Array<OneD, NekDouble> &A0 = m_scalars["A0"]();
66 
67  ASSERTL1(CheckScalars("beta"), "beta not defined.");
68  const Array<OneD, NekDouble> &beta = m_scalars["beta"]();
69 
70  const Array<OneD, NekDouble> &alpha = m_scalars["alpha"]();
71 
72  ASSERTL1(CheckScalars("N"), "N not defined.");
73  const Array<OneD, NekDouble> &N = m_scalars["N"]();
74 
75  for (i = 0; i < nTracePts; ++i)
76  {
77  RiemannSolverUpwind(Fwd[0][i], Fwd[1][i], Bwd[0][i], Bwd[1][i],
78  flux[0][i], flux[1][i], A0[i], beta[i], N[i], alpha[i]);
79  }
80 }
81 
82 /**
83  * Riemann solver for upwinding at an interface between two
84  * elements. Uses the characteristic variables for calculating
85  * the upwinded state \f$(A_u, u_u)\f$ from the left
86  * \f$(A_L, u_L)\f$ and right state \f$(A_R, u_R)\f$. Returns the
87  * upwinded flux $\mathbf{F}^u$ needed for the weak formulation
88  * (1). Details can be found in "Pulse wave propagation in the
89  * human vascular system", section 3.3
90  *
91  */
93  NekDouble AR, NekDouble uR,
94  NekDouble &Aflux, NekDouble &uflux,
95  NekDouble A0, NekDouble beta,
96  NekDouble n, NekDouble alpha)
97 {
98  NekDouble W1 = 0.0;
99  NekDouble W2 = 0.0;
100  NekDouble IL = 0.0;
101  NekDouble IR = 0.0;
102  NekDouble Au = 0.0;
103  NekDouble uu = 0.0;
104  NekDouble cL = 0.0;
105  NekDouble cR = 0.0;
106  NekDouble P = 0.0;
107 
108  ASSERTL1(CheckParams("rho"), "rho not defined.");
109  NekDouble rho = m_params["rho"]();
110  NekDouble nDomains = m_params["domains"]();
111 
112  m_nVariables = m_session->GetVariables().size();
113 
114  m_vessels =
116 
117  if (m_session->DefinesSolverInfo("PressureArea"))
118  {
120  m_session->GetSolverInfo("PressureArea"), m_vessels, m_session);
121  }
122  else
123  {
126  }
127 
128  // Compute the wave speeds to check dynamics are sub-sonic
129  m_pressureArea->GetC(cL, beta, AL, A0, alpha);
130  m_pressureArea->GetC(cR, beta, AR, A0, alpha);
131  ASSERTL1(fabs(cL + cR) > fabs(uL + uR), "Conditions are not sub-sonic");
132 
133  /*
134  Calculate the characteristics. The use of the normal here allows
135  for the definition of the characteristics (and hence the left
136  and right state) to be inverted if n is in the -ve
137  x-direction. This means we end up with the positive
138  defintion of the flux which has to therefore be multiplied
139  by the normal at the end of the method. This is a bit of a
140  mind twister but is efficient from a coding perspective.
141  */
142  m_pressureArea->GetCharIntegral(IL, beta, AL, A0, alpha);
143  m_pressureArea->GetCharIntegral(IR, beta, AR, A0, alpha);
144  W1 = uL + n * IL;
145  W2 = uR - n * IR;
146 
147  // Calculate conservative variables from characteristics
148  m_pressureArea->GetAFromChars(Au, n * W1, n * W2, beta, A0, alpha);
149  m_pressureArea->GetUFromChars(uu, W1, W2);
150 
151  // Pressure for the energy flux
152  m_pressureArea->GetPressure(P, beta, Au, A0, 0, 0, alpha);
153 
154  // Compute the fluxes multiplied by the normal
155  Aflux = Au * uu * n;
156  uflux = (uu * uu / 2 + P / rho) * n;
157 }
158 
159 } // namespace Nektar
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:145
The RiemannSolver class provides an abstract interface under which solvers for various Riemann proble...
Definition: RiemannSolver.h:62
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
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)
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)
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
std::shared_ptr< SessionReader > SessionReaderSharedPtr
RiemannSolverFactory & GetRiemannSolverFactory()
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
PressureAreaFactory & GetPressureAreaFactory()
double NekDouble
P
Definition: main.py:133