Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshquantities
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tt_pub
meshquantities
Commits
3f579773
Commit
3f579773
authored
Aug 15, 2023
by
Tscherpel, Tabea
Browse files
Options
Downloads
Patches
Plain Diff
Replace meshquantities.py
parent
4fc1afc1
Branches
main
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
meshquantities.py
+61
-57
61 additions, 57 deletions
meshquantities.py
with
61 additions
and
57 deletions
meshquantities.py
+
61
−
57
View file @
3f579773
...
@@ -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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment