Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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.
76 
77  /// Interface function to advect the vector field.
79  const int nConvectiveFields,
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,
87 
88  /**
89  * @brief Set the flux vector callback function.
90  *
91  * This routine is a utility function to avoid the explicit use of
92  * boost::bind. A function and object can be passed to this function
93  * instead.
94  */
95  template<typename FuncPointerT, typename ObjectPointerT>
96  void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
97  {
98  m_fluxVector = boost::bind(func, obj, _1, _2);
99  }
100 
101  /**
102  * @brief Set a Riemann solver object for this advection object.
103  *
104  * @param riemann The RiemannSolver object.
105  */
107  {
108  m_riemann = riemann;
109  }
110 
111  /**
112  * @brief Set the flux vector callback function.
113  *
114  * @param fluxVector The callback function to override.
115  */
116  inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
117  {
118  m_fluxVector = fluxVector;
119  }
120 
121  /**
122  * @brief Set the base flow used for linearised advection objects.
123  *
124  * @param inarray Vector to use as baseflow
125  */
126  inline void SetBaseFlow(
127  const Array<OneD, Array<OneD, NekDouble> >& inarray,
129  {
130  v_SetBaseFlow(inarray, fields);
131  }
132 
133 protected:
134  /// Callback function to the flux vector (set when advection is in
135  /// conservative form).
136  AdvectionFluxVecCB m_fluxVector;
137  /// Riemann solver for DG-type schemes.
139  /// Storage for space dimension. Used for homogeneous extension.
141 
142  /// Initialises the advection object.
143  SOLVER_UTILS_EXPORT virtual void v_InitObject(
146 
147  /// Advects a vector field.
148  SOLVER_UTILS_EXPORT virtual void v_Advect(
149  const int nConvectiveFields,
151  const Array<OneD, Array<OneD, NekDouble> > &advVel,
152  const Array<OneD, Array<OneD, NekDouble> > &inarray,
153  Array<OneD, Array<OneD, NekDouble> > &outarray,
154  const NekDouble &time,
157 
158  /// Overrides the base flow used during linearised advection
159  SOLVER_UTILS_EXPORT virtual void v_SetBaseFlow(
160  const Array<OneD, Array<OneD, NekDouble> > &inarray,
162 };
163 
164 /// A shared pointer to an Advection object.
165 typedef boost::shared_ptr<Advection> AdvectionSharedPtr;
166 
167 /// Datatype of the NekFactory used to instantiate classes derived
168 /// from the Advection class.
169 typedef LibUtilities::NekFactory<std::string, Advection,
170 std::string> AdvectionFactory;
171 
172 /// Gets the factory for initialising advection objects.
173 SOLVER_UTILS_EXPORT AdvectionFactory& GetAdvectionFactory();
174 
175 }
176 }
177 
178 #endif
LibUtilities::NekFactory< std::string, Advection, std::string > AdvectionFactory
Datatype of the NekFactory used to instantiate classes derived from the Advection class...
Definition: Advection.h:170
SOLVER_UTILS_EXPORT void InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Interface function to initialise the advection object.
Definition: Advection.cpp:60
virtual SOLVER_UTILS_EXPORT void v_Advect(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &advVel, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time, const Array< OneD, Array< OneD, NekDouble > > &pFwd=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &pBwd=NullNekDoubleArrayofArray)=0
Advects a vector field.
boost::shared_ptr< Advection > AdvectionSharedPtr
A shared pointer to an Advection object.
Definition: Advection.h:165
virtual SOLVER_UTILS_EXPORT void v_SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
Overrides the base flow used during linearised advection.
Definition: Advection.cpp:127
RiemannSolverSharedPtr m_riemann
Riemann solver for DG-type schemes.
Definition: Advection.h:138
boost::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
Set the flux vector callback function.
Definition: Advection.h:96
void SetFluxVector(AdvectionFluxVecCB fluxVector)
Set the flux vector callback function.
Definition: Advection.h:116
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
double NekDouble
void SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
Set the base flow used for linearised advection objects.
Definition: Advection.h:126
SOLVER_UTILS_EXPORT void Advect(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &advVel, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time, const Array< OneD, Array< OneD, NekDouble > > &pFwd=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &pBwd=NullNekDoubleArrayofArray)
Interface function to advect the vector field.
Definition: Advection.cpp:76
#define SOLVER_UTILS_EXPORT
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:136
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:140
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:100
Defines a callback function which evaluates the flux vector.
Definition: Advection.h:69
Provides a generic Factory class.
Definition: NekFactory.hpp:116
void SetRiemannSolver(RiemannSolverSharedPtr riemann)
Set a Riemann solver object for this advection object.
Definition: Advection.h:106