]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Address initial comments. Add tests.
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Tue, 8 Aug 2017 22:02:34 +0000 (16:02 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 22 Sep 2017 15:59:06 +0000 (09:59 -0600)
14 files changed:
include/deal.II/particles/particle.h [moved from include/deal.II/particle/particle.h with 88% similarity]
include/deal.II/particles/property_pool.h [moved from include/deal.II/particle/property_pool.h with 95% similarity]
source/CMakeLists.txt
source/particles/CMakeLists.txt [moved from source/particle/CMakeLists.txt with 90% similarity]
source/particles/particle.cc [moved from source/particle/particle.cc with 98% similarity]
source/particles/particle.inst.in [moved from source/particle/particle.inst.in with 96% similarity]
source/particles/property_pool.cc [moved from source/particle/property_pool.cc with 88% similarity]
tests/particles/CMakeLists.txt [moved from tests/particle/CMakeLists.txt with 100% similarity]
tests/particles/particle_01.cc [moved from tests/particle/particle_01.cc with 93% similarity]
tests/particles/particle_01.output [moved from tests/particle/particle_01.output with 100% similarity]
tests/particles/particle_02.cc [new file with mode: 0644]
tests/particles/particle_02.output [new file with mode: 0644]
tests/particles/particle_03.cc [new file with mode: 0644]
tests/particles/particle_03.output [new file with mode: 0644]

similarity index 88%
rename from include/deal.II/particle/particle.h
rename to include/deal.II/particles/particle.h
index ab488769b39e210bbfffbc85fafa7f8dbfbbdc03..6c7bc369fdefe30e93f1693081c044fda1ca596d 100644 (file)
 //
 // ---------------------------------------------------------------------
 
-#ifndef dealii__particle_particle_h
-#define dealii__particle_particle_h
+#ifndef dealii__particles_particle_h
+#define dealii__particles_particle_h
 
-#include <deal.II/particle/property_pool.h>
+#include <deal.II/particles/property_pool.h>
 
 #include <deal.II/base/point.h>
 #include <deal.II/base/types.h>
 
 DEAL_II_NAMESPACE_OPEN
 
-namespace Particle
+/**
+ * A namespace that contains all classes that are related to the particle
+ * implementation, in particular the fundamental <code>Particle</code> class.
+ */
+namespace Particles
 {
   /**
    * A namespace for all type definitions related to particles.
@@ -53,7 +57,7 @@ namespace Particle
      * An identifier that denotes the MPI type associated with
      * types::global_dof_index.
      */
-#  define ASPECT_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG
+#  define PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED_LONG_LONG
 #else
     /**
      * The type used for indices of particles. While in
@@ -72,7 +76,7 @@ namespace Particle
      * An identifier that denotes the MPI type associated with
      * types::global_dof_index.
      */
-#  define ASPECT_PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
+#  define PARTICLE_INDEX_MPI_TYPE MPI_UNSIGNED
 #endif
   }
 
@@ -98,14 +102,14 @@ namespace Particle
 
     /**
      * Constructor for Particle, creates a particle with the specified
-     * ID at the specified location. Note that Aspect
-     * does not check for duplicate particle IDs so the generator must
+     * ID at the specified location. Note that deal.II
+     * does not check for duplicate particle IDs so the user must
      * make sure the IDs are unique over all processes.
      *
-     * @param[in] new_location Initial location of particle.
-     * @param[in] new_reference_location Initial location of the particle
+     * @param new_location Initial location of particle.
+     * @param new_reference_location Initial location of the particle
      * in the coordinate system of the reference cell.
-     * @param[in] new_id Globally unique ID number of particle.
+     * @param new_id Globally unique ID number of particle.
      */
     Particle (const Point<dim> &new_location,
               const Point<dim> &new_reference_location,
@@ -195,8 +199,7 @@ namespace Particle
     get_location () const;
 
     /**
-     * Set the reference location of this particle. Note that this does not
-     * check whether this is a valid location in the simulation domain.
+     * Set the reference location of this particle.
      *
      * @param [in] new_loc The new reference location for this particle.
      */
@@ -204,17 +207,13 @@ namespace Particle
     set_reference_location (const Point<dim> &new_loc);
 
     /**
-     * Get the reference location of this particle in its current cell.
-     *
-     * @return The reference location of this particle.
+     * Return the reference location of this particle in its current cell.
      */
     const Point<dim> &
     get_reference_location () const;
 
     /**
-     * Get the ID number of this particle.
-     *
-     * @return The id of this particle.
+     * Return the ID number of this particle.
      */
     types::particle_index
     get_id () const;
@@ -268,8 +267,6 @@ namespace Particle
 
     /**
      * Current particle location in the reference cell.
-     * Storing this reduces the number of times we need to compute this
-     * location, which takes a significant amount of computing time.
      */
     Point<dim>             reference_location;
 
similarity index 95%
rename from include/deal.II/particle/property_pool.h
rename to include/deal.II/particles/property_pool.h
index 99dc52c028e287d8d6b0010db6c6b34afc53daaf..a392c2344962690ff04d474961f6d18c19bdff7a 100644 (file)
 //
 // ---------------------------------------------------------------------
 
-#ifndef dealii__particle_property_pool_h
-#define dealii__particle_property_pool_h
+#ifndef dealii__particles_property_pool_h
+#define dealii__particles_property_pool_h
 
 #include <deal.II/base/array_view.h>
 
 DEAL_II_NAMESPACE_OPEN
 
-namespace Particle
+namespace Particles
 {
   /**
    * This class manages the memory space in which particles store their
index e21a35381102f161dbb62ab671e5958193b73df2..d9c364a350532bce436455f59845acac6fdeb418 100644 (file)
@@ -48,7 +48,7 @@ ADD_SUBDIRECTORY(integrators)
 ADD_SUBDIRECTORY(matrix_free)
 ADD_SUBDIRECTORY(meshworker)
 ADD_SUBDIRECTORY(opencascade)
-ADD_SUBDIRECTORY(particle)
+ADD_SUBDIRECTORY(particles)
 ADD_SUBDIRECTORY(physics)
 ADD_SUBDIRECTORY(non_matching)
 ADD_SUBDIRECTORY(sundials)
similarity index 90%
rename from source/particle/CMakeLists.txt
rename to source/particles/CMakeLists.txt
index 99db585c8859401d2f97ea03bcf017f37469d2f4..b45a281df69de1f0fa4997f9a75f71325356313a 100644 (file)
@@ -1,6 +1,6 @@
 ## ---------------------------------------------------------------------
 ##
-## Copyright (C) 2016 by the deal.II authors
+## Copyright (C) 2017 by the deal.II authors
 ##
 ## This file is part of the deal.II library.
 ##
@@ -26,7 +26,7 @@ SET(_inst
   )
 
 FILE(GLOB _header
-  ${CMAKE_SOURCE_DIR}/include/deal.II/particle/*.h
+  ${CMAKE_SOURCE_DIR}/include/deal.II/particles/*.h
   )
 
 DEAL_II_ADD_LIBRARY(obj_particle OBJECT ${_src} ${_header} ${_inst})
similarity index 98%
rename from source/particle/particle.cc
rename to source/particles/particle.cc
index f842b41148ae1c8dab9304a4725d48c726437a13..11e74a23cabec7e33a522bbd5963a3d0da73dfd5 100644 (file)
 //
 // ---------------------------------------------------------------------
 
-#include <deal.II/particle/particle.h>
+#include <deal.II/particles/particle.h>
 
 DEAL_II_NAMESPACE_OPEN
 
-namespace Particle
+namespace Particles
 {
   template <int dim>
   Particle<dim>::Particle ()
@@ -92,8 +92,6 @@ namespace Particle
     data = static_cast<const void *> (pdata);
   }
 
-#ifdef DEAL_II_WITH_CXX11
-
   template <int dim>
   Particle<dim>::Particle (Particle<dim> &&particle)
     :
@@ -149,7 +147,6 @@ namespace Particle
       }
     return *this;
   }
-#endif
 
   template <int dim>
   Particle<dim>::~Particle ()
similarity index 96%
rename from source/particle/particle.inst.in
rename to source/particles/particle.inst.in
index 0c888d702c8fea364e611d410dd5987fcdc2f968..4b693348c0f19cdee4d923899e105447213049dc 100644 (file)
@@ -16,7 +16,7 @@
 
 for (deal_II_dimension : DIMENSIONS)
 {
-    namespace Particle
+    namespace Particles
     \{
     template
     class Particle <deal_II_dimension>;
similarity index 88%
rename from source/particle/property_pool.cc
rename to source/particles/property_pool.cc
index 1aa1adaa0578086ebaf29da2a6e0c022f3c2d816..4a85e3fffdba720e9e6e47bff28354ee8f02401e 100644 (file)
 // ---------------------------------------------------------------------
 
 
-#include <deal.II/particle/property_pool.h>
-#include <deal.II/particle/particle.h>
+#include <deal.II/particles/property_pool.h>
 
 DEAL_II_NAMESPACE_OPEN
 
-namespace Particle
+namespace Particles
 {
-  const PropertyPool::Handle PropertyPool::invalid_handle = NULL;
+  const typename PropertyPool::Handle PropertyPool::invalid_handle = NULL;
 
 
   PropertyPool::PropertyPool (const unsigned int n_properties_per_slot)
@@ -54,6 +53,7 @@ namespace Particle
   }
 
 
+
   void
   PropertyPool::reserve(const std::size_t size)
   {
similarity index 93%
rename from tests/particle/particle_01.cc
rename to tests/particles/particle_01.cc
index fa8a00938560028e94b227337380246cd0a9b6d9..876e03ac16e48e6337c9dbdd3441026d50b5d0a1 100644 (file)
@@ -18,7 +18,7 @@
 // check the creation and destruction of particles
 
 #include "../tests.h"
-#include <deal.II/particle/particle.h>
+#include <deal.II/particles/particle.h>
 #include <fstream>
 #include <iomanip>
 
@@ -27,7 +27,7 @@ template <int dim>
 void test ()
 {
   {
-    Particle::Particle<dim> particle;
+    Particles::Particle<dim> particle;
 
     deallog << "Particle location: " << particle.get_location() << std::endl;
 
diff --git a/tests/particles/particle_02.cc b/tests/particles/particle_02.cc
new file mode 100644 (file)
index 0000000..95cc692
--- /dev/null
@@ -0,0 +1,72 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check Particle constructors, copy, and move operations.
+
+#include "../tests.h"
+#include <deal.II/particles/particle.h>
+#include <fstream>
+#include <iomanip>
+
+
+template <int dim>
+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 Particles::types::particle_index index(7);
+
+    Particles::Particle<2> particle(position,reference_position,index);
+
+    deallog << "Particle location: " << particle.get_location() << std::endl
+        << "Particle reference location: " << particle.get_reference_location() << std::endl
+        << "Particle index: " << particle.get_id() << std::endl;
+
+    const Particles::Particle<2> copy(particle);
+
+    deallog << "Copy particle location: " << copy.get_location() << std::endl
+        << "Copy particle reference location: " << copy.get_reference_location() << std::endl
+        << "Copy particle index: " << copy.get_id() << std::endl;
+
+    const Particles::Particle<2> moved_particle(std::move(particle));
+
+    deallog << "Moved particle location: " << moved_particle.get_location() << std::endl
+        << "Moved particle reference location: " << moved_particle.get_reference_location() << std::endl
+        << "Moved particle index: " << moved_particle.get_id() << std::endl;
+
+    deallog << "Original particle location: " << particle.get_location() << std::endl
+        << "Original particle reference location: " << particle.get_reference_location() << std::endl
+        << "Original particle index: " << particle.get_id() << std::endl;
+  }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+  initlog();
+  test<2>();
+}
diff --git a/tests/particles/particle_02.output b/tests/particles/particle_02.output
new file mode 100644 (file)
index 0000000..2a4fefe
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::Particle location: 0.300000 0.500000
+DEAL::Particle reference location: 0.200000 0.400000
+DEAL::Particle index: 7
+DEAL::Copy particle location: 0.300000 0.500000
+DEAL::Copy particle reference location: 0.200000 0.400000
+DEAL::Copy particle index: 7
+DEAL::Moved particle location: 0.300000 0.500000
+DEAL::Moved particle reference location: 0.200000 0.400000
+DEAL::Moved particle index: 7
+DEAL::Original particle location: 0.300000 0.500000
+DEAL::Original particle reference location: 0.200000 0.400000
+DEAL::Original particle index: 7
+DEAL::OK
diff --git a/tests/particles/particle_03.cc b/tests/particles/particle_03.cc
new file mode 100644 (file)
index 0000000..06d2685
--- /dev/null
@@ -0,0 +1,75 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Like particle_02, but with particle properties.
+
+#include "../tests.h"
+#include <deal.II/particles/particle.h>
+#include <fstream>
+#include <iomanip>
+
+
+template <int dim>
+void test ()
+{
+  {
+    const unsigned int n_properties_per_particle = 3;
+    Particles::PropertyPool pool(n_properties_per_particle);
+
+    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 Particles::types::particle_index index(7);
+
+    std::vector<double> properties = {0.15,0.45,0.75};
+
+    Particles::Particle<2> particle(position,reference_position,index);
+    particle.set_property_pool(pool);
+    particle.set_properties(properties);
+
+    deallog << "Particle properties: "
+        << std::vector<double>(particle.get_properties().begin(),particle.get_properties().end())
+        << std::endl;
+
+    const Particles::Particle<2> copy(particle);
+
+    deallog << "Copy particle properties: "
+        << std::vector<double>(copy.get_properties().begin(),copy.get_properties().end())
+        << std::endl;
+
+    const Particles::Particle<2> moved_particle(std::move(particle));
+
+    deallog << "Moved particle properties: "
+        << std::vector<double>(moved_particle.get_properties().begin(),moved_particle.get_properties().end())
+        << std::endl;
+  }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+  initlog();
+  test<2>();
+}
diff --git a/tests/particles/particle_03.output b/tests/particles/particle_03.output
new file mode 100644 (file)
index 0000000..558d9d5
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Particle properties: 0.150000 0.450000 0.750000
+DEAL::Copy particle properties: 0.150000 0.450000 0.750000
+DEAL::Moved particle properties: 0.150000 0.450000 0.750000
+DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.