From 63b6ef8ccf8dfa62d196ce88734b9043b0135149 Mon Sep 17 00:00:00 2001 From: frohne Date: Mon, 1 Apr 2013 23:06:38 +0000 Subject: [PATCH] define a bool variable to decide to read in the obstacle or not git-svn-id: https://svn.dealii.org/trunk@29135 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-42/step-42.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/deal.II/examples/step-42/step-42.cc b/deal.II/examples/step-42/step-42.cc index cdd7085f13..fa58eae468 100644 --- a/deal.II/examples/step-42/step-42.cc +++ b/deal.II/examples/step-42/step-42.cc @@ -484,9 +484,10 @@ namespace Step42 class Obstacle : public Function { public: - Obstacle (std_cxx1x::shared_ptr > const &_input) : + Obstacle (std_cxx1x::shared_ptr > const &_input, bool _use_read_obstacle) : Function(dim), - input_obstacle_copy(_input) {}; + input_obstacle_copy(_input), + use_read_obstacle(_use_read_obstacle) {}; virtual double value (const Point &p, const unsigned int component = 0) const; @@ -496,6 +497,7 @@ namespace Step42 private: std_cxx1x::shared_ptr > const &input_obstacle_copy; + bool use_read_obstacle; }; template @@ -510,8 +512,10 @@ namespace Step42 return_value = p(1); if (component == 2) { - return_value = -std::sqrt (0.36 - (p(0)-0.5)*(p(0)-0.5) - (p(1)-0.5)*(p(1)-0.5)) + 1.59; - // return_value = 1.999 - input_obstacle_copy->obstacle_function (p(0), p(1)); + if (use_read_obstacle) + return_value = 1.999 - input_obstacle_copy->obstacle_function (p(0), p(1)); + else + return_value = -std::sqrt (0.36 - (p(0)-0.5)*(p(0)-0.5) - (p(1)-0.5)*(p(1)-0.5)) + 1.59; } return return_value; } @@ -565,6 +569,7 @@ namespace Step42 unsigned int n_refinements_global; unsigned int cycle; + bool use_read_obstacle; MPI_Comm mpi_communicator; @@ -1071,7 +1076,7 @@ namespace Step42 { computing_timer.enter_section("Update solution and constraints"); - const EquationData::Obstacle obstacle (input_obstacle); + const EquationData::Obstacle obstacle (input_obstacle, use_read_obstacle); std::vector vertex_touched (dof_handler.n_dofs (), false); typename DoFHandler::active_cell_iterator @@ -1526,9 +1531,13 @@ namespace Step42 template void PlasticityContactProblem::run () { - pcout << "Read the obstacle from a file." << std::endl; - input_obstacle.reset (new Input("obstacle_file.pbm")); - pcout << "Ostacle is available now." << std::endl; + use_read_obstacle = false; + if (use_read_obstacle) + { + pcout << "Read the obstacle from a file." << std::endl; + input_obstacle.reset (new Input("obstacle_file.pbm")); + pcout << "Ostacle is available now." << std::endl; + } const unsigned int n_cycles = 6; for (cycle=0; cycle