From d95e70918f355617a957238a6ca81758cc9f575f Mon Sep 17 00:00:00 2001 From: Chichi Lalescu <chichilalescu@gmail.com> Date: Fri, 7 Apr 2017 12:47:26 +0200 Subject: [PATCH] not tested --- put particle code in vorticity equation --- bfps/NSVorticityEquation.py | 60 +++++++++++++++++++++++++++++++++++ setup.py | 62 +------------------------------------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/bfps/NSVorticityEquation.py b/bfps/NSVorticityEquation.py index aa7ff11e..bac06e02 100644 --- a/bfps/NSVorticityEquation.py +++ b/bfps/NSVorticityEquation.py @@ -117,6 +117,50 @@ class NSVorticityEquation(_fluid_particle_base): //endcpp """ return None + def add_particles( + self, + integration_steps = 2, + neighbours = 1, + smoothness = 1): + assert(integration_steps > 0 and integration_steps < 6) + self.parameters['tracers0_integration_steps'] = int(integration_steps) + self.parameters['tracers0_neighbours'] = int(neighbours) + self.parameters['tracers0_smoothness'] = int(smoothness) + self.parameters['tracers0_interpolator'] = 'spline' + self.particle_includes += """ + #include "particles_system_builder.hpp" + #include "particles_output_hdf5.hpp" + """ + ## initialize + self.particle_start += """ + std::unique_ptr<abstract_particles_system<double>> ps = particles_system_builder( + fs->cvorticity, // (field object) + fs->kk, // (kspace object, contains dkx, dky, dkz) + tracers0_integration_steps, // to check coherency between parameters and hdf input file (nb rhs) + nparticles, // to check coherency between parameters and hdf input file + fname, // particles input filename + "tracers0", // dataset name for initial input + tracers0_neighbours, // parameter (interpolation no neighbours) + tracers0_smoothness, // parameter + MPI_COMM_WORLD); + particles_output_hdf5<double,3,3> particles_output_writer_mpi(MPI_COMM_WORLD, simname, nparticles); + """ + self.particle_loop += """ + fs->compute_velocity(fs->cvorticity); + fs->cvelocity->ift(); + ps->completeLoop(dt); + """ + output_particles = """ + particles_output_writer_mpi.save(ps->getParticlesPositions(), + ps->getParticlesCurrentRhs(), + ps->getParticlesIndexes(), + ps->getLocalNbParticles(), + iteration); + """ + self.fluid_output += output_particles + self.particle_end += 'ps.realease();\n' + + return None def create_stat_output( self, dset_name, @@ -517,6 +561,16 @@ class NSVorticityEquation(_fluid_particle_base): dest = 'dtfactor', default = 0.5, help = 'dt is computed as DTFACTOR / N') + parser.add_argument( + '--neighbours', + type = int, + dest = 'neighbours', + default = 1) + parser.add_argument( + '--smoothness', + type = int, + dest = 'smoothness', + default = 1) return None def prepare_launch( self, @@ -566,6 +620,12 @@ class NSVorticityEquation(_fluid_particle_base): **kwargs): opt = self.prepare_launch(args = args) self.fill_up_fluid_code() + if opt.nparticles > 0: + self.name += '-particles' + self.add_particles( + integration_steps = 4, + neighbours = opt.neighbours, + smoothness = opt.smoothness) self.finalize_code() self.launch_jobs(opt = opt) return None diff --git a/setup.py b/setup.py index 8d4ae0f9..21acd263 100644 --- a/setup.py +++ b/setup.py @@ -133,67 +133,6 @@ libraries = ['fftw3_mpi', 'fftw3f'] libraries += extra_libraries - - -def compile_bfps_library( - use_timingoutput = False, - extra_compile_args = None): - """ - use_timingoutput sets the USE_TIMINGOUTPUT definition, - thus scope timers are being output. - """ - if not os.path.isdir('obj'): - os.makedirs('obj') - need_to_compile = True - if not os.path.isfile('bfps/libbfps.a'): - need_to_compile = True - else: - ofile = 'bfps/libbfps.a' - libtime = datetime.datetime.fromtimestamp(os.path.getctime(ofile)) - latest = libtime - for fname in header_list: - latest = max(latest, - datetime.datetime.fromtimestamp(os.path.getctime('bfps/' + fname))) - need_to_compile = (latest > libtime) - if use_timingoutput: - extra_compile_args += ['-DUSE_TIMINGOUTPUT'] - for fname in src_file_list: - ifile = 'bfps/cpp/' + fname + '.cpp' - ofile = 'obj/' + fname + '.o' - if not os.path.exists(ofile): - need_to_compile_file = True - else: - need_to_compile_file = (need_to_compile or - (datetime.datetime.fromtimestamp(os.path.getctime(ofile)) < - datetime.datetime.fromtimestamp(os.path.getctime(ifile)))) - if need_to_compile_file: - command_strings = [compiler, '-c'] - command_strings += ['bfps/cpp/' + fname + '.cpp'] - command_strings += ['-o', 'obj/' + fname + '.o'] - command_strings += extra_compile_args - command_strings += ['-I' + idir for idir in include_dirs] - command_strings.append('-Ibfps/cpp/') - print(' '.join(command_strings)) - subprocess.check_call(command_strings) - command_strings = ['ar', 'rvs', 'bfps/libbfps.a'] - command_strings += ['obj/' + fname + '.o' for fname in src_file_list] - print(' '.join(command_strings)) - subprocess.check_call(command_strings) - - ### save compiling information - pickle.dump( - {'include_dirs' : include_dirs, - 'library_dirs' : library_dirs, - 'compiler' : compiler, - 'extra_compile_args' : extra_compile_args, - 'libraries' : libraries, - 'install_date' : now, - 'VERSION' : VERSION, - 'git_revision' : git_revision}, - open('bfps/install_info.pickle', 'wb'), - protocol = 2) - return None - import distutils.cmd class CompileLibCommand(distutils.cmd.Command): @@ -222,6 +161,7 @@ class CompileLibCommand(distutils.cmd.Command): datetime.datetime.fromtimestamp(os.path.getctime('bfps/' + fname))) need_to_compile = (latest > libtime) eca = extra_compile_args + eca += ['-fPIC'] if self.timing_output: eca += ['-DUSE_TIMINGOUTPUT'] for fname in src_file_list: -- GitLab