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