Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RiemannSolver.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: RiemannSolver.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: Abstract base class for Riemann solvers with factory.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERUTILS_RIEMANNSOLVER
37 #define NEKTAR_SOLVERUTILS_RIEMANNSOLVER
38 
42 
43 #include <string>
44 
45 #include <boost/function.hpp>
46 #include <boost/call_traits.hpp>
47 
48 namespace Nektar
49 {
50  template <typename Dim, typename DataType>
51  class Array;
52 
53  namespace SolverUtils
54  {
55  typedef boost::function<
56  const Array<OneD, const NekDouble>& ()> RSScalarFuncType;
57  typedef boost::function<
58  const Array<OneD, const Array<OneD, NekDouble> >& ()> RSVecFuncType;
59  typedef boost::function<
61 
63  {
64  public:
66  const int nDim,
67  const Array<OneD, const Array<OneD, NekDouble> > &Fwd,
68  const Array<OneD, const Array<OneD, NekDouble> > &Bwd,
69  Array<OneD, Array<OneD, NekDouble> > &flux);
70 
71  template<typename FuncPointerT, typename ObjectPointerT>
72  void SetScalar(std::string name,
73  FuncPointerT func,
74  ObjectPointerT obj)
75  {
76  m_scalars[name] = boost::bind(func, obj);
77  }
78 
79  void SetScalar(std::string name, RSScalarFuncType fp)
80  {
81  m_scalars[name] = fp;
82  }
83 
84  template<typename FuncPointerT, typename ObjectPointerT>
85  void SetVector(std::string name,
86  FuncPointerT func,
87  ObjectPointerT obj)
88  {
89  m_vectors[name] = boost::bind(func, obj);
90  }
91 
92  void SetVector(std::string name, RSVecFuncType fp)
93  {
94  m_vectors[name] = fp;
95  }
96 
97  template<typename FuncPointerT, typename ObjectPointerT>
98  void SetParam(std::string name,
99  FuncPointerT func,
100  ObjectPointerT obj)
101  {
102  m_params[name] = boost::bind(func, obj);
103  }
104 
105  void SetParam(std::string name, RSParamFuncType fp)
106  {
107  m_params[name] = fp;
108  }
109 
110  template<typename FuncPointerT, typename ObjectPointerT>
111  void SetAuxScal(std::string name,
112  FuncPointerT func,
113  ObjectPointerT obj)
114  {
115  m_auxScal[name] = boost::bind(func, obj);
116  }
117 
118  template<typename FuncPointerT, typename ObjectPointerT>
119  void SetAuxVec(std::string name,
120  FuncPointerT func,
121  ObjectPointerT obj)
122  {
123  m_auxVec[name] = boost::bind(func, obj);
124  }
125 
126  std::map<std::string, RSScalarFuncType> &GetScalars()
127  {
128  return m_scalars;
129  }
130 
131  std::map<std::string, RSVecFuncType> &GetVectors()
132  {
133  return m_vectors;
134  }
135 
136  std::map<std::string, RSParamFuncType> &GetParams()
137  {
138  return m_params;
139  }
140 
142 
143  protected:
144  /// Indicates whether the Riemann solver requires a rotation to be
145  /// applied to the velocity fields.
147  /// Map of scalar function types.
148  std::map<std::string, RSScalarFuncType> m_scalars;
149  /// Map of vector function types.
150  std::map<std::string, RSVecFuncType> m_vectors;
151  /// Map of parameter function types.
152  std::map<std::string, RSParamFuncType > m_params;
153  /// Map of auxiliary scalar function types.
154  std::map<std::string, RSScalarFuncType> m_auxScal;
155  /// Map of auxiliary vector function types.
156  std::map<std::string, RSVecFuncType> m_auxVec;
157  /// Rotation matrices for each trace quadrature point.
158  Array<OneD, Array<OneD, NekDouble> > m_rotMat;
159  /// Rotation storage
160  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > m_rotStorage;
161 
163 
164  virtual void v_Solve(
165  const int nDim,
166  const Array<OneD, const Array<OneD, NekDouble> > &Fwd,
167  const Array<OneD, const Array<OneD, NekDouble> > &Bwd,
168  Array<OneD, Array<OneD, NekDouble> > &flux) = 0;
169 
171  const Array<OneD, const Array<OneD, NekDouble> > &normals);
172  void FromToRotation(
173  Array<OneD, const NekDouble> &from,
174  Array<OneD, const NekDouble> &to,
175  NekDouble *mat);
177  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
178  const Array<OneD, const Array<OneD, NekDouble> > &normals,
179  const Array<OneD, const Array<OneD, NekDouble> > &vecLocs,
180  Array<OneD, Array<OneD, NekDouble> > &outarray);
182  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
183  const Array<OneD, const Array<OneD, NekDouble> > &normals,
184  const Array<OneD, const Array<OneD, NekDouble> > &vecLocs,
185  Array<OneD, Array<OneD, NekDouble> > &outarray);
186  bool CheckScalars (std::string name);
187  bool CheckVectors (std::string name);
188  bool CheckParams (std::string name);
189  bool CheckAuxScal (std::string name);
190  bool CheckAuxVec (std::string name);
191  };
192 
193  /// A shared pointer to an EquationSystem object
194  typedef boost::shared_ptr<RiemannSolver> RiemannSolverSharedPtr;
195  /// Datatype of the NekFactory used to instantiate classes derived
196  /// from the RiemannSolver class.
200  }
201 }
202 
203 #endif