From e7ec515aa79570a398fabbafc845d459cbcfd5c3 Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 17 Dec 2010 00:37:46 +0000 Subject: [PATCH] More minor simplifications. git-svn-id: https://svn.dealii.org/trunk@22991 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-38/step-38.cc | 90 ++++++++++------------------- 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/deal.II/examples/step-38/step-38.cc b/deal.II/examples/step-38/step-38.cc index ad2e48152c..e2985c233e 100644 --- a/deal.II/examples/step-38/step-38.cc +++ b/deal.II/examples/step-38/step-38.cc @@ -152,18 +152,9 @@ class LaplaceBeltrami { public: LaplaceBeltrami (); - // arguments are: - // triangulation - // right-hand side - // fe_degree for solution - // fe_degree for mapping - // exact solution is known - - ~LaplaceBeltrami (); void run (); private: - void make_mesh (); void setup_system (); void assemble_system (); @@ -195,12 +186,6 @@ LaplaceBeltrami::LaplaceBeltrami () {} -template -LaplaceBeltrami::~LaplaceBeltrami () -{ - dof_handler.clear (); -} - template void LaplaceBeltrami::make_mesh () @@ -251,19 +236,20 @@ void LaplaceBeltrami::setup_system () system_rhs.reinit (dof_handler.n_dofs()); } + template void LaplaceBeltrami::assemble_system () -{ - +{ system_matrix = 0; system_rhs = 0; QGauss quadrature_formula(2); - FEValues fe_values (mapping,fe, quadrature_formula, - update_values | update_cell_normal_vectors | - update_gradients | - update_quadrature_points | update_JxW_values); + FEValues fe_values (mapping, fe, quadrature_formula, + update_values | + update_gradients | + update_quadrature_points | + update_JxW_values); const unsigned int dofs_per_cell = fe.dofs_per_cell; const unsigned int n_q_points = quadrature_formula.size(); @@ -290,29 +276,18 @@ void LaplaceBeltrami::assemble_system () rhs.value_list (fe_values.get_quadrature_points(), rhs_values); for (unsigned int i=0; iget_dof_indices (local_dof_indices); for (unsigned int i=0; i::assemble_system () } - std::map bdy_values; - VectorTools::interpolate_boundary_values (mapping,dof_handler, + std::map boundary_values; + VectorTools::interpolate_boundary_values (mapping, + dof_handler, 0, Solution(), - bdy_values - ); - - MatrixTools::apply_boundary_values (bdy_values, + boundary_values); + MatrixTools::apply_boundary_values (boundary_values, system_matrix, solution, system_rhs,false); @@ -344,8 +318,8 @@ void LaplaceBeltrami::assemble_system () template void LaplaceBeltrami::solve () { - SolverControl solver_control (solution.size(), 1e-7); - SolverCG<> cg (solver_control); + SolverControl solver_control (solution.size(), 1e-7); + SolverCG<> cg (solver_control); PreconditionSSOR<> preconditioner; preconditioner.initialize(system_matrix, 1.2); @@ -359,19 +333,14 @@ void LaplaceBeltrami::solve () template void LaplaceBeltrami::output_results () const { - - std::string filename = "solution.vtk"; - - std::ofstream output (filename.c_str()); - DataOut > data_out; data_out.attach_dof_handler (dof_handler); - - - - data_out.add_data_vector (solution, "solution",DataOut_DoFData,dim-1,dim>::type_dof_data); + data_out.add_data_vector (solution, "solution", + DataOut >::type_dof_data); data_out.build_patches (mapping, mapping.get_degree()); + + std::ofstream output ("solution.vtk"); data_out.write_vtk (output); } @@ -385,8 +354,7 @@ void LaplaceBeltrami::compute_error () const Solution(), difference_per_cell, QGauss(2*fe.degree+1), - VectorTools::H1_norm); - + VectorTools::H1_norm); std::cout << "H1 error = " << difference_per_cell.l2_norm() -- 2.39.5