https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | List of all members
ADFParser Class Reference

#include <ADFParser.h>

Inheritance diagram for ADFParser:
[legend]

Public Member Functions

 ADFParser ()
 
 ADFParser (const ADFParser &cpy)
 
bool JITCompile ()
 
Real Eval (const Real *)
 
ADReal Eval (const ADReal *Vars)
 

Protected Attributes

const Real _epsilon
 

Detailed Description

Definition at line 17 of file ADFParser.h.

Constructor & Destructor Documentation

◆ ADFParser() [1/2]

ADFParser::ADFParser ( )

Definition at line 14 of file ADFParser.C.

14 : FunctionParserAD(), _epsilon(1e-12) {}
const Real _epsilon
Definition: ADFParser.h:29

◆ ADFParser() [2/2]

ADFParser::ADFParser ( const ADFParser cpy)

Definition at line 16 of file ADFParser.C.

16 : FunctionParserAD(cpy), _epsilon(1e-12) {}
const Real _epsilon
Definition: ADFParser.h:29

Member Function Documentation

◆ Eval() [1/2]

Real ADFParser::Eval ( const Real )
inline

Definition at line 25 of file ADFParser.h.

25 { mooseError("Not implemented."); }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ Eval() [2/2]

ADReal ADFParser::Eval ( const ADReal Vars)

Definition at line 65 of file ADFParser.C.

66 {
67  mooseAssert(compiledFunction, "ADFParser objects must be JIT compiled before evaluation!");
68  ADReal ret;
69  (*reinterpret_cast<CompiledFunctionPtr<ADReal>>(compiledFunction))(&ret, vars, pImmed, _epsilon);
70  return ret;
71 }
char ** vars
const Real _epsilon
Definition: ADFParser.h:29
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47

◆ JITCompile()

bool ADFParser::JITCompile ( )

Definition at line 27 of file ADFParser.C.

28 {
29 #if LIBMESH_HAVE_FPARSER_JIT
30  std::string includes;
31  const auto type_hash = typeid(ADReal).hash_code();
32  bool result;
33 
34  std::string fopenmp;
35 #if defined(_OPENMP)
36  fopenmp = "-fopenmp";
37 #endif
38 
39  const auto include_path_env = std::getenv("MOOSE_ADFPARSER_JIT_INCLUDE");
40  if (include_path_env)
41  result = JITCompileHelper(
42  "ADReal", fopenmp, "#include \"" + std::string(include_path_env) + "\"\n", type_hash);
43  else
44  {
45  // check if we can find an installed version of the monolithic include
46  const std::string include_path =
47  MooseUtils::pathjoin(Moose::getExecutablePath(), "../include/moose/ADRealMonolithic.h");
48  if (MooseUtils::checkFileReadable(include_path, false, false, false))
49  result =
50  JITCompileHelper("ADReal", fopenmp, "#include \"" + include_path + "\"\n", type_hash);
51  else
52  // otherwise use the compiled in location from the source tree
53  result = JITCompileHelper(
54  "ADReal", fopenmp + " " + ADFPARSER_INCLUDES, "#include \"ADReal.h\"\n", type_hash);
55  }
56 
57  if (!result)
58 #endif
59  mooseError("ADFParser::JITCompile() failed. Evaluation not possible.");
60 
61  return true;
62 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
std::string getExecutablePath()
This function returns the PATH of the running executable.
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true, bool check_for_git_lfs_pointer=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:250
std::filesystem::path pathjoin(const std::filesystem::path &p)
Definition: MooseUtils.C:59

Member Data Documentation

◆ _epsilon

const Real ADFParser::_epsilon
protected

Definition at line 29 of file ADFParser.h.

Referenced by Eval().


The documentation for this class was generated from the following files: