From fe089b0ae431d5450024816fd9584b7dc9089af0 Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 14 Dec 2011 17:15:57 +0000 Subject: [PATCH] Simplify code. git-svn-id: https://svn.dealii.org/trunk@24825 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/deal.II/data_out.cc | 87 ++++++--------------------------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/tests/deal.II/data_out.cc b/tests/deal.II/data_out.cc index 7cbaee77f3..c7d8542053 100644 --- a/tests/deal.II/data_out.cc +++ b/tests/deal.II/data_out.cc @@ -1,8 +1,8 @@ //---------------------------- data_out.cc --------------------------- // $Id$ -// Version: $Name$ +// Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2007, 2008 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -25,18 +25,11 @@ #include #include #include -#include #include -#include #include #include #include #include -#include -#include -#include -#include -#include #include #include @@ -50,12 +43,12 @@ std::ofstream logfile("data_out/output"); template -class LaplaceProblem +class LaplaceProblem { public: LaplaceProblem (); void run (); - + private: void make_grid_and_dofs (); void solve (); @@ -65,57 +58,10 @@ class LaplaceProblem FE_Q fe; DoFHandler dof_handler; - SparsityPattern sparsity_pattern; - SparseMatrix system_matrix; - Vector solution; - Vector system_rhs; -}; - - -template -class RightHandSide : public Function -{ - public: - virtual double value (const Point &p, - const unsigned int component = 0) const; }; - -template -class BoundaryValues : public Function -{ - public: - virtual double value (const Point &p, - const unsigned int component = 0) const; -}; - - - - -template -double RightHandSide::value (const Point &p, - const unsigned int) const -{ - double return_value = 0; - for (unsigned int i=0; i -double BoundaryValues::value (const Point &p, - const unsigned int) const -{ - return p.square(); -} - - - - template LaplaceProblem::LaplaceProblem () : fe (1), dof_handler (triangulation) @@ -133,8 +79,8 @@ void LaplaceProblem::make_grid_and_dofs () triangulation.begin_active()->set_refine_flag (); triangulation.execute_coarsening_and_refinement (); }; - - + + deallog << " Number of active cells: " << triangulation.n_active_cells() << std::endl @@ -148,23 +94,14 @@ void LaplaceProblem::make_grid_and_dofs () << dof_handler.n_dofs() << std::endl; - sparsity_pattern.reinit (dof_handler.n_dofs(), - dof_handler.n_dofs(), - dof_handler.max_couplings_between_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); - sparsity_pattern.compress(); - - system_matrix.reinit (sparsity_pattern); - solution.reinit (dof_handler.n_dofs()); - system_rhs.reinit (dof_handler.n_dofs()); } template -void LaplaceProblem::solve () +void LaplaceProblem::solve () { // dummy solve. just insert some // arbitrary values @@ -251,26 +188,26 @@ void LaplaceProblem<3>::output_results () const template -void LaplaceProblem::run () +void LaplaceProblem::run () { make_grid_and_dofs(); solve (); output_results (); } - -int main () + +int main () { deallog.depth_console (0); logfile << std::setprecision(2); deallog << std::setprecision(2); - + LaplaceProblem<2> laplace_problem_2d; laplace_problem_2d.run (); LaplaceProblem<3> laplace_problem_3d; laplace_problem_3d.run (); - + return 0; } -- 2.39.5