]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add get_manifold() to 1D vertex iterators. 4367/head
authorDavid Wells <wellsd2@rpi.edu>
Wed, 10 May 2017 17:14:44 +0000 (13:14 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Thu, 11 May 2017 23:03:42 +0000 (19:03 -0400)
doc/news/changes/minor/20170510DavidWells [new file with mode: 0644]
include/deal.II/grid/tria_accessor.h
include/deal.II/grid/tria_accessor.templates.h
tests/grid/oned_vertex_manifold.cc [new file with mode: 0644]
tests/grid/oned_vertex_manifold.output [new file with mode: 0644]

diff --git a/doc/news/changes/minor/20170510DavidWells b/doc/news/changes/minor/20170510DavidWells
new file mode 100644 (file)
index 0000000..522955b
--- /dev/null
@@ -0,0 +1,3 @@
+New: The vertex (and face) iterator for dimension 1 triangulations now implements
+the get_manifold method.
+<br> (David Wells, 2017/05/10)
index 3cb868ad464e78d42080c1263275aeef59c6f2a4..5d39d7d7e96290782327f38a22fadb7c631ae38c 100644 (file)
@@ -2109,6 +2109,11 @@ public:
    */
   types::boundary_id boundary_id () const;
 
+  /**
+   * Return a constant reference to the manifold object used for this object.
+   */
+  const Manifold<1,spacedim> &get_manifold () const;
+
   /**
    * Return the manifold indicator of this object.
    *
index 5e8634bfe1b274bf9e084eb60a27d52e1474930e..3b6df0e3d5b7bcc870e6296ad84f875f41b3ed64 100644 (file)
@@ -2885,6 +2885,16 @@ TriaAccessor<0, 1, spacedim>::boundary_id () const
 
 
 
+template <int spacedim>
+inline
+const Manifold<1, spacedim> &
+TriaAccessor<0, 1, spacedim>::get_manifold () const
+{
+  return this->tria->get_manifold(this->manifold_id());
+}
+
+
+
 template <int spacedim>
 inline
 types::manifold_id
diff --git a/tests/grid/oned_vertex_manifold.cc b/tests/grid/oned_vertex_manifold.cc
new file mode 100644 (file)
index 0000000..5fb36a9
--- /dev/null
@@ -0,0 +1,66 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+// Test vertex manifold ids in 1D.
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/manifold_lib.h>
+
+int main()
+{
+  initlog(true);
+
+  SphericalManifold<1> spherical_manifold;
+
+
+  constexpr types::manifold_id spherical_manifold_id = 42;
+
+  Triangulation<1> triangulation;
+  GridGenerator::hyper_cube(triangulation);
+  triangulation.refine_global(1);
+  triangulation.set_manifold(spherical_manifold_id, spherical_manifold);
+
+  triangulation.begin_active()->set_all_manifold_ids(spherical_manifold_id);
+
+  for (const auto cell : triangulation.active_cell_iterators())
+    {
+      deallog << "current cell manifold id: "
+              << cell->manifold_id()
+              << std::endl;
+
+      for (unsigned int vertex_n = 0; vertex_n < GeometryInfo<1>::vertices_per_cell;
+           ++vertex_n)
+        {
+          deallog << "current vertex: "
+                  << cell->vertex(vertex_n)
+                  << std::endl;
+          deallog << "current vertex manifold id: "
+                  << cell->face(vertex_n)->manifold_id()
+                  << std::endl;
+
+          if (cell->face(vertex_n)->manifold_id() == 42)
+            {
+              // since the reference is const, the pointer we compare it to
+              // must also be a to a const object
+              const auto &spherical_reference = spherical_manifold;
+              Assert(&spherical_reference == &cell->face(vertex_n)->get_manifold(),
+                     ExcMessage("manifolds should be the same."));
+            }
+        }
+    }
+}
diff --git a/tests/grid/oned_vertex_manifold.output b/tests/grid/oned_vertex_manifold.output
new file mode 100644 (file)
index 0000000..3392a04
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL::current cell manifold id: 42
+DEAL::current vertex: 0.00000
+DEAL::current vertex manifold id: 42
+DEAL::current vertex: 0.500000
+DEAL::current vertex manifold id: 42
+DEAL::current cell manifold id: 4294967295
+DEAL::current vertex: 0.500000
+DEAL::current vertex manifold id: 42
+DEAL::current vertex: 1.00000
+DEAL::current vertex manifold id: 4294967295

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.