diff --git a/src/bvpy/gbvp.py b/src/bvpy/gbvp.py index ebc23fd5ed73def588a29c8a2cebcb332f4dbfa2..283756876fd552e57c156753bd31567c947930d0 100644 --- a/src/bvpy/gbvp.py +++ b/src/bvpy/gbvp.py @@ -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_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.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