Commit 91b619e1 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

remove redundant method parameter

parent f97782d8
......@@ -512,12 +512,12 @@ class NavierStokes(_fluid_particle_base):
output_vel_acc += 'fs->ift_velocity();\n'
output_vel_acc += """
{0}->read_rFFTW(fs->rvelocity);
ps{1}->sample({0}, particle_file, "velocity");
ps{1}->sample({0}, "velocity");
""".format(interpolator[s], s0 + s)
if not type(acc_name) == type(None):
output_vel_acc += """
{0}->read_rFFTW({1});
ps{2}->sample({0}, particle_file, "acceleration");
ps{2}->sample({0}, "acceleration");
""".format(interpolator[s], acc_name, s0 + s)
output_vel_acc += '}\n'
......@@ -536,7 +536,7 @@ class NavierStokes(_fluid_particle_base):
for s in range(nspecies):
neighbours = self.parameters[interpolator[s] + '_neighbours']
self.particle_start += 'sprintf(fname, "tracers{0}");\n'.format(s0 + s)
self.particle_end += ('ps{0}->write(particle_file);\n' +
self.particle_end += ('ps{0}->write();\n' +
'delete ps{0};\n').format(s0 + s)
self.particle_variables += '{0}<VELOCITY_TRACER, {1}, {2}> *ps{3};\n'.format(
class_name,
......@@ -545,7 +545,6 @@ class NavierStokes(_fluid_particle_base):
s0 + s)
self.particle_start += ('ps{0} = new {1}<VELOCITY_TRACER, {2}, {3}>(\n' +
'fname, particle_file, {4},\n' +
'nparticles,\n' +
'niter_part, tracers{0}_integration_steps);\n').format(
s0 + s,
class_name,
......@@ -554,7 +553,7 @@ class NavierStokes(_fluid_particle_base):
interpolator[s])
self.particle_start += ('ps{0}->dt = dt;\n' +
'ps{0}->iteration = iteration;\n' +
'ps{0}->read(particle_file);\n').format(s0 + s)
'ps{0}->read();\n').format(s0 + s)
if not frozen_particles:
if type(kcut) == list:
update_field = ('fs->low_pass_Fourier(fs->cvelocity, 3, {0});\n'.format(kcut[s]) +
......@@ -562,7 +561,7 @@ class NavierStokes(_fluid_particle_base):
self.particle_loop += update_field
self.particle_loop += '{0}->read_rFFTW(fs->rvelocity);\n'.format(interpolator[s])
self.particle_loop += 'ps{0}->step();\n'.format(s0 + s)
self.particle_stat_src += 'ps{0}->write(particle_file, false);\n'.format(s0 + s)
self.particle_stat_src += 'ps{0}->write(false);\n'.format(s0 + s)
self.particle_stat_src += output_vel_acc
self.particle_stat_src += '}\n'
self.particle_species += nspecies
......@@ -882,9 +881,7 @@ class NavierStokes(_fluid_particle_base):
with h5py.File(self.get_particle_file_name(), 'a') as ofile:
for s in range(self.particle_species):
ofile.create_group('tracers{0}'.format(s))
time_chunk = 2**20 // (8*3*
self.parameters['nparticles']*
self.parameters['tracers{0}_integration_steps'.format(s)])
time_chunk = 2**20 // (8*3*self.parameters['nparticles'])
time_chunk = max(time_chunk, 1)
dims = (1,
self.parameters['tracers{0}_integration_steps'.format(s)],
......@@ -895,15 +892,13 @@ class NavierStokes(_fluid_particle_base):
self.parameters['nparticles'],
3)
chunks = (time_chunk,
self.parameters['tracers{0}_integration_steps'.format(s)],
1,
self.parameters['nparticles'],
3)
create_particle_dataset(
ofile,
'/tracers{0}/rhs'.format(s),
dims, maxshape, chunks)
time_chunk = 2**20 // (8*3*self.parameters['nparticles'])
time_chunk = max(time_chunk, 1)
create_particle_dataset(
ofile,
'/tracers{0}/state'.format(s),
......
......@@ -44,7 +44,6 @@ distributed_particles<particle_type, rnumber, interp_neighbours>::distributed_pa
const char *NAME,
const hid_t data_file_id,
interpolator<rnumber, interp_neighbours> *FIELD,
const int NPARTICLES,
const int TRAJ_SKIP,
const int INTEGRATION_STEPS) : particles_io_base<particle_type>(
NAME,
......@@ -57,7 +56,6 @@ distributed_particles<particle_type, rnumber, interp_neighbours>::distributed_pa
this->vel = FIELD;
this->rhs.resize(INTEGRATION_STEPS);
this->integration_steps = INTEGRATION_STEPS;
assert(this->nparticles == NPARTICLES);
}
template <int particle_type, class rnumber, int interp_neighbours>
......@@ -98,12 +96,11 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::get_rhs(
template <int particle_type, class rnumber, int interp_neighbours>
void distributed_particles<particle_type, rnumber, interp_neighbours>::sample(
interpolator<rnumber, interp_neighbours> *field,
const hid_t data_file_id,
const char *dset_name)
{
std::unordered_map<int, single_particle_state<POINT3D>> y;
this->sample(field, y);
this->write(data_file_id, dset_name, y);
this->write(dset_name, y);
}
template <int particle_type, class rnumber, int interp_neighbours>
......@@ -317,8 +314,7 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::step()
template <int particle_type, class rnumber, int interp_neighbours>
void distributed_particles<particle_type, rnumber, interp_neighbours>::read(
const hid_t data_file_id)
void distributed_particles<particle_type, rnumber, interp_neighbours>::read()
{
double *temp = new double[this->chunk_size*this->ncomponents];
for (int cindex=0; cindex<this->get_number_of_chunks(); cindex++)
......@@ -363,7 +359,6 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::read(
template <int particle_type, class rnumber, int interp_neighbours>
void distributed_particles<particle_type, rnumber, interp_neighbours>::write(
const hid_t data_file_id,
const char *dset_name,
std::unordered_map<int, single_particle_state<POINT3D>> &y)
{
......@@ -396,7 +391,6 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::write(
template <int particle_type, class rnumber, int interp_neighbours>
void distributed_particles<particle_type, rnumber, interp_neighbours>::write(
const hid_t data_file_id,
const bool write_rhs)
{
double *temp0 = new double[this->chunk_size*this->ncomponents];
......
......@@ -65,14 +65,12 @@ class distributed_particles: public particles_io_base<particle_type>
const char *NAME,
const hid_t data_file_id,
interpolator<rnumber, interp_neighbours> *FIELD,
const int NPARTICLES,
const int TRAJ_SKIP,
const int INTEGRATION_STEPS = 2);
~distributed_particles();
void sample(
interpolator<rnumber, interp_neighbours> *field,
const hid_t data_file_id,
const char *dset_name);
void sample(
interpolator<rnumber, interp_neighbours> *field,
......@@ -87,16 +85,14 @@ class distributed_particles: public particles_io_base<particle_type>
/* input/output */
void read(const hid_t data_file_id);
void read();
void write(
const hid_t data_file_id,
const char *dset_name,
std::unordered_map<int, single_particle_state<POINT3D>> &y);
void write(
const hid_t data_file_id,
const char *dset_name,
std::unordered_map<int, single_particle_state<particle_type>> &y);
void write(const hid_t data_file_id, const bool write_rhs = true);
void write(const bool write_rhs = true);
/* solvers */
void step();
......
......@@ -44,7 +44,6 @@ particles<particle_type, rnumber, interp_neighbours>::particles(
const char *NAME,
const hid_t data_file_id,
interpolator_base<rnumber, interp_neighbours> *FIELD,
const int NPARTICLES,
const int TRAJ_SKIP,
const int INTEGRATION_STEPS) : particles_io_base<particle_type>(
NAME,
......@@ -56,7 +55,6 @@ particles<particle_type, rnumber, interp_neighbours>::particles(
(INTEGRATION_STEPS >= 1));
this->vel = FIELD;
this->integration_steps = INTEGRATION_STEPS;
assert(this->nparticles == NPARTICLES);
this->array_size = this->nparticles * this->ncomponents;
this->state = new double[this->array_size];
std::fill_n(this->state, this->array_size, 0.0);
......@@ -186,8 +184,7 @@ void particles<particle_type, rnumber, interp_neighbours>::step()
template <int particle_type, class rnumber, int interp_neighbours>
void particles<particle_type, rnumber, interp_neighbours>::read(
const hid_t data_file_id)
void particles<particle_type, rnumber, interp_neighbours>::read()
{
if (this->myrank == 0)
for (int cindex=0; cindex<this->get_number_of_chunks(); cindex++)
......@@ -215,7 +212,6 @@ void particles<particle_type, rnumber, interp_neighbours>::read(
template <int particle_type, class rnumber, int interp_neighbours>
void particles<particle_type, rnumber, interp_neighbours>::write(
const hid_t data_file_id,
const bool write_rhs)
{
if (this->myrank == 0)
......@@ -231,7 +227,6 @@ void particles<particle_type, rnumber, interp_neighbours>::write(
template <int particle_type, class rnumber, int interp_neighbours>
void particles<particle_type, rnumber, interp_neighbours>::sample(
interpolator_base<rnumber, interp_neighbours> *field,
const hid_t data_file_id,
const char *dset_name)
{
double *y = new double[this->nparticles*3];
......
......@@ -63,14 +63,12 @@ class particles: public particles_io_base<particle_type>
const char *NAME,
const hid_t data_file_id,
interpolator_base<rnumber, interp_neighbours> *FIELD,
const int NPARTICLES,
const int TRAJ_SKIP,
const int INTEGRATION_STEPS = 2);
~particles();
void sample(
interpolator_base<rnumber, interp_neighbours> *field,
const hid_t data_file_id,
const char *dset_name);
inline void sample(
......@@ -85,12 +83,11 @@ class particles: public particles_io_base<particle_type>
double *__restrict__ rhs);
/* input/output */
void read(const hid_t data_file_id);
void read();
void write(
const hid_t data_file_id,
const char *dset_name,
const double *data);
void write(const hid_t data_file_id, const bool write_rhs = true);
void write(const bool write_rhs = true);
/* solvers */
void step();
......
......@@ -120,8 +120,8 @@ class particles_io_base
return this->chunk_offsets.size();
}
inline const unsigned int get_number_of_rhs_chunks();
virtual void read( const hid_t data_file_id) = 0;
virtual void write(const hid_t data_file_id, const bool write_rhs = true) = 0;
virtual void read() = 0;
virtual void write(const bool write_rhs = true) = 0;
};
#endif//PARTICLES_BASE
......
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