Dear Sir/Mam,
when i am trying to find out L2 norm of the error, the error increases as finer the mesh. for example, when ‘mesh = UnitSquareMesh(4,4)’ error_L2 = 0.0956198463430736, when ‘mesh = UnitSquareMesh(16,16)’ error_L2 = 0.1695765431464665.
when we are going to finer and finer mesh , the error should decreases, and the order of convergence should 2. But here error increases.
Kindly clarify the issues .
waiting for positive response!
Your analytical solution (1 + x^2 + y^2, 1 + y x + 2 y)^\top is exactly representable by a second order (or higher) polynomial approximation. So as @dokken states, your error is machine precision.
If you want to examine convergence rates for higher order polynomials, you need to design a solution which is not exactly representable by a (Lagrange) polynomial approximation.
Could you Please tell me , How to plot 3d- diagram of u_1 and u_2 ,
where , u=(u_1, u_2) in paraview. Similarly for u_D1, u_D2, where u_D= Expression((‘u_D1’, ‘u_D1’), degree=2) in paraview.
It is possible to plot 3d diagram of u when it is a scalar problem, Issues are having when u as a solution of vector problem.
from __future__ import print_function
from fenics import *
import numpy as np
mesh = UnitSquareMesh(8, 8)
V = VectorFunctionSpace(mesh, 'P', 2)
u_D = Expression(('1 + x[0]*x[0]+x[1]*x[1] ', '1 + x[1]*x[0] + 2*x[1]'), degree=2)
bc=DirichletBC(V,u_D, "on_boundary")
bcu=[bc]
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant((-4,0))
a=inner(grad(u),grad(v))*dx
b=inner(f,v)*dx
u=Function(V)
solve(a==b, u, bcu)
(u_1,u_2)=u.split(True)
u_1file_pvd=File("u_1.pvd")
u_1file_pvd << u_1
Dear @dokken ,
From the previous problem u is vector function not a scalar function , when u is a scalar function , i can save as .pvd, then it is possible to plot its 3d-figure in paraview, when u is vector function containing two components say u1 and u2 as u=(u1,u2) then it is not possible to plot it’s 3d-figure.
I have to plot u1 and u2 separately. How is it possible?
Warp by vector and warp by scalar are two very different functions.
Warp by scalar warps a function from 2D to 3D. Warp by vector warps a function from 2D to 2D (as seen in your figures). You need to carefully think about how you would like to warp your vector function, as it does not make sense to warp it into 3D.
But such a plot for a vector function does not make sense (at it has both an x and a y component) How do you want to warp the vector?
If you want to warp the domain by the magnitude of the vector, you can do it by choosing Filters->Calculator and insert sqrt(f_8.f_8) (if f_8 is the name of the vector field (this can be looked up in the Vectors part of the calculator). Press apply and use the Warp by scalar filter on the result.