From: Luca Heltai Date: Mon, 2 Dec 2019 17:00:31 +0000 (+0100) Subject: New set id method in particle. X-Git-Tag: v9.2.0-rc1~796^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c7592a9686e8441c6512f5e55a4617681e89ecf;p=dealii.git New set id method in particle. --- diff --git a/doc/news/changes/minor/20191202LucaHeltai2 b/doc/news/changes/minor/20191202LucaHeltai2 new file mode 100644 index 0000000000..548bfdadea --- /dev/null +++ b/doc/news/changes/minor/20191202LucaHeltai2 @@ -0,0 +1,3 @@ +New: Particles::Particle::set_id() allows to set a particle ID number. +
+(Luca Heltai, 2019/12/02) diff --git a/include/deal.II/particles/particle.h b/include/deal.II/particles/particle.h index fc5f4cf811..230cbcdb78 100644 --- a/include/deal.II/particles/particle.h +++ b/include/deal.II/particles/particle.h @@ -270,6 +270,14 @@ namespace Particles types::particle_index get_id() const; + /** + * Set the ID number of this particle. + * + * @param[in] new_id The new ID number for this particle. + */ + void + set_id(const types::particle_index &new_id); + /** * Tell the particle where to store its properties (even if it does not * own properties). Usually this is only done once per particle, but diff --git a/source/particles/particle.cc b/source/particles/particle.cc index b08f23983c..d421719f9f 100644 --- a/source/particles/particle.cc +++ b/source/particles/particle.cc @@ -272,6 +272,15 @@ namespace Particles + template + void + Particle::set_id(const types::particle_index &new_id) + { + id = new_id; + } + + + template void Particle::set_property_pool(PropertyPool &new_property_pool) diff --git a/tests/particles/particle_08.cc b/tests/particles/particle_08.cc new file mode 100644 index 0000000000..531896cd0c --- /dev/null +++ b/tests/particles/particle_08.cc @@ -0,0 +1,53 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +// Test set/get id. + +#include + +#include "../tests.h" + + +template +void +test() +{ + { + Point<2> position; + position(0) = 0.3; + position(1) = 0.5; + + Point<2> reference_position; + reference_position(0) = 0.2; + reference_position(1) = 0.4; + + const types::particle_index index(7); + + Particles::Particle<2> particle(position, reference_position, index); + + deallog << "ID: " << particle.get_id() << std::endl; + particle.set_id(9); + deallog << "New ID: " << particle.get_id() << std::endl; + } +} + +int +main() +{ + initlog(); + test<2>(); +} diff --git a/tests/particles/particle_08.output b/tests/particles/particle_08.output new file mode 100644 index 0000000000..2a5d9d3a3f --- /dev/null +++ b/tests/particles/particle_08.output @@ -0,0 +1,3 @@ + +DEAL::ID: 7 +DEAL::New ID: 9