testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 2D Delaunay triangles meshes: scheme order is ", -a
+ print( "FE for diffusion on 2D Delaunay triangles meshes: scheme order is ", -a)
assert abs(a+2)<0.02
# Plot of convergence curve
### 2D FE right triangles mesh
method = 'FE'
BC = 'Dirichlet'
- meshList=[5,20,50,100, 200,400]
+ meshList=[5,20,50,100, 200]
nbMeshes=len(meshList)
error_tab=[0]*nbMeshes
mesh_size_tab=[0]*nbMeshes
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-0.001
- assert max_sol_num<1.003
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-0.001
+ assert max_sol_num<1.003
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 2D right triangle meshes: scheme order is ", -a
+ print( "FE for diffusion on 2D right triangle meshes: scheme order is ", -a)
assert abs(a+2)<0.01
# Plot of convergence curve
curv_abs=np.linspace(0,sqrt(2),resolution+1)
plt.close('all')
i=0
- testColor="Orange (not order 2), singular matrix"
+ testColor="Red, to be investigated"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>=-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a
+ print( "FE for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a)
assert abs(a+0.82)<0.02
# Plot of convergence curve
### 2D FE right triangles mesh
method = 'FE'
BC = 'Neumann'
- meshList=[5,20,50,100, 200,400]
+ meshList=[5,20,50,100, 200]
nbMeshes=len(meshList)
error_tab=[0]*nbMeshes
mesh_size_tab=[0]*nbMeshes
curv_abs=np.linspace(0,sqrt(2),resolution+1)
plt.close('all')
i=0
- testColor="Orange (not order 2), singular matrix"
+ testColor="Red, to be investigated"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1.22
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1.22
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 2D right triangle meshes: scheme order is ", -a
+ print( "FE for diffusion on 2D right triangle meshes: scheme order is ", -a)
assert abs(a+0.91)<0.01
# Plot of convergence curve
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a)
assert abs(a+0.6)<0.02
# Plot of convergence curve
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ assert min_sol_num>-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D Equilateral triangle meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D Equilateral triangle meshes: scheme order is ", -a)
assert abs(a+1.97)<0.01
# Plot of convergence curve
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D hexagon meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D hexagon meshes: scheme order is ", -a)
assert abs(a+1.94)<0.01
# Plot of convergence curve
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-0.001
- assert max_sol_num<1.01
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-0.001
+ assert max_sol_num<1.01
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D right triangle meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D right triangle meshes: scheme order is ", -a)
assert abs(a+0.02)<0.01
# Plot of convergence curve
curv_abs=np.linspace(0,sqrt(2),resolution+1)
plt.close('all')
i=0
- testColor="Green"
+ testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num> 1e-5
- assert max_sol_num<1.04
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ assert min_sol_num> 1e-5
+ assert max_sol_num<1.04
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D square meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D square meshes: scheme order is ", -a)
assert abs(a+2)<0.1
# Plot of convergence curve
with open('Convergence_Poisson_2DFV_'+mesh_name+'.json', 'w') as outfile:
json.dump(convergence_synthesis, outfile)
if __name__ == """__main__""":
- convergence_StationaryDiffusion_2DFV_Dirichlet_Squares()
+ convergence_StationaryDiffusion_2DFV_Dirichlet_Squares()
testColor="Red"#Linear solver fails
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1
- assert max_sol_num<1.2
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1
+ assert max_sol_num<1.2
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D Delaunay triangle meshes: scheme order is ", -a)
assert abs(a+0.6)<0.02
# Plot of convergence curve
### 2D FV right triangles mesh
method = 'FV'
BC = 'Neumann'
- meshList=[5,20,50,100, 200,400]
+ meshList=[5,20,50,100, 200]
nbMeshes=len(meshList)
error_tab=[0]*nbMeshes
mesh_size_tab=[0]*nbMeshes
curv_abs=np.linspace(0,sqrt(2),resolution+1)
plt.close('all')
i=0
- testColor="Orange \n (suspicious order 0 convergence), singular matrix"#Convergence of the linear solver if direct solver. Scheme seems to diverge (order -0.005)
+ testColor="Red, to be investigated"#Convergence of the linear solver if direct solver. Scheme seems to diverge (order -0.005)
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>-1.22
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>-1.22
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D right triangle meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D right triangle meshes: scheme order is ", -a)
assert abs(a-0.005)<0.01
# Plot of convergence curve
### 2D FV Square mesh
method='FV'
BC = 'Neumann'
- meshList=[5,20,50,100, 200,400]
+ meshList=[5,20,50,100, 200]
nbMeshes=len(meshList)
error_tab=[0]*nbMeshes
mesh_size_tab=[0]*nbMeshes
curv_abs=np.linspace(0,sqrt(2),resolution+1)
plt.close('all')
i=0
- testColor="Green, despite singular matrix"
+ testColor="Red, to be investigated"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num> -1.
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ assert min_sol_num> -1.
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 2D square meshes: scheme order is ", -a
+ print( "FV for diffusion on 2D square meshes: scheme order is ", -a)
assert abs(a+2)<0.1
# Plot of convergence curve
with open('Convergence_Poisson_2DFV_'+mesh_name+'.json', 'w') as outfile:
json.dump(convergence_synthesis, outfile)
if __name__ == """__main__""":
- convergence_StationaryDiffusion_2DFV_Neumann_Squares()
+ convergence_StationaryDiffusion_2DFV_Neumann_Squares()
### 3D FE Delaunay Tetrahedra meshes
method = 'FE'
BC = 'Dirichlet'
- meshList=['meshCubeTetrahedra_0','meshCubeTetrahedra_1','meshCubeTetrahedra_2','meshCubeTetrahedra_3','meshCubeTetrahedra_4','meshCubeTetrahedra_5','meshCubeTetrahedra_6']
+ meshList=['meshCubeTetrahedra_0','meshCubeTetrahedra_1','meshCubeTetrahedra_2','meshCubeTetrahedra_3','meshCubeTetrahedra_4','meshCubeTetrahedra_5']
mesh_path=os.environ['CDMATH_INSTALL']+'/share/meshes/3DTetrahedra/'
mesh_name='cubeWithDelaunayTetrahedra'
meshType="Unstructured_Tetrahedra"
testColor="Orange (not order 2)"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>=0
- assert max_sol_num<1
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>=0
+ assert max_sol_num<1
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a
+ print( "FE for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a)
assert abs(a+0.627)<0.01
# Plot of convergence curve
### 3D FE Regular Tetrahedra meshes
method = 'FE'
BC = 'Dirichlet'
- meshList=[5,20,50,70]
+ meshList=[5,10,20]
mesh_name='cubeWithRegularTetrahedra'
meshType="Regular_Tetrahedra"
nbMeshes=len(meshList)
testColor="Orange (not order 2)"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>=0.
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>=0.
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FE for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a
- assert abs(a+1.34)<0.001
+ print( "FE for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a)
+ assert abs(a+1.34)<0.003
# Plot of convergence curve
plt.close()
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for filename in meshList:
- my_mesh=cm.Mesh(mesh_path+filename+".med")
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(mesh_path+filename+".med")
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>=0
- assert max_sol_num<1
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>=0
+ assert max_sol_num<1
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a
+ print( "FV for diffusion on 3D Delaunay tetrahedron meshes: scheme order is ", -a)
assert abs(a+0.54)<0.01
# Plot of convergence curve
### 3D FV Regular Cubes meshes
method = 'FV'
BC = 'Dirichlet'
- meshList=[5,20,50,100]
+ meshList=[5,10,20,30]
mesh_name='cubeWithRegularCubes'
meshType="Regular_Cubes"
nbMeshes=len(meshList)
testColor="Orange (not order 2)"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>0.
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>0.
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a
+ print( "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a)
assert abs(a+1.34)<0.01
# Plot of convergence curve
### 3D FV Regular Tetrahedra meshes
method = 'FV'
BC = 'Dirichlet'
- meshList=[5,10,20,30]
+ meshList=[5,10,15,20]
mesh_name='cubeWithRegularTetrahedra'
meshType="Regular_Tetrahedra"
nbMeshes=len(meshList)
testColor="Green"
# Storing of numerical errors, mesh sizes and diagonal values
for nx in meshList:
- my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1)
- error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
+ my_mesh=cm.Mesh(0,1,nx,0,1,nx,0,1,nx,1)
+ error_tab[i], mesh_size_tab[i], diag_data[i], min_sol_num, max_sol_num, time_tab[i] =validationStationaryDiffusionEquation.SolveStationaryDiffusionEquation(my_mesh,resolution,meshType,method,BC)
- assert min_sol_num>0.
- assert max_sol_num<1.
- plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
- error_tab[i]=log10(error_tab[i])
- time_tab[i]=log10(time_tab[i])
- mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
- i=i+1
+ assert min_sol_num>0.
+ assert max_sol_num<1.
+ plt.plot(curv_abs, diag_data[i], label= str(mesh_size_tab[i]) + ' cells')
+ error_tab[i]=log10(error_tab[i])
+ time_tab[i]=log10(time_tab[i])
+ mesh_size_tab[i] = 0.5*log10(mesh_size_tab[i])
+ i=i+1
end = time.time()
a=( a3*b1-a2*b2)/det
b=(-a2*b1+a1*b2)/det
- print "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a
- assert abs(a+0.006)<0.001
+ print( "FV for diffusion on 3D regular tetrahedron meshes: scheme order is ", -a)
+ assert abs(a+0.0006)<0.001
# Plot of convergence curve
plt.close()
erreur_abs=0
if method =='FE':
for i in range(my_mesh.getNumberOfNodes()) :
- if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) :
+ if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) :
erreur_abs = abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i])
else:
for i in range(my_mesh.getNumberOfCells()) :
- if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) :
+ if erreur_abs < abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i]) :
erreur_abs = abs(my_RHSfield[i]/(spaceDim*pi*pi) - my_ResultField[i])
print("Absolute error = max(| exact solution - numerical solution |) = ",erreur_abs )
print("Relative error = max(| exact solution - numerical solution |)/max(| exact solution |) = ",erreur_abs/max_abs_sol_exacte)