From: bangerth Date: Thu, 14 Dec 2006 17:41:58 +0000 (+0000) Subject: hp-ify the code. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0809b6a243111d75d80fa0c91fd04bf2b5c6ee8e;p=dealii-svn.git hp-ify the code. git-svn-id: https://svn.dealii.org/trunk@14244 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-27/step-27.cc b/deal.II/examples/step-27/step-27.cc index 0a3bb510a5..ac0fa71ee8 100644 --- a/deal.II/examples/step-27/step-27.cc +++ b/deal.II/examples/step-27/step-27.cc @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -70,8 +70,9 @@ class LaplaceProblem Triangulation triangulation; - DoFHandler dof_handler; - FE_Q fe; + hp::DoFHandler dof_handler; + hp::FECollection fe_collection; + hp::QCollection quadrature_collection; ConstraintMatrix hanging_node_constraints; @@ -85,9 +86,14 @@ class LaplaceProblem template LaplaceProblem::LaplaceProblem () : - dof_handler (triangulation), - fe (2) -{} + dof_handler (triangulation) +{ + for (unsigned int degree=1; degree<5; ++degree) + { + fe_collection.push_back (FE_Q(degree)); + quadrature_collection.push_back (QGauss(degree+2)); + } +} template @@ -99,7 +105,7 @@ LaplaceProblem::~LaplaceProblem () template void LaplaceProblem::setup_system () { - dof_handler.distribute_dofs (fe); + dof_handler.distribute_dofs (fe_collection); sparsity_pattern.reinit (dof_handler.n_dofs(), dof_handler.n_dofs(), @@ -123,32 +129,31 @@ void LaplaceProblem::setup_system () template void LaplaceProblem::assemble_system () -{ - const QGauss quadrature_formula(3); - - FEValues fe_values (fe, quadrature_formula, - update_values | update_gradients | - 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; - - FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); - Vector cell_rhs (dofs_per_cell); - - std::vector local_dof_indices (dofs_per_cell); +{ + hp::FEValues hp_fe_values (fe_collection, + quadrature_collection, + update_values | update_gradients | + update_q_points | update_JxW_values); - typename DoFHandler::active_cell_iterator + typename hp::DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) { + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); + Vector cell_rhs (dofs_per_cell); + + std::vector local_dof_indices (dofs_per_cell); + cell_matrix = 0; cell_rhs = 0; - fe_values.reinit (cell); + hp_fe_values.reinit (cell); - for (unsigned int q_point=0; q_point &fe_values = hp_fe_values.get_present_fe_values (); + + for (unsigned int q_point=0; q_point::output_results (const unsigned int cycle) const const std::string filename = "solution-" + Utilities::int_to_string (cycle, 2) + ".gnuplot"; - DataOut data_out; + DataOut > data_out; data_out.attach_dof_handler (dof_handler); data_out.add_data_vector (solution, "solution");