Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dolfin_warp
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Genet
dolfin_warp
Commits
08e216b3
Commit
08e216b3
authored
6 years ago
by
PATTE Cecile
Browse files
Options
Downloads
Patches
Plain Diff
Allow for reference mesh with PartId but no local basis in compute_strains
parent
2795d2d3
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
compute_strains.py
+25
-24
25 additions, 24 deletions
compute_strains.py
with
25 additions
and
24 deletions
compute_strains.py
+
25
−
24
View file @
08e216b3
...
...
@@ -27,9 +27,9 @@ def compute_strains(
disp_array_name
=
"
displacement
"
,
defo_grad_array_name
=
"
DeformationGradient
"
,
strain_array_name
=
"
Strain
"
,
mesh
_w_local_basis
_folder
=
None
,
mesh
_w_local_basis
_basename
=
None
,
mesh
_w_local_basis
_ext
=
"
vtk
"
,
ref_
mesh_folder
=
None
,
ref_
mesh_basename
=
None
,
ref_
mesh_ext
=
"
vtk
"
,
CYL_or_PPS
=
"
PPS
"
,
write_strains
=
1
,
temporal_offset
=
None
,
...
...
@@ -40,17 +40,17 @@ def compute_strains(
write_binned_strains_vs_radius
=
0
,
verbose
=
1
):
if
(
mesh
_w_local_basis
_folder
is
not
None
)
and
(
mesh
_w_local_basis
_basename
is
not
None
):
mesh
_w_local_basis
=
myvtk
.
readUGrid
(
filename
=
mesh_
w_local_basis_
folder
+
"
/
"
+
mesh_
w_local_basis_basename
+
"
.
"
+
mesh_w_local_basis
_ext
,
if
(
ref_
mesh_folder
is
not
None
)
and
(
ref_
mesh_basename
is
not
None
):
ref_
mesh
=
myvtk
.
readUGrid
(
filename
=
ref_
mesh_folder
+
"
/
"
+
ref_
mesh_
basename
+
"
.
"
+
ref_mesh
_ext
,
verbose
=
verbose
)
mesh_w_local_basis_n_cells
=
mesh_w_local_basis
.
GetNumberOfCells
()
if
(
verbose
):
print
"
mesh
_w_local_basis
_n_cells =
"
+
str
(
mesh
_w_local_basis
_n_cells
)
if
(
mesh
_w_local_basis
.
GetCellData
().
HasArray
(
"
sector_id
"
)):
iarray_sector_id
=
mesh
_w_local_basis
.
GetCellData
().
GetArray
(
"
sector_id
"
)
ref_mesh_n_cells
=
ref_mesh
.
GetNumberOfCells
()
if
(
verbose
):
print
"
ref_
mesh_n_cells =
"
+
str
(
ref_
mesh_n_cells
)
if
(
ref_
mesh
.
GetCellData
().
HasArray
(
"
sector_id
"
)):
iarray_sector_id
=
ref_
mesh
.
GetCellData
().
GetArray
(
"
sector_id
"
)
n_sector_ids
=
0
for
k_cell
in
xrange
(
mesh
_w_local_basis
_n_cells
):
for
k_cell
in
xrange
(
ref_
mesh_n_cells
):
sector_id
=
int
(
iarray_sector_id
.
GetTuple1
(
k_cell
))
if
(
sector_id
<
0
):
continue
if
(
sector_id
>
n_sector_ids
-
1
):
...
...
@@ -59,7 +59,7 @@ def compute_strains(
else
:
n_sector_ids
=
0
else
:
mesh
_w_local_basis
=
None
ref_
mesh
=
None
n_sector_ids
=
0
working_filenames
=
glob
.
glob
(
working_folder
+
"
/
"
+
working_basename
+
"
_[0-9]*.
"
+
working_ext
)
...
...
@@ -102,10 +102,12 @@ def compute_strains(
filename
=
mesh_filename
,
verbose
=
verbose
)
n_cells
=
mesh
.
GetNumberOfCells
()
if
(
mesh_w_local_basis
is
not
None
):
assert
(
n_cells
==
mesh_w_local_basis_n_cells
),
"
mesh_w_local_basis_n_cells (
"
+
str
(
mesh_w_local_basis_n_cells
)
+
"
) ≠ n_cells (
"
+
str
(
n_cells
)
+
"
). Aborting.
"
mesh
.
GetCellData
().
AddArray
(
mesh_w_local_basis
.
GetCellData
().
GetArray
(
"
part_id
"
))
mesh
.
GetCellData
().
AddArray
(
mesh_w_local_basis
.
GetCellData
().
GetArray
(
"
sector_id
"
))
if
(
ref_mesh
is
not
None
):
assert
(
n_cells
==
ref_mesh_n_cells
),
"
ref_mesh_n_cells (
"
+
str
(
ref_mesh_n_cells
)
+
"
) ≠ n_cells (
"
+
str
(
n_cells
)
+
"
). Aborting.
"
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
part_id
"
)):
mesh
.
GetCellData
().
AddArray
(
ref_mesh
.
GetCellData
().
GetArray
(
"
part_id
"
))
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
sector_id
"
)):
mesh
.
GetCellData
().
AddArray
(
ref_mesh
.
GetCellData
().
GetArray
(
"
sector_id
"
))
myvtk
.
addDeformationGradients
(
mesh
=
mesh
,
disp_array_name
=
disp_array_name
,
...
...
@@ -122,7 +124,7 @@ def compute_strains(
mesh
=
mesh
,
defo_grad_array_name
=
defo_grad_array_name
,
strain_array_name
=
strain_array_name
,
mesh_w_local_basis
=
mesh
_w_local_basis
,
mesh_w_local_basis
=
ref_
mesh
,
verbose
=
verbose
)
myvtk
.
writeUGrid
(
ugrid
=
mesh
,
...
...
@@ -130,8 +132,7 @@ def compute_strains(
verbose
=
verbose
)
if
(
write_strains
)
or
(
write_strains_vs_radius
)
or
(
write_binned_strains_vs_radius
):
if
(
mesh_w_local_basis
is
not
None
):
assert
(
mesh
.
GetCellData
().
HasArray
(
strain_array_name
+
"
_
"
+
CYL_or_PPS
))
if
(
ref_mesh
is
not
None
)
and
(
mesh
.
GetCellData
().
HasArray
(
strain_array_name
+
"
_
"
+
CYL_or_PPS
)):
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
strain_array_name
+
"
_
"
+
CYL_or_PPS
)
else
:
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
strain_array_name
)
...
...
@@ -171,16 +172,16 @@ def compute_strains(
strain_file
.
write
(
"
\n
"
)
if
(
write_strains_vs_radius
):
assert
(
mesh
_w_local_basis
.
GetCellData
().
HasArray
(
"
rr
"
))
farray_rr
=
mesh
_w_local_basis
.
GetCellData
().
GetArray
(
"
rr
"
)
assert
(
ref_
mesh
.
GetCellData
().
HasArray
(
"
rr
"
))
farray_rr
=
ref_
mesh
.
GetCellData
().
GetArray
(
"
rr
"
)
for
k_cell
in
xrange
(
n_cells
):
strain_vs_radius_file
.
write
(
"
"
.
join
([
str
(
val
)
for
val
in
[
k_frame
,
farray_rr
.
GetTuple1
(
k_cell
)]
+
list
(
farray_strain
.
GetTuple
(
k_cell
))])
+
"
\n
"
)
strain_vs_radius_file
.
write
(
"
\n
"
)
strain_vs_radius_file
.
write
(
"
\n
"
)
if
(
write_binned_strains_vs_radius
):
assert
(
mesh
_w_local_basis
.
GetCellData
().
HasArray
(
"
rr
"
))
farray_rr
=
mesh
_w_local_basis
.
GetCellData
().
GetArray
(
"
rr
"
)
assert
(
ref_
mesh
.
GetCellData
().
HasArray
(
"
rr
"
))
farray_rr
=
ref_
mesh
.
GetCellData
().
GetArray
(
"
rr
"
)
n_r
=
10
binned_strains
=
[[]
for
k_r
in
xrange
(
n_r
)]
for
k_cell
in
xrange
(
n_cells
):
...
...
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