Skip to content

# idaholab/moose

Merge pull request #13308 from aeslaughter/python-mms

`Return components of vector PDEs`
• Loading branch information...
aeslaughter committed Apr 25, 2019
2 parents 6cda000 + dcc301c commit 558ff84110297bea4b558fab971f6e08dc211946
 @@ -39,6 +39,5 @@ ADLagrangeVecFunctionDirichletBC::computeQpResidual() _values = RealVectorValue(_exact_x.value(_t, *_current_node), _exact_y.value(_t, *_current_node), _exact_z.value(_t, *_current_node)); return _u - _values; }
 @@ -94,15 +94,30 @@ def evaluate(pde, soln, variable='u', locals()['{}_y'.format(_f_)] = locals()[_f_].components.get(R.j, 0) locals()['{}_z'.format(_f_)] = locals()[_f_].components.get(R.k, 0) locals()[variable] = eval(soln) # Evaluate the supplied solution _exact_ = eval(soln) locals()[variable] = _exact_ # Evaluate the PDE pde = pde.replace('grad', 'gradient') pde = pde.replace('div', 'divergence') _func_ = eval(pde) if negative: return -eval(pde), locals()[variable] else: return eval(pde), locals()[variable] _func_ = -1 * _func_ # Convert vector exact solution to a list if isinstance(_exact_, Vector): _exact_ = [_exact_.components.get(R.i, 0), _exact_.components.get(R.j, 0), _exact_.components.get(R.k, 0)] # Convert vector result to a list if isinstance(_func_, Vector): _func_ = [_func_.components.get(R.i, 0), _func_.components.get(R.j, 0), _func_.components.get(R.k, 0)] return _func_, _exact_ def _check_reserved(var): """Error checking for input variables."""
 @@ -57,6 +57,15 @@ def testEvaluateWithKwargs(self): self.assertEqual(s, '-x^2*k*t*sin(x*t) + 2*x*k*cos(x*t)') def testEvaluateVectorFunction(self): f, e = mms.evaluate('div(u.outer(u))', 'cos(x*t)*e_i') s = mms.fparser(f) self.assertEqual(s, '[-2*t*sin(x*t)*cos(x*t), 0, 0]') s = mms.fparser(e) self.assertEqual(s, '[cos(x*t), 0, 0]') def testExceptions(self): try:

#### 0 comments on commit `558ff84`

Please sign in to comment.
You can’t perform that action at this time.