]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implementation of 3d boundary data in UCD format and in Triangulation<3>::create_tria...
authorthird-party <third-party@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 11 Oct 2000 13:36:31 +0000 (13:36 +0000)
committerthird-party <third-party@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 11 Oct 2000 13:36:31 +0000 (13:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@3405 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/grid_in.cc
deal.II/deal.II/source/grid/tria.cc
deal.II/doc/news/2000/c-3-0.html

index 4ac2484c39299b0cb13d81a56a9e3dae2103dd89..f5e6f05e5a472f87c0d38dd3341ddc0d45617828 100644 (file)
@@ -2923,10 +2923,22 @@ class Triangulation : public TriaDimensionInfo<dim>,
                                     /**
                                      * Exception
                                      */
+    DeclException4 (ExcQuadInexistant,
+                    int, int, int, int,
+                   << "When trying to give a boundary indicator to a quad: "
+                   << "the quad with bounding lines " << arg1 << ", " << arg2
+                   << ", " << arg3 << ", " << arg4 << " does not exist.");
+                                    /**
+                                     * Exception
+                                     */                                      
     DeclException0 (ExcInteriorLineCantBeBoundary);
                                     /**
                                      * Exception
                                      */
+    DeclException0 (ExcInteriorQuadCantBeBoundary);
+                                     /**
+                                     * Exception
+                                     */                                      
     DeclException0 (ExcInternalError);
                                     /**
                                      * Exception
index f31ba93d303e41b22ec52a982fe311fd9bf2350f..8205cf08d251358bc22a1495ed676a6374f513f7 100644 (file)
@@ -121,7 +121,7 @@ void GridIn<dim>::read_ucd (istream &in)
              };
        }
       else
-       if ((cell_type == "line") && (dim == 2))
+       if ((cell_type == "line") && ((dim == 2) || (dim == 3)))
                                           // boundary info
          {
            subcelldata.boundary_lines.push_back (CellData<1>());
@@ -137,20 +137,51 @@ void GridIn<dim>::read_ucd (istream &in)
                                                 // vertex with this index exists
                subcelldata.boundary_lines.back().vertices[i]
                  = vertex_indices[subcelldata.boundary_lines.back().vertices[i]];
-           else 
-             {
-                                                // no such vertex index
-               AssertThrow (false,
-                            ExcInvalidVertexIndex(cell,
-                                                  subcelldata.boundary_lines.back().vertices[i]));
-               subcelldata.boundary_lines.back().vertices[i] = -1;
-             };
+             else 
+               {
+                                                  // no such vertex index
+                 AssertThrow (false,
+                              ExcInvalidVertexIndex(cell,
+                                                    subcelldata.boundary_lines.back().vertices[i]));
+                 subcelldata.boundary_lines.back().vertices[i] = -1;
+               };
          }
        else
-                                          // cannot read this
-         AssertThrow (false, ExcUnknownIdentifier(cell_type));
+         if ((cell_type == "quad") && (dim == 3))
+                                            // boundary info
+           {
+             subcelldata.boundary_quads.push_back (CellData<2>());
+             in >> subcelldata.boundary_quads.back().vertices[0]
+                >> subcelldata.boundary_quads.back().vertices[1]
+                >> subcelldata.boundary_quads.back().vertices[2]
+                >> subcelldata.boundary_quads.back().vertices[3];
+             
+             subcelldata.boundary_quads.back().material_id = material_id;
+             
+                                              // transform from ucd to
+                                              // consecutive numbering
+             for (unsigned int i=0; i<4; ++i)
+               if (vertex_indices.find (subcelldata.boundary_quads.back().vertices[i]) !=
+                   vertex_indices.end())
+                                                  // vertex with this index exists
+                 subcelldata.boundary_quads.back().vertices[i]
+                   = vertex_indices[subcelldata.boundary_quads.back().vertices[i]];
+               else
+                 {
+                                                    // no such vertex index
+                   Assert (false,
+                           ExcInvalidVertexIndex(cell,
+                                                 subcelldata.boundary_quads.back().vertices[i]));
+                   subcelldata.boundary_quads.back().vertices[i] = -1;
+                 };
+             
+           }
+         else
+                                            // cannot read this
+           AssertThrow (false, ExcUnknownIdentifier(cell_type));
     };
 
+  
                                   // check that no forbidden arrays are used
   Assert (subcelldata.check_consistency(dim), ExcInternalError());
 
index 6ba3e6ad4e7959e178e8c5d182b3fcafefc98d67..fd4c96b52b5329f25cde500e2029c456444836d1 100644 (file)
@@ -1322,10 +1322,157 @@ void Triangulation<3>::create_triangulation (const vector<Point<3> >    &v,
                                   // now set boundary indicators
                                   // where given
                                   //
-                                  // not yet implemented
-  AssertThrow ((subcelldata.boundary_lines.size() == 0) &&
-              (subcelldata.boundary_quads.size() == 0),
-              ExcNotImplemented());
+                                  // first do so for lines
+  vector<CellData<1> >::const_iterator boundary_line
+    = subcelldata.boundary_lines.begin();
+  vector<CellData<1> >::const_iterator end_boundary_line
+    = subcelldata.boundary_lines.end();
+  for (; boundary_line!=end_boundary_line; ++boundary_line)
+    {
+      line_iterator line;
+      pair <int, int> line_vertices(make_pair(boundary_line->vertices[0],
+                                             boundary_line->vertices[1]));
+      if (needed_lines.find(line_vertices) != needed_lines.end())
+                                        // line found in this
+                                        // direction
+       line = needed_lines[line_vertices];
+                 
+      else
+       {
+                                          // look wether it exists in
+                                          // reverse direction
+         swap (line_vertices.first, line_vertices.second);
+         if (needed_lines.find(line_vertices) != needed_lines.end())
+           line = needed_lines[line_vertices];
+         else
+           {
+                                              // line does not exist
+             AssertThrow (false, ExcLineInexistant(line_vertices.first,
+                                                   line_vertices.second));
+             line = end_line();
+           };
+       };
+                                      // Assert that only exterior
+                                      // lines are given a boundary
+                                      // indicator
+      AssertThrow (line->boundary_indicator() == 0,
+                  ExcInteriorLineCantBeBoundary());
+                   
+      line -> set_boundary_indicator (boundary_line->material_id);
+    };       
+
+
+                                  // now go on with boundary faces
+  vector<CellData<2> >::const_iterator boundary_quad
+    = subcelldata.boundary_quads.begin();
+  vector<CellData<2> >::const_iterator end_boundary_quad
+    = subcelldata.boundary_quads.end();
+  for (; boundary_quad!=end_boundary_quad; ++boundary_quad)
+    {
+      quad_iterator quad;
+      line_iterator line[4];
+      vector <int> quad_vertices(4);
+                                      // first find the lines that
+                                      // are made up of the given
+                                      // vertices, then build up a
+                                      // quad from these lines
+                                      // finally use the find
+                                      // function of the map template
+                                      // to find the quad
+      pair <int, int> line_vertices[4]
+       = { make_pair (boundary_quad->vertices[0], boundary_quad->vertices[1]),
+           make_pair (boundary_quad->vertices[1], boundary_quad->vertices[2]),
+           make_pair (boundary_quad->vertices[3], boundary_quad->vertices[2]),
+           make_pair (boundary_quad->vertices[0], boundary_quad->vertices[3]) };
+       
+      for (unsigned int i=0; i<4; ++i)
+       {
+                                          // check whether line
+                                          // already exists
+         if (needed_lines.find(line_vertices[i]) != needed_lines.end())
+           line[i] = needed_lines[line_vertices[i]];
+         else
+                                            // look wether it exists
+                                            // in reverse direction
+         {
+           swap (line_vertices[i].first, line_vertices[i].second);
+           if (needed_lines.find(line_vertices[i]) != needed_lines.end())
+             line[i] = needed_lines[line_vertices[i]];
+           else
+             {
+                                                // line does not exist
+               AssertThrow (false, ExcLineInexistant(line_vertices[i].first,
+                                                     line_vertices[i].second));
+               line[i] = end_line();
+             };
+         };
+       };  
+      
+                                      // Set up 2 quads that are
+                                      // built up fromt the lines for
+                                      // reasons of comparison to
+                                      // needed_quads.  The second
+                                      // quad is the reversed version
+                                      // of the first quad in order
+                                      // find the quad regardless of
+                                      // its orientation.  This is
+                                      // introduced for convenience
+                                      // and because boundary quad
+                                      // orientation does not carry
+                                      // any information.
+      Quad quad_compare_1(line[0]->index(), line[1]->index(), line[2]->index(), line[3]->index());
+      Quad quad_compare_2(line[3]->index(), line[2]->index(), line[1]->index(), line[0]->index());      
+      
+                                      // try to find the quad with
+                                      // lines situated as
+                                      // constructed above.  if it
+                                      // could not be found, rotate
+                                      // the boundary lines 3 times
+                                      // until it is found or it does
+                                      // not exist.
+      unsigned int n_rotations=0;
+      bool not_found_quad_1;
+      while ( (not_found_quad_1=(needed_quads.find(quad_compare_1) == needed_quads.end())) && 
+             (                  needed_quads.find(quad_compare_2) == needed_quads.end()) &&
+             (n_rotations<4))
+       {
+         rotate(line, line+1, line+4);
+                                          // update the quads with
+                                          // rotated lines
+         for (unsigned int i=0; i<4; ++i)
+           {
+             quad_compare_1.set_line(i,   line[i]->index());
+             quad_compare_2.set_line(3-i, line[i]->index());
+           };
+             
+         ++n_rotations;
+       };  
+      if (n_rotations==4)
+       {
+                               // quad does not exist
+         AssertThrow (false, ExcQuadInexistant(line[0]->index(), line[1]->index(),
+                                               line[2]->index(), line[3]->index()));
+         quad = end_quad();
+       }
+                                      // exception not thrown,
+                                      // therefore assign the quad
+                                      // appropriately
+      if (not_found_quad_1)
+       quad = needed_quads[quad_compare_2];
+      else
+       quad = needed_quads[quad_compare_1];
+
+                                      // check whether this face is
+                                      // really an exterior one
+      AssertThrow(quad->boundary_indicator()==0,
+                 ExcInteriorQuadCantBeBoundary());
+      quad->set_boundary_indicator (boundary_quad->material_id); 
+    };
+                                                                                      
 
 
                                   /////////////////////////////////////////
index f50c45014db32017ee55118d71dc99d46bb43276..15ad0795c2c4aaeecc9ba68493ae62df28d0de7e 100644 (file)
@@ -469,6 +469,24 @@ documentation, etc</a>.
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p>
+       Extended: The <code class="class">Triangulation</code>
+       class can handle boundary information in 3d as well
+       (i.e. lines and quads in 3d with special material IDs).
+       <br>
+       (<a href="mailto://ms@biomech.tu-graz.ac.at">Michael 
+        Stadler</a> 2000/10/11)
+       </p>       
+
+  <li> <p>
+       Extended: The <code class="class">GridIn</code>
+       class can now read 3D UCD data, including boundary information
+       (i.e. lines and quads in 3d with special material IDs).
+       <br>
+       (<a href="mailto://ms@biomech.tu-graz.ac.at">Michael
+        Stadler</a> 2000/10/11)
+       </p>       
+
   <li> <p>
        Extended: The <code class="member">GridIn::delete_unused_vertices</code>
        function now eliminates vertices from the input that are not

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.