From b175bb4440aa371848bbbb64eeb8b6520503a7c7 Mon Sep 17 00:00:00 2001 From: Ralf Hartmann Date: Thu, 5 Apr 2001 16:53:25 +0000 Subject: [PATCH] Extend all functions of the KellyErrorEstimator to use an arbitrary mapping. For backward compatibility keep a second version without mapping argument of each public function. Then the global mapping_q1 object can be removed. git-svn-id: https://svn.dealii.org/trunk@4383 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/numerics/error_estimator.h | 51 ++++++++++++--- .../source/numerics/error_estimator.cc | 63 ++++++++++++++----- 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/deal.II/deal.II/include/numerics/error_estimator.h b/deal.II/deal.II/include/numerics/error_estimator.h index 96f53add2f..f58b695698 100644 --- a/deal.II/deal.II/include/numerics/error_estimator.h +++ b/deal.II/deal.II/include/numerics/error_estimator.h @@ -269,7 +269,8 @@ class KellyErrorEstimator * implemented in two and three * dimensions. */ - static void estimate (const DoFHandler &dof, + static void estimate (const Mapping &mapping, + const DoFHandler &dof, const Quadrature &quadrature, const FunctionMap &neumann_bc, const Vector &solution, @@ -278,6 +279,19 @@ class KellyErrorEstimator const Function *coefficients = 0, unsigned int n_threads = multithread_info.n_default_threads); + /** + * Calls the @p{estimate} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + static void estimate (const DoFHandler &dof, + const Quadrature &quadrature, + const FunctionMap &neumann_bc, + const Vector &solution, + Vector &error, + const std::vector &component_mask = std::vector(), + const Function *coefficients = 0, + unsigned int n_threads = multithread_info.n_default_threads); /** * Same function as above, but * accepts more than one solution @@ -305,14 +319,29 @@ class KellyErrorEstimator * references, so we had to use a * vector of pointers.) */ - static void estimate (const DoFHandler &dof, - const Quadrature &quadrature, - const FunctionMap &neumann_bc, + static void estimate (const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &quadrature, + const FunctionMap &neumann_bc, + const std::vector*> &solutions, + std::vector*> &errors, + const std::vector &component_mask = std::vector(), + const Function *coefficients = 0, + unsigned int n_threads = multithread_info.n_default_threads); + + /** + * Calls the @p{estimate} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + static void estimate (const DoFHandler &dof, + const Quadrature &quadrature, + const FunctionMap &neumann_bc, const std::vector*> &solutions, - std::vector*> &errors, - const std::vector &component_mask = std::vector(), - const Function *coefficients = 0, - unsigned int n_threads = multithread_info.n_default_threads); + std::vector*> &errors, + const std::vector &component_mask = std::vector(), + const Function *coefficients = 0, + unsigned int n_threads = multithread_info.n_default_threads); /** @@ -374,7 +403,7 @@ class KellyErrorEstimator * functions of the error * estimator is gathered in this * struct. It is passed as a - * reference to the seperate + * reference to the separate * functions in this class. * * The reason for invention of @@ -415,6 +444,7 @@ class KellyErrorEstimator */ struct Data { + const Mapping &mapping; const DoFHandler &dof_handler; const Quadrature &quadrature; const FunctionMap &neumann_bc; @@ -500,7 +530,8 @@ class KellyErrorEstimator * class Data. All variables are * passed as references. */ - Data(const DoFHandler &dof, + Data(const Mapping &mapping, + const DoFHandler &dof, const Quadrature &quadrature, const FunctionMap &neumann_bc, const std::vector*> &solutions, diff --git a/deal.II/deal.II/source/numerics/error_estimator.cc b/deal.II/deal.II/source/numerics/error_estimator.cc index c4c7cef004..13c1f0b3d9 100644 --- a/deal.II/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/deal.II/source/numerics/error_estimator.cc @@ -39,10 +39,6 @@ using namespace std; -//TODO:[RH,GK] Replace global by local object; better: have two functions, or by default arg -static const MappingQ1 mapping; - - static inline @@ -55,7 +51,8 @@ double sqr (const double x) #if deal_II_dimension == 1 template <> -KellyErrorEstimator<1>::Data::Data(const DoFHandler<1> &, +KellyErrorEstimator<1>::Data::Data(const Mapping<1> &, + const DoFHandler<1> &, const Quadrature<0> &, const FunctionMap &, const std::vector*> &, @@ -63,6 +60,7 @@ KellyErrorEstimator<1>::Data::Data(const DoFHandler<1> &, const Function<1> *, const unsigned int , FaceIntegrals &): + mapping(* static_cast *> (0)), dof_handler(* static_cast *> (0)), quadrature(* static_cast *> (0)), neumann_bc(* static_cast (0)), @@ -75,7 +73,8 @@ KellyErrorEstimator<1>::Data::Data(const DoFHandler<1> &, #else template -KellyErrorEstimator::Data::Data(const DoFHandler &dof_handler, +KellyErrorEstimator::Data::Data(const Mapping &mapping, + const DoFHandler &dof_handler, const Quadrature &quadrature, const FunctionMap &neumann_bc, const std::vector*> &solutions, @@ -83,6 +82,7 @@ KellyErrorEstimator::Data::Data(const DoFHandler &dof_ha const Function *coefficients, const unsigned int n_threads, FaceIntegrals &face_integrals): + mapping (mapping), dof_handler (dof_handler), quadrature (quadrature), neumann_bc (neumann_bc), @@ -149,7 +149,8 @@ KellyErrorEstimator::Data::Data(const DoFHandler &dof_ha // the following function is still independent of dimension, but it // calls dimension dependent functions template -void KellyErrorEstimator::estimate (const DoFHandler &dof_handler, +void KellyErrorEstimator::estimate (const Mapping &mapping, + const DoFHandler &dof_handler, const Quadrature &quadrature, const FunctionMap &neumann_bc, const Vector &solution, @@ -161,11 +162,26 @@ void KellyErrorEstimator::estimate (const DoFHandler &dof_handler, // just pass on to the other function const std::vector*> solutions (1, &solution); std::vector*> errors (1, &error); - estimate (dof_handler, quadrature, neumann_bc, solutions, errors, + estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors, component_mask, coefficients, n_threads); }; +template +void KellyErrorEstimator::estimate (const DoFHandler &dof_handler, + const Quadrature &quadrature, + const FunctionMap &neumann_bc, + const Vector &solution, + Vector &error, + const std::vector &component_mask, + const Function *coefficients, + unsigned int n_threads) +{ + static const MappingQ1 mapping; + estimate(mapping, dof_handler, quadrature, neumann_bc, solution, + error, component_mask, coefficients, n_threads); +}; + #if deal_II_dimension == 1 @@ -181,7 +197,8 @@ void KellyErrorEstimator<1>::estimate_some (Data &, const unsigned int) template <> -void KellyErrorEstimator<1>::estimate (const DoFHandler<1> &dof_handler, +void KellyErrorEstimator<1>::estimate (const Mapping<1> &mapping, + const DoFHandler<1> &dof_handler, const Quadrature<0> &, const FunctionMap &neumann_bc, const std::vector*> &solutions, @@ -376,7 +393,7 @@ void KellyErrorEstimator::estimate_some (Data &data, // need not compute all values on the // neighbor cells, so using two objects // gives us a performance gain). - FEFaceValues fe_face_values_cell (mapping, + FEFaceValues fe_face_values_cell (data.mapping, data.dof_handler.get_fe(), data.quadrature, UpdateFlags(update_gradients | @@ -385,11 +402,11 @@ void KellyErrorEstimator::estimate_some (Data &data, (data.coefficients != 0)) ? update_q_points : 0) | update_normal_vectors)); - FEFaceValues fe_face_values_neighbor (mapping, + FEFaceValues fe_face_values_neighbor (data.mapping, data.dof_handler.get_fe(), data.quadrature, update_gradients); - FESubfaceValues fe_subface_values (mapping, + FESubfaceValues fe_subface_values (data.mapping, data.dof_handler.get_fe(), data.quadrature, update_gradients); @@ -503,7 +520,8 @@ void KellyErrorEstimator::estimate_some (Data &data, template -void KellyErrorEstimator::estimate (const DoFHandler &dof_handler, +void KellyErrorEstimator::estimate (const Mapping &mapping, + const DoFHandler &dof_handler, const Quadrature &quadrature, const FunctionMap &neumann_bc, const std::vector*> &solutions, @@ -564,7 +582,8 @@ void KellyErrorEstimator::estimate (const DoFHandler &do // components std::vector data_structures (n_threads); for (unsigned int i=0; i::estimate (const DoFHandler &do #endif +template +void KellyErrorEstimator::estimate (const DoFHandler &dof_handler, + const Quadrature &quadrature, + const FunctionMap &neumann_bc, + const std::vector*> &solutions, + std::vector*> &errors, + const std::vector &component_mask, + const Function *coefficients, + unsigned int n_threads) +{ + static const MappingQ1 mapping; + estimate(mapping, dof_handler, quadrature, neumann_bc, solutions, + errors, component_mask, coefficients, n_threads); +} + + #if deal_II_dimension == 1 -- 2.39.5