Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Advection.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Advection.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 advection.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_SOLVERUTILS_ADVECTION
37 #define NEKTAR_SOLVERUTILS_ADVECTION
38 
39 #include <string>
40 #include <boost/function.hpp>
41 
44 #include <MultiRegions/ExpList.h>
47 
48 namespace Nektar
49 {
50  namespace SolverUtils
51  {
52  /// Defines a callback function which evaluates the flux vector \f$ F(u)
53  /// \f$ in a conservative advection of the form \f$ \nabla\cdot F(u)
54  /// \f$.
55  typedef boost::function<void (
56  const Array<OneD, Array<OneD, NekDouble> >&,
57  Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
58  AdvectionFluxVecCB;
59 
60  /**
61  * @brief An abstract base class encapsulating the concept of advection
62  * of a vector field.
63  *
64  * Subclasses override the Advection::v_InitObject function to
65  * initialise the object and the Advection::v_Advect function to
66  * evaluate the advection of the vector field.
67  */
68  class Advection
69  {
70  public:
73  Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
74 
76  const int nConvectiveFields,
77  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
78  const Array<OneD, Array<OneD, NekDouble> > &advVel,
79  const Array<OneD, Array<OneD, NekDouble> > &inarray,
80  Array<OneD, Array<OneD, NekDouble> > &outarray);
81 
82  /**
83  * @brief Set the flux vector callback function.
84  *
85  * This routine is a utility function to avoid the explicit use of
86  * boost::bind. A function and object can be passed to this function
87  * instead.
88  */
89  template<typename FuncPointerT, typename ObjectPointerT>
90  void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
91  {
92  m_fluxVector = boost::bind(func, obj, _1, _2);
93  }
94 
95  /**
96  * @brief Set a Riemann solver object for this advection object.
97  *
98  * @param riemann The RiemannSolver object.
99  */
101  {
102  m_riemann = riemann;
103  }
104 
105  /**
106  * @brief Set the flux vector callback function.
107  *
108  * @param fluxVector The callback function to override.
109  */
110  inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
111  {
112  m_fluxVector = fluxVector;
113  }
114 
115  protected:
116  virtual void v_InitObject(
118  Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
119 
120  virtual void v_Advect(
121  const int nConvectiveFields,
122  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
123  const Array<OneD, Array<OneD, NekDouble> > &advVel,
124  const Array<OneD, Array<OneD, NekDouble> > &inarray,
125  Array<OneD, Array<OneD, NekDouble> > &outarray)=0;
126 
127  /// Callback function to the flux vector (set when advection is in
128  /// conservative form).
129  AdvectionFluxVecCB m_fluxVector;
130  /// Riemann solver for DG-type schemes.
132  /// Storage for space dimension. Used for homogeneous extension.
134  };
135 
136  /// A shared pointer to an Advection object.
137  typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
138 
139  /// Datatype of the NekFactory used to instantiate classes derived
140  /// from the Advection class.
141  typedef LibUtilities::NekFactory<std::string, Advection,
142  std::string> AdvectionFactory;
144  }
145 }
146 
147 #endif