Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dolfin_dic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
BERBEROGLU Ezgi
dolfin_dic
Commits
d215dacc
Commit
d215dacc
authored
5 years ago
by
Martin Genet
Browse files
Options
Downloads
Patches
Plain Diff
Compute_strains should work when there is part_id but no sector_id
parent
57b8e122
No related branches found
Branches containing commit
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
+38
-20
38 additions, 20 deletions
compute_strains.py
with
38 additions
and
20 deletions
compute_strains.py
+
38
−
20
View file @
d215dacc
...
@@ -49,6 +49,18 @@ def compute_strains(
...
@@ -49,6 +49,18 @@ def compute_strains(
ref_mesh_n_cells
=
ref_mesh
.
GetNumberOfCells
()
ref_mesh_n_cells
=
ref_mesh
.
GetNumberOfCells
()
if
(
verbose
):
print
"
ref_mesh_n_cells =
"
+
str
(
ref_mesh_n_cells
)
if
(
verbose
):
print
"
ref_mesh_n_cells =
"
+
str
(
ref_mesh_n_cells
)
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
part_id
"
)):
iarray_part_id
=
ref_mesh
.
GetCellData
().
GetArray
(
"
part_id
"
)
n_part_ids
=
0
for
k_cell
in
xrange
(
ref_mesh_n_cells
):
part_id
=
int
(
iarray_part_id
.
GetTuple1
(
k_cell
))
if
(
part_id
>
n_part_ids
-
1
):
n_part_ids
=
part_id
+
1
if
(
verbose
):
print
"
n_part_ids =
"
+
str
(
n_part_ids
)
else
:
iarray_part_id
=
None
n_part_ids
=
0
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
sector_id
"
)):
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
sector_id
"
)):
iarray_sector_id
=
ref_mesh
.
GetCellData
().
GetArray
(
"
sector_id
"
)
iarray_sector_id
=
ref_mesh
.
GetCellData
().
GetArray
(
"
sector_id
"
)
n_sector_ids
=
0
n_sector_ids
=
0
...
@@ -62,13 +74,9 @@ def compute_strains(
...
@@ -62,13 +74,9 @@ def compute_strains(
iarray_sector_id
=
None
iarray_sector_id
=
None
n_sector_ids
=
0
n_sector_ids
=
0
if
(
ref_mesh
.
GetCellData
().
HasArray
(
"
part_id
"
)):
iarray_part_id
=
ref_mesh
.
GetCellData
().
GetArray
(
"
part_id
"
)
else
:
iarray_part_id
=
None
else
:
else
:
ref_mesh
=
None
ref_mesh
=
None
n_part_ids
=
0
n_sector_ids
=
0
n_sector_ids
=
0
working_filenames
=
glob
.
glob
(
working_folder
+
"
/
"
+
working_basename
+
"
_[0-9]*.
"
+
working_ext
)
working_filenames
=
glob
.
glob
(
working_folder
+
"
/
"
+
working_basename
+
"
_[0-9]*.
"
+
working_ext
)
...
@@ -142,6 +150,13 @@ def compute_strains(
...
@@ -142,6 +150,13 @@ def compute_strains(
field_name
=
"
part_id
"
,
field_name
=
"
part_id
"
,
threshold_value
=
0.5
,
threshold_value
=
0.5
,
threshold_by_upper_or_lower
=
"
lower
"
)
threshold_by_upper_or_lower
=
"
lower
"
)
n_points
=
mesh
.
GetNumberOfPoints
()
n_cells
=
mesh
.
GetNumberOfCells
()
if
(
iarray_part_id
is
not
None
):
iarray_part_id
=
mesh
.
GetCellData
().
GetArray
(
"
part_id
"
)
n_part_ids
=
0
if
(
iarray_sector_id
is
not
None
):
iarray_sector_id
=
mesh
.
GetCellData
().
GetArray
(
"
sector_id
"
)
myvtk
.
writeUGrid
(
myvtk
.
writeUGrid
(
ugrid
=
mesh
,
ugrid
=
mesh
,
filename
=
working_folder
+
"
/
"
+
working_basename
+
"
_
"
+
str
(
k_frame
).
zfill
(
working_zfill
)
+
"
.
"
+
working_ext
,
filename
=
working_folder
+
"
/
"
+
working_basename
+
"
_
"
+
str
(
k_frame
).
zfill
(
working_zfill
)
+
"
.
"
+
working_ext
,
...
@@ -154,24 +169,27 @@ def compute_strains(
...
@@ -154,24 +169,27 @@ def compute_strains(
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
strain_array_name
)
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
strain_array_name
)
if
(
write_strains
):
if
(
write_strains
):
if
(
n_sector_ids
==
0
):
if
(
n_sector_ids
in
(
0
,
1
)):
strains_all
=
[]
if
(
n_part_ids
==
0
):
for
k_cell
in
xrange
(
n_cells
):
strains_all
=
[
farray_strain
.
GetTuple
(
k_cell
)
for
k_cell
in
xrange
(
n_cells
)]
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
else
:
elif
(
n_sector_ids
==
1
):
strains_all
=
[
farray_strain
.
GetTuple
(
k_cell
)
for
k_cell
in
xrange
(
n_cells
)
if
iarray_part_id
.
GetTuple1
(
k_cell
)
>
0
]
strains_all
=
[]
for
k_cell
in
xrange
(
n_cells
):
sector_id
=
int
(
iarray_sector_id
.
GetTuple
(
k_cell
)[
0
])
if
(
sector_id
<
0
):
continue
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
elif
(
n_sector_ids
>
1
):
elif
(
n_sector_ids
>
1
):
strains_all
=
[]
strains_all
=
[]
strains_per_sector
=
[[]
for
sector_id
in
xrange
(
n_sector_ids
)]
strains_per_sector
=
[[]
for
sector_id
in
xrange
(
n_sector_ids
)]
for
k_cell
in
xrange
(
n_cells
):
if
(
n_part_ids
==
0
):
sector_id
=
int
(
iarray_sector_id
.
GetTuple
(
k_cell
)[
0
])
for
k_cell
in
xrange
(
n_cells
):
if
(
sector_id
<
0
):
continue
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
sector_id
=
int
(
iarray_sector_id
.
GetTuple1
(
k_cell
))
strains_per_sector
[
sector_id
].
append
(
farray_strain
.
GetTuple
(
k_cell
))
strains_per_sector
[
sector_id
].
append
(
farray_strain
.
GetTuple
(
k_cell
))
else
:
for
k_cell
in
xrange
(
n_cells
):
part_id
=
int
(
iarray_part_id
.
GetTuple1
(
k_cell
))
if
(
part_id
>
0
):
continue
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
sector_id
=
int
(
iarray_sector_id
.
GetTuple1
(
k_cell
))
if
(
sector_id
<
0
):
continue
strains_per_sector
[
sector_id
].
append
(
farray_strain
.
GetTuple
(
k_cell
))
if
(
temporal_offset
is
not
None
)
and
(
temporal_resolution
is
not
None
):
if
(
temporal_offset
is
not
None
)
and
(
temporal_resolution
is
not
None
):
strain_file
.
write
(
str
(
temporal_offset
+
k_frame
*
temporal_resolution
))
strain_file
.
write
(
str
(
temporal_offset
+
k_frame
*
temporal_resolution
))
...
...
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