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
190669f0
Commit
190669f0
authored
8 years ago
by
Martin Genet
Browse files
Options
Downloads
Patches
Plain Diff
Adding choice to write or not the strain file (similar to the strain_vs_radius file)
parent
1c6b33f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compute_strains.py
+41
-37
41 additions, 37 deletions
compute_strains.py
with
41 additions
and
37 deletions
compute_strains.py
+
41
−
37
View file @
190669f0
...
...
@@ -23,6 +23,7 @@ def compute_strains(
ref_folder
=
None
,
ref_basename
=
None
,
CYL_or_PPS
=
"
PPS
"
,
write_strains
=
1
,
write_strain_vs_radius
=
0
,
verbose
=
1
):
...
...
@@ -53,8 +54,9 @@ def compute_strains(
n_zfill
=
len
(
glob
.
glob
(
sol_folder
+
"
/
"
+
sol_basename
+
"
_*.
"
+
sol_ext
)[
0
].
rsplit
(
"
_
"
)[
-
1
].
split
(
"
.
"
)[
0
])
if
(
verbose
):
print
"
n_zfill =
"
+
str
(
n_zfill
)
strain_file
=
open
(
sol_folder
+
"
/
"
+
sol_basename
+
"
-strains.dat
"
,
"
w
"
)
strain_file
.
write
(
"
#t Err_avg Err_std Ecc_avg Ecc_std Ell_avg Ell_std Erc_avg Erc_std Erl_avg Erl_std Ecl_avg Ecl_std
\n
"
)
if
(
write_strains
):
strain_file
=
open
(
sol_folder
+
"
/
"
+
sol_basename
+
"
-strains.dat
"
,
"
w
"
)
strain_file
.
write
(
"
#t Err_avg Err_std Ecc_avg Ecc_std Ell_avg Ell_std Erc_avg Erc_std Erl_avg Erl_std Ecl_avg Ecl_std
\n
"
)
if
(
write_strain_vs_radius
):
strain_vs_radius_file
=
open
(
sol_folder
+
"
/
"
+
sol_basename
+
"
-strains_vs_radius.dat
"
,
"
w
"
)
...
...
@@ -79,41 +81,43 @@ def compute_strains(
filename
=
sol_folder
+
"
/
"
+
sol_basename
+
"
_
"
+
str
(
k_frame
).
zfill
(
n_zfill
)
+
"
.
"
+
sol_ext
,
verbose
=
0
)
if
(
ref_mesh
is
not
None
):
assert
(
mesh
.
GetCellData
().
HasArray
(
"
Strain_
"
+
CYL_or_PPS
))
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
"
Strain_
"
+
CYL_or_PPS
)
else
:
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
"
Strain
"
)
if
(
n_sector_ids
==
0
):
strains_all
=
[]
for
k_cell
in
xrange
(
n_cells
):
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
elif
(
n_sector_ids
==
1
):
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
):
strains_all
=
[]
strains_per_sector
=
[[]
for
sector_id
in
xrange
(
n_sector_ids
)]
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
))
strains_per_sector
[
sector_id
].
append
(
farray_strain
.
GetTuple
(
k_cell
))
strain_file
.
write
(
str
(
k_frame
))
strains_all_avg
=
numpy
.
mean
(
strains_all
,
0
)
strains_all_std
=
numpy
.
std
(
strains_all
,
0
)
strain_file
.
write
(
""
.
join
([
"
"
+
str
(
strains_all_avg
[
k_comp
])
+
"
"
+
str
(
strains_all_std
[
k_comp
])
for
k_comp
in
xrange
(
6
)]))
if
(
n_sector_ids
>
1
):
for
sector_id
in
xrange
(
n_sector_ids
):
strains_per_sector_avg
=
numpy
.
mean
(
strains_per_sector
[
sector_id
],
0
)
strains_per_sector_std
=
numpy
.
std
(
strains_per_sector
[
sector_id
],
0
)
strain_file
.
write
(
""
.
join
([
"
"
+
str
(
strains_per_sector_avg
[
k_comp
])
+
"
"
+
str
(
strains_per_sector_std
[
k_comp
])
for
k_comp
in
xrange
(
6
)]))
strain_file
.
write
(
"
\n
"
)
if
(
write_strains
)
or
(
write_strain_vs_radius
):
if
(
ref_mesh
is
not
None
):
assert
(
mesh
.
GetCellData
().
HasArray
(
"
Strain_
"
+
CYL_or_PPS
))
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
"
Strain_
"
+
CYL_or_PPS
)
else
:
farray_strain
=
mesh
.
GetCellData
().
GetArray
(
"
Strain
"
)
if
(
write_strains
):
if
(
n_sector_ids
==
0
):
strains_all
=
[]
for
k_cell
in
xrange
(
n_cells
):
strains_all
.
append
(
farray_strain
.
GetTuple
(
k_cell
))
elif
(
n_sector_ids
==
1
):
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
):
strains_all
=
[]
strains_per_sector
=
[[]
for
sector_id
in
xrange
(
n_sector_ids
)]
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
))
strains_per_sector
[
sector_id
].
append
(
farray_strain
.
GetTuple
(
k_cell
))
strain_file
.
write
(
str
(
k_frame
))
strains_all_avg
=
numpy
.
mean
(
strains_all
,
0
)
strains_all_std
=
numpy
.
std
(
strains_all
,
0
)
strain_file
.
write
(
""
.
join
([
"
"
+
str
(
strains_all_avg
[
k_comp
])
+
"
"
+
str
(
strains_all_std
[
k_comp
])
for
k_comp
in
xrange
(
6
)]))
if
(
n_sector_ids
>
1
):
for
sector_id
in
xrange
(
n_sector_ids
):
strains_per_sector_avg
=
numpy
.
mean
(
strains_per_sector
[
sector_id
],
0
)
strains_per_sector_std
=
numpy
.
std
(
strains_per_sector
[
sector_id
],
0
)
strain_file
.
write
(
""
.
join
([
"
"
+
str
(
strains_per_sector_avg
[
k_comp
])
+
"
"
+
str
(
strains_per_sector_std
[
k_comp
])
for
k_comp
in
xrange
(
6
)]))
strain_file
.
write
(
"
\n
"
)
if
(
write_strain_vs_radius
):
assert
(
ref_mesh
.
GetCellData
().
HasArray
(
"
r
"
))
...
...
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