From: Luca Heltai Date: Mon, 28 Jul 2014 12:54:25 +0000 (+0200) Subject: Made the default Manifold objects inside Triangulation be Manifold. Now get_boundary... X-Git-Tag: v8.2.0-rc1~227^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c9d9bb56a488095596aead21a370276a4013e05;p=dealii.git Made the default Manifold objects inside Triangulation be Manifold. Now get_boundary and get_manifold do different things. --- diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index bbfac47794..f2dabfed9e 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -42,6 +42,7 @@ DEAL_II_NAMESPACE_OPEN template class Boundary; template class StraightBoundary; +template class Manifold; template class TriaAccessor; template class TriaAccessor<0,1,spacedim>; @@ -1864,7 +1865,7 @@ public: * @see @ref GlossManifoldIndicator "Glossary entry on manifold indicators" */ void set_manifold (const types::manifold_id number, - const Boundary &manifold_object); + const Manifold &manifold_object); /** @@ -1897,7 +1898,7 @@ public: * * @see @ref GlossManifoldIndicator "Glossary entry on manifold indicators" */ - const Boundary &get_manifold (const types::manifold_id number) const; + const Manifold &get_manifold (const types::manifold_id number) const; /** * Returns a vector containing all boundary indicators assigned to @@ -3331,7 +3332,7 @@ private: * Collection of manifold objects. We store only objects, which are * not of type FlatManifold. */ - std::map , Triangulation > > manifold; + std::map , Triangulation > > manifold; /** diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 122090bc63..2f8c17fbdc 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -37,6 +37,7 @@ template class TriaIterator; template class TriaActiveIterator; template class Boundary; +template class Manifold; namespace internal @@ -1200,7 +1201,7 @@ public: * involves querying both the manifold or boundary indicators. See there * for more information. */ - const Boundary &get_manifold () const; + const Manifold &get_manifold () const; /** * @} diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index b208e361eb..d6cda3e65f 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -1912,13 +1912,28 @@ TriaAccessor::at_boundary () const template const Boundary & TriaAccessor::get_boundary () const -{ - return get_manifold(); +{ + Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); + + // Get the default (manifold_id) + const types::manifold_id mi = this->objects().manifold_id[this->present_index]; + + // In case this is not valid, check + // the boundary id, after having + // casted it to a manifold id + if(mi == numbers::invalid_manifold_id) + return this->tria->get_boundary(structdim < dim ? + this->objects().boundary_or_material_id[this->present_index].boundary_id: + dim < spacedim ? + this->objects().boundary_or_material_id[this->present_index].material_id: + numbers::invalid_manifold_id); + else + return this->tria->get_boundary(mi); } template -const Boundary & +const Manifold & TriaAccessor::get_manifold () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); diff --git a/source/grid/tria.cc b/source/grid/tria.cc index d7724a2082..afe95637c7 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -4039,7 +4040,7 @@ namespace internal // new vertex is placed on the surface according to // the information stored in the boundary class - const Boundary &manifold = cell->get_manifold(); + const Manifold &manifold = cell->get_manifold(); triangulation.vertices[next_unused_vertex] = manifold.get_new_point_on_quad (cell); @@ -8992,7 +8993,7 @@ Triangulation::set_boundary (const types::manifold_id m_number, template void Triangulation::set_manifold (const types::manifold_id m_number, - const Boundary &manifold_object) + const Manifold &manifold_object) { Assert(m_number < numbers::invalid_manifold_id, ExcIndexRange(m_number,0,numbers::invalid_manifold_id)); @@ -9026,17 +9027,22 @@ template const Boundary & Triangulation::get_boundary (const types::manifold_id m_number) const { - return get_manifold(m_number); + const Boundary * man = + dynamic_cast *>(&get_manifold(m_number)); + Assert(man != NULL, + ExcMessage("You tried to get a Boundary, but I only have a Manifold.")); + + return *man; } template -const Boundary & +const Manifold & Triangulation::get_manifold (const types::manifold_id m_number) const { //look, if there is a manifold stored at //manifold_id number. - typename std::map, Triangulation > >::const_iterator it + typename std::map, Triangulation > >::const_iterator it = manifold.find(m_number); if (it != manifold.end()) @@ -9128,7 +9134,7 @@ copy_triangulation (const Triangulation &old_tria) faces = new internal::Triangulation::TriaFaces(*old_tria.faces); typename std::map , Triangulation > >::const_iterator + SmartPointer , Triangulation > >::const_iterator bdry_iterator = old_tria.manifold.begin(); for (; bdry_iterator != old_tria.manifold.end() ; bdry_iterator++) manifold[bdry_iterator->first] = bdry_iterator->second;