]> https://gitweb.dealii.org/ - dealii.git/commitdiff
newline bug in grid_in_abaqus fixed
authorReza Rastak <rastak@stanford.edu>
Tue, 30 Apr 2019 22:03:56 +0000 (15:03 -0700)
committerReza Rastak <rastak@stanford.edu>
Tue, 30 Apr 2019 22:03:56 +0000 (15:03 -0700)
source/grid/grid_in.cc
tests/grid/grid_in_abaqus_01.cc
tests/grid/grid_in_abaqus_01.output

index addc9a384cb5edd8a344b3e189e52edbf6a3caf7..c7f0ac1486c6d297a8fe382f18bf59dd0486cfc2 100644 (file)
@@ -3563,19 +3563,18 @@ namespace
 
     AssertThrow(input_stream, ExcIO());
     std::string line;
-    std::getline(input_stream, line);
 
-    while (!input_stream.fail() && !input_stream.eof())
+    while (std::getline(input_stream, line))
       {
+      cont:
         std::transform(line.begin(), line.end(), line.begin(), ::toupper);
 
         if (line.compare("*HEADING") == 0 || line.compare(0, 2, "**") == 0 ||
             line.compare(0, 5, "*PART") == 0)
           {
             // Skip header and comments
-            while (!input_stream.fail() && !input_stream.eof())
+            while (std::getline(input_stream, line))
               {
-                std::getline(input_stream, line);
                 if (line[0] == '*')
                   goto cont; // My eyes, they burn!
               }
@@ -3589,9 +3588,8 @@ namespace
 
             // Contains lines in the form:
             // Index, x, y, z
-            while (!input_stream.fail() && !input_stream.eof())
+            while (std::getline(input_stream, line))
               {
-                std::getline(input_stream, line);
                 if (line[0] == '*')
                   goto cont;
 
@@ -3631,8 +3629,7 @@ namespace
             }
 
             // Read ELEMENT definition
-            std::getline(input_stream, line);
-            while (!input_stream.fail() && !input_stream.eof())
+            while (std::getline(input_stream, line))
               {
                 if (line[0] == '*')
                   goto cont;
@@ -3652,8 +3649,6 @@ namespace
                 // Overwrite cell index from file by material
                 cell[0] = static_cast<double>(material);
                 cell_list.push_back(cell);
-
-                std::getline(input_stream, line);
               }
           }
         else if (line.compare(0, 8, "*SURFACE") == 0)
@@ -3683,8 +3678,7 @@ namespace
             // definition of each "set" of faces that comprise the surface
             // These are either marked by an "S" or "E" in 3d or 2d
             // respectively.
-            std::getline(input_stream, line);
-            while (!input_stream.fail() && !input_stream.eof())
+            while (std::getline(input_stream, line))
               {
                 if (line[0] == '*')
                   goto cont;
@@ -3736,8 +3730,6 @@ namespace
 
                     face_list.push_back(quad_node_list);
                   }
-
-                std::getline(input_stream, line);
               }
           }
         else if (line.compare(0, 6, "*ELSET") == 0)
@@ -3819,8 +3811,7 @@ namespace
             else
               {
                 // Option (2)
-                std::getline(input_stream, line);
-                while (!input_stream.fail() && !input_stream.eof())
+                while (std::getline(input_stream, line))
                   {
                     if (line[0] == '*')
                       break;
@@ -3841,8 +3832,6 @@ namespace
 
                         elements.push_back(elid);
                       }
-
-                    std::getline(input_stream, line);
                   }
 
                 elsets_list[elset_name] = elements;
@@ -3853,9 +3842,8 @@ namespace
         else if (line.compare(0, 5, "*NSET") == 0)
           {
             // Skip nodesets; we have no use for them
-            while (!input_stream.fail() && !input_stream.eof())
+            while (std::getline(input_stream, line))
               {
-                std::getline(input_stream, line);
                 if (line[0] == '*')
                   goto cont;
               }
@@ -3891,11 +3879,6 @@ namespace
               }
           }
         // Note: All other lines / entries are ignored
-
-        std::getline(input_stream, line);
-
-      cont:
-        (void)0;
       }
   }
 
index ece4295d29855d3b69fb3b05abbaf82837542a2e..6a005f2bb839533094e7c335361b7b4b894e0396 100644 (file)
@@ -66,6 +66,8 @@ main()
       //      // Failing test
       deallog << "2d_test_abaqus.inp" << std::endl;
       abaqus_grid<2>(SOURCE_DIR "/grids/abaqus/2d/2d_test_abaqus.inp");
+      deallog << "2d_short_handwritten.inp" << std::endl;
+      abaqus_grid<2>(SOURCE_DIR "/grids/abaqus/2d/2d_short_handwritten.inp");
 
       deallog << "3d_test_cube_1.inp" << std::endl;
       abaqus_grid<3>(SOURCE_DIR "/grids/abaqus/3d/3d_test_cube_1.inp");
index afd1b2fe78e9e831d162860c3058ad4bc984023f..07655f512ad80027ad1fd2a14455fa8471fef965 100644 (file)
@@ -8,6 +8,9 @@ DEAL::  hash=19
 DEAL::2d_test_abaqus.inp
 DEAL::  75 active cells
 DEAL::  hash=7783
+DEAL::2d_short_handwritten.inp
+DEAL::  1 active cells
+DEAL::  hash=0
 DEAL::3d_test_cube_1.inp
 DEAL::  1 active cells
 DEAL::  hash=0

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.