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 <functional>
39#include <string>
40
46#include <iomanip>
47
48namespace Nektar::SolverUtils
49{
50
51class Advection;
52
53/// A shared pointer to an Advection object.
54typedef std::shared_ptr<Advection> AdvectionSharedPtr;
55
56/// Datatype of the NekFactory used to instantiate classes derived
57/// from the Advection class.
60
61/// Gets the factory for initialising advection objects.
63
64/**
65 * Defines a callback function type which evaluates the flux vector \f$ F(u) \f$
66 * in a conservative advection of the form \f$ \nabla\cdot F(u) \f$.
67 */
68typedef std::function<void(const Array<OneD, Array<OneD, NekDouble>> &,
71
72/**
73 * @brief An abstract base class encapsulating the concept of advection
74 * of a vector field.
75 *
76 * Subclasses override the Advection::v_InitObject function to
77 * initialise the object and the Advection::v_Advect function to
78 * evaluate the advection of the vector field.
79 */
81{
82public:
84
85 /// Interface function to initialise the advection object.
89
90 /// Interface function to advect the vector field.
92 const int nConvectiveFields,
94 const Array<OneD, Array<OneD, NekDouble>> &advVel,
95 const Array<OneD, Array<OneD, NekDouble>> &inarray,
96 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
97 const Array<OneD, Array<OneD, NekDouble>> &pFwd =
99 const Array<OneD, Array<OneD, NekDouble>> &pBwd =
101
102 /**
103 * @brief Set the flux vector callback function.
104 *
105 * This routine is a utility function to avoid the explicit use of
106 * std::bind. A function and object can be passed to this function
107 * instead.
108 */
109 template <typename FuncPointerT, typename ObjectPointerT>
110 void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
111 {
113 std::bind(func, obj, std::placeholders::_1, std::placeholders::_2);
114 }
115
116 /**
117 * @brief Set a Riemann solver object for this advection object.
118 *
119 * @param riemann The RiemannSolver object.
120 */
122 {
123 m_riemann = riemann;
124 }
125
126 /**
127 * @brief Set the flux vector callback function.
128 *
129 * @param fluxVector The callback function to override.
130 */
131 inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
132 {
133 m_fluxVector = fluxVector;
134 }
135
136 /**
137 * @brief Set the base flow used for linearised advection objects.
138 *
139 * @param inarray Vector to use as baseflow
140 */
141 inline void SetBaseFlow(
142 const Array<OneD, Array<OneD, NekDouble>> &inarray,
144 {
145 v_SetBaseFlow(inarray, fields);
146 }
147
148 template <typename DataType, typename TypeNekBlkMatSharedPtr>
150 const int nConvectiveFields, const int nSpaceDim,
152 const Array<OneD, TypeNekBlkMatSharedPtr> &TracePntJacCons,
154 const Array<OneD, TypeNekBlkMatSharedPtr> &TracePntJacGrad,
155 const Array<OneD, Array<OneD, DataType>> &TracePntJacGradSign);
156
157 template <typename DataType, typename TypeNekBlkMatSharedPtr>
159 const Array<OneD, MultiRegions::ExpListSharedPtr> &pFields, const int m,
160 const int n, const Array<OneD, const TypeNekBlkMatSharedPtr> &PntJac,
161 const Array<OneD, const Array<OneD, DataType>> &PntJacSign,
163 Array<OneD, DNekMatSharedPtr> &TraceJacBwd);
164
165protected:
166 /// Callback function to the flux vector (set when advection is in
167 /// conservative form).
169 /// Riemann solver for DG-type schemes.
171 /// Storage for space dimension. Used for homogeneous extension.
173
174 /// Initialises the advection object.
178
179 /// Advects a vector field.
181 const int nConvectiveFields,
183 const Array<OneD, Array<OneD, NekDouble>> &advVel,
184 const Array<OneD, Array<OneD, NekDouble>> &inarray,
185 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
186 const Array<OneD, Array<OneD, NekDouble>> &pFwd =
188 const Array<OneD, Array<OneD, NekDouble>> &pBwd =
190
191 /// Overrides the base flow used during linearised advection
193 const Array<OneD, Array<OneD, NekDouble>> &inarray,
195};
196
197} // namespace Nektar::SolverUtils
198
199#endif
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:81
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:172
virtual SOLVER_UTILS_EXPORT ~Advection()
Definition: Advection.h:83
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:168
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:295
void CalcJacobTraceInteg(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const int m, const int n, const Array< OneD, const TypeNekBlkMatSharedPtr > &PntJac, const Array< OneD, const Array< OneD, DataType > > &PntJacSign, Array< OneD, DNekMatSharedPtr > &TraceJacFwd, Array< OneD, DNekMatSharedPtr > &TraceJacBwd)
Definition: Advection.cpp:241
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.
SOLVER_UTILS_EXPORT void InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Interface function to initialise the advection object.
Definition: Advection.cpp:53
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:322
SOLVER_UTILS_EXPORT void AddTraceJacToMat(const int nConvectiveFields, const int nSpaceDim, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, TypeNekBlkMatSharedPtr > &TracePntJacCons, Array< OneD, Array< OneD, TypeNekBlkMatSharedPtr > > &gmtxarray, const Array< OneD, TypeNekBlkMatSharedPtr > &TracePntJacGrad, const Array< OneD, Array< OneD, DataType > > &TracePntJacGradSign)
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:141
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:67
RiemannSolverSharedPtr m_riemann
Riemann solver for DG-type schemes.
Definition: Advection.h:170
void SetFluxVector(AdvectionFluxVecCB fluxVector)
Set the flux vector callback function.
Definition: Advection.h:131
void SetRiemannSolver(RiemannSolverSharedPtr riemann)
Set a Riemann solver object for this advection object.
Definition: Advection.h:121
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
Set the flux vector callback function.
Definition: Advection.h:110
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &)> AdvectionFluxVecCB
Definition: Advection.h:70
std::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:43
LibUtilities::NekFactory< std::string, Advection, std::string > AdvectionFactory
Datatype of the NekFactory used to instantiate classes derived from the Advection class.
Definition: Advection.h:59
std::shared_ptr< Advection > AdvectionSharedPtr
A shared pointer to an Advection object.
Definition: Advection.h:54
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
double NekDouble