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#ifndef NEKTAR_LIBUTILITIES_BASICUTILS_EQUATION_H
36#define NEKTAR_LIBUTILITIES_BASICUTILS_EQUATION_H
37
38#include <map>
39#include <string>
40
43
45{
46
47/**
48 * @class Equation
49 *
50 * This class stores a string form of a symbolic expression to be evaluated
51 * e.g. for the boundary conditions, the unique numeric ID of that expression
52 * and a reference to the unique static instance of the Interpreter.
53 *
54 * The scenario is that for multiple copies of Equation class holding their
55 * symbolic expressions in the std::string form, there is a unique instance of
56 * Interpreter, which holds a set of pre-processed symbolic expressions in the
57 * form of sequential containers of execution functors, ready for fast
58 * evaluation.
59 *
60 * The interpreter also keeps all constants and parameters specified in an XML
61 * file. There should be only one copy of Equation class per each symbolic
62 * expression specified in XML file, modulo possible bugs. Classes Equation and
63 * Interpreter are complementary in a sense that the expression ID stored in the
64 * Equation class is generated by the Interpreter which holds ordered container
65 * of pre-processed expressions.
66 */
68{
69public:
72 const std::string &expr = "",
73 const std::string &vlist = "");
74
76
78
80 NekDouble z = 0,
81 NekDouble t = 0) const;
82
86 Array<OneD, NekDouble> &result) const;
87
91 const NekDouble t,
92 Array<OneD, NekDouble> &result) const;
93
98 Array<OneD, NekDouble> &result) const;
99
101 const std::vector<Array<OneD, const NekDouble>> points,
102 Array<OneD, NekDouble> &result) const;
103
104 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name,
105 NekDouble value);
106
108 const std::map<std::string, NekDouble> &constants);
109
110 LIB_UTILITIES_EXPORT std::string GetExpression(void) const;
111
112 LIB_UTILITIES_EXPORT std::string GetVlist(void) const;
113
114 /// Returns time spend on expression evaluation at points (it does not
115 /// include parse/pre-processing time).
117
118private:
119 std::string m_vlist;
120 std::string m_expr;
123};
124
125typedef std::shared_ptr<Equation> EquationSharedPtr;
126
127} // namespace Nektar::LibUtilities
128
129#endif // NEKTAR_LIBUTILITIES_EQUATION_HPP
#define LIB_UTILITIES_EXPORT
InterpreterSharedPtr m_evaluator
Definition: Equation.h:122
NekDouble GetTime() const
Returns time spend on expression evaluation at points (it does not include parse/pre-processing time)...
Equation(const Equation &)=default
Equation & operator=(const Equation &src)
std::string GetExpression(void) const
void SetConstants(const std::map< std::string, NekDouble > &constants)
void SetParameter(const std::string &name, NekDouble value)
std::shared_ptr< Interpreter > InterpreterSharedPtr
Definition: Interpreter.h:322
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:125
std::vector< double > z(NPUPPER)
double NekDouble