Added support for single-precision turbulent fields
@@ -216,6 +216,10 @@ class TurbVelocityField(generator_interface.BaseGenerator):
self.grid_data['grid'][i][attrib.attrib['Name']] = dict()
self.grid_data['grid'][i][attrib.attrib['Name']]['file'] = (
attrib.DataItem.text.replace(' ', ''))
+ if attrib.DataItem.attrib['Precision'].strip() == '4':
+ self.grid_data['grid'][i][attrib.attrib['Name']]['Precision'] = np.float32
+ elif attrib.DataItem.attrib['Precision'].strip() == '8':
+ self.grid_data['grid'][i][attrib.attrib['Name']]['Precision'] = np.float64
# now we have the file names and the dimensions
self.grid_data['initial_x_grid'] = np.array(np.arange(0,
@@ -238,7 +242,6 @@ class TurbVelocityField(generator_interface.BaseGenerator):
self.grid_data['initial_x_grid'] += self.settings['offset'][0] + self.grid_data['origin'][0]
self.grid_data['initial_x_grid'] -= np.max(self.grid_data['initial_x_grid'])
self.grid_data['initial_y_grid'] += self.settings['offset'][1] + self.grid_data['origin'][1]
- # self.grid_data['initial_y_grid'] = self.grid_data['initial_y_grid'][::-1]
self.grid_data['initial_z_grid'] += self.settings['offset'][2] + self.grid_data['origin'][2] + centre_z_offset
self.bbox = self.get_field_bbox(self.grid_data['initial_x_grid'],
@@ -260,12 +263,6 @@ class TurbVelocityField(generator_interface.BaseGenerator):
self.update_coeff(t)
- print('coeff = ', self.coeff)
- print('t0 = ', self._t0)
- print('t1 = ', self._t1)
- print('id0 = ', id(self._interpolator0))
- print('id1 = ', id(self._interpolator1))
-
self.init_interpolator()
self.interpolate_zeta(zeta,
for_pos,
@@ -435,7 +432,8 @@ class TurbVelocityField(generator_interface.BaseGenerator):
if i_cache == 0:
# load file, but dont copy it
self.vel_holder0[i_dim] = np.memmap(self.route + '/' + file_name,
- dtype='float64',
+ # dtype='float64',
+ dtype=self.grid_data['grid'][i_grid][velocities[i_dim]]['Precision'],
shape=(self.grid_data['dimensions'][2],
self.grid_data['dimensions'][1],
self.grid_data['dimensions'][0]),
@@ -449,7 +447,8 @@ class TurbVelocityField(generator_interface.BaseGenerator):
elif i_cache == 1:
# load file, but dont copy it
self.vel_holder1[i_dim] = np.memmap(self.route + '/' + file_name,
- dtype='float64',
+ # dtype='float64',
+ dtype=self.grid_data['grid'][i_grid][velocities[i_dim]]['Precision'],
shape=(self.grid_data['dimensions'][2],
self.grid_data['dimensions'][1],
self.grid_data['dimensions'][0]),
