]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
improved structure for cutoff functions
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 8 Feb 2002 16:21:13 +0000 (16:21 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 8 Feb 2002 16:21:13 +0000 (16:21 +0000)
git-svn-id: https://svn.dealii.org/trunk@5482 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function_lib.h
deal.II/base/source/function_lib_cutoff.cc

index 06345b2564e1ee635d5637bd32aa38126769b328..81e77418b9857c66477c8abf8c149ac1aded973d 100644 (file)
@@ -785,6 +785,71 @@ namespace Functions
   };
 
 
+/**
+ * Base function for cut-off function. This class stores the center
+ * and the radius of the supporting ball of a cut-off function. It
+ * also stores the number of the non-zero component, if the function
+ * is vector-valued.
+ *
+ * @author Guido Kanschat, 2002
+ */
+  template <int dim>
+  class CutOffFunctionBase : public Function<dim>
+  {
+    public:
+                                      /**
+                                       * Constructor. Arguments are the
+                                       * center of the ball and its
+                                       * radius.
+                                       *
+                                       * If an argument @p{select} is
+                                       * given and not -1, the
+                                       * cut-off function will be
+                                       * non-zero for this component
+                                       * only.
+                                       */
+      CutOffFunctionBase (const double radius = 1.,
+                         Point<dim> = Point<dim>(),
+                         const unsigned int n_components = 1,
+                         const unsigned int select = no_component);
+      
+                                      /**
+                                       * Move the center of the ball
+                                       * to new point @p{p}.
+                                       */
+      void new_center (const Point<dim>& p);
+      
+                                      /**
+                                       * Set the radius of the ball to @p{r}.
+                                       */
+      void new_radius (const double r);
+
+    protected:
+                                      /**
+                                       * Center of the integration ball.
+                                       */
+      const Point<dim> center;
+
+                                      /**
+                                       * Radius of the ball.
+                                       */
+      const double radius;
+
+                                      /**
+                                       * Component selected. If
+                                       * @p{no_component}, the function is
+                                       * the same in all components.
+                                       */
+      const unsigned int selected;
+                                      /**
+                                       * Value for no selected component.
+                                       */
+      static const unsigned int no_component = static_cast<unsigned int>(-1);
+
+  };
+  
+  
+  
 /**
  * Cut-off function in L-infinity for an arbitrary ball.  This
  * function is the characteristic function of a ball around @p{center}
@@ -794,7 +859,7 @@ namespace Functions
  * @author Guido Kanschat, 2001, 2002
  */
   template<int dim>
-  class CutOffFunctionLinfty : public Function<dim>
+  class CutOffFunctionLinfty : public CutOffFunctionBase<dim>
   {
     public:
                                       /**
@@ -831,28 +896,6 @@ namespace Functions
                                        */
       virtual void vector_value_list (const typename std::vector<Point<dim> > &points,
                                      std::vector<Vector<double> >           &values) const;
-
-    private:
-                                      /**
-                                       * Center of the integration ball.
-                                       */
-      const Point<dim> center;
-
-                                      /**
-                                       * Radius of the ball.
-                                       */
-      const double radius;
-
-                                      /**
-                                       * Component selected. If
-                                       * @p{no_component}, the function is
-                                       * the same in all components.
-                                       */
-      const unsigned int selected;
-                                      /**
-                                       * Value for no selected component.
-                                       */
-      static const unsigned int no_component = static_cast<unsigned int>(-1);
   };
   
   
@@ -865,7 +908,7 @@ namespace Functions
  * @author Guido Kanschat, 2001, 2002
  */
   template<int dim>
