Nektar++
Diffusion.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Diffusion.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 diffusion.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERUTILS_DIFFUSION
36 #define NEKTAR_SOLVERUTILS_DIFFUSION
37 
38 #include <string>
39 #include <functional>
40 
41 #include <boost/core/ignore_unused.hpp>
42 
46 #include <MultiRegions/ExpList.h>
49 
50 namespace Nektar
51 {
52  namespace SolverUtils
53  {
54  typedef std::function<void (
55  const Array<OneD, Array<OneD, NekDouble> > &,
56  const Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&,
57  Array<OneD, Array<OneD, Array<OneD, NekDouble> > >&)>
59 
60  typedef std::function<void (
65 
66  typedef std::function<void (
71 
72  typedef std::function<void (
76 
77  class Diffusion
78  {
79  public:
80 
82  {};
83 
87 
89  const std::size_t nConvectiveFields,
91  const Array<OneD, Array<OneD, NekDouble> > &inarray,
92  Array<OneD, Array<OneD, NekDouble> > &outarray,
95 
98  &fluxvector);
99 
100  template<typename FuncPointerT, typename ObjectPointerT>
101  void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
102  {
103  m_fluxVector = std::bind(
104  func, obj, std::placeholders::_1, std::placeholders::_2,
105  std::placeholders::_3);
106  }
107 
109  {
110  m_fluxVector = fluxVector;
111  }
112 
113  template<typename FuncPointerT, typename ObjectPointerT>
114  void SetFluxVectorNS(FuncPointerT func, ObjectPointerT obj)
115  {
116  m_fluxVectorNS = std::bind(
117  func, obj, std::placeholders::_1, std::placeholders::_2,
118  std::placeholders::_3);
119  }
120 
122  {
123  m_fluxVectorNS = fluxVector;
124  }
125 
126  template<typename FuncPointerT, typename ObjectPointerT>
127  void SetFluxPenaltyNS(FuncPointerT func, ObjectPointerT obj)
128  {
129  m_fluxPenaltyNS = std::bind(
130  func, obj, std::placeholders::_1, std::placeholders::_2,
131  std::placeholders::_3);
132  }
133 
135  {
136  m_fluxPenaltyNS = flux;
137  }
138 
140  {
141  v_SetHomoDerivs(deriv);
142  }
143 
145  {
146  return v_GetFluxTensor();
147  }
148 
149  protected:
153 
154  virtual void v_InitObject(
157  {
158  boost::ignore_unused(pSession, pFields);
159  };
160 
161  virtual void v_Diffuse(
162  const std::size_t nConvectiveFields,
164  const Array<OneD, Array<OneD, NekDouble> > &inarray,
165  Array<OneD, Array<OneD, NekDouble> > &outarray,
168 
169  virtual void v_SetHomoDerivs(
171  {
172  boost::ignore_unused(deriv);
173  }
174 
176  {
178  return tmp;
179  }
180  };
181 
182  /// A shared pointer to an EquationSystem object
183  typedef std::shared_ptr<Diffusion> DiffusionSharedPtr;
184 
185  /// Datatype of the NekFactory used to instantiate classes derived
186  /// from the Diffusion class.
188  SOLVER_UTILS_EXPORT DiffusionFactory& GetDiffusionFactory();
189  }
190 }
191 
192 #endif
std::shared_ptr< Diffusion > DiffusionSharedPtr
A shared pointer to an EquationSystem object.
Definition: Diffusion.h:183
virtual void v_Diffuse(const std::size_t nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const Array< OneD, Array< OneD, NekDouble > > &pFwd=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &pBwd=NullNekDoubleArrayofArray)=0
virtual Array< OneD, Array< OneD, Array< OneD, NekDouble > > > & GetFluxTensor()
Definition: Diffusion.h:144
void SetHomoDerivs(Array< OneD, Array< OneD, NekDouble > > &deriv)
Definition: Diffusion.h:139
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &)> DiffusionFluxVecCB
Definition: Diffusion.h:58
SOLVER_UTILS_EXPORT void InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Definition: Diffusion.cpp:47
SOLVER_UTILS_EXPORT void FluxVec(Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &fluxvector)
DiffusionFactory & GetDiffusionFactory()
Definition: Diffusion.cpp:41
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, const Array< OneD, Array< OneD, NekDouble > > &, Array< OneD, Array< OneD, NekDouble > > &)> DiffusionFluxPenaltyNS
Definition: Diffusion.h:70
DiffusionFluxVecCBNS m_fluxVectorNS
Definition: Diffusion.h:151
void SetFluxPenaltyNS(DiffusionFluxPenaltyNS flux)
Definition: Diffusion.h:134
void SetFluxVector(FuncPointerT func, ObjectPointerT obj)
Definition: Diffusion.h:101
DiffusionFluxPenaltyNS m_fluxPenaltyNS
Definition: Diffusion.h:152
void SetFluxPenaltyNS(FuncPointerT func, ObjectPointerT obj)
Definition: Diffusion.h:127
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &)> DiffusionFluxVecCBNS
Definition: Diffusion.h:64
std::function< void(const Array< OneD, Array< OneD, NekDouble > > &, Array< OneD, NekDouble > &)> DiffusionArtificialDiffusion
Definition: Diffusion.h:75
void SetFluxVectorNS(DiffusionFluxVecCBNS fluxVector)
Definition: Diffusion.h:121
#define SOLVER_UTILS_EXPORT
DiffusionFluxVecCB m_fluxVector
Definition: Diffusion.h:150
LibUtilities::NekFactory< std::string, Diffusion, std::string > DiffusionFactory
Datatype of the NekFactory used to instantiate classes derived from the Diffusion class...
Definition: Diffusion.h:187
void SetFluxVector(DiffusionFluxVecCB fluxVector)
Definition: Diffusion.h:108
SOLVER_UTILS_EXPORT void Diffuse(const std::size_t nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const Array< OneD, Array< OneD, NekDouble > > &pFwd=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &pBwd=NullNekDoubleArrayofArray)
Definition: Diffusion.cpp:54
void SetFluxVectorNS(FuncPointerT func, ObjectPointerT obj)
Definition: Diffusion.h:114
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Definition: Diffusion.h:154
virtual Array< OneD, Array< OneD, Array< OneD, NekDouble > > > & v_GetFluxTensor()
Definition: Diffusion.h:175
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual SOLVER_UTILS_EXPORT ~Diffusion()
Definition: Diffusion.h:81
Provides a generic Factory class.
Definition: NekFactory.hpp:103
virtual void v_SetHomoDerivs(Array< OneD, Array< OneD, NekDouble > > &deriv)
Definition: Diffusion.h:169