Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chaofan Chen
ogs
Commits
685b04b6
Verified
Commit
685b04b6
authored
1 year ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[py] ruff fixes in Tests/Data/Mechanics/Linear/test_ip_data/2D-clamped-gravity.py.
parent
b57489e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Data/Mechanics/Linear/test_ip_data/2D-clamped-gravity.py
+17
-22
17 additions, 22 deletions
.../Data/Mechanics/Linear/test_ip_data/2D-clamped-gravity.py
with
17 additions
and
22 deletions
Tests/Data/Mechanics/Linear/test_ip_data/2D-clamped-gravity.py
+
17
−
22
View file @
685b04b6
...
@@ -16,21 +16,23 @@
...
@@ -16,21 +16,23 @@
# # Deformation of a linear elastic Material due to its own gravity
# # Deformation of a linear elastic Material due to its own gravity
# %%
# %%
import
os
import
subprocess
from
pathlib
import
Path
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
import
pyvista
as
pv
import
pyvista
as
pv
from
IPython.display
import
HTML
,
display
pv
.
set_jupyter_backend
(
"
static
"
)
pv
.
set_jupyter_backend
(
"
static
"
)
import
os
# %
import
subprocess
import
matplotlib.pyplot
as
plt
# %%
outdir
=
Path
(
os
.
environ
.
get
(
"
OGS_TESTRUNNER_OUT_DIR
"
,
"
_out
"
))
outdir
=
os
.
environ
.
get
(
"
OGS_TESTRUNNER_OUT_DIR
"
,
"
_out
"
)
if
not
outdir
.
exists
():
if
not
os
.
path
.
exists
(
outdir
):
outdir
.
mkdir
(
parents
=
True
)
os
.
makedirs
(
outdir
)
with
(
outdir
/
"
.gitignore
"
).
open
(
mode
=
"
w
"
)
as
fh
:
with
open
(
os
.
path
.
join
(
outdir
,
"
.gitignore
"
),
"
w
"
)
as
fh
:
fh
.
write
(
"
*
\n
"
)
fh
.
write
(
"
*
\n
"
)
# %% [markdown]
# %% [markdown]
...
@@ -141,7 +143,7 @@ def u_y_ana(y):
...
@@ -141,7 +143,7 @@ def u_y_ana(y):
# # Run OGS
# # Run OGS
# %%
# %%
with
open
(
os
.
path
.
join
(
outdir
,
"
ogs-out.txt
"
)
,
"
w
"
)
as
fh
:
with
(
outdir
/
"
ogs-out.txt
"
)
.
open
(
mode
=
"
w
"
)
as
fh
:
subprocess
.
run
(
subprocess
.
run
(
[
"
ogs
"
,
"
-o
"
,
outdir
,
"
square_1e2_test_ip_data.prj
"
],
[
"
ogs
"
,
"
-o
"
,
outdir
,
"
square_1e2_test_ip_data.prj
"
],
check
=
True
,
check
=
True
,
...
@@ -151,14 +153,14 @@ with open(os.path.join(outdir, "ogs-out.txt"), "w") as fh:
...
@@ -151,14 +153,14 @@ with open(os.path.join(outdir, "ogs-out.txt"), "w") as fh:
# %%
# %%
# convert last result to point cloud
# convert last result to point cloud
with
open
(
os
.
path
.
join
(
outdir
,
"
point-cloud-out.txt
"
)
,
"
w
"
)
as
fh
:
with
(
outdir
/
"
point-cloud-out.txt
"
)
.
open
(
mode
=
"
w
"
)
as
fh
:
subprocess
.
run
(
subprocess
.
run
(
[
[
"
ipDataToPointCloud
"
,
"
ipDataToPointCloud
"
,
"
-i
"
,
"
-i
"
,
os
.
path
.
join
(
outdir
,
"
square_1e2_ts_4_t_1.000000.vtu
"
)
,
outdir
/
"
square_1e2_ts_4_t_1.000000.vtu
"
,
"
-o
"
,
"
-o
"
,
os
.
path
.
join
(
outdir
,
"
square_1e2_ts_4_point_cloud.vtu
"
)
,
outdir
/
"
square_1e2_ts_4_point_cloud.vtu
"
,
],
],
check
=
True
,
check
=
True
,
stdout
=
fh
,
stdout
=
fh
,
...
@@ -185,8 +187,8 @@ def add_vertex_cells(mesh):
...
@@ -185,8 +187,8 @@ def add_vertex_cells(mesh):
# %%
# %%
mesh
=
pv
.
read
(
os
.
path
.
join
(
outdir
,
"
square_1e2_ts_4_t_1.000000.vtu
"
)
)
mesh
=
pv
.
read
(
outdir
/
"
square_1e2_ts_4_t_1.000000.vtu
"
)
mesh_pc
=
pv
.
read
(
os
.
path
.
join
(
outdir
,
"
square_1e2_ts_4_point_cloud.vtu
"
)
)
mesh_pc
=
pv
.
read
(
outdir
/
"
square_1e2_ts_4_point_cloud.vtu
"
)
mesh_pc
=
add_vertex_cells
(
mesh_pc
)
# add vertex cells to make pyvista vis work
mesh_pc
=
add_vertex_cells
(
mesh_pc
)
# add vertex cells to make pyvista vis work
# %%
# %%
...
@@ -262,7 +264,6 @@ ax2.set_xlabel(r"$\Delta u_y$ / m")
...
@@ -262,7 +264,6 @@ ax2.set_xlabel(r"$\Delta u_y$ / m")
ax
.
legend
()
ax
.
legend
()
ax
fig
.
set_size_inches
(
12
,
4
)
fig
.
set_size_inches
(
12
,
4
)
# %%
# %%
...
@@ -311,16 +312,10 @@ ax.set_ylabel("$y$ / m")
...
@@ -311,16 +312,10 @@ ax.set_ylabel("$y$ / m")
ax
.
legend
()
ax
.
legend
()
ax
fig
.
set_size_inches
(
12
,
4
)
fig
.
set_size_inches
(
12
,
4
)
# %% [markdown]
# # Checks (Assertions)
# %%
# %%
from
IPython.display
import
HTML
,
display
def
allclose
(
x
,
y
,
abstol
):
def
allclose
(
x
,
y
,
abstol
):
d
=
np
.
max
(
np
.
abs
(
x
-
y
))
d
=
np
.
max
(
np
.
abs
(
x
-
y
))
...
...
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