Skip to content
Snippets Groups Projects
Commit 3f579773 authored by Tscherpel, Tabea's avatar Tscherpel, Tabea
Browse files

Replace meshquantities.py

parent 4fc1afc1
Branches main
No related tags found
No related merge requests found
...@@ -10,63 +10,6 @@ from mshr import * ...@@ -10,63 +10,6 @@ from mshr import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import tikzplotlib import tikzplotlib
## define 3D meshes
dim = 3 # space dimension
s = 20.0 # scaling factor
mesh1 = meshcube(2,s) # mesh of cube domain
mesh2 = meshdiamond(50,s) # mesh of diamond shaped domain with 50 slices
refpt = [.1111111,.33333333,0.33333333]
## plot initial meshes
plt.figure(1)
plot(mesh1)
plt.savefig("cube_mesh.png")
tikzplotlib.save("cube_mesh.tex")
plt.figure(2)
plot(mesh2)
plt.savefig("diamond_mesh.png")
tikzplotlib.save("diamond_mesh.tex")
## uniform refinement
# with maximal 5 full refinements and at most 10^6 vertices in the final mesh
vlist1, ebarlist1 = ebar(mesh1,0,6,10e+6,refpt)
vlist2, ebarlist2 = ebar(mesh2,0,6,10e+6,refpt)
plt.figure(3)
plt.semilogx(vlist1,ebarlist1,'-o')
plt.semilogx(vlist2,ebarlist2,'-s')
plt.semilogx(vlist2,14*np.ones(len(vlist1)),'--k')
plt.ylim([7, 15])
plt.legend(['$\mathcal{T}_0 = \mathcal{T}_{F}$',\
'$\mathcal{T}_0 = \mathcal{T}_{D,50}$'],\
loc="upper left")
plt.xlabel('V')
plt.ylabel('$\overline{e}$')
plt.grid()
tikzplotlib.save("ebar_unif.tex")
plt.savefig("ebar_unif.png")
## adaptive refinement (58 times)
vlist3, ebarlist3 = ebar(mesh1,1,58,10e+6,refpt)
vlist4, ebarlist4 = ebar(mesh2,1,58,10e+6,refpt)
plt.figure(4)
plt.semilogx(vlist3,ebarlist3,'-o')
plt.semilogx(vlist4,ebarlist4,'-s')
plt.semilogx(vlist4,14*np.ones(len(vlist4)),'--k')
plt.ylim([7, 15])
plt.legend(['$\mathcal{T}_0 = \mathcal{T}_{F}$',\
'$\mathcal{T}_0 = \mathcal{T}_{D,50}$'],\
loc="upper left")
plt.xlabel('V')
plt.ylabel('$\overline{e}$')
plt.grid()
tikzplotlib.save("ebar_adapt.tex")
plt.savefig("ebar_adapt.png")
plt.show()
#################### ####################
##### routines ##### ##### routines #####
#################### ####################
...@@ -193,3 +136,64 @@ def adaptiveref(mesh,refpt): ...@@ -193,3 +136,64 @@ def adaptiveref(mesh,refpt):
return(mesh) return(mesh)
####################
### main routine ###
####################
## define 3D meshes
dim = 3 # space dimension
s = 20.0 # scaling factor
mesh1 = meshcube(2,s) # mesh of cube domain
mesh2 = meshdiamond(50,s) # mesh of diamond shaped domain with 50 slices
refpt = [.1111111,.33333333,0.33333333]
## plot initial meshes
plt.figure(1)
plot(mesh1)
plt.savefig("cube_mesh.png")
tikzplotlib.save("cube_mesh.tex")
plt.figure(2)
plot(mesh2)
plt.savefig("diamond_mesh.png")
tikzplotlib.save("diamond_mesh.tex")
## uniform refinement
# with maximal 5 full refinements and at most 10^6 vertices in the final mesh
vlist1, ebarlist1 = ebar(mesh1,0,6,10e+6,refpt)
vlist2, ebarlist2 = ebar(mesh2,0,6,10e+6,refpt)
plt.figure(3)
plt.semilogx(vlist1,ebarlist1,'-o')
plt.semilogx(vlist2,ebarlist2,'-s')
plt.semilogx(vlist2,14*np.ones(len(vlist1)),'--k')
plt.ylim([7, 15])
plt.legend(['$\mathcal{T}_0 = \mathcal{T}_{F}$',\
'$\mathcal{T}_0 = \mathcal{T}_{D,50}$'],\
loc="upper left")
plt.xlabel('V')
plt.ylabel('$\overline{e}$')
plt.grid()
tikzplotlib.save("ebar_unif.tex")
plt.savefig("ebar_unif.png")
## adaptive refinement (58 times)
vlist3, ebarlist3 = ebar(mesh1,1,58,10e+6,refpt)
vlist4, ebarlist4 = ebar(mesh2,1,58,10e+6,refpt)
plt.figure(4)
plt.semilogx(vlist3,ebarlist3,'-o')
plt.semilogx(vlist4,ebarlist4,'-s')
plt.semilogx(vlist4,14*np.ones(len(vlist4)),'--k')
plt.ylim([7, 15])
plt.legend(['$\mathcal{T}_0 = \mathcal{T}_{F}$',\
'$\mathcal{T}_0 = \mathcal{T}_{D,50}$'],\
loc="upper left")
plt.xlabel('V')
plt.ylabel('$\overline{e}$')
plt.grid()
tikzplotlib.save("ebar_adapt.tex")
plt.savefig("ebar_adapt.png")
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment