From 57dc4ec4a3dbb51b36295fb5d3ca7a18f15cf0e8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 27 Mar 2001 14:09:01 +0000 Subject: [PATCH] Purge the ProblemBase class. Keep it in tests/big-tests/problem_base.h to allow big-tests to compile as before. git-svn-id: https://svn.dealii.org/trunk@4304 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/numerics/base.cc | 187 ----------------- deal.II/doc/news/2001/c-3-1.html | 8 +- tests/big-tests/convergence/convergence.cc | 2 +- .../error-estimation/error-estimation.cc | 2 +- .../fixed-point-iteration/nonlinear.cc | 2 +- tests/big-tests/poisson/poisson.cc | 2 + tests/big-tests/poisson/poisson.h | 2 +- .../base.h => tests/big-tests/problem_base.h | 194 +++++++++++++++++- 8 files changed, 196 insertions(+), 203 deletions(-) delete mode 100644 deal.II/deal.II/source/numerics/base.cc rename deal.II/deal.II/include/numerics/base.h => tests/big-tests/problem_base.h (61%) diff --git a/deal.II/deal.II/source/numerics/base.cc b/deal.II/deal.II/source/numerics/base.cc deleted file mode 100644 index a94cdf9920..0000000000 --- a/deal.II/deal.II/source/numerics/base.cc +++ /dev/null @@ -1,187 +0,0 @@ -//---------------------------- base.cc --------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//---------------------------- base.cc --------------------------- - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - - -template -ProblemBase::ProblemBase () : - tria(0), - dof_handler(0), - system_sparsity(), // dummy initialisation, is later reinit'd - system_matrix() // dummy initialisation, is later reinit'd -{}; - - -template -void ProblemBase::set_tria_and_dof (Triangulation *t, - DoFHandler *d) -{ - tria = t; - dof_handler = d; - - // allow a user to reset both tria and - // dof to null pointers, but don't allow - // something other - if ((tria != 0) || (dof_handler != 0)) - { - Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); - Assert (tria == &dof_handler->get_tria(), ExcDofAndTriaDontMatch()); - }; -}; - - -template -void ProblemBase::clear () { - if (tria) { delete tria; tria = 0; }; - if (dof_handler) { delete dof_handler; dof_handler = 0; }; - system_sparsity.reinit (0,0,1); - system_matrix.clear (); - right_hand_side.reinit (0); - solution.reinit (0); - constraints.clear (); -}; - - -template -ProblemBase::~ProblemBase () {}; - - -template -void ProblemBase::assemble (const Equation &equation, - const Quadrature &quadrature, - const UpdateFlags update_flags, - const FunctionMap &dirichlet_bc) -{ - Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); - - system_sparsity.reinit (dof_handler->n_dofs(), - dof_handler->n_dofs(), - dof_handler->max_couplings_between_dofs()); - right_hand_side.reinit (dof_handler->n_dofs()); - - // make up sparsity pattern and - // compress with constraints - constraints.clear (); - DoFTools::make_hanging_node_constraints (*dof_handler, constraints); - constraints.close (); - DoFTools::make_sparsity_pattern (*dof_handler, system_sparsity); - constraints.condense (system_sparsity); - - // reinite system matrix - system_matrix.reinit (system_sparsity); - // reinit solution vector, preset - // with zeroes. - solution.reinit (dof_handler->n_dofs()); - - // create assembler - Assembler::AssemblerData data (*dof_handler, - true, true, //assemble matrix and rhs - system_matrix, - right_hand_side, - quadrature, - update_flags); - active_assemble_iterator assembler (tria, - tria->begin_active()->level(), - tria->begin_active()->index(), - &data); - // loop over all cells, fill matrix and rhs - do - { - assembler->assemble (equation); - } - while ((++assembler).state() == valid); - - // condense system matrix in-place - constraints.condense (system_matrix); - - // condense right hand side in-place - constraints.condense (right_hand_side); - - // apply Dirichlet bc as described - // in the docs - std::map boundary_value_list; - - for (typename FunctionMap::const_iterator dirichlet = dirichlet_bc.begin() ; - dirichlet != dirichlet_bc.end() ; ++dirichlet) - VectorTools::interpolate_boundary_values (*dof_handler, - dirichlet->first, - *(dirichlet->second), - boundary_value_list); - MatrixTools::apply_boundary_values (boundary_value_list, - system_matrix, solution, - right_hand_side, - true); -}; - - -template -void ProblemBase::solve () -{ - Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); - - SolverControl control(4000, 1e-16); - PrimitiveVectorMemory<> memory; - SolverCG<> cg(control,memory); - - PreconditionSSOR<> prec; - prec.initialize (system_matrix, 1.2); - - // solve - cg.solve (system_matrix, solution, right_hand_side, prec); - // distribute solution - constraints.distribute (solution); -}; - - -template -void ProblemBase::fill_data (DataOut &out) const -{ - Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); - - out.clear (); - out.attach_dof_handler (*dof_handler); - - out.add_data_vector (solution, get_solution_name()); -}; - - -template -std::string ProblemBase::get_solution_name () const -{ - return "solution"; -}; - - -// explicit instantiations -template class ProblemBase; diff --git a/deal.II/doc/news/2001/c-3-1.html b/deal.II/doc/news/2001/c-3-1.html index 5573d92097..886e189203 100644 --- a/deal.II/doc/news/2001/c-3-1.html +++ b/deal.II/doc/news/2001/c-3-1.html @@ -281,7 +281,14 @@ documentation, etc.
  1. + Removed: the ProblemBase class, + which has been deprecated since before the release of + deal.II 3.0 has finally been removed. +
    + (WB 2001/03/27)

    + +
  2. New: There is now a class MappingC1 that implements a continous C1 mapping of the boundary by using a cubic mapping with continuous derivatives @@ -311,7 +318,6 @@ documentation, etc. (RH 2001/03/27)

  3. -

    New: Boundary and derived classes now have a function get_tangents_at_vertices that returns a diff --git a/tests/big-tests/convergence/convergence.cc b/tests/big-tests/convergence/convergence.cc index 763cec6cd6..6d0525c532 100644 --- a/tests/big-tests/convergence/convergence.cc +++ b/tests/big-tests/convergence/convergence.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include "../problem_base.h" #include #include #include diff --git a/tests/big-tests/error-estimation/error-estimation.cc b/tests/big-tests/error-estimation/error-estimation.cc index 8c8f107312..e11544f3dd 100644 --- a/tests/big-tests/error-estimation/error-estimation.cc +++ b/tests/big-tests/error-estimation/error-estimation.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include "../problem_base.h" #include #include #include diff --git a/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc b/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc index aaf36230c8..82d023bb61 100644 --- a/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc +++ b/tests/big-tests/nonlinear/fixed-point-iteration/nonlinear.cc @@ -17,7 +17,7 @@ #include #include #include -#include +#include "../../problem_base.h" #include #include #include diff --git a/tests/big-tests/poisson/poisson.cc b/tests/big-tests/poisson/poisson.cc index bbfa7841ea..2e647e228a 100644 --- a/tests/big-tests/poisson/poisson.cc +++ b/tests/big-tests/poisson/poisson.cc @@ -8,6 +8,7 @@ #include + int main (int argc, char **argv) { if (argc!=2) { @@ -27,3 +28,4 @@ int main (int argc, char **argv) { return 0; }; + diff --git a/tests/big-tests/poisson/poisson.h b/tests/big-tests/poisson/poisson.h index 9fff2c0617..ce4ea0c407 100644 --- a/tests/big-tests/poisson/poisson.h +++ b/tests/big-tests/poisson/poisson.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include "../problem_base.h" #include #include diff --git a/deal.II/deal.II/include/numerics/base.h b/tests/big-tests/problem_base.h similarity index 61% rename from deal.II/deal.II/include/numerics/base.h rename to tests/big-tests/problem_base.h index 5de0659be8..fa5b32c741 100644 --- a/deal.II/deal.II/include/numerics/base.h +++ b/tests/big-tests/problem_base.h @@ -1,16 +1,16 @@ -//---------------------------- base.h --------------------------- -// Version: $Name$ -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//---------------------------- base.h --------------------------- +/*---------------------------- problem_base.h ---------------------------*/ +/* Previously deal.II/include/numerics/base.h and deal.II/source/numerics/base.cc, + but deprecated before deal.II version 3.0 and removed after version 3.1 + + Kept here to ensure that the example programs in big-tests still + compile. It is put into this directory to allow simple access from + all the subdirectories. +*/ + #ifndef __deal2__base_h #define __deal2__base_h -/*---------------------------- problem_base.h ---------------------------*/ #include @@ -248,7 +248,179 @@ class ProblemBase }; -/*---------------------------- problem_base.h ---------------------------*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +template +ProblemBase::ProblemBase () : + tria(0), + dof_handler(0), + system_sparsity(), // dummy initialisation, is later reinit'd + system_matrix() // dummy initialisation, is later reinit'd +{}; + + +template +void ProblemBase::set_tria_and_dof (Triangulation *t, + DoFHandler *d) +{ + tria = t; + dof_handler = d; + + // allow a user to reset both tria and + // dof to null pointers, but don't allow + // something other + if ((tria != 0) || (dof_handler != 0)) + { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + Assert (tria == &dof_handler->get_tria(), ExcDofAndTriaDontMatch()); + }; +}; + + +template +void ProblemBase::clear () { + if (tria) { delete tria; tria = 0; }; + if (dof_handler) { delete dof_handler; dof_handler = 0; }; + system_sparsity.reinit (0,0,1); + system_matrix.clear (); + right_hand_side.reinit (0); + solution.reinit (0); + constraints.clear (); +}; + + +template +ProblemBase::~ProblemBase () {}; + + +template +void ProblemBase::assemble (const Equation &equation, + const Quadrature &quadrature, + const UpdateFlags update_flags, + const FunctionMap &dirichlet_bc) +{ + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + + system_sparsity.reinit (dof_handler->n_dofs(), + dof_handler->n_dofs(), + dof_handler->max_couplings_between_dofs()); + right_hand_side.reinit (dof_handler->n_dofs()); + + // make up sparsity pattern and + // compress with constraints + constraints.clear (); + DoFTools::make_hanging_node_constraints (*dof_handler, constraints); + constraints.close (); + DoFTools::make_sparsity_pattern (*dof_handler, system_sparsity); + constraints.condense (system_sparsity); + + // reinite system matrix + system_matrix.reinit (system_sparsity); + // reinit solution vector, preset + // with zeroes. + solution.reinit (dof_handler->n_dofs()); + + // create assembler + Assembler::AssemblerData data (*dof_handler, + true, true, //assemble matrix and rhs + system_matrix, + right_hand_side, + quadrature, + update_flags); + active_assemble_iterator assembler (tria, + tria->begin_active()->level(), + tria->begin_active()->index(), + &data); + // loop over all cells, fill matrix and rhs + do + { + assembler->assemble (equation); + } + while ((++assembler).state() == valid); + + // condense system matrix in-place + constraints.condense (system_matrix); + + // condense right hand side in-place + constraints.condense (right_hand_side); + + // apply Dirichlet bc as described + // in the docs + std::map boundary_value_list; + + for (typename FunctionMap::const_iterator dirichlet = dirichlet_bc.begin() ; + dirichlet != dirichlet_bc.end() ; ++dirichlet) + VectorTools::interpolate_boundary_values (*dof_handler, + dirichlet->first, + *(dirichlet->second), + boundary_value_list); + MatrixTools::apply_boundary_values (boundary_value_list, + system_matrix, solution, + right_hand_side, + true); +}; + + +template +void ProblemBase::solve () +{ + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + + SolverControl control(4000, 1e-16); + PrimitiveVectorMemory<> memory; + SolverCG<> cg(control,memory); + + PreconditionSSOR<> prec; + prec.initialize (system_matrix, 1.2); + + // solve + cg.solve (system_matrix, solution, right_hand_side, prec); + // distribute solution + constraints.distribute (solution); +}; + + +template +void ProblemBase::fill_data (DataOut &out) const +{ + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + + out.clear (); + out.attach_dof_handler (*dof_handler); + + out.add_data_vector (solution, get_solution_name()); +}; + + +template +std::string ProblemBase::get_solution_name () const +{ + return "solution"; +}; + + + #endif -/*---------------------------- problem_base.h ---------------------------*/ + -- 2.39.5