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
41#include <boost/core/ignore_unused.hpp>
42
45
46namespace Nektar
47{
48namespace LibUtilities
49{
50
51/**
52 * @class Equation
53 *
54 * This class stores a string form of a symbolic expression to be evaluated
55 * e.g. for the boundary conditions, the unique numeric ID of that expression
56 * and a reference to the unique static instance of the Interpreter.
57 *
58 * The scenario is that for multiple copies of Equation class holding their
59 * symbolic expressions in the std::string form, there is a unique instance of
60 * Interpreter, which holds a set of pre-processed symbolic expressions in the
61 * form of sequential containers of execution functors, ready for fast
62 * evaluation.
63 *
64 * The interpreter also keeps all constants and parameters specified in an XML
65 * file. There should be only one copy of Equation class per each symbolic
66 * expression specified in XML file, modulo possible bugs. Classes Equation and
67 * Interpreter are complementary in a sense that the expression ID stored in the
68 * Equation class is generated by the Interpreter which holds ordered container
69 * of pre-processed expressions.
70 */
72{
73public:
76 const std::string &expr = "",
77 const std::string &vlist = "");
78
80
82
84 NekDouble z = 0,
85 NekDouble t = 0) const;
86
90 Array<OneD, NekDouble> &result) const;
91
95 const NekDouble t,
96 Array<OneD, NekDouble> &result) const;
97
102 Array<OneD, NekDouble> &result) const;
103
105 const std::vector<Array<OneD, const NekDouble>> points,
106 Array<OneD, NekDouble> &result) const;
107
108 LIB_UTILITIES_EXPORT void SetParameter(const std::string &name,
109 NekDouble value);
110
112 const std::map<std::string, NekDouble> &constants);
113
114 LIB_UTILITIES_EXPORT std::string GetExpression(void) const;
115
116 LIB_UTILITIES_EXPORT std::string GetVlist(void) const;
117
118 /// Returns time spend on expression evaluation at points (it does not
119 /// include parse/pre-processing time).
121
122private:
123 std::string m_vlist;
124 std::string m_expr;
127};
128
129typedef std::shared_ptr<Equation> EquationSharedPtr;
130
131} // namespace LibUtilities
132} // namespace Nektar
133
134#endif // NEKTAR_LIBUTILITIES_EQUATION_HPP
#define LIB_UTILITIES_EXPORT
InterpreterSharedPtr m_evaluator
Definition: Equation.h:126
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:324
std::shared_ptr< Equation > EquationSharedPtr
Definition: Equation.h:129
std::vector< double > z(NPUPPER)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble