From 5e838f15abb95bac8320bc30d27a38feedaa2f95 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 1 Oct 2020 08:38:52 +0200 Subject: [PATCH] Make accessor functions of particles inline --- include/deal.II/particles/particle.h | 87 ++++++ include/deal.II/particles/particle_accessor.h | 221 ++++++++++++++++ include/deal.II/particles/particle_iterator.h | 112 ++++++++ source/particles/CMakeLists.txt | 4 - source/particles/particle.cc | 84 ------ source/particles/particle_accessor.cc | 248 ------------------ source/particles/particle_accessor.inst.in | 26 -- source/particles/particle_iterator.cc | 136 ---------- source/particles/particle_iterator.inst.in | 26 -- 9 files changed, 420 insertions(+), 524 deletions(-) delete mode 100644 source/particles/particle_accessor.cc delete mode 100644 source/particles/particle_accessor.inst.in delete mode 100644 source/particles/particle_iterator.cc delete mode 100644 source/particles/particle_iterator.inst.in diff --git a/include/deal.II/particles/particle.h b/include/deal.II/particles/particle.h index 6f42ce801b..61e1b1724d 100644 --- a/include/deal.II/particles/particle.h +++ b/include/deal.II/particles/particle.h @@ -471,6 +471,8 @@ namespace Particles } } + + template template void @@ -486,6 +488,91 @@ namespace Particles if (n_properties > 0) ar &boost::serialization::make_array(properties, n_properties); } + + + + template + void + Particle::set_location(const Point &new_loc) + { + location = new_loc; + } + + + + template + const Point & + Particle::get_location() const + { + return location; + } + + + + template + void + Particle::set_reference_location(const Point &new_loc) + { + reference_location = new_loc; + } + + + + template + const Point & + Particle::get_reference_location() const + { + return reference_location; + } + + + + template + types::particle_index + Particle::get_id() const + { + return id; + } + + + + template + void + Particle::set_id(const types::particle_index &new_id) + { + id = new_id; + } + + + + template + void + Particle::set_property_pool(PropertyPool &new_property_pool) + { + property_pool = &new_property_pool; + } + + + + template + const ArrayView + Particle::get_properties() const + { + Assert(has_properties(), ExcInternalError()); + + return property_pool->get_properties(properties); + } + + + + template + bool + Particle::has_properties() const + { + return (property_pool != nullptr) && + (properties != PropertyPool::invalid_handle); + } + } // namespace Particles DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/particles/particle_accessor.h b/include/deal.II/particles/particle_accessor.h index 1de0522555..08bddc4586 100644 --- a/include/deal.II/particles/particle_accessor.h +++ b/include/deal.II/particles/particle_accessor.h @@ -292,6 +292,227 @@ namespace Particles } + // ------------------------- inline functions ------------------------------ + template + ParticleAccessor::ParticleAccessor() + : map(nullptr) + , particle() + {} + + + + template + ParticleAccessor::ParticleAccessor( + const std::multimap> &map, + const typename std::multimap>::iterator & particle) + : map(const_cast< + std::multimap> *>(&map)) + , particle(particle) + {} + + + + template + void + ParticleAccessor::write_data(void *&data) const + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.write_data(data); + } + + + + template + void + ParticleAccessor::set_location(const Point &new_loc) + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.set_location(new_loc); + } + + + + template + const Point & + ParticleAccessor::get_location() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.get_location(); + } + + + + template + void + ParticleAccessor::set_reference_location( + const Point &new_loc) + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.set_reference_location(new_loc); + } + + + + template + const Point & + ParticleAccessor::get_reference_location() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.get_reference_location(); + } + + + + template + types::particle_index + ParticleAccessor::get_id() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.get_id(); + } + + + + template + void + ParticleAccessor::set_property_pool( + PropertyPool &new_property_pool) + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.set_property_pool(new_property_pool); + } + + + + template + bool + ParticleAccessor::has_properties() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.has_properties(); + } + + + + template + void + ParticleAccessor::set_properties( + const std::vector &new_properties) + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.set_properties(new_properties); + } + + + + template + void + ParticleAccessor::set_properties( + const ArrayView &new_properties) + { + Assert(particle != map->end(), ExcInternalError()); + + particle->second.set_properties(new_properties); + } + + + + template + const ArrayView + ParticleAccessor::get_properties() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.get_properties(); + } + + + + template + typename Triangulation::cell_iterator + ParticleAccessor::get_surrounding_cell( + const Triangulation &triangulation) const + { + Assert(particle != map->end(), ExcInternalError()); + + const typename Triangulation::cell_iterator cell( + &triangulation, particle->first.first, particle->first.second); + return cell; + } + + + + template + const ArrayView + ParticleAccessor::get_properties() + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.get_properties(); + } + + + + template + std::size_t + ParticleAccessor::serialized_size_in_bytes() const + { + Assert(particle != map->end(), ExcInternalError()); + + return particle->second.serialized_size_in_bytes(); + } + + + + template + void + ParticleAccessor::next() + { + Assert(particle != map->end(), ExcInternalError()); + ++particle; + } + + + + template + void + ParticleAccessor::prev() + { + Assert(particle != map->begin(), ExcInternalError()); + --particle; + } + + + + template + bool + ParticleAccessor:: + operator!=(const ParticleAccessor &other) const + { + return (map != other.map) || (particle != other.particle); + } + + + + template + bool + ParticleAccessor:: + operator==(const ParticleAccessor &other) const + { + return (map == other.map) && (particle == other.particle); + } + + } // namespace Particles DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/particles/particle_iterator.h b/include/deal.II/particles/particle_iterator.h index 2384f2503c..1bb56a2bae 100644 --- a/include/deal.II/particles/particle_iterator.h +++ b/include/deal.II/particles/particle_iterator.h @@ -139,6 +139,118 @@ namespace Particles */ ParticleAccessor accessor; }; + + + + // ------------------------------ inline functions ------------------------- + + template + ParticleIterator::ParticleIterator( + const std::multimap> &map, + const typename std::multimap>::iterator & particle) + : accessor(map, particle) + {} + + + + template + ParticleAccessor &ParticleIterator::operator*() + { + return accessor; + } + + + + template + ParticleAccessor *ParticleIterator::operator->() + { + return &(this->operator*()); + } + + + + template + const ParticleAccessor &ParticleIterator:: + operator*() const + { + return accessor; + } + + + + template + const ParticleAccessor *ParticleIterator:: + operator->() const + { + return &(this->operator*()); + } + + + + template + bool + ParticleIterator:: + operator!=(const ParticleIterator &other) const + { + return accessor != other.accessor; + } + + + + template + bool + ParticleIterator:: + operator==(const ParticleIterator &other) const + { + return accessor == other.accessor; + } + + + + template + ParticleIterator & + ParticleIterator::operator++() + { + accessor.next(); + return *this; + } + + + + template + ParticleIterator + ParticleIterator::operator++(int) + { + ParticleIterator tmp(*this); + operator++(); + + return tmp; + } + + + + template + ParticleIterator & + ParticleIterator::operator--() + { + accessor.prev(); + return *this; + } + + + + template + ParticleIterator + ParticleIterator::operator--(int) + { + ParticleIterator tmp(*this); + operator--(); + + return tmp; + } + + } // namespace Particles DEAL_II_NAMESPACE_CLOSE diff --git a/source/particles/CMakeLists.txt b/source/particles/CMakeLists.txt index ce0c4f38c9..b92cf37918 100644 --- a/source/particles/CMakeLists.txt +++ b/source/particles/CMakeLists.txt @@ -19,8 +19,6 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) SET(_src data_out.cc particle.cc - particle_accessor.cc - particle_iterator.cc particle_handler.cc generators.cc property_pool.cc @@ -30,8 +28,6 @@ SET(_src SET(_inst data_out.inst.in particle.inst.in - particle_accessor.inst.in - particle_iterator.inst.in particle_handler.inst.in generators.inst.in utilities.inst.in diff --git a/source/particles/particle.cc b/source/particles/particle.cc index b3f20809fb..eea8eeabd2 100644 --- a/source/particles/particle.cc +++ b/source/particles/particle.cc @@ -227,69 +227,6 @@ namespace Particles - template - void - Particle::set_location(const Point &new_loc) - { - location = new_loc; - } - - - - template - const Point & - Particle::get_location() const - { - return location; - } - - - - template - void - Particle::set_reference_location(const Point &new_loc) - { - reference_location = new_loc; - } - - - - template - const Point & - Particle::get_reference_location() const - { - return reference_location; - } - - - - template - types::particle_index - Particle::get_id() const - { - return id; - } - - - - template - void - Particle::set_id(const types::particle_index &new_id) - { - id = new_id; - } - - - - template - void - Particle::set_property_pool(PropertyPool &new_property_pool) - { - property_pool = &new_property_pool; - } - - - template void Particle::set_properties( @@ -320,17 +257,6 @@ namespace Particles - template - const ArrayView - Particle::get_properties() const - { - Assert(has_properties(), ExcInternalError()); - - return property_pool->get_properties(properties); - } - - - template const ArrayView Particle::get_properties() @@ -350,16 +276,6 @@ namespace Particles return property_pool->get_properties(properties); } - - - - template - bool - Particle::has_properties() const - { - return (property_pool != nullptr) && - (properties != PropertyPool::invalid_handle); - } } // namespace Particles DEAL_II_NAMESPACE_CLOSE diff --git a/source/particles/particle_accessor.cc b/source/particles/particle_accessor.cc deleted file mode 100644 index 95d3cdc303..0000000000 --- a/source/particles/particle_accessor.cc +++ /dev/null @@ -1,248 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 2018 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. -// -// --------------------------------------------------------------------- - -#include - -DEAL_II_NAMESPACE_OPEN - -namespace Particles -{ - template - ParticleAccessor::ParticleAccessor() - : map(nullptr) - , particle() - {} - - - - template - ParticleAccessor::ParticleAccessor( - const std::multimap> &map, - const typename std::multimap>::iterator & particle) - : map(const_cast< - std::multimap> *>(&map)) - , particle(particle) - {} - - - - template - void - ParticleAccessor::write_data(void *&data) const - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.write_data(data); - } - - - - template - void - ParticleAccessor::set_location(const Point &new_loc) - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.set_location(new_loc); - } - - - - template - const Point & - ParticleAccessor::get_location() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.get_location(); - } - - - - template - void - ParticleAccessor::set_reference_location( - const Point &new_loc) - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.set_reference_location(new_loc); - } - - - - template - const Point & - ParticleAccessor::get_reference_location() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.get_reference_location(); - } - - - - template - types::particle_index - ParticleAccessor::get_id() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.get_id(); - } - - - - template - void - ParticleAccessor::set_property_pool( - PropertyPool &new_property_pool) - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.set_property_pool(new_property_pool); - } - - - - template - bool - ParticleAccessor::has_properties() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.has_properties(); - } - - - - template - void - ParticleAccessor::set_properties( - const std::vector &new_properties) - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.set_properties(new_properties); - } - - - - template - void - ParticleAccessor::set_properties( - const ArrayView &new_properties) - { - Assert(particle != map->end(), ExcInternalError()); - - particle->second.set_properties(new_properties); - } - - - - template - const ArrayView - ParticleAccessor::get_properties() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.get_properties(); - } - - - - template - typename Triangulation::cell_iterator - ParticleAccessor::get_surrounding_cell( - const Triangulation &triangulation) const - { - Assert(particle != map->end(), ExcInternalError()); - - const typename Triangulation::cell_iterator cell( - &triangulation, particle->first.first, particle->first.second); - return cell; - } - - - - template - const ArrayView - ParticleAccessor::get_properties() - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.get_properties(); - } - - - - template - std::size_t - ParticleAccessor::serialized_size_in_bytes() const - { - Assert(particle != map->end(), ExcInternalError()); - - return particle->second.serialized_size_in_bytes(); - } - - - - template - void - ParticleAccessor::next() - { - Assert(particle != map->end(), ExcInternalError()); - ++particle; - } - - - - template - void - ParticleAccessor::prev() - { - Assert(particle != map->begin(), ExcInternalError()); - --particle; - } - - - - template - bool - ParticleAccessor:: - operator!=(const ParticleAccessor &other) const - { - return (map != other.map) || (particle != other.particle); - } - - - - template - bool - ParticleAccessor:: - operator==(const ParticleAccessor &other) const - { - return (map == other.map) && (particle == other.particle); - } -} // namespace Particles - -DEAL_II_NAMESPACE_CLOSE - -DEAL_II_NAMESPACE_OPEN - -#include "particle_accessor.inst" - -DEAL_II_NAMESPACE_CLOSE diff --git a/source/particles/particle_accessor.inst.in b/source/particles/particle_accessor.inst.in deleted file mode 100644 index 3f8fdf5920..0000000000 --- a/source/particles/particle_accessor.inst.in +++ /dev/null @@ -1,26 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 2018 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. -// -// --------------------------------------------------------------------- - - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) - { -#if deal_II_dimension <= deal_II_space_dimension - namespace Particles - \{ - template class ParticleAccessor; - \} -#endif - } diff --git a/source/particles/particle_iterator.cc b/source/particles/particle_iterator.cc deleted file mode 100644 index 07f7f49381..0000000000 --- a/source/particles/particle_iterator.cc +++ /dev/null @@ -1,136 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 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. -// -// --------------------------------------------------------------------- - -#include - -DEAL_II_NAMESPACE_OPEN - -namespace Particles -{ - template - ParticleIterator::ParticleIterator( - const std::multimap> &map, - const typename std::multimap>::iterator & particle) - : accessor(map, particle) - {} - - - - template - ParticleAccessor &ParticleIterator::operator*() - { - return accessor; - } - - - - template - ParticleAccessor *ParticleIterator::operator->() - { - return &(this->operator*()); - } - - - - template - const ParticleAccessor &ParticleIterator:: - operator*() const - { - return accessor; - } - - - - template - const ParticleAccessor *ParticleIterator:: - operator->() const - { - return &(this->operator*()); - } - - - - template - bool - ParticleIterator:: - operator!=(const ParticleIterator &other) const - { - return accessor != other.accessor; - } - - - - template - bool - ParticleIterator:: - operator==(const ParticleIterator &other) const - { - return accessor == other.accessor; - } - - - - template - ParticleIterator & - ParticleIterator::operator++() - { - accessor.next(); - return *this; - } - - - - template - ParticleIterator - ParticleIterator::operator++(int) - { - ParticleIterator tmp(*this); - operator++(); - - return tmp; - } - - - - template - ParticleIterator & - ParticleIterator::operator--() - { - accessor.prev(); - return *this; - } - - - - template - ParticleIterator - ParticleIterator::operator--(int) - { - ParticleIterator tmp(*this); - operator--(); - - return tmp; - } -} // namespace Particles - - -DEAL_II_NAMESPACE_CLOSE - -DEAL_II_NAMESPACE_OPEN - -#include "particle_iterator.inst" - -DEAL_II_NAMESPACE_CLOSE diff --git a/source/particles/particle_iterator.inst.in b/source/particles/particle_iterator.inst.in deleted file mode 100644 index f82407d67a..0000000000 --- a/source/particles/particle_iterator.inst.in +++ /dev/null @@ -1,26 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 2018 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. -// -// --------------------------------------------------------------------- - - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) - { -#if deal_II_dimension <= deal_II_space_dimension - namespace Particles - \{ - template class ParticleIterator; - \} -#endif - } -- 2.39.5