]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix sphere obstacle function
authorJoerg Frohne <frohne@mathematik.uni-siegen.de>
Sat, 28 Sep 2013 23:20:10 +0000 (23:20 +0000)
committerJoerg Frohne <frohne@mathematik.uni-siegen.de>
Sat, 28 Sep 2013 23:20:10 +0000 (23:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@31009 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 04cdd6195b21a409e98a105b64f4573bccc5878b..b58953756ac9673b05dcf521afd60d913074965e 100644 (file)
@@ -385,23 +385,28 @@ namespace Step42
 
 
     template <int dim>
-    double
-    SphereObstacle<dim>::value (const Point<dim> &p,
-                                const unsigned int component) const
-    {
-      if (component == 0)
-        return p(0);
-      else if (component == 1)
-        return p(1);
-      else if (component == 2)
-        return (-std::sqrt(0.36
-                           - (p(0) - 0.5) * (p(0) - 0.5)
-                           - (p(1) - 0.5) * (p(1) - 0.5))
-                + z_surface + 0.59);
+      double
+      SphereObstacle<dim>::value (
+          const Point<dim> &p, const unsigned int component) const
+      {
+        if (component == 0)
+          return p(0);
+        else if (component == 1)
+          return p(1);
+        else if (component == 2)
+          {
+            double return_value = 1000.0;
+            if ((p(0) - 0.5) * (p(0) - 0.5) + (p(1) - 0.5) * (p(1) - 0.5)
+                < 0.36)
+              return_value = (-std::sqrt(
+                  0.36 - (p(0) - 0.5) * (p(0) - 0.5)
+                      - (p(1) - 0.5) * (p(1) - 0.5)) + z_surface + 0.59);
+            return return_value;
+          }
 
-      Assert (false, ExcNotImplemented());
-      return 1e9; // an unreasonable value; ignored in debug mode because of the preceding Assert
-    }
+        Assert(false, ExcNotImplemented());
+        return 1e9; // an unreasonable value; ignored in debug mode because of the preceding Assert
+      }
 
 
     template <int dim>

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.