From ca922371fe999bbe1ad4d8b5043a65d16769714c Mon Sep 17 00:00:00 2001 From: heltai Date: Fri, 18 Jul 2014 13:18:57 +0000 Subject: [PATCH] Added a template argument to the Function classes. git-svn-id: https://svn.dealii.org/branches/branch_boundary_to_manifold@33196 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/grid/tria.h | 28 +++++++++++++------ deal.II/include/deal.II/grid/tria_accessor.h | 10 +++++-- .../deal.II/grid/tria_accessor.templates.h | 23 ++++++++++++--- deal.II/source/grid/grid_tools.cc | 3 +- deal.II/source/grid/tria.cc | 23 +++++++++------ 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/deal.II/include/deal.II/grid/tria.h b/deal.II/include/deal.II/grid/tria.h index 5af6ef9b29..abb9507893 100644 --- a/deal.II/include/deal.II/grid/tria.h +++ b/deal.II/include/deal.II/grid/tria.h @@ -43,6 +43,9 @@ DEAL_II_NAMESPACE_OPEN template class Boundary; template class StraightBoundary; +template class Manifold; +template class FlatManifold; + template class TriaAccessor; template class TriaAccessor<0,1,spacedim>; @@ -1235,12 +1238,18 @@ private: public: /** - * Default manifold object. This is used - * for those objects for which no - * boundary description has been explicitly - * set using set_manifold(). + * Default manifold object. This is used for those objects for which + * no manifold description has been explicitly set using + * set_manifold(). + */ + static const FlatManifold flat_manifold; + + /** + * Default boundary object. This is used for those objects for which + * no boundary description has been explicitly set using + * set_boundary(). */ - static const StraightBoundary straight_boundary; + static const StraightBoundary straight_boundary; /** * Declare some symbolic names @@ -1840,7 +1849,7 @@ public: * @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" */ void set_boundary (const types::manifold_id number, - const Boundary &boundary_object); + const Manifold &boundary_object); /** @@ -1875,7 +1884,7 @@ public: * * @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators" */ - const Boundary &get_boundary (const types::manifold_id number) const; + const Manifold &get_boundary (const types::manifold_id number) const; /** * Return a constant reference to a Manifold object used for this @@ -1885,7 +1894,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 @@ -3319,7 +3328,8 @@ 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/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index 122090bc63..83cb8fed54 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -1187,9 +1187,13 @@ public: /** * Return a constant reference to the manifold object used for this * object. This function exists for backward compatibility and calls - * get_manifold() internally. + * get_manifold() internally, casting the result to a + * Boundary. If the object cannot be casted, it checks + * if the Manifold was actually a FlatManifold, in which case it + * returns a StraightBoundary. */ - const Boundary &get_boundary () const; + // const Boundary &get_boundary () const; + const Manifold &get_boundary () const; /** * Return a constant reference to the manifold object used for this object. @@ -1200,7 +1204,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/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index b208e361eb..b77ca261dc 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -1910,15 +1910,30 @@ TriaAccessor::at_boundary () const template -const Boundary & +const Manifold & TriaAccessor::get_boundary () const { +// const Boundary * ptr = +// dynamic_cast *>(&get_manifold()); +// if(ptr) +// return *ptr; +// else +// { +// // Check if the object returned was a FlatManifold... +// if(dynamic_cast *>(&get_manifold())) +// return Triangulation::straight_boundary; +// else +// Assert(false, +// ExcMessage("Requested object is not a Boundary.")); +// return Triangulation::straight_boundary; +// } +// return Triangulation::straight_boundary; return get_manifold(); } template -const Boundary & +const Manifold & TriaAccessor::get_manifold () const { Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); @@ -1935,8 +1950,8 @@ TriaAccessor::get_manifold () const dim < spacedim ? this->objects().boundary_or_material_id[this->present_index].material_id: numbers::invalid_manifold_id); - else - return this->tria->get_manifold(mi); + + return this->tria->get_manifold(mi); } diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index 8a1e931f92..9e754916f0 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -1755,7 +1755,8 @@ next_cell: const Boundary *manifold = (respect_manifold ? - &object->get_boundary() : + dynamic_cast* >(&object->get_boundary()) : 0); const unsigned int structdim = Iterator::AccessorType::structure_dimension; diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 3ed89fc573..b96bb1c321 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -4055,7 +4056,7 @@ namespace internal // 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); @@ -9484,6 +9485,12 @@ namespace internal } +template +const FlatManifold +Triangulation::flat_manifold = FlatManifold(); + + + template const StraightBoundary Triangulation::straight_boundary = StraightBoundary(); @@ -9590,7 +9597,7 @@ Triangulation::set_mesh_smoothing(const MeshSmoothing mesh_smooth template void Triangulation::set_boundary (const types::manifold_id m_number, - const Boundary &boundary_object) + const Manifold &boundary_object) { Assert(m_number < numbers::invalid_manifold_id, ExcIndexRange(m_number,0,numbers::invalid_manifold_id)); @@ -9621,7 +9628,7 @@ Triangulation::set_manifold (const types::manifold_id m_number) template -const Boundary & +const Manifold & Triangulation::get_boundary (const types::manifold_id m_number) const { return get_manifold(m_number); @@ -9629,12 +9636,12 @@ Triangulation::get_boundary (const types::manifold_id m_number) c 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()) @@ -9646,8 +9653,8 @@ Triangulation::get_manifold (const types::manifold_id m_number) c { //if we have not found an entry //connected with number, we return - //straight_boundary - return straight_boundary; + //flat_manifold + return flat_manifold; } } @@ -9728,7 +9735,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; -- 2.39.5