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

add option to use new particle class

parent b75e68c2
No related branches found
No related tags found
No related merge requests found
...@@ -349,9 +349,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -349,9 +349,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
kcut = None, kcut = None,
neighbours = 1, neighbours = 1,
smoothness = 1, smoothness = 1,
name = 'particle_field'): name = 'particle_field',
self.fluid_includes += '#include "interpolator.hpp"\n' field_class = 'rFFTW_interpolator'):
self.fluid_variables += 'interpolator<{0}, {1}> *vel_{2}, *acc_{2};\n'.format(self.C_dtype, neighbours, name) self.fluid_includes += '#include "{0}.hpp"\n'.format(field_class)
self.fluid_variables += field_class + '<{0}, {1}> *vel_{2}, *acc_{2};\n'.format(self.C_dtype, neighbours, name)
self.parameters[name + '_type'] = interp_type self.parameters[name + '_type'] = interp_type
self.parameters[name + '_neighbours'] = neighbours self.parameters[name + '_neighbours'] = neighbours
if interp_type == 'spline': if interp_type == 'spline':
...@@ -359,11 +360,12 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -359,11 +360,12 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
beta_name = 'beta_n{0}_m{1}'.format(neighbours, smoothness) beta_name = 'beta_n{0}_m{1}'.format(neighbours, smoothness)
elif interp_type == 'Lagrange': elif interp_type == 'Lagrange':
beta_name = 'beta_Lagrange_n{0}'.format(neighbours) beta_name = 'beta_Lagrange_n{0}'.format(neighbours)
self.fluid_start += ('vel_{0} = new interpolator<{1}, {2}>(fs, {3});\n' + self.fluid_start += ('vel_{0} = new {1}<{2}, {3}>(fs, {4});\n' +
'acc_{0} = new interpolator<{1}, {2}>(fs, {3});\n').format(name, 'acc_{0} = new {1}<{2}, {3}>(fs, {4});\n').format(name,
self.C_dtype, field_class,
neighbours, self.C_dtype,
beta_name) neighbours,
beta_name)
self.fluid_end += ('delete vel_{0};\n' + self.fluid_end += ('delete vel_{0};\n' +
'delete acc_{0};\n').format(name) 'delete acc_{0};\n').format(name)
update_fields = 'fs->compute_velocity(fs->cvorticity);\n' update_fields = 'fs->compute_velocity(fs->cvorticity);\n'
...@@ -382,7 +384,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -382,7 +384,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
integration_steps = 2, integration_steps = 2,
kcut = 'fs->kM', kcut = 'fs->kM',
frozen_particles = False, frozen_particles = False,
fields_name = None): fields_name = None,
particle_class = 'rFFTW_particles'):
if integration_method == 'cRK4': if integration_method == 'cRK4':
integration_steps = 4 integration_steps = 4
elif integration_method == 'Heun': elif integration_method == 'Heun':
...@@ -452,21 +455,32 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -452,21 +455,32 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
self.particle_start += 'sprintf(fname, "tracers{0}");\n'.format(self.particle_species) self.particle_start += 'sprintf(fname, "tracers{0}");\n'.format(self.particle_species)
self.particle_end += ('ps{0}->write(stat_file);\n' + self.particle_end += ('ps{0}->write(stat_file);\n' +
'delete ps{0};\n').format(self.particle_species) 'delete ps{0};\n').format(self.particle_species)
self.particle_includes += '#include "particles.hpp"\n' self.particle_includes += '#include "{0}.hpp"\n'.format(particle_class)
if integration_method == 'AdamsBashforth': if particle_class == 'particles':
multistep = 'true' if integration_method == 'AdamsBashforth':
else: multistep = 'true'
multistep = 'false' else:
self.particle_variables += 'particles<VELOCITY_TRACER, {0}, {1}, {2}> *ps{3};\n'.format( multistep = 'false'
self.C_dtype, self.particle_variables += 'particles<VELOCITY_TRACER, {0}, {1}, {2}> *ps{3};\n'.format(
multistep, self.C_dtype,
neighbours, multistep,
self.particle_species) neighbours,
self.particle_start += ('ps{0} = new particles<VELOCITY_TRACER, {1}, {2},{3}>(\n' + self.particle_species)
self.particle_start += ('ps{0} = new particles<VELOCITY_TRACER, {1}, {2},{3}>(\n' +
'fname, fs, vel_{4},\n' + 'fname, fs, vel_{4},\n' +
'nparticles,\n' + 'nparticles,\n' +
'niter_part, tracers{0}_integration_steps);\n').format( 'niter_part, tracers{0}_integration_steps);\n').format(
self.particle_species, self.C_dtype, multistep, neighbours, fields_name) self.particle_species, self.C_dtype, multistep, neighbours, fields_name)
else:
self.particle_variables += 'rFFTW_particles<VELOCITY_TRACER, {0}, {1}> *ps{2};\n'.format(
self.C_dtype,
neighbours,
self.particle_species)
self.particle_start += ('ps{0} = new rFFTW_particles<VELOCITY_TRACER, {1}, {2}>(\n' +
'fname, fs, vel_{3},\n' +
'nparticles,\n' +
'niter_part, tracers{0}_integration_steps);\n').format(
self.particle_species, self.C_dtype, neighbours, fields_name)
self.particle_start += ('ps{0}->dt = dt;\n' + self.particle_start += ('ps{0}->dt = dt;\n' +
'ps{0}->iteration = iteration;\n' + 'ps{0}->iteration = iteration;\n' +
'ps{0}->read(stat_file);\n').format(self.particle_species) 'ps{0}->read(stat_file);\n').format(self.particle_species)
...@@ -483,7 +497,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -483,7 +497,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
assert(integration_steps == 4) assert(integration_steps == 4)
self.particle_loop += 'ps{0}->cRK4();\n'.format(self.particle_species) self.particle_loop += 'ps{0}->cRK4();\n'.format(self.particle_species)
self.particle_loop += 'ps{0}->iteration++;\n'.format(self.particle_species) self.particle_loop += 'ps{0}->iteration++;\n'.format(self.particle_species)
self.particle_loop += 'ps{0}->synchronize();\n'.format(self.particle_species) if particle_class == 'particles':
self.particle_loop += 'ps{0}->synchronize();\n'.format(self.particle_species)
self.particle_loop += (('if (ps{0}->iteration % niter_part == 0)\n' + self.particle_loop += (('if (ps{0}->iteration % niter_part == 0)\n' +
'{{\n' + '{{\n' +
'ps{0}->write(stat_file, false);\n').format(self.particle_species) + 'ps{0}->write(stat_file, false);\n').format(self.particle_species) +
......
...@@ -31,7 +31,6 @@ rFFTW_interpolator<rnumber, interp_neighbours>::rFFTW_interpolator( ...@@ -31,7 +31,6 @@ rFFTW_interpolator<rnumber, interp_neighbours>::rFFTW_interpolator(
fluid_solver_base<rnumber> *fs, fluid_solver_base<rnumber> *fs,
base_polynomial_values BETA_POLYS) base_polynomial_values BETA_POLYS)
{ {
int tdims[4];
this->descriptor = fs->rd; this->descriptor = fs->rd;
this->field_size = 2*fs->cd->local_size; this->field_size = 2*fs->cd->local_size;
this->compute_beta = BETA_POLYS; this->compute_beta = BETA_POLYS;
...@@ -77,8 +76,8 @@ int rFFTW_interpolator<rnumber, interp_neighbours>::read_rFFTW(void *void_src) ...@@ -77,8 +76,8 @@ int rFFTW_interpolator<rnumber, interp_neighbours>::read_rFFTW(void *void_src)
rnumber *dst = this->f1; rnumber *dst = this->f1;
/* do big copy of middle stuff */ /* do big copy of middle stuff */
std::copy(src, std::copy(src,
src + this->unbuffered_descriptor->local_size, src + this->field_size,
dst + this->buffer_size); dst);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
...@@ -119,7 +118,7 @@ void rFFTW_interpolator<rnumber, interp_neighbours>::operator()( ...@@ -119,7 +118,7 @@ void rFFTW_interpolator<rnumber, interp_neighbours>::operator()(
{ {
ptrdiff_t tindex = ((bigiz *this->descriptor->sizes[1] + ptrdiff_t tindex = ((bigiz *this->descriptor->sizes[1] +
bigiy)*this->descriptor->sizes[2] + bigiy)*this->descriptor->sizes[2] +
bigix)*3+c + this->buffer_size; bigix)*3+c;
dest[c] += (this->f0[tindex]*(1-t) + t*this->f1[tindex])*(bz[iz+interp_neighbours]* dest[c] += (this->f0[tindex]*(1-t) + t*this->f1[tindex])*(bz[iz+interp_neighbours]*
by[iy+interp_neighbours]* by[iy+interp_neighbours]*
bx[ix+interp_neighbours]); bx[ix+interp_neighbours]);
......
...@@ -49,10 +49,10 @@ class rFFTW_interpolator ...@@ -49,10 +49,10 @@ class rFFTW_interpolator
field_descriptor<rnumber> *descriptor; field_descriptor<rnumber> *descriptor;
rnumber *f0, *f1, *temp; rnumber *f0, *f1, *temp;
interpolator( rFFTW_interpolator(
fluid_solver_base<rnumber> *FSOLVER, fluid_solver_base<rnumber> *FSOLVER,
base_polynomial_values BETA_POLYS); base_polynomial_values BETA_POLYS);
~interpolator(); ~rFFTW_interpolator();
void operator()(double t, int *__restrict__ xg, double *__restrict__ xx, double *__restrict__ dest, int *deriv = NULL); void operator()(double t, int *__restrict__ xg, double *__restrict__ xx, double *__restrict__ dest, int *deriv = NULL);
int read_rFFTW(void *src); int read_rFFTW(void *src);
......
...@@ -71,7 +71,7 @@ if hostname in ['frontend01', 'frontend02']: ...@@ -71,7 +71,7 @@ if hostname in ['frontend01', 'frontend02']:
'-mhard-float', '-mhard-float',
'-mieee-fp', '-mieee-fp',
'-ffast-math', '-ffast-math',
'-mlarge-data-threshold=65536', # '-mlarge-data-threshold=65536',
'-mno-sse4', '-mno-sse4',
'-mpush-args', '-mpush-args',
'-mred-zone', '-mred-zone',
......
...@@ -50,7 +50,9 @@ src_file_list = ['field_descriptor', ...@@ -50,7 +50,9 @@ src_file_list = ['field_descriptor',
'fluid_solver_base', 'fluid_solver_base',
'fluid_solver', 'fluid_solver',
'interpolator', 'interpolator',
'rFFTW_interpolator',
'particles', 'particles',
'rFFTW_particles',
'fftw_tools', 'fftw_tools',
'spline_n1', 'spline_n1',
'spline_n2', 'spline_n2',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment