Skip to content
Snippets Groups Projects
Commit d95e7091 authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

not tested --- put particle code in vorticity equation

parent fdac951e
Branches
Tags
2 merge requests!21Bugfix/nansampling,!3Bugfix/event manager show html
...@@ -117,6 +117,50 @@ class NSVorticityEquation(_fluid_particle_base): ...@@ -117,6 +117,50 @@ class NSVorticityEquation(_fluid_particle_base):
//endcpp //endcpp
""" """
return None 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( def create_stat_output(
self, self,
dset_name, dset_name,
...@@ -517,6 +561,16 @@ class NSVorticityEquation(_fluid_particle_base): ...@@ -517,6 +561,16 @@ class NSVorticityEquation(_fluid_particle_base):
dest = 'dtfactor', dest = 'dtfactor',
default = 0.5, default = 0.5,
help = 'dt is computed as DTFACTOR / N') 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 return None
def prepare_launch( def prepare_launch(
self, self,
...@@ -566,6 +620,12 @@ class NSVorticityEquation(_fluid_particle_base): ...@@ -566,6 +620,12 @@ class NSVorticityEquation(_fluid_particle_base):
**kwargs): **kwargs):
opt = self.prepare_launch(args = args) opt = self.prepare_launch(args = args)
self.fill_up_fluid_code() 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.finalize_code()
self.launch_jobs(opt = opt) self.launch_jobs(opt = opt)
return None return None
......
...@@ -133,67 +133,6 @@ libraries = ['fftw3_mpi', ...@@ -133,67 +133,6 @@ libraries = ['fftw3_mpi',
'fftw3f'] 'fftw3f']
libraries += extra_libraries 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 import distutils.cmd
class CompileLibCommand(distutils.cmd.Command): class CompileLibCommand(distutils.cmd.Command):
...@@ -222,6 +161,7 @@ class CompileLibCommand(distutils.cmd.Command): ...@@ -222,6 +161,7 @@ class CompileLibCommand(distutils.cmd.Command):
datetime.datetime.fromtimestamp(os.path.getctime('bfps/' + fname))) datetime.datetime.fromtimestamp(os.path.getctime('bfps/' + fname)))
need_to_compile = (latest > libtime) need_to_compile = (latest > libtime)
eca = extra_compile_args eca = extra_compile_args
eca += ['-fPIC']
if self.timing_output: if self.timing_output:
eca += ['-DUSE_TIMINGOUTPUT'] eca += ['-DUSE_TIMINGOUTPUT']
for fname in src_file_list: for fname in src_file_list:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment