Problem using Gmesh - solution to manufactured problem gives errors that are too large.
6 months ago by
Hi I am new to fenics and have been doing the examples. In the example above, I solved the Poisson equation for a manufactured solution using a mesh created with UnitSquareMesh. I get the expected error of 10e-15. Next I created a mesh with Gmesh for a unit square and I generated a msh file. I used convert-mesh to generate the xml file. Then I read the xml file and generated the mesh using Mesh(‘name.xml’). Now, checking the error between the computed solution and the exact solution gives errors in the range of 10e-5. Can anyone explain what I am doing wrong? I am using fenics installed with Docker, python3 and Gmesh 3.0 on a machine running Windows 7.
from fenics import * #replace dolfin with fenics import numpy as np #use np # Create mesh from internal method mesh = UnitSquareMesh(3, 3) #Create mesh from XML file #mesh = Mesh("mesh.xml") #define function space V = FunctionSpace(mesh, 'Lagrange', 1) # Define boundary conditions u_D = Expression('1. + x*x + 2*x*x', degree=2) #u_D, degree = 2 def u0_boundary(x, on_boundary): return on_boundary bc = DirichletBC(V, u_D, u0_boundary) # Define variational problem u = TrialFunction(V) v = TestFunction(V) f = Constant(-6.0) a = dot(grad(u), grad(v))*dx #new for for a L = f*v*dx # Compute solution u = Function(V) solve(a == L, u, bc)
Community: FEniCS Project
Please login to add an answer/comment or follow this question.