Skip to content
Snippets Groups Projects
Commit b39b430f authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

adds mechanism for control of initial condition behavior

parent 294a2437
No related branches found
No related tags found
1 merge request!134adds mechanism for control of initial condition behavior
Pipeline #239606 passed
...@@ -929,40 +929,56 @@ class DNS(_code): ...@@ -929,40 +929,56 @@ class DNS(_code):
return None return None
def generate_initial_condition( def generate_initial_condition(
self, self,
opt = None): opt = None,
need_field = None,
checkpoint_field = None):
"""Creates the "checkpoint 0" file.
Keyword arguments:
opt --- options object, this method may access any of
* opt.src_simname,
* opt.src_work_dir,
* opt.src_iteration
need_field --- boolean: does the DNS need the "0" iteration field
to be present in the "checkpoint 0" file?
checkpoint_field --- string: name of field used for checkpoints, one of
'velocity' or 'vorticity'.
"""
# take care of fields' initial condition # take care of fields' initial condition
if type(checkpoint_field) == type(None):
if self.dns_type in ['NSE', 'NSE_alt_dealias']:
checkpoint_field = 'velocity'
else:
checkpoint_field = 'vorticity'
# first, check if initial field exists # first, check if initial field exists
need_field = False if type(need_field) == type(None):
if self.check_current_vorticity_exists: need_field = False
need_field = True if self.check_current_vorticity_exists:
if self.dns_type in ['NSE', 'NSE_alt_dealias']:
checkpoint_field = 'velocity'
else:
checkpoint_field = 'vorticity'
if self.dns_type in [
'NSE',
'NSE_alt_dealias',
'NSVE',
'NSVE_no_output',
'static_field',
'NSVEparticles',
'NSVEcomplex_particles',
'NSVE_Stokes_particles',
'NSVEparticles_no_output',
'NSVEp_extra_sampling']:
if not os.path.exists(self.get_checkpoint_0_fname()):
need_field = True need_field = True
else: if self.dns_type in [
f = h5py.File(self.get_checkpoint_0_fname(), 'r') 'NSE',
try: 'NSE_alt_dealias',
dset = f[checkpoint_field + '/complex/0'] 'NSVE',
need_field = (dset.shape != (self.parameters['ny'], 'NSVE_no_output',
self.parameters['nz'], 'static_field',
self.parameters['nx']//2+1, 'NSVEparticles',
3)) 'NSVEcomplex_particles',
except: 'NSVE_Stokes_particles',
'NSVEparticles_no_output',
'NSVEp_extra_sampling']:
if not os.path.exists(self.get_checkpoint_0_fname()):
need_field = True need_field = True
f.close() else:
f = h5py.File(self.get_checkpoint_0_fname(), 'r')
try:
dset = f[checkpoint_field + '/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: if need_field:
# sanity check. User cannot demand a random initial condition and a source simulation at the same time. # sanity check. User cannot demand a random initial condition and a source simulation at the same time.
assert ((len(opt.src_simname) == 0) or (self.parameters['field_random_seed'] == 0)), \ assert ((len(opt.src_simname) == 0) or (self.parameters['field_random_seed'] == 0)), \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment