Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a2fa8a47 authored by PETIT Manuel's avatar PETIT Manuel
Browse files

Fix write solution issues due to `prev_growth` type (fe.Constant).

Simplified the file writing process by commenting out or removing unused sections for cell and boundary labels, and domain parameter handling. Adjusted growth data writing to use `growth_steps` instead of `growth_scheme.prev_growth` for consistency.
parent 69353a14
No related branches found
No related tags found
No related merge requests found
Pipeline #1104586 passed with warnings
...@@ -121,43 +121,24 @@ class GBVP(BVP): ...@@ -121,43 +121,24 @@ class GBVP(BVP):
if filename is not None: if filename is not None:
with fe.HDF5File(MPI_COMM_WORLD, filename, 'w') as file: with fe.HDF5File(MPI_COMM_WORLD, filename, 'w') as file:
file.write(self.domain.mesh, "mesh") file.write(self.domain.mesh, "mesh")
file.write(self.domain.cdata, "cell_labels") #file.write(self.domain.cdata, "cell_labels")
file.write(self.domain.bdata, "boundary_labels") #file.write(self.domain.bdata, "boundary_labels")
file.write(self.solution, f'solution_t{self.time.current}') file.write(self.solution, f'solution_t{self.time.current}')
file.write(self.growth_scheme.prev_growth, f'growth_t{self.time.current}') file.write(self.growth_steps[self.time.current], f'growth_t{self.time.current}')
def save_dict_to_hdf5(group, dictionary): # 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
save metadata to HDF5 file # with h5py.File(filename, 'a') as file:
""" # sub_domain_names = file.create_group("sub_domain_names")
for key, value in dictionary.items(): # for label, domain in self.domain.sub_domain_names.items():
key = str(key) # Conversion explicite des clés en chaînes # dtype = h5py.string_dtype(encoding="utf-8")
# sub_domain_names.create_dataset(str(label), data=domain, dtype=dtype)
if isinstance(value, dict): # Si la valeur est un dictionnaire, créer un sous-groupe #
sub_group = group.create_group(key) # sub_boundary_names = file.create_group("sub_boundary_names")
save_dict_to_hdf5(sub_group, value) # Appel récursif pour les sous-dictionnaires # for label, bound in self.domain.sub_boundary_names.items():
elif isinstance(value, list): # Si la valeur est une liste, créer un dataset # dtype = h5py.string_dtype(encoding="utf-8")
group.create_dataset(key, data=value) # sub_boundary_names.create_dataset(str(label), data=bound, dtype=dtype)
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)
logger.setLevel(logging.WARNING) logger.setLevel(logging.WARNING)
self._progressbar.set_range(tmin, tmax) self._progressbar.set_range(tmin, tmax)
...@@ -172,7 +153,7 @@ class GBVP(BVP): ...@@ -172,7 +153,7 @@ class GBVP(BVP):
if filename is not None: if filename is not None:
with fe.HDF5File(MPI_COMM_WORLD, filename, 'a') as file: with fe.HDF5File(MPI_COMM_WORLD, filename, 'a') as file:
file.write(self.solution, f'solution_t{self.time.current}') file.write(self.solution, f'solution_t{self.time.current}')
file.write(self.growth_scheme.prev_growth, f'growth_t{self.time.current}') file.write(self.growth_steps[self.time.current], f'growth_t{self.time.current}')
self._progressbar.update(self.time.current) self._progressbar.update(self.time.current)
self._progressbar.show() self._progressbar.show()
...@@ -230,5 +211,4 @@ class GBVP(BVP): ...@@ -230,5 +211,4 @@ class GBVP(BVP):
# - Update time # - Update time
self.time.step(self.growth_scheme.dt) self.time.step(self.growth_scheme.dt)
self.growth_scheme.update_time(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
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment