]> https://gitweb.dealii.org/ - dealii.git/commitdiff
splitting obstacle class into two classes
authorJoerg Frohne <frohne@mathematik.uni-siegen.de>
Thu, 26 Sep 2013 15:26:10 +0000 (15:26 +0000)
committerJoerg Frohne <frohne@mathematik.uni-siegen.de>
Thu, 26 Sep 2013 15:26:10 +0000 (15:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@30959 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 604346b30f56a8681a55ef5cbaf4f8914017e2e4..23550886df088c914f7f984338b78022ca6d67b7 100644 (file)
@@ -494,16 +494,61 @@ namespace Step42
     // a function (here a ball).
     // z_max_domain is the z value of the surface of the work piece
     template <int dim>
-    class Obstacle : public Function<dim>
+    class SphereObstacle : public Function<dim>
     {
     public:
-      Obstacle (const std_cxx1x::shared_ptr<Input<dim> > &input,
-                const bool use_read_obstacle,
+      SphereObstacle (const double z_max_domain)
+        :
+        Function<dim>(dim),
+        z_max_domain(z_max_domain)
+      {}
+
+      virtual
+      double value (const Point<dim> &p,
+                    const unsigned int component = 0) const;
+
+      virtual
+      void vector_value (const Point<dim> &p,
+                         Vector<double> &values) const;
+
+    private:
+      double z_max_domain;
+    };
+
+
+    template <int dim>
+    double
+    SphereObstacle<dim>::value (const Point<dim> &p,
+                          const unsigned int component) const
+    {
+      if (component == 0)
+        return p(0);
+      if (component == 1)
+        return p(1);
+
+      //component==2:
+      return -std::sqrt(0.36 - (p(0) - 0.5) * (p(0) - 0.5)
+          - (p(1) - 0.5) * (p(1) - 0.5)) + z_max_domain + 0.59;
+    }
+
+    template <int dim>
+    void
+    SphereObstacle<dim>::vector_value (const Point<dim> &p,
+                                 Vector<double> &values) const
+    {
+      for (unsigned int c = 0; c < this->n_components; ++c)
+        values(c) = SphereObstacle<dim>::value(p, c);
+    }
+
+    template <int dim>
+    class ChineseObstacle : public Function<dim>
+    {
+    public:
+      ChineseObstacle (const std_cxx1x::shared_ptr<Input<dim> > &input,
                 const double z_max_domain)
         :
         Function<dim>(dim),
         input_obstacle(input),
-        use_read_obstacle(use_read_obstacle),
         z_max_domain(z_max_domain)
       {}
 
@@ -517,14 +562,13 @@ namespace Step42
 
     private:
       const std_cxx1x::shared_ptr<Input<dim> > &input_obstacle;
-      bool use_read_obstacle;
       double z_max_domain;
     };
 
 
     template <int dim>
     double
-    Obstacle<dim>::value (const Point<dim> &p,
+    ChineseObstacle<dim>::value (const Point<dim> &p,
                           const unsigned int component) const
     {
       if (component == 0)
@@ -533,29 +577,20 @@ namespace Step42
         return p(1);
 
       //component==2:
-      if (use_read_obstacle)
-        {
-          if (p(0) >= 0.0 && p(0) <= 1.0 && p(1) >= 0.0 && p(1) <= 1.0)
-            return z_max_domain + 0.999
-                   - input_obstacle->get_value(p(0), p(1));
-          else
-            return 10000.0;
-        }
-      else
-        {
-          //sphere:
-          return -std::sqrt(0.36 - (p(0) - 0.5) * (p(0) - 0.5)
-                            - (p(1) - 0.5) * (p(1) - 0.5)) + z_max_domain + 0.59;
-        }
+        if (p(0) >= 0.0 && p(0) <= 1.0 && p(1) >= 0.0 && p(1) <= 1.0)
+          return z_max_domain + 0.999 - input_obstacle->get_value(p(0), p(1));
+        else
+        return 10000.0;
+
     }
 
     template <int dim>
     void
-    Obstacle<dim>::vector_value (const Point<dim> &p,
+    ChineseObstacle<dim>::vector_value (const Point<dim> &p,
                                  Vector<double> &values) const
     {
       for (unsigned int c = 0; c < this->n_components; ++c)
-        values(c) = Obstacle<dim>::value(p, c);
+        values(c) = ChineseObstacle<dim>::value(p, c);
     }
   }
 
@@ -1241,8 +1276,10 @@ namespace Step42
   void
   PlasticityContactProblem<dim>::update_solution_and_constraints ()
   {
-    const EquationData::Obstacle<dim> obstacle(input_obstacle,
-                                               (obstacle_filename != ""), (base_mesh == "box" ? 1.0 : 0.5));
+    const EquationData::SphereObstacle<dim> obstacle((base_mesh == "box" ? 1.0 : 0.5));
+
+//    const EquationData::ChineseObstacle<dim> obstacle(input_obstacle, (base_mesh == "box" ? 1.0 : 0.5));
+
     std::vector<bool> vertex_touched(dof_handler.n_dofs(), false);
 
     typename DoFHandler<dim>::active_cell_iterator cell =

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.