From 0825b35fbdf8b163fa4c4ea6c1b07e7b2db36a5a Mon Sep 17 00:00:00 2001 From: heister Date: Thu, 18 Apr 2013 19:24:10 +0000 Subject: [PATCH] step-42: take over patch for obstacle reading git-svn-id: https://svn.dealii.org/trunk@29335 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-42/step-42.cc | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index c85e1d08d7..de28338a59 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -214,26 +214,19 @@ namespace Step42 template void Input::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> 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 > const &_input, bool _use_read_obstacle) : Function(dim), input_obstacle_copy(_input), - use_read_obstacle(_use_read_obstacle) {}; + use_read_obstacle(_use_read_obstacle) + {} virtual double value (const Point &p, const unsigned int component = 0) const; -- 2.39.5