diff --git a/bfps/cpp/particles_base.cpp b/bfps/cpp/particles_base.cpp new file mode 100644 index 0000000000000000000000000000000000000000..efa12df03645cbea22607a671af9a14f04be9e1b --- /dev/null +++ b/bfps/cpp/particles_base.cpp @@ -0,0 +1,83 @@ +/********************************************************************** +* * +* Copyright 2015 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 * +* * +**********************************************************************/ + + + +#include <algorithm> +#include "particles_base.hpp" + +template <int particle_type> +single_particle_state<particle_type>::single_particle_state() +{ + switch(particle_type) + { + case VELOCITY_TRACER: + this->data = new double[3]; + std::fill_n(this->data, 3, 0); + break; + } +} + +template <int particle_type> +single_particle_state<particle_type>::single_particle_state( + const single_particle_state<particle_type> &src) +{ + switch(particle_type) + { + case VELOCITY_TRACER: + this->data = new double[3]; + std::copy(src.data, src.data + 3, this->data); + break; + } +} + +template <int particle_type> +single_particle_state<particle_type>::~single_particle_state() +{ + switch(particle_type) + { + case VELOCITY_TRACER: + delete[] this->data; + break; + } +} + +template <int particle_type> +single_particle_state<particle_type> &single_particle_state<particle_type>::operator=( + const single_particle_state &src) +{ + switch(particle_type) + { + case VELOCITY_TRACER: + std::copy(src.data, src.data + 3, this->data); + break; + } + return *this; +} + + + +/*****************************************************************************/ +template class single_particle_state<VELOCITY_TRACER>; +/*****************************************************************************/ diff --git a/bfps/cpp/particles_base.hpp b/bfps/cpp/particles_base.hpp index cf61f38efadf0030a67a10ff94c21a92e79bdd64..3e2f77b814c755f8f3858315b880f0484ce4aac0 100644 --- a/bfps/cpp/particles_base.hpp +++ b/bfps/cpp/particles_base.hpp @@ -33,5 +33,20 @@ /* particle types */ enum particle_types {VELOCITY_TRACER}; +/* 1 particle state type */ + +template <int particle_type> +class single_particle_state +{ + public: + double *data; + + single_particle_state(); + single_particle_state(const single_particle_state &src); + ~single_particle_state(); + + single_particle_state<particle_type> &operator=(const single_particle_state &src); +}; + #endif//PARTICLES_BASE diff --git a/setup.py b/setup.py index 3affff2ea0bcea3b1c7a42a72ca965b98863706f..03611700a0e41819e1731d8a4e04936a8836f67a 100644 --- a/setup.py +++ b/setup.py @@ -93,6 +93,7 @@ src_file_list = ['field_descriptor', 'fluid_solver_base', 'fluid_solver', 'interpolator_base', + 'particles_base', 'rFFTW_interpolator', 'rFFTW_particles', 'interpolator', @@ -106,8 +107,7 @@ src_file_list = ['field_descriptor', 'spline_n6', 'Lagrange_polys'] -header_list = (['cpp/base.hpp', - 'cpp/particles_base.hpp'] + +header_list = (['cpp/base.hpp'] + ['cpp/' + fname + '.hpp' for fname in src_file_list])