Nektar++
PulseWaveSystem.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: PulseWaveSystem.h
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: Generic timestepping for PulseWaveSolver
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERS_PULSEWAVESOLVER_EQUATIONSYSTEMS_PULSEWAVESYSTEM_H
37 #define NEKTAR_SOLVERS_PULSEWAVESOLVER_EQUATIONSYSTEMS_PULSEWAVESYSTEM_H
38 
41 
42 using namespace Nektar::SolverUtils;
43 
44 namespace Nektar
45 {
46 
48 {
49  eNotSetPulse, ///< flux not defined
50  eUpwindPulse, ///< simple upwinding scheme
51  SIZE_UpwindTypePulse ///< Length of enum list
52 };
53 
54 const char *const UpwindTypeMapPulse[] = {
55  "NoSetPulse",
56  "UpwindPulse",
57 };
58 
60 {
61  InterfacePoint(const int vid, const int domain, const int elmt,
62  const int elmtVert, const int traceId, const int bcpos)
63  : m_vid(vid), m_domain(domain), m_elmt(elmt), m_elmtVert(elmtVert),
64  m_traceId(traceId), m_bcPosition(bcpos){};
65  int m_vid; // Global Vid of interface point
66  int m_domain; // domain interface point belongs to
67  int m_elmt; // element id of vertex
68  int m_elmtVert; // vertex id within local element
69  int m_traceId; // Element id within the trace
70  int m_bcPosition; // Position of boundary condition in region
71  int m_riemannOrd; // order of point in Riemann solve
72 };
73 
74 typedef std::shared_ptr<InterfacePoint> InterfacePointShPtr;
75 
76 /// Base class for unsteady solvers.
78 {
79 public:
80  /// Destructor
81  virtual ~PulseWaveSystem();
82 
84  {
85  return m_nDomains;
86  }
87 
89  {
90  return m_vessels;
91  }
92 
93 protected:
95  size_t m_nDomains;
97  size_t m_nVariables;
99 
103 
107 
116 
117  // keep local copy so can be reordered in parallle
118  std::map<int, SpatialDomains::CompositeMap> m_domain;
119  std::vector<int> m_domOrder;
120 
123 
124  // Extra Fields
125  bool extraFields = false;
129 
130  std::vector<std::vector<InterfacePointShPtr>> m_vesselIntfcs;
131  std::vector<std::vector<InterfacePointShPtr>> m_bifurcations;
132  std::vector<std::vector<InterfacePointShPtr>> m_mergingJcts;
133 
134  /// Initialises PulseWaveSystem class members.
136  const SpatialDomains::MeshGraphSharedPtr &pGraph);
137 
138  virtual void v_InitObject(bool DeclareField = false) override;
139 
140  /// Sets up initial conditions.
141  virtual void v_DoInitialise() override;
142 
143  /// Solves an unsteady problem.
144  virtual void v_DoSolve() override;
145 
146  /// Links the subdomains
149 
150  /// Riemann Problem for Bifurcation
151  void BifurcationRiemann(Array<OneD, NekDouble> &Au,
155  Array<OneD, NekDouble> &alpha);
156 
157  /// Riemann Problem for Merging Flow
158  void MergingRiemann(Array<OneD, NekDouble> &Au, Array<OneD, NekDouble> &uu,
161  Array<OneD, NekDouble> &alpha);
162 
163  /// Riemann Problem for Interface/Junction
164  void InterfaceRiemann(Array<OneD, NekDouble> &Au,
168  Array<OneD, NekDouble> &alpha);
169 
170  // Ouptut field information
171  virtual void v_Output(void) override;
172 
173  // Checkpoint field output
174  void CheckPoint_Output(const int n);
175 
176  /// Compute the L2 error between fields and a given exact solution.
177  virtual NekDouble v_L2Error(
178  unsigned int field,
179  const Array<OneD, NekDouble> &exactsoln = NullNekDouble1DArray,
180  bool Normalised = false) override;
181 
182  /// Compute the L_inf error between fields and a given exact solution.
183  virtual NekDouble v_LinfError(unsigned int field,
184  const Array<OneD, NekDouble> &exactsoln =
185  NullNekDouble1DArray) override;
186 
187  /// Write input fields to the given filename.
188  void WriteVessels(const std::string &outname);
189 
190  void EnforceInterfaceConditions(
191  const Array<OneD, const Array<OneD, NekDouble>> &fields);
192 
193 private:
194  /// Communicator for interfaces
196 
197  void SetUpDomainInterfaces(void);
198  void FillDataFromInterfacePoint(
200  const Array<OneD, const Array<OneD, NekDouble>> &field, NekDouble &A,
201  NekDouble &u, NekDouble &beta, NekDouble &A_0, NekDouble &alpha);
202 
203  /// Set and retrn a series of communicators for each partition
204  void GetCommArray(std::map<int, LibUtilities::CommSharedPtr> &retval);
205 
206  void SetUpDomainInterfaceBCs(
208  std::map<int, LibUtilities::CommSharedPtr> &domComm);
209 };
210 
211 typedef std::shared_ptr<PulseWaveSystem> PulseWaveSystemSharedPtr;
212 } // namespace Nektar
213 
214 #endif
Base class for unsteady solvers.
Array< OneD, Array< OneD, NekDouble > > m_A_0
Array< OneD, int > m_fieldPhysOffset
Array< OneD, Array< OneD, NekDouble > > m_beta_trace
void LinkSubdomains(Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &fields)
Links the subdomains.
Array< OneD, Array< OneD, NekDouble > > m_W2
Array< OneD, Array< OneD, NekDouble > > m_trace_fwd_normal
PulseWavePressureAreaSharedPtr m_pressureArea
Array< OneD, MultiRegions::ExpListSharedPtr > UpdateVessels(void)
Array< OneD, Array< OneD, NekDouble > > m_W1
std::vector< int > m_domOrder
Array< OneD, Array< OneD, NekDouble > > m_alpha_trace
std::map< int, SpatialDomains::CompositeMap > m_domain
UpwindTypePulse m_upwindTypePulse
Array< OneD, Array< OneD, NekDouble > > m_A_0_trace
Array< OneD, Array< OneD, NekDouble > > m_pressure
Array< OneD, Array< OneD, NekDouble > > m_gamma
Array< OneD, Array< OneD, NekDouble > > m_alpha
Gs::gs_data * m_intComm
Communicator for interfaces.
std::vector< std::vector< InterfacePointShPtr > > m_vesselIntfcs
Array< OneD, Array< OneD, NekDouble > > m_PWV
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
std::vector< std::vector< InterfacePointShPtr > > m_bifurcations
std::vector< std::vector< InterfacePointShPtr > > m_mergingJcts
Array< OneD, Array< OneD, NekDouble > > m_beta
Base class for unsteady solvers.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:61
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
std::shared_ptr< InterfacePoint > InterfacePointShPtr
std::shared_ptr< PulseWaveSystem > PulseWaveSystemSharedPtr
@ eUpwindPulse
simple upwinding scheme
@ eNotSetPulse
flux not defined
@ SIZE_UpwindTypePulse
Length of enum list.
const char *const UpwindTypeMapPulse[]
static Array< OneD, NekDouble > NullNekDouble1DArray
double NekDouble
InterfacePoint(const int vid, const int domain, const int elmt, const int elmtVert, const int traceId, const int bcpos)