Skip to content

Commit 45a59de

Browse files
committed
refact: move verbosity in __init__ to load_from_h5 and improved information
1 parent 8d31592 commit 45a59de

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

wakis/gridFIT3D.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,8 @@ def __init__(self, xmin=None, xmax=None,
9898
# Grid data
9999
# generate from file
100100
if load_from_h5 is not None:
101-
t0 = time.time()
102101
self.load_from_h5(load_from_h5)
103-
if verbose > 1:
104-
print(f'Loaded grid with {self.Nx*self.Ny*self.Nz} mesh cells')
105-
print(f' * Simulation domain bounds: \n\
106-
x:[{xmin:.3f}, {xmax:.3f}],\n\
107-
y:[{ymin:.3f}, {ymax:.3f}],\n\
108-
z:[{zmin:.3f}, {zmax:.3f}]')
109-
print(f'Total grid loading time: {time.time() - t0} s')
110-
return
102+
return #TODO: support MPI decomposition
111103

112104
# generate from custom x,y,z arrays
113105
elif x is not None and y is not None and z is not None:
@@ -143,6 +135,7 @@ def __init__(self, xmin=None, xmax=None,
143135
" - OR load from a HDF5 file using load_from_h5"
144136
)
145137

138+
#TODO: allow non uniform dx, dy, dz
146139
self.dx = np.min(np.diff(self.x))
147140
self.dy = np.min(np.diff(self.y))
148141
#self.dz = np.min(np.diff(self.z))
@@ -1021,4 +1014,17 @@ def load_from_h5(self, filename):
10211014
# asign masks to grid.cell_data
10221015
with h5py.File(filename, 'r') as hf:
10231016
for key in self.stl_solids.keys():
1024-
self.grid[key] = hf['grid_'+key][()]
1017+
self.grid[key] = hf['grid_'+key][()]
1018+
1019+
# add verbosity
1020+
if self.verbose > 1:
1021+
print(f'Loaded grid with {self.Nx*self.Ny*self.Nz} mesh cells:')
1022+
print(f' * Number of cells: Nx={self.Nx}, Ny={self.Ny}, Nz={self.Nz}')
1023+
print(f' * Simulation domain bounds: \n\
1024+
x:[{self.xmin:.3f}, {self.xmax:.3f}],\n\
1025+
y:[{self.ymin:.3f}, {self.ymax:.3f}],\n\
1026+
z:[{self.zmin:.3f}, {self.zmax:.3f}]')
1027+
print(f' * STL solids imported:\n\
1028+
{list(self.stl_solids.keys())}')
1029+
print(f' * STL solids assigned materials [eps_r, mu_r, sigma]:\n\
1030+
{list(self.stl_materials.values())}')

0 commit comments

Comments
 (0)