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 
53 /// Defines a callback function which evaluates the flux vector \f$ F(u)
54 /// \f$ in a conservative advection of the form \f$ \nabla\cdot F(u)
55 /// \f$.
56 typedef boost::function<void (
57  const Array<OneD, Array<OneD, NekDouble> >&,
58  Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
59  AdvectionFluxVecCB;
60 
61 /**
62  * @brief An abstract base class encapsulating the concept of advection
63  * of a vector field.
64  *
65  * Subclasses override the Advection::v_InitObject function to
66  * initialise the object and the Advection::v_Advect function to
67  * evaluate the advection of the vector field.
68  */
69 class Advection
70 {
71 public:
72  /// Interface function to initialise the advection object.
75  Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
76 
77  /// Interface function to advect the vector field.
79  const int nConvectiveFields,
80  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
81  const Array<OneD, Array<OneD, NekDouble> > &advVel,
82  const Array<OneD, Array<OneD, NekDouble> > &inarray,
83  Array<OneD, Array<OneD, NekDouble> > &outarray,
84  const NekDouble &time);
85 
86  /**
87  * @brief Set the flux vector callback function.
88  *
89  * This routine is a utility function to avoid the explicit use of
90  * boost::bind. A function and object can be passed to this function
91  * instead.
92  */
93  template<typename FuncPointerT, typename ObjectPointerT>
94  void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
95  {
96  m_fluxVector = boost::bind(func, obj, _1, _2);
97  }
98 
99  /**
100  * @brief Set a Riemann solver object for this advection object.
101  *
102  * @param riemann The RiemannSolver object.
103  */
105  {
106  m_riemann = riemann;
107  }
108 
109  /**
110  * @brief Set the flux vector callback function.
111  *
112  * @param fluxVector The callback function to override.
113  */
114  inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
115  {
116  m_fluxVector = fluxVector;
117  }
118 
119  /**
120  * @brief Set the base flow used for linearised advection objects.
121  *
122  * @param inarray Vector to use as baseflow
123  */
124  inline void SetBaseFlow(const Array<OneD, Array<OneD, NekDouble> >& inarray)
125  {
126  v_SetBaseFlow(inarray);
127  }
128 
129 protected:
130  /// Callback function to the flux vector (set when advection is in
131  /// conservative form).
132  AdvectionFluxVecCB m_fluxVector;
133  /// Riemann solver for DG-type schemes.
135  /// Storage for space dimension. Used for homogeneous extension.
137 
138  /// Initialises the advection object.
139  SOLVER_UTILS_EXPORT virtual void v_InitObject(
141  Array<OneD, MultiRegions::ExpListSharedPtr> pFields);
142 
143  /// Advects a vector field.
144  SOLVER_UTILS_EXPORT virtual void v_Advect(
145  const int nConvectiveFields,
146  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
147  const Array<OneD, Array<OneD, NekDouble> > &advVel,
148  const Array<OneD, Array<OneD, NekDouble> > &inarray,
149  Array<OneD, Array<OneD, NekDouble> > &outarray,
150  const NekDouble &time)=0;
151 
152  /// Overrides the base flow used during linearised advection
153  SOLVER_UTILS_EXPORT virtual void v_SetBaseFlow(
154  const Array<OneD, Array<OneD, NekDouble> > &inarray);
155 };
156 
157 /// A shared pointer to an Advection object.
158 typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
159 
160 /// Datatype of the NekFactory used to instantiate classes derived
161 /// from the Advection class.
162 typedef LibUtilities::NekFactory<std::string, Advection,
163 std::string> AdvectionFactory;
164 
165 /// Gets the factory for initialising advection objects.
167 
168 }
169 }
170 
171 #endif