]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix Neumann part of 1d Kelly estimator
authorTimo Heister <timo.heister@gmail.com>
Fri, 22 Jan 2016 03:01:00 +0000 (22:01 -0500)
committerTimo Heister <timo.heister@gmail.com>
Fri, 22 Jan 2016 03:03:17 +0000 (22:03 -0500)
Neumann conditions were evaluated at the wrong point. Also adjust test
(and print coordinates to prove that it is correct now).

source/numerics/error_estimator_1d.cc
tests/codim_one/error_estimator_02.cc
tests/codim_one/error_estimator_02.output

index 675797954a623dce96af663df3e1066f6075a59d..0e6f97e861b1ac03f55bf6373b8f99329f0308ad 100644 (file)
@@ -394,7 +394,7 @@ estimate (const Mapping<1,spacedim>                  &mapping,
                 if (n_components==1)
                   {
                     const double
-                    v = neumann_bc.find(n)->second->value(cell->vertex(0));
+                    v = neumann_bc.find(n)->second->value(cell->vertex(n));
 
                     for (unsigned int s=0; s<n_solution_vectors; ++s)
                       grad_neighbor[s](0) = v;
@@ -402,7 +402,7 @@ estimate (const Mapping<1,spacedim>                  &mapping,
                 else
                   {
                     Vector<double> v(n_components);
-                    neumann_bc.find(n)->second->vector_value(cell->vertex(0), v);
+                    neumann_bc.find(n)->second->vector_value(cell->vertex(n), v);
 
                     for (unsigned int s=0; s<n_solution_vectors; ++s)
                       grad_neighbor[s] = v;
index e54befd8545256ee0742d0cd44f76c513c236024..79d4a457b969358b9e41c485e469e17f4120e3e8 100644 (file)
@@ -39,6 +39,7 @@
 #include <fstream>
 
 
+// function is x^2+2xy
 template<int dim>
 class MyFunction : public Function<dim>
 {
@@ -60,6 +61,33 @@ public:
 };
 
 
+// normal derivative of function above is 0 except for x=1, y=1 with n=(0,1,0)
+template<int dim>
+class MyNormalDerivative : public Function<dim>
+{
+public:
+  MyNormalDerivative () : Function<dim>(1) {}
+
+  virtual double value (const Point<dim>   &p,
+                        const unsigned int  component) const
+  {
+    double val = 0.0;
+    if (abs(p(1)-1.0)<1e-5)
+      val = 2.0;
+
+    deallog << "evaluate normal derivative at " << p << " with value " << val << std::endl;
+    return val;
+  }
+
+  virtual void   vector_value (const Point<dim>   &p,
+                               Vector<double>     &values) const
+  {
+    values(0) = value(p,0);
+    values(1) = value(p,1);
+  }
+};
+
+
 
 template <int dim>
 Quadrature<dim-1> &
@@ -122,8 +150,14 @@ check ()
 
   Vector<float> error (tria.n_active_cells());
 
+  std::map<types::boundary_id,const Function<spacedim>*> neumann_bc;
+  MyNormalDerivative<spacedim> function_normal;
+  neumann_bc[0] = &function_normal;
+  neumann_bc[1] = &function_normal;
+
+  deallog << "estimating..." << std::endl;
   KellyErrorEstimator<dim,spacedim>::estimate (mapping, dof, q_face,
-                                               typename FunctionMap<spacedim>::type(),
+                                               neumann_bc,
                                                v, error);
   deallog << "Estimated error indicators:" << std::endl;
   for (unsigned int i=0; i<error.size(); ++i)
index de3f9c8bd7f6e6f5bf8d28afc93f0760e24ac9ea..0216fa5f85a13f4c1095d60594d144a0c4aba8a9 100644 (file)
@@ -1,9 +1,12 @@
 
+DEAL:<1,2>::estimating...
+DEAL:<1,2>::evaluate normal derivative at 1.00000 1.00000 with value 2.00000
+DEAL:<1,2>::evaluate normal derivative at 0.00000 0.00000 with value 0.00000
 DEAL:<1,2>::Estimated error indicators:
 DEAL:<1,2>::0
 DEAL:<1,2>::0
 DEAL:<1,2>::0
-DEAL:<1,2>::1.00000
+DEAL:<1,2>::0
 DEAL:<1,2>::0
 DEAL:<1,2>::0
 DEAL:<1,2>::0
@@ -13,6 +16,127 @@ DEAL:<1,2>::0
 DEAL:<1,2>::0
 DEAL:<1,2>::0
 DEAL:<1,2>::OK
+DEAL:<2,3>::estimating...
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.0173580 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.0825024 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.167498 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.232642 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00867898 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.517358 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.582502 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.0412512 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.0837488 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.116321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.258679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.667498 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.291251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.732642 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.333749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.366321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.00867898 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.0412512 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.0837488 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.116321 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.133679 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.166251 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.208749 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.241321 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.517358 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.133679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.582502 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.383679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.166251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.416251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.208749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.667498 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.241321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.732642 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.458749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.267358 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.767358 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.832502 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.917498 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.332502 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.982642 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.417498 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.491321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.0173580 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.482642 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.0825024 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.167498 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.232642 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.258679 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.767358 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.291251 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.832502 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.333749 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.917498 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.366321 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.982642 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.0173580 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.0825024 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.167498 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.232642 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.383679 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.416251 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.458749 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.00000 0.00000 0.491321 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.0173580 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.0825024 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.167498 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.232642 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.267358 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.332502 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.417498 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.482642 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.508679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.541251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.583749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.616321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.758679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.791251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.833749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.866321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.267358 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.332502 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.267358 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.417498 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.332502 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.482642 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.417498 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.517358 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.482642 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.582502 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.667498 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.732642 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.633679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.666251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.708749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.741321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.883679 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.916251 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.958749 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.991321 0.00000 0.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.517358 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.582502 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.667498 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.732642 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.767358 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.832502 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.917498 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 0.982642 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.517358 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.767358 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.582502 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.832502 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.667498 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.917498 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.732642 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 1.00000 1.00000 0.982642 with value 2.00000
+DEAL:<2,3>::evaluate normal derivative at 0.767358 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.832502 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.917498 0.00000 1.00000 with value 0.00000
+DEAL:<2,3>::evaluate normal derivative at 0.982642 0.00000 1.00000 with value 0.00000
 DEAL:<2,3>::Estimated error indicators:
 DEAL:<2,3>::0
 DEAL:<2,3>::0

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.