]> https://gitweb.dealii.org/ - dealii.git/commitdiff
added new option to read indicators in a ucd file as manifold ids and not as boundary ids
authoramola <amola@terminus.sissa.it>
Tue, 5 Apr 2016 07:50:30 +0000 (09:50 +0200)
committeramola <amola@terminus.sissa.it>
Fri, 8 Apr 2016 16:08:10 +0000 (18:08 +0200)
include/deal.II/grid/grid_in.h
source/grid/grid_in.cc
source/grid/tria.cc

index 1177d079554bfae685fc3826f14f3913d491f587..30bf5513320b7d7728a236bab758e91973ab29ab 100644 (file)
@@ -366,8 +366,14 @@ public:
 
   /**
    * Read grid data from an ucd file. Numerical data is ignored.
+   * It is not possible to use a ucd file to set both boundary_id and
+   * manifold_id for the same cell. Yet it is possible to use
+   * the flag apply_all_indicators_to_manifolds to decide if
+   * the indicators in the file refer to manifolds (flag set to true)
+   * or boundaries (flag set to false).
    */
-  void read_ucd (std::istream &in);
+  void read_ucd (std::istream                                  &in,
+                 const bool apply_all_indicators_to_manifolds=false);
 
   /**
    * Read grid data from an Abaqus file. Numerical and constitutive data is
index df169e1498b881cdabfe0f8f6c758b8a07808673..119c196546551c67407c5c59ed861ad38d9dff47 100644 (file)
@@ -610,7 +610,8 @@ void GridIn<dim, spacedim>::read_unv(std::istream &in)
 
 
 template <int dim, int spacedim>
-void GridIn<dim, spacedim>::read_ucd (std::istream &in)
+void GridIn<dim, spacedim>::read_ucd (std::istream                            &in,
+                                      const bool apply_all_indicators_to_manifolds)
 {
   Assert (tria != 0, ExcNoTriangulationSelected());
   AssertThrow (in, ExcIO());
@@ -727,8 +728,12 @@ void GridIn<dim, spacedim>::read_ucd (std::istream &in)
           Assert(material_id < numbers::internal_face_boundary_id,
                  ExcIndexRange(material_id,0,numbers::internal_face_boundary_id));
 
-          subcelldata.boundary_lines.back().boundary_id
-            = static_cast<types::boundary_id>(material_id);
+          if (apply_all_indicators_to_manifolds)
+            subcelldata.boundary_lines.back().manifold_id
+              = static_cast<types::manifold_id>(material_id);
+          else
+            subcelldata.boundary_lines.back().boundary_id
+              = static_cast<types::boundary_id>(material_id);
 
           // transform from ucd to
           // consecutive numbering
@@ -764,8 +769,12 @@ void GridIn<dim, spacedim>::read_ucd (std::istream &in)
           Assert(material_id < numbers::internal_face_boundary_id,
                  ExcIndexRange(material_id,0,numbers::internal_face_boundary_id));
 
-          subcelldata.boundary_quads.back().boundary_id
-            = static_cast<types::boundary_id>(material_id);
+          if (apply_all_indicators_to_manifolds)
+            subcelldata.boundary_quads.back().manifold_id
+              = static_cast<types::manifold_id>(material_id);
+          else
+            subcelldata.boundary_quads.back().boundary_id
+              = static_cast<types::boundary_id>(material_id);
 
           // transform from ucd to
           // consecutive numbering
index 7bd94ee3f8f483e376fdc9ff718dbddc01955a6b..fce3fc83006b6e9e05a319ed5ee526d5df9f82c3 100644 (file)
@@ -2068,13 +2068,32 @@ namespace internal
             // need to allow that
             if (boundary_line->boundary_id != numbers::internal_face_boundary_id)
               {
-                AssertThrow (! (line->boundary_id() == numbers::internal_face_boundary_id),
-                             ExcInteriorLineCantBeBoundary(line->vertex_index(0),
-                                                           line->vertex_index(1),
-                                                           boundary_line->boundary_id));
-                line->set_boundary_id (boundary_line->boundary_id);
+                if (line->boundary_id() == numbers::internal_face_boundary_id)
+                  {
+                    // if we are here, it means that we want to assign a boundary indicator
+                    // different from numbers::internal_face_boundary_id to an internal line.
+                    // As said, this would be not allowed, and an exception should be immediately
+                    // thrown. Still, there is the possibility that one only wants to specifiy a
+                    // manifold_id here. If that is the case (manifold_id !=  numbers::flat_manifold_id)
+                    // the operation is allowed. Otherwise, we really tried to specify a boundary_id
+                    // (and not a manifold_id) to an internal face. The exception must be thrown.
+                    if (boundary_line->manifold_id == numbers::flat_manifold_id)
+                      {
+                        // If we are here, this assertion will surely fail, for the aforementioned
+                        // reasons
+                        AssertThrow (! (line->boundary_id() == numbers::internal_face_boundary_id),
+                                     ExcInteriorLineCantBeBoundary(line->vertex_index(0),
+                                                                   line->vertex_index(1),
+                                                                   boundary_line->boundary_id));
+                      }
+                    else
+                      {
+                        line->set_manifold_id (boundary_line->manifold_id);
+                      }
+                  }
+                else
+                  line->set_boundary_id (boundary_line->boundary_id);
               }
-
             line->set_manifold_id (boundary_line->manifold_id);
           }
 

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.