From: frohne Date: Mon, 11 Feb 2013 17:35:29 +0000 (+0000) Subject: reorganize the runtime output for the shell X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c07c90cec314101657dca5aa3b5daa906e8abedb;p=dealii-svn.git reorganize the runtime output for the shell git-svn-id: https://svn.dealii.org/trunk@28312 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index 15adf63b26..40fd40bc28 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -194,162 +194,159 @@ namespace Step42 }; template - double Input::hv(int i, int j) { - return HV[nx*j+i]; // i indiziert x-werte, j indiziert y-werte + double Input::hv(int i, int j) + { + return HV[nx*j+i]; // i indiziert x-werte, j indiziert y-werte } template - double& Input::set_height(int i, int j) { - return HV[nx*j+i]; // i indiziert x-werte, j indiziert y-werte + double& Input::set_height(int i, int j) + { + return HV[nx*j+i]; // i indiziert x-werte, j indiziert y-werte } template - double Input::mikro_height(double x,double y, double z) { + double Input::mikro_height(double x,double y, double z) + { int ix = (int)(x/hx); int iy = (int)(y/hy); - if (ix<0) { - ix = 0; - // cerr << "hm\n"; - } - if (iy<0) { - iy = 0; - // cerr << "hm\n"; - } + if (ix<0) + ix = 0; - if (ix>=nx-1) { - ix = nx-2; - } - if (iy>=ny-1) { - iy = ny-2; - } + if (iy<0) + iy = 0; - double val = 0.; - { - FullMatrix H(4,4); - Vector X(4); - Vector b(4); - - double xx = 0.; - double yy = 0.; - - xx = (ix )*hx; - yy = (iy )*hy; - H(0,0) = xx; - H(0,1) = yy; - H(0,2) = xx*yy; - H(0,3) = 1.; - b(0) = hv(ix ,iy ); - - xx = (ix+1)*hx; - yy = (iy )*hy; - H(1,0) = xx; - H(1,1) = yy; - H(1,2) = xx*yy; - H(1,3) = 1.; - b(1) = hv(ix+1,iy ); - - xx = (ix+1)*hx; - yy = (iy+1)*hy; - H(2,0) = xx; - H(2,1) = yy; - H(2,2) = xx*yy; - H(2,3) = 1.; - b(2) = hv(ix+1,iy+1); - - xx = (ix )*hx; - yy = (iy+1)*hy; - H(3,0) = xx; - H(3,1) = yy; - H(3,2) = xx*yy; - H(3,3) = 1.; - b(3) = hv(ix ,iy+1); - - H.gauss_jordan(); - H.vmult(X,b); - - val = X(0)*x + X(1)*y + X(2)*x*y + X(3); - } + if (ix>=nx-1) + ix = nx-2; - return val; - } + if (iy>=ny-1) + iy = ny-2; - template - void Input::read_surface(const char* name) { - 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); - - pcout<< nx << " " << ny << " " << lx << " " << ly << " " < H(4,4); + Vector X(4); + Vector b(4); + + double xx = 0.0; + double yy = 0.0; + + xx = ix*hx; + yy = iy*hy; + H(0,0) = xx; + H(0,1) = yy; + H(0,2) = xx*yy; + H(0,3) = 1.0; + b(0) = hv (ix, iy); + + xx = (ix + 1)*hx; + yy = iy*hy; + H(1,0) = xx; + H(1,1) = yy; + H(1,2) = xx*yy; + H(1,3) = 1.0; + b(1) = hv (ix + 1, iy); + + xx = (ix + 1)*hx; + yy = (iy + 1)*hy; + H(2,0) = xx; + H(2,1) = yy; + H(2,2) = xx*yy; + H(2,3) = 1.0; + b(2) = hv (ix + 1, iy + 1); + + xx = ix*hx; + yy = (iy + 1)*hy; + H(3,0) = xx; + H(3,1) = yy; + H(3,2) = xx*yy; + H(3,3) = 1.0; + b(3) = hv (ix, iy + 1); + + H.gauss_jordan (); + H.vmult (X, b); + + val = X(0)*x + X(1)*y + X(2)*x*y + X(3); + } - if (HV) delete[] HV; - HV = new double [nx*ny]; + return val; + } - int j=0; - double max_hlp=0; - double min_hlp=1e+10; - while (fgets(zeile,SZ,fp)) { - int reached = 0; - for (int k=0;!reached;k++) { - sscanf(zeile,"%lf",&hlp); + template + void Input::read_surface(const char* name) + { + 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; + if (hlp > max_hlp) + max_hlp=hlp; + if (hlp < min_hlp) + min_hlp=hlp; - set_height(k,ny-1-j) = hlp; - int pos = strcspn(zeile,","); - if (!strpbrk(zeile,",")) { - reached = 1; - continue; + set_height (k, ny - 1 - j) = hlp; + int pos = strcspn (zeile, ","); + if (!strpbrk (zeile, ",")) + { + reached = 1; + continue; } - for (int i=0;i<=pos;i++) { - zeile[i] = ' '; + + for (int i=0; i<=pos; i++) + { + zeile[i] = ' '; } } - j++; + j++; } - pcout<< "/** highest point: " << max_hlp < @@ -723,13 +720,13 @@ namespace Step42 constraints_hanging_nodes); constraints_hanging_nodes.close (); - pcout << "Number of active cells: " + pcout << " Number of active cells: " << triangulation.n_active_cells() << std::endl - << "Total number of cells: " + << " Total number of cells: " << triangulation.n_cells() << std::endl - << "Number of degrees of freedom: " + << " Number of degrees of freedom: " << dof_handler.n_dofs () << std::endl; @@ -1003,8 +1000,8 @@ namespace Step42 unsigned int sum_elast_points = Utilities::MPI::sum(elast_points, mpi_communicator); unsigned int sum_plast_points = Utilities::MPI::sum(plast_points, mpi_communicator); - pcout<< "Elast-Points = " << sum_elast_points < @@ -1130,7 +1127,7 @@ namespace Step42 unsigned int sum_contact_constraints = Utilities::MPI::sum(active_set_locally_owned.n_elements (), mpi_communicator); - pcout << "Number of Contact-Constaints: " << sum_contact_constraints < void PlasticityContactProblem::solve () { - pcout << "Solving ..." << std::endl; Timer t; TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton); @@ -1246,10 +1242,10 @@ namespace Step42 AdditionalData(30, true)); solver.solve(system_matrix_newton, distributed_solution, system_rhs_newton, preconditioner_u); - pcout << "Initial error: " << solver_control.initial_value() < " << solver_control.last_value() + << " in " << solver_control.last_step() + << " FGMRES iterations." << std::endl; MPI_Barrier (mpi_communicator); @@ -1287,14 +1283,14 @@ namespace Step42 additional_data.smoother_sweeps = 2; additional_data.aggregation_threshold = 1e-2; - IndexSet active_set_old (active_set); + IndexSet active_set_old (active_set); unsigned int j = 0; unsigned int number_assemble_system = 0; for (; j<=100; j++) { pcout<< " " < vertex_touched (triangulation.n_vertices(), false); @@ -1513,17 +1499,17 @@ namespace Step42 template void PlasticityContactProblem::run () { - pcout << "Solving problem in " << dim << " space dimensions." << std::endl; + pcout << "Read the obstacle from a file." << std::endl; + input_obstacle.reset (new Input("obstacle_file.dat")); + pcout << "Ostacle is available now." << std::endl; - Timer t; + Timer t; run_time.resize (8); - // Read in the obstacle data. - input_obstacle.reset (new Input("obstacle_file.dat")); - const unsigned int n_cycles = 6; for (unsigned int cycle=0; cycle