From 182fb350cb41acaca99e84f1f55e40cab8ac2195 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 14 Nov 2002 07:48:38 +0000 Subject: [PATCH] point evaluation implemented, not tested git-svn-id: https://svn.dealii.org/trunk@6762 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/vectors.h | 22 ++++++++++ deal.II/deal.II/source/numerics/vectors.cc | 49 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 160619dc76..be6ec9107f 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -21,6 +21,7 @@ #include #include +template class Point; template class Function; template class FunctionMap; template class Quadrature; @@ -820,6 +821,27 @@ class VectorTools const Function *weight=0, const double exponent = 2.); + /** + * Point error evaluation. Find + * the first cell containing the + * given point and compute the + * difference of a finite element + * function and a continuous + * function at this point. + * + * Since the function uses a + * simple test for checking + * whether a point is in a cell, + * it is only implemented for + * Q1-mapping yet. + */ + template + static void point_difference (const DoFHandler& dof, + const InVector& fe_function, + const Function& exact_solution, + Vector& difference, + const Point& point); + /** * Mean-value filter for Stokes. * The pressure in Stokes' diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index b0f9fa7f5c..d806af7768 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -1358,6 +1358,55 @@ VectorTools::integrate_difference (const DoFHandler &dof, +template +void +VectorTools::point_difference (const DoFHandler& dof, + const InVector& fe_function, + const Function& exact_function, + Vector& difference, + const Point& point) +{ + static const MappingQ1 mapping; + const FiniteElement& fe = dof.get_fe(); + + Assert(difference.size() == fe.n_components(), + ExcDimensionMismatch(difference.size(), fe.n_components())); + + DoFHandler::active_cell_iterator cell = dof_handler->begin_active(); + const DoFHandler::active_cell_iterator endc = dof_handler->end(); + + std::vector > u_value(1, Vector (fe.n_components())); + + for (;cell != endc; ++cell) + { + if (cell->point_inside(point)) + { + Point unit_point = mapping->transform_real_to_unit_cell( + cell, evaluation_point); + for (unsigned int i=0; i > quadrature_point(1, unit_point); + vector weight(1, 1.); + Quadrature quadrature(quadrature_point, weight); + FEValues fe_values( + mapping, fe, quadrature, UpdateFlags(update_values)); + fe_values.reinit(cell); + fe_values.get_function_values(u, u_value); + break; + } + } + if (fe.n_components() == 1) + { + const double value = exact_function.value(point); + difference(0) = value; + } else { + exact_function.vector_value(point, difference); + } + for (unsigned int i=0;i double -- 2.39.5