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:
83 /// Interface function to initialise the advection object.
87 {
88 v_InitObject(pSession, pFields);
89 }
90
91 /// Interface function to advect the vector field.
93 const int nConvectiveFields,
95 const Array<OneD, Array<OneD, NekDouble>> &advVel,
96 const Array<OneD, Array<OneD, NekDouble>> &inarray,
97 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
98 const Array<OneD, Array<OneD, NekDouble>> &pFwd =
100 const Array<OneD, Array<OneD, NekDouble>> &pBwd =
102 {
103 v_Advect(nConvectiveFields, fields, advVel, inarray, outarray, time,
104 pFwd, pBwd);
105 }
106
107 /**
108 * @brief Set the flux vector callback function.
109 *
110 * This routine is a utility function to avoid the explicit use of
111 * std::bind. A function and object can be passed to this function
112 * instead.
113 */
114 template <typename FuncPointerT, typename ObjectPointerT>
115 void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
116 {
118 std::bind(func, obj, std::placeholders::_1, std::placeholders::_2);
119 }
120
121 /**
122 * @brief Set a Riemann solver object for this advection object.
123 *
124 * @param riemann The RiemannSolver object.
125 */
127 {
128 m_riemann = riemann;
129 }
130
131 /**
132 * @brief Set the flux vector callback function.
133 *
134 * @param fluxVector The callback function to override.
135 */
136 inline void SetFluxVector(AdvectionFluxVecCB fluxVector)
137 {
138 m_fluxVector = fluxVector;
139 }
140
141 /**
142 * @brief Set the base flow used for linearised advection objects.
143 *
144 * @param inarray Vector to use as baseflow
145 */
146 inline void SetBaseFlow(
147 const Array<OneD, Array<OneD, NekDouble>> &inarray,
149 {
150 v_SetBaseFlow(inarray, fields);
151 }
152
153 template <typename DataType, typename TypeNekBlkMatSharedPtr>
155 const int nConvectiveFields, const int nSpaceDim,
157 const Array<OneD, TypeNekBlkMatSharedPtr> &TracePntJacCons,
159 const Array<OneD, TypeNekBlkMatSharedPtr> &TracePntJacGrad,
160 const Array<OneD, Array<OneD, DataType>> &TracePntJacGradSign);
161
162 template <typename DataType, typename TypeNekBlkMatSharedPtr>
164 const Array<OneD, MultiRegions::ExpListSharedPtr> &pFields, const int m,
165 const int n, const Array<OneD, const TypeNekBlkMatSharedPtr> &PntJac,
166 const Array<OneD, const Array<OneD, DataType>> &PntJacSign,
168 Array<OneD, DNekMatSharedPtr> &TraceJacBwd);
169
170protected:
171 SOLVER_UTILS_EXPORT virtual ~Advection() = default;
172
173 /// Callback function to the flux vector (set when advection is in
174 /// conservative form).
176 /// Riemann solver for DG-type schemes.
178 /// Storage for space dimension. Used for homogeneous extension.
180
181 /// Initialises the advection object.
185
186 /// Advects a vector field.
188 const int nConvectiveFields,
190 const Array<OneD, Array<OneD, NekDouble>> &advVel,
191 const Array<OneD, Array<OneD, NekDouble>> &inarray,
192 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
193 const Array<OneD, Array<OneD, NekDouble>> &pFwd =
195 const Array<OneD, Array<OneD, NekDouble>> &pBwd =
197
198 /// Overrides the base flow used during linearised advection
200 const Array<OneD, Array<OneD, NekDouble>> &inarray,
202};
203
204} // namespace Nektar::SolverUtils
205
206#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:179
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
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.h:84
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:264
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:210
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.
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:291
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:146
virtual SOLVER_UTILS_EXPORT ~Advection()=default
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.h:92
RiemannSolverSharedPtr m_riemann
Riemann solver for DG-type schemes.
Definition: Advection.h:177
void SetFluxVector(AdvectionFluxVecCB fluxVector)
Set the flux vector callback function.
Definition: Advection.h:136
void SetRiemannSolver(RiemannSolverSharedPtr riemann)
Set a Riemann solver object for this advection object.
Definition: Advection.h:126
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
Set the flux vector callback function.
Definition: Advection.h:115
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