Commit 07261318 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

clean up field initial condition code

parent c8211acc
Pipeline #43254 failed with stage
......@@ -1001,8 +1001,23 @@ class DNS(_code):
particle_initial_condition = None):
if not os.path.exists(os.path.join(self.work_dir, self.simname + '.h5')):
# take care of fields' initial condition
# first, check if initial field exists
need_field = False
if not os.path.exists(self.get_checkpoint_0_fname()):
f = h5py.File(self.get_checkpoint_0_fname(), 'w')
need_field = True
else:
f = h5py.File(self.get_checkpoint_0_fname(), 'r')
try:
dset = f['vorticity/complex/0']
need_field = (dset.shape == (self.parameters['ny'],
self.parameters['nz'],
self.parameters['nx']//2+1,
3))
except:
need_field = True
f.close()
if need_field:
f = h5py.File(self.get_checkpoint_0_fname(), 'a')
if len(opt.src_simname) > 0:
source_cp = 0
src_file = 'not_a_file'
......@@ -1027,32 +1042,9 @@ class DNS(_code):
amplitude = 0.05)
f['vorticity/complex/{0}'.format(0)] = data
f.close()
## take care of particles' initial condition
#if self.dns_type in ['NSVEparticles', 'NSVEparticles_no_output']:
# if opt.pclouds > 1:
# np.random.seed(opt.particle_rand_seed)
# if opt.pcloud_type == 'random-cube':
# particle_initial_condition = (
# np.random.random((opt.pclouds, 1, 3))*2*np.pi +
# np.random.random((1, self.parameters['nparticles'], 3))*opt.particle_cloud_size)
# elif opt.pcloud_type == 'regular-cube':
# onedarray = np.linspace(
# -opt.particle_cloud_size/2,
# opt.particle_cloud_size/2,
# self.parameters['nparticles'])
# particle_initial_condition = np.zeros(
# (opt.pclouds,
# self.parameters['nparticles'],
# self.parameters['nparticles'],
# self.parameters['nparticles'], 3),
# dtype = np.float64)
# particle_initial_condition[:] = \
# np.random.random((opt.pclouds, 1, 1, 1, 3))*2*np.pi
# particle_initial_condition[..., 0] += onedarray[None, None, None, :]
# particle_initial_condition[..., 1] += onedarray[None, None, :, None]
# particle_initial_condition[..., 2] += onedarray[None, :, None, None]
self.write_par(
particle_ic = None)
# take care of particles' initial condition
if self.dns_type in ['NSVEparticles', 'NSVEcomplex_particles', 'NSVEparticles_no_output', 'NSVEp_extra_sampling']:
self.generate_particle_data(opt = opt)
self.run(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment