manufactured solutions


211
views
0
7 months ago by
Hi,

In the 2016 version of FEniCS one could easily perform symbolic operations to e.g. compute right hand sides of a PDE.

With the 2017 versions the compiler complains about jit and cannot do, for example,

p_ex = Expression("sin(pi*x[0])*sin(pi*x[1])", degree = 3, cell=triangle)

s = div(grad(p_ex))
​
Community: FEniCS Project

2 Answers


5
7 months ago by
This never used to give expected value of s, i.e. pi**2*p_ex. Because p_ex is a not a sine, it is a continuous piece-wise polynomial of degree 3 (interpolating sine).

As of general approach to do symbolic computation of manufactured solutions I like using SymPy to generate C++ code for Expressions. See, https://github.com/blechta/dolfin-tape/blob/master/dolfintape/demo_problems/exact_solutions.py for examples.
I am not sure I understood the question. :)
written 7 months ago by Minas Mattheakis  
Great! Thank you very much
written 7 months ago by Ever Ardo RB  
2
7 months ago by
Hi,

you have to project p_ex and then compute s. Try this:

mesh = UnitSquareMesh(10, 10)
Q = FunctionSpace(mesh, 'P', 2)
p_ex = Expression("sin(pi*x[0])*sin(pi*x[1])", degree = 3, cell=triangle)
p_ex = project(p_ex, Q)
s = Function(Q)
vtfile = File('1/s.pvd')
s = project(div(nabla_grad(p_ex)), Q) 
vtfile << s​
Please login to add an answer/comment or follow this question.

Similar posts:
Search »