From 45152404fe99583304b1496d011a072199c2b6c5 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Thu, 21 Jan 2016 22:01:00 -0500 Subject: [PATCH] fix Neumann part of 1d Kelly estimator 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 | 4 +- tests/codim_one/error_estimator_02.cc | 36 ++++++- tests/codim_one/error_estimator_02.output | 126 +++++++++++++++++++++- 3 files changed, 162 insertions(+), 4 deletions(-) diff --git a/source/numerics/error_estimator_1d.cc b/source/numerics/error_estimator_1d.cc index 675797954a..0e6f97e861 100644 --- a/source/numerics/error_estimator_1d.cc +++ b/source/numerics/error_estimator_1d.cc @@ -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 &mapping, else { Vector 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 +// function is x^2+2xy template class MyFunction : public Function { @@ -60,6 +61,33 @@ public: }; +// normal derivative of function above is 0 except for x=1, y=1 with n=(0,1,0) +template +class MyNormalDerivative : public Function +{ +public: + MyNormalDerivative () : Function(1) {} + + virtual double value (const Point &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 &p, + Vector &values) const + { + values(0) = value(p,0); + values(1) = value(p,1); + } +}; + + template Quadrature & @@ -122,8 +150,14 @@ check () Vector error (tria.n_active_cells()); + std::map*> neumann_bc; + MyNormalDerivative function_normal; + neumann_bc[0] = &function_normal; + neumann_bc[1] = &function_normal; + + deallog << "estimating..." << std::endl; KellyErrorEstimator::estimate (mapping, dof, q_face, - typename FunctionMap::type(), + neumann_bc, v, error); deallog << "Estimated error indicators:" << std::endl; for (unsigned int i=0; i::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 -- 2.39.5