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

checkpoint

parent 07261318
Pipeline #43263 failed with stage
......@@ -430,9 +430,7 @@ class DNS(_code):
return None
def write_par(
self,
iter0 = 0,
particle_ic = None,
particles_off = False):
iter0 = 0):
assert (self.parameters['niter_todo'] % self.parameters['niter_stat'] == 0)
assert (self.parameters['niter_todo'] % self.parameters['niter_out'] == 0)
assert (self.parameters['niter_out'] % self.parameters['niter_stat'] == 0)
......@@ -479,7 +477,7 @@ class DNS(_code):
4),
dtype = np.int64)
ofile['checkpoint'] = int(0)
if (self.dns_type in ['NSVE', 'NSVE_no_output']) or particles_off:
if (self.dns_type in ['NSVE', 'NSVE_no_output']):
return None
if type(particle_ic) == type(None):
......@@ -995,11 +993,9 @@ class DNS(_code):
particle_file.create_group('tracers0/pressure_gradient')
particle_file.create_group('tracers0/pressure_Hessian')
return None
def launch_jobs(
def generate_initial_condition(
self,
opt = None,
particle_initial_condition = None):
if not os.path.exists(os.path.join(self.work_dir, self.simname + '.h5')):
opt = None):
# take care of fields' initial condition
# first, check if initial field exists
need_field = False
......@@ -1042,11 +1038,16 @@ class DNS(_code):
amplitude = 0.05)
f['vorticity/complex/{0}'.format(0)] = data
f.close()
self.write_par(
particle_ic = None)
# take care of particles' initial condition
# now 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)
return None
def launch_jobs(
self,
opt = None):
if not os.path.exists(self.get_data_file_name()):
self.generate_initial_condition()
self.write_par()
self.run(
nb_processes = opt.nb_processes,
nb_threads_per_process = opt.nb_threads_per_process,
......
#! /usr/bin/env python
#######################################################################
# #
# Copyright 2019 Max Planck Institute #
# for Dynamics and Self-Organization #
# #
# This file is part of bfps. #
# #
# bfps is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published #
# by the Free Software Foundation, either version 3 of the License, #
# or (at your option) any later version. #
# #
# bfps is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with bfps. If not, see <http://www.gnu.org/licenses/> #
# #
# Contact: Cristian.Lalescu@ds.mpg.de #
# #
#######################################################################
import os
import numpy as np
import h5py
import sys
import bfps
from bfps import DNS
def main():
nclouds = 4
nparticles_per_cloud = 3
nparticles = nclouds*nparticles_per_cloud
niterations = 32
c = DNS()
ic_file = h5py.File(c.get_checkpoint_0_fname(), 'a')
ic_file['tracers0/state/0'] = np.random.random((nclouds, nparticles_per_cloud, 3))
ic_file['tracers0/rhs/0'] = np.zeros((2, nclouds, nparticles_per_cloud, 3))
ic_file.close()
c.launch(
['NSVEparticles',
'-n', '32',
'--src-simname', 'B32p1e4',
'--forcing_type', 'linear',
'--src-wd', bfps.lib_dir + '/test',
'--src-iteration', '0',
'--np', '4',
'--ntpp', '1',
'--fftw_plan_rigor', 'FFTW_PATIENT',
'--niter_todo', '{0}'.format(niterations),
'--niter_out', '{0}'.format(niterations),
'--niter_stat', '1',
'--nparticles', '{0}'.format(nparticles),
'--tracers0_integration_steps', '2',
'--wd', './'])
return None
if __name__ == '__main__':
main()
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