libMesh
parsed_function.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 #ifndef LIBMESH_PARSED_FUNCTION_H
19 #define LIBMESH_PARSED_FUNCTION_H
20 
21 #include "libmesh/libmesh_config.h"
22 #include "libmesh/function_base.h"
23 #include "libmesh/auto_ptr.h" // libmesh_make_unique
24 
25 #ifdef LIBMESH_HAVE_FPARSER
26 
27 // Local includes
28 #include "libmesh/dense_vector.h"
29 #include "libmesh/int_range.h"
30 #include "libmesh/vector_value.h"
31 #include "libmesh/point.h"
32 
33 // FParser includes
34 #include "libmesh/fparser_ad.hh"
35 
36 // C++ includes
37 #include <algorithm> // std::find
38 #include <cmath>
39 #include <cmath>
40 #include <cstddef>
41 #include <iomanip>
42 #include <limits>
43 #include <sstream>
44 #include <string>
45 #include <vector>
46 
47 namespace libMesh
48 {
49 
59 template <typename Output=Number, typename OutputGradient=Gradient>
60 class ParsedFunction : public FunctionBase<Output>
61 {
62 public:
63  explicit
64  ParsedFunction (const std::string & expression,
65  const std::vector<std::string> * additional_vars=nullptr,
66  const std::vector<Output> * initial_vals=nullptr);
67 
73  ParsedFunction & operator= (const ParsedFunction &) = delete;
74 
89  ParsedFunction (const ParsedFunction &) = default;
90  ParsedFunction (ParsedFunction &&) = default;
92  virtual ~ParsedFunction () = default;
93 
97  void reparse (const std::string & expression);
98 
99  virtual Output operator() (const Point & p,
100  const Real time = 0) override;
101 
105  virtual bool has_derivatives() { return _valid_derivatives; }
106 
107  virtual Output dot(const Point & p,
108  const Real time = 0);
109 
110  virtual OutputGradient gradient(const Point & p,
111  const Real time = 0);
112 
113  virtual void operator() (const Point & p,
114  const Real time,
115  DenseVector<Output> & output) override;
116 
117  virtual Output component (unsigned int i,
118  const Point & p,
119  Real time) override;
120 
121  const std::string & expression() { return _expression; }
122 
126  virtual Output & getVarAddress(const std::string & variable_name);
127 
128  virtual std::unique_ptr<FunctionBase<Output>> clone() const override;
129 
138  Output get_inline_value(const std::string & inline_var_name) const;
139 
150  void set_inline_value(const std::string & inline_var_name,
151  Output newval);
152 
153 protected:
157  void partial_reparse (const std::string & expression);
158 
162  std::size_t find_name (const std::string & varname,
163  const std::string & expr) const;
164 
168  bool expression_is_time_dependent( const std::string & expression ) const;
169 
170 private:
174  void set_spacetime(const Point & p,
175  const Real time = 0);
176 
180  inline Output eval(FunctionParserADBase<Output> & parser,
181  const std::string & libmesh_dbg_var(function_name),
182  unsigned int libmesh_dbg_var(component_idx)) const;
183 
184  std::string _expression;
185  std::vector<std::string> _subexpressions;
186  std::vector<FunctionParserADBase<Output>> parsers;
187  std::vector<Output> _spacetime;
188 
189  // derivative functions
190  std::vector<FunctionParserADBase<Output>> dx_parsers;
191 #if LIBMESH_DIM > 1
192  std::vector<FunctionParserADBase<Output>> dy_parsers;
193 #endif
194 #if LIBMESH_DIM > 2
195  std::vector<FunctionParserADBase<Output>> dz_parsers;
196 #endif
197  std::vector<FunctionParserADBase<Output>> dt_parsers;
199 
200  // Variables/values that can be parsed and handled by the function parser
201  std::string variables;
202  std::vector<std::string> _additional_vars;
203  std::vector<Output> _initial_vals;
204 };
205 
206 
207 /*----------------------- Inline functions ----------------------------------*/
208 
209 template <typename Output, typename OutputGradient>
210 inline
212  const std::vector<std::string> * additional_vars,
213  const std::vector<Output> * initial_vals) :
214  _expression (), // overridden by parse()
215  // Size the spacetime vector to account for space, time, and any additional
216  // variables passed
217  _spacetime (LIBMESH_DIM+1 + (additional_vars ? additional_vars->size() : 0)),
218  _valid_derivatives (true),
219  _additional_vars (additional_vars ? *additional_vars : std::vector<std::string>()),
220  _initial_vals (initial_vals ? *initial_vals : std::vector<Output>())
221 {
222  // time-dependence established in reparse function
223  this->reparse(expression);
224  this->_initialized = true;
225 }
226 
227 
228 template <typename Output, typename OutputGradient>
229 inline
230 void
231 ParsedFunction<Output,OutputGradient>::reparse (const std::string & expression)
232 {
233  variables = "x";
234 #if LIBMESH_DIM > 1
235  variables += ",y";
236 #endif
237 #if LIBMESH_DIM > 2
238  variables += ",z";
239 #endif
240  variables += ",t";
241 
242  // If additional vars were passed, append them to the string
243  // that we send to the function parser. Also add them to the
244  // end of our spacetime vector
245  for (auto i : index_range(_additional_vars))
246  {
247  variables += "," + _additional_vars[i];
248  // Initialize extra variables to the vector passed in or zero
249  // Note: The initial_vals vector can be shorter than the additional_vars vector
250  _spacetime[LIBMESH_DIM+1 + i] =
251  (i < _initial_vals.size()) ? _initial_vals[i] : 0;
252  }
253 
254  this->partial_reparse(expression);
255 
256  this->_is_time_dependent = this->expression_is_time_dependent(expression);
257 }
258 
259 template <typename Output, typename OutputGradient>
260 inline
261 Output
263 {
264  set_spacetime(p, time);
265  return eval(parsers[0], "f", 0);
266 }
267 
268 template <typename Output, typename OutputGradient>
269 inline
270 Output
272 {
273  set_spacetime(p, time);
274  return eval(dt_parsers[0], "df/dt", 0);
275 }
276 
277 template <typename Output, typename OutputGradient>
278 inline
279 OutputGradient
281 {
282  OutputGradient grad;
283  set_spacetime(p, time);
284 
285  grad(0) = eval(dx_parsers[0], "df/dx", 0);
286 #if LIBMESH_DIM > 1
287  grad(1) = eval(dy_parsers[0], "df/dy", 0);
288 #endif
289 #if LIBMESH_DIM > 2
290  grad(2) = eval(dz_parsers[0], "df/dz", 0);
291 #endif
292 
293  return grad;
294 }
295 
296 template <typename Output, typename OutputGradient>
297 inline
298 void
300  (const Point & p,
301  const Real time,
302  DenseVector<Output> & output)
303 {
304  set_spacetime(p, time);
305 
306  unsigned int size = output.size();
307 
308  libmesh_assert_equal_to (size, parsers.size());
309 
310  // The remaining locations in _spacetime are currently fixed at construction
311  // but could potentially be made dynamic
312  for (unsigned int i=0; i != size; ++i)
313  output(i) = eval(parsers[i], "f", i);
314 }
315 
320 template <typename Output, typename OutputGradient>
321 inline
322 Output
324  const Point & p,
325  Real time)
326 {
327  set_spacetime(p, time);
328  libmesh_assert_less (i, parsers.size());
329 
330  // The remaining locations in _spacetime are currently fixed at construction
331  // but could potentially be made dynamic
332  libmesh_assert_less(i, parsers.size());
333  return eval(parsers[i], "f", i);
334 }
335 
339 template <typename Output, typename OutputGradient>
340 inline
341 Output &
342 ParsedFunction<Output,OutputGradient>::getVarAddress (const std::string & variable_name)
343 {
344  const std::vector<std::string>::iterator it =
345  std::find(_additional_vars.begin(), _additional_vars.end(), variable_name);
346 
347  if (it == _additional_vars.end())
348  libmesh_error_msg("ERROR: Requested variable not found in parsed function");
349 
350  // Iterator Arithmetic (How far from the end of the array is our target address?)
351  return _spacetime[_spacetime.size() - (_additional_vars.end() - it)];
352 }
353 
354 
355 template <typename Output, typename OutputGradient>
356 inline
357 std::unique_ptr<FunctionBase<Output>>
359 {
360  return libmesh_make_unique<ParsedFunction>(_expression,
361  &_additional_vars,
362  &_initial_vals);
363 }
364 
365 template <typename Output, typename OutputGradient>
366 inline
367 Output
368 ParsedFunction<Output,OutputGradient>::get_inline_value (const std::string & inline_var_name) const
369 {
370  libmesh_assert_greater (_subexpressions.size(), 0);
371 
372 #ifndef NDEBUG
373  bool found_var_name = false;
374 #endif
375  Output old_var_value(0.);
376 
377  for (const auto & subexpression : _subexpressions)
378  {
379  const std::size_t varname_i =
380  find_name(inline_var_name, subexpression);
381  if (varname_i == std::string::npos)
382  continue;
383 
384  const std::size_t assignment_i =
385  subexpression.find(":", varname_i+1);
386 
387  libmesh_assert_not_equal_to(assignment_i, std::string::npos);
388 
389  libmesh_assert_equal_to(subexpression[assignment_i+1], '=');
390  for (std::size_t i = varname_i+1; i != assignment_i; ++i)
391  libmesh_assert_equal_to(subexpression[i], ' ');
392 
393  std::size_t end_assignment_i =
394  subexpression.find(";", assignment_i+1);
395 
396  libmesh_assert_not_equal_to(end_assignment_i, std::string::npos);
397 
398  std::string new_subexpression =
399  subexpression.substr(0, end_assignment_i+1) +
400  inline_var_name;
401 
402 #ifdef LIBMESH_HAVE_FPARSER
403  // Parse and evaluate the new subexpression.
404  // Add the same constants as we used originally.
405  FunctionParserADBase<Output> fp;
406  fp.AddConstant("NaN", std::numeric_limits<Real>::quiet_NaN());
407  fp.AddConstant("pi", std::acos(Real(-1)));
408  fp.AddConstant("e", std::exp(Real(1)));
409  if (fp.Parse(new_subexpression, variables) != -1) // -1 for success
410  libmesh_error_msg
411  ("ERROR: FunctionParser is unable to parse modified expression: "
412  << new_subexpression << '\n' << fp.ErrorMsg());
413 
414  Output new_var_value = this->eval(fp, new_subexpression, 0);
415 #ifdef NDEBUG
416  return new_var_value;
417 #else
418  if (found_var_name)
419  {
420  libmesh_assert_equal_to(old_var_value, new_var_value);
421  }
422  else
423  {
424  old_var_value = new_var_value;
425  found_var_name = true;
426  }
427 #endif
428 
429 #else
430  libmesh_error_msg("ERROR: This functionality requires fparser!");
431 #endif
432  }
433 
434  libmesh_assert(found_var_name);
435  return old_var_value;
436 }
437 
438 
439 template <typename Output, typename OutputGradient>
440 inline
441 void
442 ParsedFunction<Output,OutputGradient>::set_inline_value (const std::string & inline_var_name,
443  Output newval)
444 {
445  libmesh_assert_greater (_subexpressions.size(), 0);
446 
447 #ifndef NDEBUG
448  bool found_var_name = false;
449 #endif
450  for (auto & subexpression : _subexpressions)
451  {
452  const std::size_t varname_i =
453  find_name(inline_var_name, subexpression);
454  if (varname_i == std::string::npos)
455  continue;
456 
457 #ifndef NDEBUG
458  found_var_name = true;
459 #endif
460  const std::size_t assignment_i =
461  subexpression.find(":", varname_i+1);
462 
463  libmesh_assert_not_equal_to(assignment_i, std::string::npos);
464 
465  libmesh_assert_equal_to(subexpression[assignment_i+1], '=');
466  for (std::size_t i = varname_i+1; i != assignment_i; ++i)
467  libmesh_assert_equal_to(subexpression[i], ' ');
468 
469  std::size_t end_assignment_i =
470  subexpression.find(";", assignment_i+1);
471 
472  libmesh_assert_not_equal_to(end_assignment_i, std::string::npos);
473 
474  std::ostringstream new_subexpression;
475  new_subexpression << subexpression.substr(0, assignment_i+2)
476  << std::setprecision(std::numeric_limits<Output>::digits10+2)
477 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
478  << '(' << newval.real() << '+'
479  << newval.imag() << 'i' << ')'
480 #else
481  << newval
482 #endif
483  << subexpression.substr(end_assignment_i,
484  std::string::npos);
485  subexpression = new_subexpression.str();
486  }
487 
488  libmesh_assert(found_var_name);
489 
490  std::string new_expression;
491 
492  for (const auto & subexpression : _subexpressions)
493  {
494  new_expression += '{';
495  new_expression += subexpression;
496  new_expression += '}';
497  }
498 
499  this->partial_reparse(new_expression);
500 }
501 
502 
503 template <typename Output, typename OutputGradient>
504 inline
505 void
507 {
508  _expression = expression;
509  _subexpressions.clear();
510  parsers.clear();
511 
512  size_t nextstart = 0, end = 0;
513 
514  while (end != std::string::npos)
515  {
516  // If we're past the end of the string, we can't make any more
517  // subparsers
518  if (nextstart >= expression.size())
519  break;
520 
521  // If we're at the start of a brace delimited section, then we
522  // parse just that section:
523  if (expression[nextstart] == '{')
524  {
525  nextstart++;
526  end = expression.find('}', nextstart);
527  }
528  // otherwise we parse the whole thing
529  else
530  end = std::string::npos;
531 
532  // We either want the whole end of the string (end == npos) or
533  // a substring in the middle.
534  _subexpressions.push_back
535  (expression.substr(nextstart, (end == std::string::npos) ?
536  std::string::npos : end - nextstart));
537 
538  // fparser can crash on empty expressions
539  if (_subexpressions.back().empty())
540  libmesh_error_msg("ERROR: FunctionParser is unable to parse empty expression.\n");
541 
542  // Parse (and optimize if possible) the subexpression.
543  // Add some basic constants, to Real precision.
544  FunctionParserADBase<Output> fp;
545  fp.AddConstant("NaN", std::numeric_limits<Real>::quiet_NaN());
546  fp.AddConstant("pi", std::acos(Real(-1)));
547  fp.AddConstant("e", std::exp(Real(1)));
548  if (fp.Parse(_subexpressions.back(), variables) != -1) // -1 for success
549  libmesh_error_msg
550  ("ERROR: FunctionParser is unable to parse expression: "
551  << _subexpressions.back() << '\n' << fp.ErrorMsg());
552 
553  // use of derivatives is optional. suppress error output on the console
554  // use the has_derivatives() method to check if AutoDiff was successful.
555  // also enable immediate optimization
556  fp.SetADFlags(FunctionParserADBase<Output>::ADSilenceErrors |
557  FunctionParserADBase<Output>::ADAutoOptimize);
558 
559  // optimize original function
560  fp.Optimize();
561  parsers.push_back(fp);
562 
563  // generate derivatives through automatic differentiation
564  FunctionParserADBase<Output> dx_fp(fp);
565  if (dx_fp.AutoDiff("x") != -1) // -1 for success
566  _valid_derivatives = false;
567  dx_parsers.push_back(dx_fp);
568 #if LIBMESH_DIM > 1
569  FunctionParserADBase<Output> dy_fp(fp);
570  if (dy_fp.AutoDiff("y") != -1) // -1 for success
571  _valid_derivatives = false;
572  dy_parsers.push_back(dy_fp);
573 #endif
574 #if LIBMESH_DIM > 2
575  FunctionParserADBase<Output> dz_fp(fp);
576  if (dz_fp.AutoDiff("z") != -1) // -1 for success
577  _valid_derivatives = false;
578  dz_parsers.push_back(dz_fp);
579 #endif
580  FunctionParserADBase<Output> dt_fp(fp);
581  if (dt_fp.AutoDiff("t") != -1) // -1 for success
582  _valid_derivatives = false;
583  dt_parsers.push_back(dt_fp);
584 
585  // If at end, use nextstart=maxSize. Else start at next
586  // character.
587  nextstart = (end == std::string::npos) ?
588  std::string::npos : end + 1;
589  }
590 }
591 
592 
593 template <typename Output, typename OutputGradient>
594 inline
595 std::size_t
597  const std::string & expr) const
598 {
599  const std::size_t namesize = varname.size();
600  std::size_t varname_i = expr.find(varname);
601 
602  while ((varname_i != std::string::npos) &&
603  (((varname_i > 0) &&
604  (std::isalnum(expr[varname_i-1]) ||
605  (expr[varname_i-1] == '_'))) ||
606  ((varname_i+namesize < expr.size()) &&
607  (std::isalnum(expr[varname_i+namesize]) ||
608  (expr[varname_i+namesize] == '_')))))
609  {
610  varname_i = expr.find(varname, varname_i+1);
611  }
612 
613  return varname_i;
614 }
615 template <typename Output, typename OutputGradient>
616 inline
617 bool
619 {
620  bool is_time_dependent = false;
621 
622  // By definition, time is "t" for FunctionBase-based objects, so we just need to
623  // see if this expression has the variable "t" in it.
624  if (this->find_name(std::string("t"), expression) != std::string::npos)
625  is_time_dependent = true;
626 
627  return is_time_dependent;
628 }
629 
630 // Set the _spacetime argument vector
631 template <typename Output, typename OutputGradient>
632 inline
633 void
635  const Real time)
636 {
637  _spacetime[0] = p(0);
638 #if LIBMESH_DIM > 1
639  _spacetime[1] = p(1);
640 #endif
641 #if LIBMESH_DIM > 2
642  _spacetime[2] = p(2);
643 #endif
644  _spacetime[LIBMESH_DIM] = time;
645 
646  // The remaining locations in _spacetime are currently fixed at construction
647  // but could potentially be made dynamic
648 }
649 
650 // Evaluate the ith FunctionParser and check the result
651 template <typename Output, typename OutputGradient>
652 inline
653 Output
654 ParsedFunction<Output,OutputGradient>::eval (FunctionParserADBase<Output> & parser,
655  const std::string & libmesh_dbg_var(function_name),
656  unsigned int libmesh_dbg_var(component_idx)) const
657 {
658 #ifndef NDEBUG
659  Output result = parser.Eval(_spacetime.data());
660  int error_code = parser.EvalError();
661  if (error_code)
662  {
663  libMesh::err << "ERROR: FunctionParser is unable to evaluate component "
664  << component_idx
665  << " of expression '"
666  << function_name
667  << "' with arguments:\n";
668  for (const auto & item : _spacetime)
669  libMesh::err << '\t' << item << '\n';
670  libMesh::err << '\n';
671 
672  // Currently no API to report error messages, we'll do it manually
673  std::string error_message = "Reason: ";
674 
675  switch (error_code)
676  {
677  case 1:
678  error_message += "Division by zero";
679  break;
680  case 2:
681  error_message += "Square Root error (negative value)";
682  break;
683  case 3:
684  error_message += "Log error (negative value)";
685  break;
686  case 4:
687  error_message += "Trigonometric error (asin or acos of illegal value)";
688  break;
689  case 5:
690  error_message += "Maximum recursion level reached";
691  break;
692  default:
693  error_message += "Unknown";
694  break;
695  }
696  libmesh_error_msg(error_message);
697  }
698 
699  return result;
700 #else
701  return parser.Eval(_spacetime.data());
702 #endif
703 }
704 
705 } // namespace libMesh
706 
707 
708 #else // !LIBMESH_HAVE_FPARSER
709 
710 
711 namespace libMesh {
712 
713 
714 template <typename Output=Number>
715 class ParsedFunction : public FunctionBase<Output>
716 {
717 public:
718  ParsedFunction (const std::string & /* expression */,
719  const std::vector<std::string> * = nullptr,
720  const std::vector<Output> * = nullptr) : _dummy(0)
721  {
722  libmesh_not_implemented();
723  }
724 
729  ParsedFunction (ParsedFunction &&) = delete;
730  ParsedFunction (const ParsedFunction &) = delete;
731  ParsedFunction & operator= (const ParsedFunction &) = delete;
733  virtual ~ParsedFunction () = default;
734 
735  virtual Output operator() (const Point &,
736  const Real /* time */ = 0)
737  { return 0.; }
738 
739  virtual void operator() (const Point &,
740  const Real /* time */,
741  DenseVector<Output> & /* output */) {}
742 
743  virtual void init() {}
744  virtual void clear() {}
745  virtual Output & getVarAddress(const std::string & /*variable_name*/) { return _dummy; }
746  virtual std::unique_ptr<FunctionBase<Output>> clone() const
747  {
748  return libmesh_make_unique<ParsedFunction<Output>>("");
749  }
750 private:
751  Output _dummy;
752 };
753 
754 
755 
756 } // namespace libMesh
757 
758 
759 #endif // LIBMESH_HAVE_FPARSER
760 
761 #endif // LIBMESH_PARSED_FUNCTION_H
libMesh::ParsedFunction::component
virtual Output component(unsigned int i, const Point &p, Real time) override
Definition: parsed_function.h:323
libMesh::ParsedFunction::find_name
std::size_t find_name(const std::string &varname, const std::string &expr) const
Helper function for parsing out variable names.
Definition: parsed_function.h:596
libMesh::ParsedFunction::dy_parsers
std::vector< FunctionParserADBase< Output > > dy_parsers
Definition: parsed_function.h:192
libMesh::FunctionBase
Base class for functors that can be evaluated at a point and (optionally) time.
Definition: dirichlet_boundaries.h:44
libMesh::ParsedFunction
A Function generated (via FParser) by parsing a mathematical expression.
Definition: parsed_function.h:60
libMesh::ParsedFunction::_valid_derivatives
bool _valid_derivatives
Definition: parsed_function.h:198
libMesh::ParsedFunction::_initial_vals
std::vector< Output > _initial_vals
Definition: parsed_function.h:203
libMesh::ParsedFunction::eval
Output eval(FunctionParserADBase< Output > &parser, const std::string &libmesh_dbg_var(function_name), unsigned int libmesh_dbg_var(component_idx)) const
Evaluate the ith FunctionParser and check the result.
Definition: parsed_function.h:654
libMesh::ParsedFunction::operator()
virtual Output operator()(const Point &p, const Real time=0) override
Definition: parsed_function.h:262
libMesh::ParsedFunction::ParsedFunction
ParsedFunction(const std::string &expression, const std::vector< std::string > *additional_vars=nullptr, const std::vector< Output > *initial_vals=nullptr)
Definition: parsed_function.h:211
libMesh::ParsedFunction::gradient
virtual OutputGradient gradient(const Point &p, const Real time=0)
Definition: parsed_function.h:280
libMesh::ParsedFunction::get_inline_value
Output get_inline_value(const std::string &inline_var_name) const
Definition: parsed_function.h:368
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::ParsedFunction::dx_parsers
std::vector< FunctionParserADBase< Output > > dx_parsers
Definition: parsed_function.h:190
libMesh::ParsedFunction::dt_parsers
std::vector< FunctionParserADBase< Output > > dt_parsers
Definition: parsed_function.h:197
libMesh::ParsedFunction::ParsedFunction
ParsedFunction(const std::string &, const std::vector< std::string > *=nullptr, const std::vector< Output > *=nullptr)
Definition: parsed_function.h:718
libMesh::ParsedFunction::dot
virtual Output dot(const Point &p, const Real time=0)
Definition: parsed_function.h:271
end
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end.
Definition: variant_filter_iterator.h:343
libMesh::ParsedFunction::_subexpressions
std::vector< std::string > _subexpressions
Definition: parsed_function.h:185
libMesh::ParsedFunction::clear
virtual void clear()
Clears the function.
Definition: parsed_function.h:744
libMesh::ParsedFunction::variables
std::string variables
Definition: parsed_function.h:201
libMesh::ParsedFunction::init
virtual void init()
The actual initialization process.
Definition: parsed_function.h:743
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::ParsedFunction::~ParsedFunction
virtual ~ParsedFunction()=default
libMesh::ParsedFunction::getVarAddress
virtual Output & getVarAddress(const std::string &variable_name)
Definition: parsed_function.h:342
libMesh::ParsedFunction::clone
virtual std::unique_ptr< FunctionBase< Output > > clone() const override
Definition: parsed_function.h:358
libMesh::ParsedFunction::has_derivatives
virtual bool has_derivatives()
Query if the automatic derivative generation was successful.
Definition: parsed_function.h:105
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::ParsedFunction::clone
virtual std::unique_ptr< FunctionBase< Output > > clone() const
Definition: parsed_function.h:746
libMesh::ParsedFunction::expression
const std::string & expression()
Definition: parsed_function.h:121
libMesh::ParsedFunction::partial_reparse
void partial_reparse(const std::string &expression)
Re-parse with minor changes to expression.
Definition: parsed_function.h:506
libMesh::ParsedFunction::set_spacetime
void set_spacetime(const Point &p, const Real time=0)
Set the _spacetime argument vector.
Definition: parsed_function.h:634
libMesh::ParsedFunction::_dummy
Output _dummy
Definition: parsed_function.h:751
libMesh::ParsedFunction::parsers
std::vector< FunctionParserADBase< Output > > parsers
Definition: parsed_function.h:186
libMesh::ParsedFunction::dz_parsers
std::vector< FunctionParserADBase< Output > > dz_parsers
Definition: parsed_function.h:195
std
Definition: float128_shims.h:27
libMesh::ParsedFunction::set_inline_value
void set_inline_value(const std::string &inline_var_name, Output newval)
Changes the value of an inline variable.
Definition: parsed_function.h:442
libMesh::ParsedFunction::expression_is_time_dependent
bool expression_is_time_dependent(const std::string &expression) const
Definition: parsed_function.h:618
libMesh::ParsedFunction::_spacetime
std::vector< Output > _spacetime
Definition: parsed_function.h:187
libMesh::ParsedFunction::operator=
ParsedFunction & operator=(const ParsedFunction &)=delete
This class cannot be (default) copy assigned because the underlying FunctionParserADBase class does n...
libMesh::err
OStreamProxy err
libMesh::ParsedFunction::_additional_vars
std::vector< std::string > _additional_vars
Definition: parsed_function.h:202
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::ParsedFunction::_expression
std::string _expression
Definition: parsed_function.h:184
libMesh::ParsedFunction::reparse
void reparse(const std::string &expression)
Re-parse with new expression.
Definition: parsed_function.h:231
libMesh::ParsedFunction::getVarAddress
virtual Output & getVarAddress(const std::string &)
Definition: parsed_function.h:745
libMesh::DenseVector< Output >