]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
step-42: take over patch for obstacle reading
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 18 Apr 2013 19:24:10 +0000 (19:24 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 18 Apr 2013 19:24:10 +0000 (19:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@29335 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-42/step-42.cc

index c85e1d08d7e5d312bf1e25ee8e6c66dc4af7c1f3..de28338a596b22cc9ea4b8555460027abf640071 100644 (file)
@@ -214,26 +214,19 @@ namespace Step42
   template <int dim>
   void Input<dim>::read_obstacle (const char* name)
   {
-    int SZ = 100000;
-    FILE* fp = fopen (name, "r");
-    char* hlp_str = new char[SZ];
-    double hlp;
-
-    fscanf (fp, "%s", hlp_str);
-    fscanf (fp, "%d", &nx);
-    fscanf (fp, "%d", &ny);
+    std::ifstream f(name);
 
+    std::string temp;
+    f >> temp >> nx >> ny;
     assert(nx>0 && ny>0);
 
     for (int k=0; k<nx*ny; k++)
       {
-        fscanf (fp, "%lf", &hlp);
-        obstacle_data.push_back (hlp);
+       double val;
+       f >> val;
+       obstacle_data.push_back(val);
       }
 
-    fclose (fp);
-    delete[] hlp_str;
-
     hx = 1.0/(nx - 1);
     hy = 1.0/(ny - 1);
 
@@ -491,7 +484,8 @@ namespace Step42
       Obstacle (std_cxx1x::shared_ptr<Input<dim> > const &_input, bool _use_read_obstacle) :
         Function<dim>(dim),
         input_obstacle_copy(_input),
-        use_read_obstacle(_use_read_obstacle) {};
+        use_read_obstacle(_use_read_obstacle)
+         {}
 
       virtual double value (const Point<dim>   &p,
                             const unsigned int  component = 0) const;

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.