Nektar++
Equation.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Equation.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: Wrapper to Interpreter class.
32 //
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIBUTILITIES_BASICUTILS_EQUATION_H
37 #define NEKTAR_LIBUTILITIES_BASICUTILS_EQUATION_H
38 
39 #include <string>
40 #include <map>
41 
42 #include <boost/core/ignore_unused.hpp>
43 
46 
47 namespace Nektar
48 {
49 namespace LibUtilities
50 {
51 
52 /**
53  * @class Equation
54  *
55  * This class stores a string form of a symbolic expression to be evaluated
56  * e.g. for the boundary conditions, the unique numeric ID of that expression
57  * and a reference to the unique static instance of the Interpreter.
58  *
59  * The scenario is that for multiple copies of Equation class holding their
60  * symbolic expressions in the std::string form, there is a unique instance of
61  * Interpreter, which holds a set of pre-processed symbolic expressions in the
62  * form of sequential containers of execution functors, ready for fast
63  * evaluation.
64  *
65  * The interpreter also keeps all constants and parameters specified in an XML
66  * file. There should be only one copy of Equation class per each symbolic
67  * expression specified in XML file, modulo possible bugs. Classes Equation and
68  * Interpreter are complementary in a sense that the expression ID stored in the
69  * Equation class is generated by the Interpreter which holds ordered container
70  * of pre-processed expressions.
71  */
72 class Equation
73 {
74 public:
77  const std::string& expr = "",
78  const std::string& vlist = "");
79 
81 
83 
85  NekDouble x, NekDouble y = 0, NekDouble z = 0, NekDouble t = 0) const;
86 
91  Array<OneD, NekDouble>& result) const;
92 
97  const NekDouble t,
98  Array<OneD, NekDouble>& result) const;
99 
100 
106  Array<OneD, NekDouble>& result) const;
107 
109  const std::vector<Array<OneD, const NekDouble> > points,
110  Array<OneD, NekDouble>& result) const;
111 
112  LIB_UTILITIES_EXPORT void SetParameter(const std::string& name, NekDouble value);
113 
114  LIB_UTILITIES_EXPORT void SetConstants(const std::map<std::string, NekDouble> &constants);
115 
116  LIB_UTILITIES_EXPORT std::string GetExpression(void) const;
117 
118  LIB_UTILITIES_EXPORT std::string GetVlist(void) const;
119 
120  /// Returns time spend on expression evaluation at points (it does not
121  /// include parse/pre-processing time).
123 
124 private:
125  std::string m_vlist;
126  std::string m_expr;
129 };
130 
131 typedef std::shared_ptr<Equation> EquationSharedPtr;
132 
133 }
134 }
135 
136 #endif //NEKTAR_LIBUTILITIES_EQUATION_HPP
#define LIB_UTILITIES_EXPORT
InterpreterSharedPtr m_evaluator
Definition: Equation.h:128
NekDouble GetTime() const
Returns time spend on expression evaluation at points (it does not include parse/pre-processing time)...
Definition: Equation.cpp:229
Equation(const Equation &)=default
std::string GetVlist(void) const
Definition: Equation.cpp:222
Equation & operator=(const Equation &src)
Definition: Equation.cpp:86
std::string GetExpression(void) const
Definition: Equation.cpp:217
void SetConstants(const std::map< std::string, NekDouble > &constants)
Definition: Equation.cpp:212
void SetParameter(const std::string &name, NekDouble value)
Definition: Equation.cpp:207
NekDouble Evaluate() const
Definition: Equation.cpp:95
std::shared_ptr< Interpreter > InterpreterSharedPtr
Definition: Interpreter.h:325
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:131
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble