Skip to content

Commit

Permalink
add gradient and dot to NooseParsedFunctionWrapper (idaholab#3312)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Jun 12, 2014
1 parent 7bcc307 commit b2be9d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
12 changes: 12 additions & 0 deletions framework/include/functions/MooseParsedFunctionWrapper.h
Expand Up @@ -65,6 +65,18 @@ class MooseParsedFunctionWrapper
template<typename T>
T evaluate(Real t, const Point & p);

/**
* Evaluate the gradient of the function which libMesh provides through
* automatic differentiation
*/
RealGradient evaluateGradient(Real t, const Point & p);

/**
* Evaluate the time derivative of the function which libMesh provides through
* automatic differentiation
*/
Real evaluateDot(Real t, const Point & p);

private:

/// Reference to the FEProblem object
Expand Down
22 changes: 21 additions & 1 deletion framework/src/functions/MooseParsedFunctionWrapper.C
Expand Up @@ -27,7 +27,7 @@ MooseParsedFunctionWrapper::MooseParsedFunctionWrapper(FEProblem & feproblem,
initialize();

// Create the libMesh::ParsedFunction
_function_ptr = new ParsedFunction<Real>(_function_str, &_vars, &_vals);
_function_ptr = new ParsedFunction<Real,RealGradient>(_function_str, &_vars, &_vals);

// Loop through the Postprocessor variables and point the libMesh::ParsedFunction to the PostprocessorValue
for (unsigned int i = 0; i < _pp_index.size(); ++i)
Expand Down Expand Up @@ -76,6 +76,26 @@ MooseParsedFunctionWrapper::evaluate(Real t, const Point & p)
);
}

RealGradient
MooseParsedFunctionWrapper::evaluateGradient(Real t, const Point & p)
{
// Update the postprocessor / libMesh::ParsedFunction references for the desired function
update();

// Evalute the gradient of the function
return _function_ptr->gradient(p, t);
}

Real
MooseParsedFunctionWrapper::evaluateDot(Real t, const Point & p)
{
// Update the postprocessor / libMesh::ParsedFunction references for the desired function
update();

// Evalute the time derivative
return _function_ptr->dot(p, t);
}

void
MooseParsedFunctionWrapper::initialize()
{
Expand Down

0 comments on commit b2be9d8

Please sign in to comment.