From 20d1ea01225b6c300a36c62bba68284f7236f487 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 16 Apr 2002 10:56:50 +0000 Subject: [PATCH] Fix the last open issue. git-svn-id: https://svn.dealii.org/trunk@5664 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-13/step-13.cc | 43 +++++++++++++++++++---------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/deal.II/examples/step-13/step-13.cc b/deal.II/examples/step-13/step-13.cc index 0c3749b562..effa35ec9d 100644 --- a/deal.II/examples/step-13/step-13.cc +++ b/deal.II/examples/step-13/step-13.cc @@ -908,7 +908,11 @@ namespace LaplaceSolver // down to the base class's // constructor, or are stored and // used to generate a - // ``DoFHandler'' object later. + // ``DoFHandler'' object + // later. Since finite elements and + // quadrature formula should match, + // it is also passed a quadrature + // object. // // The ``solve_problem'' sets up // the data structures for the @@ -930,6 +934,7 @@ namespace LaplaceSolver public: Solver (Triangulation &triangulation, const FiniteElement &fe, + const Quadrature &quadrature, const Function &boundary_values); virtual ~Solver (); @@ -954,6 +959,7 @@ namespace LaplaceSolver // examples: protected: const SmartPointer > fe; + const SmartPointer > quadrature; DoFHandler dof_handler; Vector solution; const SmartPointer > boundary_values; @@ -1038,10 +1044,12 @@ namespace LaplaceSolver template Solver::Solver (Triangulation &triangulation, const FiniteElement &fe, + const Quadrature &quadrature, const Function &boundary_values) : Base (triangulation), fe (&fe), + quadrature (&quadrature), dof_handler (triangulation), boundary_values (&boundary_values) {}; @@ -1227,15 +1235,12 @@ namespace LaplaceSolver const typename DoFHandler::active_cell_iterator &end_cell, Threads::ThreadMutex &mutex) const { - //TODO: adaptive - QGauss4 quadrature_formula; - - FEValues fe_values (*fe, quadrature_formula, + FEValues fe_values (*fe, *quadrature, UpdateFlags(update_gradients | update_JxW_values)); const unsigned int dofs_per_cell = fe->dofs_per_cell; - const unsigned int n_q_points = quadrature_formula.n_quadrature_points; + const unsigned int n_q_points = quadrature->n_quadrature_points; FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); @@ -1437,6 +1442,7 @@ namespace LaplaceSolver public: PrimalSolver (Triangulation &triangulation, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values); protected: @@ -1452,11 +1458,13 @@ namespace LaplaceSolver PrimalSolver:: PrimalSolver (Triangulation &triangulation, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values) : Base (triangulation), - Solver (triangulation, fe, boundary_values), + Solver (triangulation, fe, + quadrature, boundary_values), rhs_function (&rhs_function) {}; @@ -1472,16 +1480,13 @@ namespace LaplaceSolver PrimalSolver:: assemble_rhs (Vector &rhs) const { - //TODO: adaptive - QGauss4 quadrature_formula; - - FEValues fe_values (*fe, quadrature_formula, + FEValues fe_values (*fe, *quadrature, UpdateFlags(update_values | update_q_points | update_JxW_values)); const unsigned int dofs_per_cell = fe->dofs_per_cell; - const unsigned int n_q_points = quadrature_formula.n_quadrature_points; + const unsigned int n_q_points = quadrature->n_quadrature_points; Vector cell_rhs (dofs_per_cell); std::vector rhs_values (n_q_points); @@ -1553,6 +1558,7 @@ namespace LaplaceSolver public: RefinementGlobal (Triangulation &coarse_grid, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values); @@ -1565,11 +1571,12 @@ namespace LaplaceSolver RefinementGlobal:: RefinementGlobal (Triangulation &coarse_grid, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values) : Base (coarse_grid), - PrimalSolver (coarse_grid, fe, + PrimalSolver (coarse_grid, fe, quadrature, rhs_function, boundary_values) {}; @@ -1610,6 +1617,7 @@ namespace LaplaceSolver public: RefinementKelly (Triangulation &coarse_grid, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values); @@ -1622,11 +1630,13 @@ namespace LaplaceSolver RefinementKelly:: RefinementKelly (Triangulation &coarse_grid, const FiniteElement &fe, + const Quadrature &quadrature, const Function &rhs_function, const Function &boundary_values) : Base (coarse_grid), - PrimalSolver (coarse_grid, fe, rhs_function, boundary_values) + PrimalSolver (coarse_grid, fe, quadrature, + rhs_function, boundary_values) {}; @@ -1860,7 +1870,8 @@ void solve_problem (const std::string &solver_name) Triangulation triangulation; GridGenerator::hyper_cube (triangulation, -1, 1); triangulation.refine_global (2); - const FE_Q fe(1); + const FE_Q fe(1); + const QGauss4 quadrature; const RightHandSide rhs_function; const Solution boundary_values; @@ -1872,10 +1883,12 @@ void solve_problem (const std::string &solver_name) LaplaceSolver::Base * solver = 0; if (solver_name == "global") solver = new LaplaceSolver::RefinementGlobal (triangulation, fe, + quadrature, rhs_function, boundary_values); else if (solver_name == "kelly") solver = new LaplaceSolver::RefinementKelly (triangulation, fe, + quadrature, rhs_function, boundary_values); else -- 2.39.5