Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bvpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
MOSAIC
bvpy
Commits
f813259d
Commit
f813259d
authored
2 months ago
by
PETIT Manuel
Browse files
Options
Downloads
Plain Diff
Merge branch 'hotfix/gbvp-write-solution'
parents
69353a14
a2fa8a47
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#1104587
failed
2 months ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bvpy/gbvp.py
+18
-38
18 additions, 38 deletions
src/bvpy/gbvp.py
with
18 additions
and
38 deletions
src/bvpy/gbvp.py
+
18
−
38
View file @
f813259d
...
...
@@ -121,43 +121,24 @@ class GBVP(BVP):
if
filename
is
not
None
:
with
fe
.
HDF5File
(
MPI_COMM_WORLD
,
filename
,
'
w
'
)
as
file
:
file
.
write
(
self
.
domain
.
mesh
,
"
mesh
"
)
file
.
write
(
self
.
domain
.
cdata
,
"
cell_labels
"
)
file
.
write
(
self
.
domain
.
bdata
,
"
boundary_labels
"
)
#
file.write(self.domain.cdata, "cell_labels")
#
file.write(self.domain.bdata, "boundary_labels")
file
.
write
(
self
.
solution
,
f
'
solution_t
{
self
.
time
.
current
}
'
)
file
.
write
(
self
.
growth_scheme
.
prev_growth
,
f
'
growth_t
{
self
.
time
.
current
}
'
)
def
save_dict_to_hdf5
(
group
,
dictionary
):
"""
save metadata to HDF5 file
"""
for
key
,
value
in
dictionary
.
items
():
key
=
str
(
key
)
# Conversion explicite des clés en chaînes
if
isinstance
(
value
,
dict
):
# Si la valeur est un dictionnaire, créer un sous-groupe
sub_group
=
group
.
create_group
(
key
)
save_dict_to_hdf5
(
sub_group
,
value
)
# Appel récursif pour les sous-dictionnaires
elif
isinstance
(
value
,
list
):
# Si la valeur est une liste, créer un dataset
group
.
create_dataset
(
key
,
data
=
value
)
elif
isinstance
(
value
,
str
):
# Si la valeur est une chaîne, gérer les chaînes
dt
=
h5py
.
string_dtype
(
encoding
=
'
utf-8
'
)
group
.
create_dataset
(
key
,
data
=
value
,
dtype
=
dt
)
else
:
# Si c'est une valeur simple (int, float, etc.)
group
.
create_dataset
(
key
,
data
=
value
)
# Add parameters related to the domain
if
MPI_COMM_WORLD
.
rank
==
0
:
# h5py does not support parallal mode, use only the main process
with
h5py
.
File
(
filename
,
'
a
'
)
as
file
:
# Add various parameters related to the domain
domain_data
=
{
**
self
.
domain
.
_characteristic_size
,
**
{
'
cell_type
'
:
self
.
domain
.
_cell_type
,
'
cell_size
'
:
self
.
domain
.
_cell_size
,
'
algorithm
'
:
self
.
domain
.
_algorithm
,
'
sub_domain_names
'
:
self
.
domain
.
sub_domain_names
,
'
sub_boundary_names
'
:
self
.
domain
.
sub_boundary_names
}}
dict_group
=
file
.
create_group
(
"
domain_parameters
"
)
save_dict_to_hdf5
(
dict_group
,
domain_data
)
file
.
write
(
self
.
growth_steps
[
self
.
time
.
current
],
f
'
growth_t
{
self
.
time
.
current
}
'
)
# Add parameters related to the domain : sub_domain / sub_boundary
# if MPI_COMM_WORLD.rank == 0: # h5py does not support parallal mode, use only the main process
# with h5py.File(filename, 'a') as file:
# sub_domain_names = file.create_group("sub_domain_names")
# for label, domain in self.domain.sub_domain_names.items():
# dtype = h5py.string_dtype(encoding="utf-8")
# sub_domain_names.create_dataset(str(label), data=domain, dtype=dtype)
#
# sub_boundary_names = file.create_group("sub_boundary_names")
# for label, bound in self.domain.sub_boundary_names.items():
# dtype = h5py.string_dtype(encoding="utf-8")
# sub_boundary_names.create_dataset(str(label), data=bound, dtype=dtype)
logger
.
setLevel
(
logging
.
WARNING
)
self
.
_progressbar
.
set_range
(
tmin
,
tmax
)
...
...
@@ -172,7 +153,7 @@ class GBVP(BVP):
if
filename
is
not
None
:
with
fe
.
HDF5File
(
MPI_COMM_WORLD
,
filename
,
'
a
'
)
as
file
:
file
.
write
(
self
.
solution
,
f
'
solution_t
{
self
.
time
.
current
}
'
)
file
.
write
(
self
.
growth_s
cheme
.
prev_growth
,
f
'
growth_t
{
self
.
time
.
current
}
'
)
file
.
write
(
self
.
growth_s
teps
[
self
.
time
.
current
]
,
f
'
growth_t
{
self
.
time
.
current
}
'
)
self
.
_progressbar
.
update
(
self
.
time
.
current
)
self
.
_progressbar
.
show
()
...
...
@@ -230,5 +211,4 @@ class GBVP(BVP):
# - Update time
self
.
time
.
step
(
self
.
growth_scheme
.
dt
)
self
.
growth_scheme
.
update_time
(
dt
)
#print(f'growth_scheme, dt={self.growth_scheme.dt}, t={self.growth_scheme.t}')
\ No newline at end of file
self
.
growth_scheme
.
update_time
(
dt
)
\ No newline at end of file
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