]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add coefficient class. Currently not used.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 10 Feb 2010 00:16:56 +0000 (00:16 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 10 Feb 2010 00:16:56 +0000 (00:16 +0000)
git-svn-id: https://svn.dealii.org/trunk@20532 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 93e2c348a93b9bceae98a647250f6cd6c80b51fc..e947b41acb452f6f961642db9f86e62fffacb32d 100644 (file)
@@ -110,6 +110,65 @@ class LaplaceProblem
 };
 
 
+
+                                 // @sect3{Nonconstant coefficients}
+
+                                // The implementation of nonconstant
+                                // coefficients is copied verbatim
+                                // from step-5:
+
+template <int dim>
+class Coefficient : public Function<dim>
+{
+  public:
+    Coefficient () : Function<dim>() {}
+
+    virtual double value (const Point<dim>   &p,
+                         const unsigned int  component = 0) const;
+
+    virtual void value_list (const std::vector<Point<dim> > &points,
+                            std::vector<double>            &values,
+                            const unsigned int              component = 0) const;
+};
+
+
+
+template <int dim>
+double Coefficient<dim>::value (const Point<dim> &p,
+                               const unsigned int) const
+{
+  if (p.square() < 0.5*0.5)
+    return 20;
+  else
+    return 1;
+}
+
+
+
+template <int dim>
+void Coefficient<dim>::value_list (const std::vector<Point<dim> > &points,
+                                  std::vector<double>            &values,
+                                  const unsigned int              component) const
+{
+  const unsigned int n_points = points.size();
+
+  Assert (values.size() == n_points,
+         ExcDimensionMismatch (values.size(), n_points));
+
+  Assert (component == 0,
+         ExcIndexRange (component, 0, 1));
+
+  for (unsigned int i=0; i<n_points; ++i)
+    {
+      if (points[i].square() < 0.5*0.5)
+       values[i] = 20;
+      else
+       values[i] = 1;
+    }
+}
+
+
+
 template <int dim>
 LaplaceProblem<dim>::LaplaceProblem (const unsigned int deg)
                :

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.