Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Forcing.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Forcing.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_FORCING
36 #define NEKTAR_SOLVERUTILS_FORCING
37 
38 #include <string>
39 
42 #include <MultiRegions/ExpList.h>
45 
46 namespace Nektar
47 {
48 namespace SolverUtils
49 {
50  // Forward declaration
51  class Forcing;
52  class EquationSystem;
53 
54  /// A shared pointer to an EquationSystem object
55  SOLVER_UTILS_EXPORT typedef std::shared_ptr<Forcing> ForcingSharedPtr;
56 
57  /// Declaration of the forcing factory
58  typedef LibUtilities::NekFactory<std::string, Forcing,
60  const std::weak_ptr<EquationSystem>&,
62  const unsigned int&,
63  const TiXmlElement*> ForcingFactory;
64 
65  /// Declaration of the forcing factory singleton
67 
68  /**
69  * @class Forcing
70  * @brief Defines a forcing term to be explicitly applied.
71  */
72  class Forcing
73  {
74  public:
76 
77  /// Initialise the forcing object
80  const unsigned int& pNumForcingFields,
81  const TiXmlElement* pForce);
82 
83  /// Apply the forcing
86  const Array<OneD, Array<OneD, NekDouble> > &inarray,
87  Array<OneD, Array<OneD, NekDouble> > &outarray,
88  const NekDouble &time);
89 
90  /// Change the advection velocity before applying the forcing.
91  /// For example, subtracting the frame velocity from the
92  /// advection velocity in the MovingRefercenceFrame.
95  const Array<OneD, Array<OneD, NekDouble> >& inarray,
96  Array<OneD, Array<OneD, NekDouble> >& outarray,
97  const NekDouble& time);
98 
99  /// Apply the forcing
102  const Array<OneD, Array<OneD, NekDouble> > &inarray,
103  Array<OneD, Array<OneD, NekDouble> > &outarray,
104  const NekDouble &time);
105  SOLVER_UTILS_EXPORT static std::vector<ForcingSharedPtr> Load(
106  const LibUtilities::SessionReaderSharedPtr &pSession,
107  const std::weak_ptr<EquationSystem> &pEquation,
109  const unsigned int& pNumForcingFields = 0);
110 
112  &GetForces();
113 
115 
116  protected:
117  /// Session reader
119  /// Weak pointer to equation system using this forcing
120  const std::weak_ptr<EquationSystem> m_equ;
121  /// Evaluated forcing function
123  /// Number of variables
125  /// Map of known SessionFunctions
126  std::map<std::string, SolverUtils::SessionFunctionSharedPtr> m_sessionFunctions;
127 
128  /// Constructor
130  const LibUtilities::SessionReaderSharedPtr &pSession,
131  const std::weak_ptr<EquationSystem> &pEquation);
132 
135  const unsigned int& pNumForcingFields,
136  const TiXmlElement* pForce) = 0;
137 
140  const Array<OneD, Array<OneD, NekDouble> > &inarray,
141  Array<OneD, Array<OneD, NekDouble> > &outarray,
142  const NekDouble &time)=0;
143 
144  SOLVER_UTILS_EXPORT virtual void v_PreApply(
146  const Array<OneD, Array<OneD, NekDouble> > &inarray,
147  Array<OneD, Array<OneD, NekDouble> > &outarray,
148  const NekDouble &time);
149 
150  SOLVER_UTILS_EXPORT virtual void v_ApplyCoeff(
152  const Array<OneD, Array<OneD, NekDouble> > &inarray,
153  Array<OneD, Array<OneD, NekDouble> > &outarray,
154  const NekDouble &time);
155  /// Get a SessionFunction by name
158  const LibUtilities::SessionReaderSharedPtr &pSession,
159  std::string pName,
160  bool pCache = false);
161 
164  std::string pFieldName,
165  Array<OneD, NekDouble>& pArray,
166  const std::string& pFunctionName,
167  NekDouble pTime = NekDouble(0));
168 
169 
171  const NekDouble pTime,
173  Array<OneD, NekDouble>& pArray);
174  };
175 }
176 }
177 
178 #endif
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:105
Defines a forcing term to be explicitly applied.
Definition: Forcing.h:73
virtual SOLVER_UTILS_EXPORT void v_Apply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)=0
virtual SOLVER_UTILS_EXPORT void v_PreApply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Definition: Forcing.cpp:90
int m_NumVariable
Number of variables.
Definition: Forcing.h:124
Array< OneD, Array< OneD, NekDouble > > m_Forcing
Evaluated forcing function.
Definition: Forcing.h:122
virtual SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)=0
virtual SOLVER_UTILS_EXPORT ~Forcing()
Definition: Forcing.h:75
SOLVER_UTILS_EXPORT void Apply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Apply the forcing.
Definition: Forcing.cpp:72
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Definition: Forcing.cpp:128
SOLVER_UTILS_EXPORT void InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Initialise the forcing object.
Definition: Forcing.cpp:58
SOLVER_UTILS_EXPORT Array< OneD, Array< OneD, NekDouble > > & UpdateForces()
Definition: Forcing.cpp:164
SOLVER_UTILS_EXPORT void ApplyCoeff(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Apply the forcing.
Definition: Forcing.cpp:116
SOLVER_UTILS_EXPORT const Array< OneD, const Array< OneD, NekDouble > > & GetForces()
Definition: Forcing.cpp:169
std::map< std::string, SolverUtils::SessionFunctionSharedPtr > m_sessionFunctions
Map of known SessionFunctions.
Definition: Forcing.h:126
SOLVER_UTILS_EXPORT void EvaluateTimeFunction(LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
Definition: Forcing.cpp:174
SOLVER_UTILS_EXPORT void PreApply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Change the advection velocity before applying the forcing. For example, subtracting the frame velocit...
Definition: Forcing.cpp:81
const std::weak_ptr< EquationSystem > m_equ
Weak pointer to equation system using this forcing.
Definition: Forcing.h:120
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, std::string pName, bool pCache=false)
Get a SessionFunction by name.
Definition: Forcing.cpp:202
SOLVER_UTILS_EXPORT Forcing(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
Constructor.
Definition: Forcing.cpp:50
virtual SOLVER_UTILS_EXPORT void v_ApplyCoeff(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Definition: Forcing.cpp:228
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: Forcing.h:118
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131
LibUtilities::NekFactory< std::string, Forcing, const LibUtilities::SessionReaderSharedPtr &, const std::weak_ptr< EquationSystem > &, const Array< OneD, MultiRegions::ExpListSharedPtr > &, const unsigned int &, const TiXmlElement * > ForcingFactory
Declaration of the forcing factory.
Definition: Forcing.h:63
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
Definition: Forcing.cpp:44
std::shared_ptr< SessionFunction > SessionFunctionSharedPtr
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
Definition: Forcing.h:52
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble