From c7c57e00c8b72be38b95383232a9451ddb35852d Mon Sep 17 00:00:00 2001 From: frohne Date: Wed, 13 Feb 2013 07:00:40 +0000 Subject: [PATCH] improve of Input class git-svn-id: https://svn.dealii.org/trunk@28357 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-42/step-42.cc | 139 +++++++--------------------- 1 file changed, 31 insertions(+), 108 deletions(-) diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index 8987076171..eb3057a17d 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -168,18 +168,18 @@ namespace Step42 mpi_communicator (MPI_COMM_WORLD), pcout (std::cout, (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)), - HV (NULL), - lx (0), - ly (0), + obstacle_data (0), + lx (1.0), // length of the cube in x direction + ly (1.0), // length of the cube in y direction + hx (0), + hy (0), nx (0), ny (0) {read_surface (name);} double hv(int i, int j); - void set_height(int i, int j,double val); - - double mikro_height(double x,double y, double z); + double mikro_height(double x,double y); void read_surface(const char* name); @@ -187,7 +187,7 @@ namespace Step42 const char* name; MPI_Comm mpi_communicator; ConditionalOStream pcout; - double* HV; + std::vector obstacle_data; double lx, ly; double hx, hy; int nx, ny; @@ -198,24 +198,13 @@ namespace Step42 { assert(i>=0 && i=0 && j25200) +// std::cout<< i << ", " << j << ", " << nx*(ny-1-j)+i < - void Input::set_height(int i, int j, double val) - { - if (i>=nx || j>=ny) - { - std::cout << "invalid:" << i << " " << j << " " << nx*j+i << std::endl; - return; - } - assert(i>=0 && i=0 && j - double Input::mikro_height(double x,double y, double z) + double Input::mikro_height(double x,double y) { int ix = (int)(x/hx); int iy = (int)(y/hy); @@ -287,75 +276,28 @@ namespace Step42 { int SZ = 100000; FILE* fp = fopen (name, "r"); - char* zeile = new char[SZ]; char* hlp_str = new char[SZ]; double hlp; - int POS; - - fgets (zeile, SZ, fp); - POS = strcspn (zeile, "="); - for (int i=0; i<=POS; i++) - zeile[i] = ' '; - sscanf (zeile, "%d", &nx); - - fgets (zeile,SZ,fp); - POS = strcspn (zeile, "="); - for (int i=0; i<=POS; i++) - zeile[i] = ' '; - sscanf (zeile, "%d", &ny); - - fgets (zeile, SZ, fp); - POS = strcspn (zeile, "="); - for (int i=0; i<=POS; i++) - zeile[i] = ' '; - sscanf (zeile, "%lf", &lx); - - fgets (zeile, SZ, fp); - POS = strcspn(zeile,"="); - for (int i=0; i<=POS; i++) - zeile[i] = ' '; - sscanf(zeile,"%lf",&ly); - - hx = lx/(nx - 1); - hy = ly/(ny - 1); - - pcout<< "Resolution of the scanned obstacle picture: " << nx << " x " << ny < max_hlp) - max_hlp=hlp; - if (hlp < min_hlp) - min_hlp=hlp; + fscanf (fp, "%s", hlp_str); + fscanf (fp, "%d", &nx); + fscanf (fp, "%d", &ny); - set_height (k, ny - 1 - j, hlp); - int pos = strcspn (zeile, ","); - if (!strpbrk (zeile, ",")) - { - reached = 1; - continue; - } + assert(nx>0 && ny>0); - for (int i=0; i<=pos; i++) - { - zeile[i] = ' '; - } - } - j++; + for (int k=0; k @@ -603,28 +545,7 @@ namespace Step42 return_value = p(1); if (component == 2) { - // Hindernis Dortmund - double x1 = p(0); - double x2 = p(1); - if (((x2-0.5)*(x2-0.5)+(x1-0.5)*(x1-0.5)<=0.3*0.3)&&((x2-0.5)*(x2-0.5)+(x1-1.0)*(x1-1.0)>=0.4*0.4)&&((x2-0.5)*(x2-0.5)+x1*x1>=0.4*0.4)) - return_value = 0.999; - else - return_value = 1e+10; - - // Hindernis Werkzeug TKSE -// return_value = 1.999 - input_obstacle_copy->mikro_height (p(0), p(1), p(2)); -// std::cout<< "Obstacle value: " << return_value -// << " p(0) = " << p(0) -// << " p(1) = " << p(1) -// <mikro_height (p(0), p(1)); } return return_value; } @@ -1515,7 +1436,9 @@ namespace Step42 void PlasticityContactProblem::run () { pcout << "Read the obstacle from a file." << std::endl; - input_obstacle.reset (new Input("obstacle_file.dat")); + input_obstacle.reset (new Input("li_kraft.pbm")); +// input_obstacle.reset (new Input("li_kraft_697x800.pbm")); + pcout << "Ostacle is available now." << std::endl; Timer t; -- 2.39.5