From 74b14f63dba140dc578464064c4b546006c6c78f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 2 Apr 1998 13:34:40 +0000 Subject: [PATCH] Make it easier to derive from ProblemBase. git-svn-id: https://svn.dealii.org/trunk@119 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/base.h | 15 ++++++++-- deal.II/deal.II/source/numerics/base.cc | 40 +++++++++++++++++++------ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/deal.II/deal.II/include/numerics/base.h b/deal.II/deal.II/include/numerics/base.h index cfc2d4297d..b7e0fa16a7 100644 --- a/deal.II/deal.II/include/numerics/base.h +++ b/deal.II/deal.II/include/numerics/base.h @@ -218,14 +218,19 @@ class ProblemBase { typedef map* > DirichletBC; /** - * Constructor. Use this triangulation and + * Constructor. + */ + ProblemBase (); + + /** + * Use this triangulation and * degree of freedom object during the * lifetime of this object. The dof * object must refer to the given * triangulation. */ - ProblemBase (Triangulation *tria, - DoFHandler *dof_handler); + void set_tria_and_dof (Triangulation *tria, + DoFHandler *dof_handler); /** * Destructor. Declare this only to have @@ -337,6 +342,10 @@ class ProblemBase { * Exception */ DeclException0 (ExcInvalidBoundaryIndicator); + /** + * Exception + */ + DeclException0 (ExcNoTriaSelected); protected: /** diff --git a/deal.II/deal.II/source/numerics/base.cc b/deal.II/deal.II/source/numerics/base.cc index 87a79eb0ef..0b0b0b631c 100644 --- a/deal.II/deal.II/source/numerics/base.cc +++ b/deal.II/deal.II/source/numerics/base.cc @@ -27,14 +27,23 @@ inline double sqr (double x) { template -ProblemBase::ProblemBase (Triangulation *tria, - DoFHandler *dof) : - tria(tria), - dof_handler(dof), +ProblemBase::ProblemBase () : + tria(0), + dof_handler(0), system_sparsity(1,1,1), // dummy initialisation, is later reinit'd system_matrix() // dummy initialisation, is later reinit'd -{ - Assert (tria == &dof->get_tria(), ExcDofAndTriaDontMatch()); +{}; + + + +template +void ProblemBase::set_tria_and_dof (Triangulation *t, + DoFHandler *d) { + tria = t; + dof_handler = d; + + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + Assert (tria == &dof_handler->get_tria(), ExcDofAndTriaDontMatch()); }; @@ -50,6 +59,8 @@ void ProblemBase::assemble (const Equation &equation, const FiniteElement &fe, const FEValues::UpdateStruct &update_flags, const DirichletBC &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()); @@ -103,6 +114,8 @@ void ProblemBase::assemble (const Equation &equation, template void ProblemBase::solve () { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + int max_iter = 4000; double tolerance = 1.e-16; @@ -124,6 +137,7 @@ void ProblemBase::integrate_difference (const Function &exact_sol const Quadrature &q, const FiniteElement &fe, const NormType &norm) const { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); Assert (fe == dof_handler->get_selected_fe(), ExcInvalidFE()); difference.erase (difference.begin(), difference.end()); @@ -256,6 +270,8 @@ void ProblemBase::integrate_difference (const Function &exact_sol template void ProblemBase::fill_data (DataOut &out) const { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + out.clear_data_vectors (); out.attach_dof_handler (*dof_handler); @@ -279,6 +295,7 @@ void ProblemBase::apply_dirichlet_bc (dSMatrix &matrix, dVector &solution, dVector &right_hand_side, const DirichletBC &dirichlet_bc) { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); Assert (dirichlet_bc.find(255) == dirichlet_bc.end(), ExcInvalidBoundaryIndicator()); @@ -373,6 +390,7 @@ void ProblemBase::apply_dirichlet_bc (dSMatrix &matrix, void ProblemBase<1>::make_boundary_value_list (const DirichletBC &, map &) const { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); Assert (false, ExcNotImplemented()); }; @@ -383,6 +401,8 @@ template void ProblemBase::make_boundary_value_list (const DirichletBC &dirichlet_bc, map &boundary_values) const { + Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); + DoFHandler::active_face_iterator face = dof_handler->begin_active_face(), endf = dof_handler->end_face(); DirichletBC::const_iterator function_ptr; @@ -402,12 +422,14 @@ ProblemBase::make_boundary_value_list (const DirichletBC &dirichlet_bc, face->get_dof_indices (face_dofs); //physical location - Assert (false, ExcNotImplemented()); - +// Assert (false, ExcNotImplemented()); + dof_locations.insert (dof_locations.begin(), + face_dofs.size(), Point()); + (*function_ptr).second->value_list (dof_locations, dof_values); // enter into list - for (unsigned int i=0; i