libMesh
fparser_parse.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // Open the getpot input file given by the input file name; write out
21 // all GetPot object data to the output file name
22 #include "libmesh/libmesh_config.h"
23 #include "libmesh/parsed_function.h"
24 #include "libmesh/point.h"
25 
26 #include <cstdlib>
27 
28 int main(int argc, char ** argv)
29 {
30  using namespace libMesh;
31 
32  if (argc < 2)
33  libmesh_error_msg("Usage: " << argv[0] << " function_to_eval [x] [y] [z] [t]");
34 
35  std::string function_string = argv[1];
36 
37  ParsedFunction<> func(function_string);
38 
39  const Point p ( (argc > 2) ? std::atof(argv[2]) : 0.0,
40  (argc > 3) ? std::atof(argv[3]) : 0.0,
41  (argc > 4) ? std::atof(argv[4]) : 0.0 );
42 
43  const libMesh::Real t = (argc > 5) ? std::atof(argv[5]) : 0.0;
44 
45  const libMesh::Number out = func(p,t);
46 
47  libMesh::out << "out = " << out << std::endl;
48 
49  return 0;
50 }
A Function generated (via FParser) by parsing a mathematical expression.
The libMesh namespace provides an interface to certain functionality in the library.
int main(int argc, char **argv)
Definition: fparser_parse.C:28
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38