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