-  class CutOffFunctionW1 : public Function<dim>
+  class CutOffFunctionW1 : public CutOffFunctionBase<dim>
   {
     public:
                                       /**
@@ -902,29 +945,6 @@ namespace Functions
                                        */
       virtual void vector_value_list (const typename std::vector<Point<dim> > &points,
                                      std::vector<Vector<double> >           &values) const;
-
-    private:
-                                      /**
-                                       * Center of the integration ball.
-                                       */
-      const Point<dim> center;
-
-                                      /**
-                                       * Radius of the ball.
-                                       */
-      const double radius;
-
-                                      /**
-                                       * Component selected. If
-                                       * @p{no_component}, the
-                                       * function is the same in all
-                                       * components.
-                                       */
-      const unsigned int selected;
-                                      /**
-                                       * Value for no selected component.
-                                       */
-      static const unsigned int no_component = static_cast<unsigned int>(-1);
   };
   
   
@@ -938,7 +958,7 @@ namespace Functions
  * @author Guido Kanschat, 2001, 2002
  */
   template<int dim>
-  class CutOffFunctionCinfty : public Function<dim>
+  class CutOffFunctionCinfty : public CutOffFunctionBase<dim>
   {
     public:
                                       /**
@@ -981,32 +1001,7 @@ namespace Functions
                                        */
       virtual Tensor<1,dim> gradient (const Point<dim>   &p,
                                      const unsigned int  component = 0) const;
-      
-    private:
-                                      /**
-                                       * Center of the integration ball.
-                                       */
-      const Point<dim> center;
-
-                                      /**
-                                       * Radius of the ball.
-                                       */
-      const double radius;
-
-                                      /**
-                                       * Component selected. If
-                                       * @p{no_component}, the function is
-                                       * the same in all components.
-                                       */
-      const unsigned int selected;
-
-                                      /**
-                                       * Value for no selected component.
-                                       */
-      static const unsigned int no_component = static_cast<unsigned int>(-1);      
   };
-  
-};
-
+}
 
 #endif
index 3270004be88390a56c44de5ede668efd0d0a1e87..7c04aa70250c585f78ff12a107523ba1d826c0d5 100644 (file)
@@ -39,12 +39,14 @@ namespace Functions
 {
 
   using namespace std;
+
+
   
   template<int dim>
-  CutOffFunctionLinfty<dim>::CutOffFunctionLinfty (const double r,
-                                                  const Point<dim> p,
-                                                  const unsigned int n_components,
-                                                  const unsigned int select)
+  CutOffFunctionBase<dim>::CutOffFunctionBase (const double r,
+                                              const Point<dim> p,
+                                              const unsigned int n_components,
+                                              unsigned int select)
                  :
                  Function<dim> (n_components),
     center(p),
@@ -53,6 +55,33 @@ namespace Functions
   {}
 
 
+  template<int dim>
+  void
+  CutOffFunctionBase<dim>::new_center (const Point<dim>& p)
+  {
+    center = p;
+  }
+
+
+  template<int dim>
+  void
+  CutOffFunctionBase<dim>::new_radius (const double r)
+  {
+    radius = r;
+  }
+
+//////////////////////////////////////////////////////////////////////
+  
+  template<int dim>
+  CutOffFunctionLinfty<dim>::CutOffFunctionLinfty (const double r,
+                                                  const Point<dim> p,
+                                                  const unsigned int n_components,
+                                                  unsigned int select)
+                 :
+                 CutOffFunctionBase<dim> (r, p, n_components, select)
+  {}
+
+
   template<int dim>
   double
   CutOffFunctionLinfty<dim>::value (const Point<dim>   &p,
@@ -113,10 +142,7 @@ namespace Functions
                                           const unsigned int n_components,
                                           const unsigned int select)
                  :
-                 Function<dim> (n_components),
-                  center(p),
-                  radius(r),
-    selected(select)
+                 CutOffFunctionBase<dim> (r, p, n_components, select)
   {}
 
 
@@ -185,10 +211,7 @@ namespace Functions
                                                   const unsigned int n_components,
                                                   const unsigned int select)
                  :
-                 Function<dim> (n_components),
-                  center(p),
-                  radius(r),
-    selected(select)
+                 CutOffFunctionBase<dim> (r, p, n_components, select)
   {}
 
 

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.