Nektar++
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Abstract base class for advection.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERUTILS_ADVECTION
36 #define NEKTAR_SOLVERUTILS_ADVECTION
37 
38 #include <string>
39 #include <functional>
40 
43 #include <MultiRegions/ExpList.h>
46 
47 namespace Nektar
48 {
49 namespace SolverUtils
50 {
51 
52 /**
53  * Defines a callback function type which evaluates the flux vector \f$ F(u) \f$
54  * in a conservative advection of the form \f$ \nabla\cdot F(u) \f$.
55  */
56 typedef std::function<void (
57  const Array<OneD, Array<OneD, NekDouble> >&,
58  Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
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 
74  {};
75 
76  /// Interface function to initialise the advection object.
80 
81  /// Interface function to advect the vector field.
83  const int nConvectiveFields,
85  const Array<OneD, Array<OneD, NekDouble> > &advVel,
86  const Array<OneD, Array<OneD, NekDouble> > &inarray,
87  Array<OneD, Array<OneD, NekDouble> > &outarray,
88  const NekDouble &time,
91 
92  /**
93  * @brief Set the flux vector callback function.
94  *
95  * This routine is a utility function to avoid the explicit use of
96  * std::bind. A function and object can be passed to this function
97  * instead.
98  */
99  template<typename FuncPointerT, typename ObjectPointerT>
100  void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
101  {
102  m_fluxVector = std::bind(
103  func, obj, std::placeholders::_1, std::placeholders::_2);
104  }
105 
106  /**
107  * @brief Set a Riemann solver object for this advection object.
108  *
109  * @param riemann The RiemannSolver object.
110  */
112  {
113  m_riemann = riemann;
114  }
115 
116  /**
117  * @brief Set the flux vector callback function.
118  *
119  * @param fluxVector The callback function to override.
120  */
121  inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
122  {
123  m_fluxVector = fluxVector;
124  }
125 
126  /**
127  * @brief Set the base flow used for linearised advection objects.
128  *
129  * @param inarray Vector to use as baseflow
130  */
131  inline void SetBaseFlow(
132  const Array<OneD, Array<OneD, NekDouble> >& inarray,
134  {
135  v_SetBaseFlow(inarray, fields);
136  }
137 
138 protected:
139  /// Callback function to the flux vector (set when advection is in
140  /// conservative form).
142  /// Riemann solver for DG-type schemes.
144  /// Storage for space dimension. Used for homogeneous extension.
146 
147  /// Initialises the advection object.
148  SOLVER_UTILS_EXPORT virtual void v_InitObject(
151 
152  /// Advects a vector field.
153  SOLVER_UTILS_EXPORT virtual void v_Advect(
154  const int nConvectiveFields,
156  const Array<OneD, Array<OneD, NekDouble> > &advVel,
157  const Array<OneD, Array<OneD, NekDouble> > &inarray,
158  Array<OneD, Array<OneD, NekDouble> > &outarray,
159  const NekDouble &time,
162 
163  /// Overrides the base flow used during linearised advection
164  SOLVER_UTILS_EXPORT virtual void v_SetBaseFlow(
165  const Array<OneD, Array<OneD, NekDouble> > &inarray,
167 };
168 
169 /// A shared pointer to an Advection object.
170 typedef std::shared_ptr<Advection> AdvectionSharedPtr;
171 
172 /// Datatype of the NekFactory used to instantiate classes derived
173 /// from the Advection class.
174 typedef LibUtilities::NekFactory<std::string, Advection,
175 std::string> AdvectionFactory;
176 
177 /// Gets the factory for initialising advection objects.
178 SOLVER_UTILS_EXPORT AdvectionFactory& GetAdvectionFactory();
179 
180 }
181 }
182 
183 #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:175
SOLVER_UTILS_EXPORT void InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Interface function to initialise the advection object.
Definition: Advection.cpp:58
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.
std::shared_ptr< Advection > AdvectionSharedPtr
A shared pointer to an Advection object.
Definition: Advection.h:170
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:126
RiemannSolverSharedPtr m_riemann
Riemann solver for DG-type schemes.
Definition: Advection.h:143
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &)> AdvectionFluxVecCB
Definition: Advection.h:59
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
Set the flux vector callback function.
Definition: Advection.h:100
std::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
void SetFluxVector(AdvectionFluxVecCB fluxVector)
Set the flux vector callback function.
Definition: Advection.h:121
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
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:131
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:74
#define SOLVER_UTILS_EXPORT
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:141
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:145
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual SOLVER_UTILS_EXPORT ~Advection()
Definition: Advection.h:73
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:98
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:69
Provides a generic Factory class.
Definition: NekFactory.hpp:103
void SetRiemannSolver(RiemannSolverSharedPtr riemann)
Set a Riemann solver object for this advection object.
Definition: Advection.h:111