MMS Verification of LevelSetAdvection Kernel

This computes the forcing function for a known solution of the advection portion of the level set equation.

Load the necessary python libraries.


In [1]:
%matplotlib inline
import glob
from sympy import *
import pandas
init_printing()

Define the Manufactured solution

Define the assumed (exact) solution as a fuction of x with a non-constant velocity.


In [2]:
x,a,b= symbols('x a b')
v = 2 
u = a*cos(pi*x)*sin(pi*x/b)
u


Out[2]:
$$a \sin{\left (\frac{\pi x}{b} \right )} \cos{\left (\pi x \right )}$$

Compute the forcing function.


In [3]:
f = v*diff(u, x)
f


Out[3]:
$$- 2 \pi a \sin{\left (\pi x \right )} \sin{\left (\frac{\pi x}{b} \right )} + \frac{2 \pi}{b} a \cos{\left (\pi x \right )} \cos{\left (\frac{\pi x}{b} \right )}$$

Create ParsedFunction Strings

Build a string of the exact and forcing function to be copied to the input file (advection_mms.i).

The only syntax that needs to change to make this string work with MOOSE ParsedFunction is the exponent operator.


In [4]:
str(u).replace('**', '^')


Out[4]:
'a*sin(pi*x/b)*cos(pi*x)'

In [5]:
str(f).replace('**', '^')


Out[5]:
'-2*pi*a*sin(pi*x)*sin(pi*x/b) + 2*pi*a*cos(pi*x)*cos(pi*x/b)/b'

Convergence Plot


In [11]:
%run convergence.py