From 64e1342d2912de79003de40d578f0000cdd98d9b Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 15 Apr 1999 13:32:17 +0000 Subject: [PATCH] Rename make_constraint_matrix to make_hanging_node_constraints (including change in the functionality of this method), and put AssemblerData into Assembler back again. git-svn-id: https://svn.dealii.org/trunk@1148 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/Attic/examples/dof/dof_test.cc | 3 +- .../Attic/examples/multigrid/multigrid.cc | 33 +++-- deal.II/deal.II/include/dofs/dof_handler.h | 26 ++-- deal.II/deal.II/include/dofs/dof_levels.h | 3 +- deal.II/deal.II/include/numerics/assembler.h | 135 +++++++++--------- deal.II/deal.II/source/dofs/dof_handler.cc | 20 +-- deal.II/deal.II/source/numerics/assembler.cc | 23 ++- deal.II/deal.II/source/numerics/base.cc | 15 +- deal.II/deal.II/source/numerics/matrices.cc | 32 ++--- deal.II/deal.II/source/numerics/vectors.cc | 10 +- tests/big-tests/dof/dof_test.cc | 3 +- tests/big-tests/multigrid/multigrid.cc | 33 +++-- 12 files changed, 177 insertions(+), 159 deletions(-) diff --git a/deal.II/deal.II/Attic/examples/dof/dof_test.cc b/deal.II/deal.II/Attic/examples/dof/dof_test.cc index 1c67685601..cc8a9f83f5 100644 --- a/deal.II/deal.II/Attic/examples/dof/dof_test.cc +++ b/deal.II/deal.II/Attic/examples/dof/dof_test.cc @@ -372,7 +372,8 @@ void TestCases::run (ParameterHandler &prm) { // computing constraints cout << " Computing constraints..." << endl; ConstraintMatrix constraints; - dof->make_constraint_matrix (constraints); + dof->make_hanging_node_constraints (constraints); + constraints.close (); constraints.condense (sparsity); cout << " Writing condensed sparsity pattern..." << endl; diff --git a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc index 6270ca3864..f5433c5899 100644 --- a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc +++ b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include @@ -336,10 +338,16 @@ void PoissonProblem::assemble (const Equation &equation, // make up sparsity pattern and // compress with constraints constraints.clear (); - dof->DoFHandler::make_constraint_matrix (constraints); + dof->DoFHandler::make_hanging_node_constraints (constraints); + constraints.close (); dof->DoFHandler::make_sparsity_pattern (system_sparsity); constraints.condense (system_sparsity); + MGTransferPrebuilt p; + p.build_matrices (*dof); +// MGSmoother smoother(*dof); + + // reinite system matrix system_matrix.reinit (system_sparsity); // reinit solution vector, preset @@ -347,12 +355,12 @@ void PoissonProblem::assemble (const Equation &equation, solution.reinit (dof->DoFHandler::n_dofs()); // create assembler - AssemblerData data (*dof, - true, true, //assemble matrix and rhs - system_matrix, - right_hand_side, - quadrature, - update_flags); + Assembler::AssemblerData data (*dof, + 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(), @@ -416,13 +424,11 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hyper_ball (); - HyperBallBoundary boundary_description; - tria->set_boundary (&boundary_description); + tria->create_hypercube (); + tria->refine_global (level+1); tria->begin_active()->set_refine_flag(); (++(++(tria->begin_active())))->set_refine_flag(); tria->execute_coarsening_and_refinement (); - tria->refine_global (level); cout << tria->n_active_cells() << " active cells." << endl; rhs = new RHSPoly(); @@ -575,11 +581,14 @@ int PoissonProblem::run (const unsigned int level) { cout << endl; + const unsigned int n_dofs = dof->DoFHandler::n_dofs(); + dof->clear (); + tria->set_boundary (0); delete fe; delete quadrature; delete boundary_quadrature; - return dof->DoFHandler::n_dofs(); + return n_dofs; }; diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index 5c8bac3232..b32a35c04a 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -588,8 +588,11 @@ class DoFHandler : public DoFDimensionInfo { void renumber_dofs (const vector &new_numbers); /** - * Make up the constraint matrix which - * is used to condensate the global + * Make up the constraints which + * is result from the use of hanging + * nodes. The object into which these + * are inserted is later + * used to condensate the global * system matrices and to prolong * the solution vectors from the true * degrees of freedom also to the @@ -597,21 +600,26 @@ class DoFHandler : public DoFDimensionInfo { * * Since this method does not make sense in * one dimension, the function returns - * immediately after clearing the - * constraint matrix. - * For more than one dimension, the matrix - * is cleared before usage. The constraint - * matrix is closed anyway, no matter of the - * dimension. + * immediately. The object is not cleared + * before use, so you should make sure + * it containts only constraints you still + * want; otherwise call the #clear# + * function. * * To condense a given sparsity pattern, * use #ConstraintMatrix::condense#. + * Before doing so, you need to close + * the constraint object, which must be + * done after all constraints are entered. + * This function does not close the object + * since you may want to enter other + * constraints later on yourself. * * This function uses the user flags for * the faces. If you need the user flags, * store them beforehand. */ - void make_constraint_matrix (ConstraintMatrix &) const; + void make_hanging_node_constraints (ConstraintMatrix &) const; /** diff --git a/deal.II/deal.II/include/dofs/dof_levels.h b/deal.II/deal.II/include/dofs/dof_levels.h index 0cb5c84a6e..e864a533ca 100644 --- a/deal.II/deal.II/include/dofs/dof_levels.h +++ b/deal.II/deal.II/include/dofs/dof_levels.h @@ -52,7 +52,8 @@ class DoFLevel { * $\ldots, u_1^m, u_2^m, u_1^{m+1}, u_2^{m+1},\ldots$ with $m$ denoting the * $m$th basis function, or $\ldots, u_1^m, u_1^{m+1}, u_1^{m+2}, \ldots, * u_2^m, u_2^{m+1}, u_2^{m+2}, \ldots$, respectively). Likewise, the - * constraint matrix returned by #DoFHandler::make_constraint_matrix ()# is then + * constraint matrix returned by #DoFHandler::make_hanging_node_constraints ()# + * is then * to be understood as a block matrix. * * The storage format of the degrees of freedom indices (short: DoF indices) is diff --git a/deal.II/deal.II/include/numerics/assembler.h b/deal.II/deal.II/include/numerics/assembler.h index f7fd813519..dfa367f789 100644 --- a/deal.II/deal.II/include/numerics/assembler.h +++ b/deal.II/deal.II/include/numerics/assembler.h @@ -124,73 +124,6 @@ class Equation { -/** - * Structure to be passed upon - * construction of an assembler object - * through the iterator object. See - * \Ref{TriaRawIterator} for a discussion - * of this mechanism. - */ -template -struct AssemblerData { - /** - * Constructor. - */ - AssemblerData (const DoFHandler &dof, - const bool assemble_matrix, - const bool assemble_rhs, - SparseMatrix &matrix, - Vector &rhs_vector, - const Quadrature &quadrature, - const UpdateFlags &update_flags); - - /** - * Pointer to the dof handler object - * to be used to iterate on. - */ - const DoFHandler &dof; - - /** - * Flags whether to assemble the matrix - * and right hand sides. - */ - const bool assemble_matrix, assemble_rhs; - - /** - * Pointer to the matrix to be assembled - * by this object. Elements are summed - * up by the assembler, so you may want - * to clear this object (set all entries - * to zero) before use. - */ - SparseMatrix &matrix; - - /** - * Pointer to the vector to be assembled - * by this object. Elements are summed - * up by the assembler, so you may want - * to clear this object (set all entries - * to zero) before use. - */ - Vector &rhs_vector; - - /** - * Pointer to a quadrature object to be - * used for this assemblage process. - */ - const Quadrature &quadrature; - - /** - * Store which of the fields of the - * FEValues object need to be reinitialized - * on each cell. - */ - const UpdateFlags update_flags; -}; - - - - /** * An #Assembler# is a specialized version of a #DoFCellAccessor# which adds * functionality to assemble global matrices and vectors from cell base ones. @@ -200,12 +133,78 @@ struct AssemblerData { template class Assembler : public DoFCellAccessor { public: + + /** + * Structure to be passed upon + * construction of an assembler object + * through the iterator object. See + * \Ref{TriaRawIterator} for a discussion + * of this mechanism. + */ + struct AssemblerData { + /** + * Constructor. + */ + AssemblerData (const DoFHandler &dof, + const bool assemble_matrix, + const bool assemble_rhs, + SparseMatrix &matrix, + Vector &rhs_vector, + const Quadrature &quadrature, + const UpdateFlags &update_flags); + + /** + * Pointer to the dof handler object + * to be used to iterate on. + */ + const DoFHandler &dof; + + /** + * Flags whether to assemble the matrix + * and right hand sides. + */ + const bool assemble_matrix, assemble_rhs; + + /** + * Pointer to the matrix to be assembled + * by this object. Elements are summed + * up by the assembler, so you may want + * to clear this object (set all entries + * to zero) before use. + */ + SparseMatrix &matrix; + + /** + * Pointer to the vector to be assembled + * by this object. Elements are summed + * up by the assembler, so you may want + * to clear this object (set all entries + * to zero) before use. + */ + Vector &rhs_vector; + + /** + * Pointer to a quadrature object to be + * used for this assemblage process. + */ + const Quadrature &quadrature; + + /** + * Store which of the fields of the + * FEValues object need to be reinitialized + * on each cell. + */ + const UpdateFlags update_flags; + }; + + + /** * Declare the data type that this accessor * class expects to get passed from the * iterator classes. */ - typedef AssemblerData AccessorData; + typedef AssemblerData AccessorData; /** * Default constructor, unused thus not diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index b515b8494f..982dae0a86 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -1576,7 +1576,8 @@ void DoFHandler::renumber_dofs (const RenumberingMethod method, if (use_constraints) { ConstraintMatrix constraints; - make_constraint_matrix (constraints); + make_hanging_node_constraints (constraints); + constraints.close (); constraints.condense (sparsity); }; @@ -1920,10 +1921,7 @@ void DoFHandler<3>::renumber_dofs (const vector &new_numbers) { #if deal_II_dimension == 1 template <> -void DoFHandler<1>::make_constraint_matrix (ConstraintMatrix &cm) const { - cm.clear (); - cm.close (); -}; +void DoFHandler<1>::make_hanging_node_constraints (ConstraintMatrix &) const {}; #endif @@ -1932,11 +1930,9 @@ void DoFHandler<1>::make_constraint_matrix (ConstraintMatrix &cm) const { #if deal_II_dimension == 2 template <> -void DoFHandler<2>::make_constraint_matrix (ConstraintMatrix &constraints) const { +void DoFHandler<2>::make_hanging_node_constraints (ConstraintMatrix &constraints) const { const unsigned int dim = 2; - constraints.clear (); - // first mark all faces which are subject // to constraints. We do so by looping // over all active cells and checking @@ -2013,8 +2009,6 @@ void DoFHandler<2>::make_constraint_matrix (ConstraintMatrix &constraints) const selected_fe->constraints()(row,i)); }; }; - - constraints.close (); }; #endif @@ -2024,11 +2018,9 @@ void DoFHandler<2>::make_constraint_matrix (ConstraintMatrix &constraints) const #if deal_II_dimension == 3 template <> -void DoFHandler<3>::make_constraint_matrix (ConstraintMatrix &constraints) const { +void DoFHandler<3>::make_hanging_node_constraints (ConstraintMatrix &constraints) const { const unsigned int dim = 3; - constraints.clear (); - // first mark all faces which are subject // to constraints. We do so by looping // over all active cells and checking @@ -2170,8 +2162,6 @@ void DoFHandler<3>::make_constraint_matrix (ConstraintMatrix &constraints) const selected_fe->constraints()(row,i)); }; }; - - constraints.close (); }; #endif diff --git a/deal.II/deal.II/source/numerics/assembler.cc b/deal.II/deal.II/source/numerics/assembler.cc index ed7ac2a37a..d6467cc194 100644 --- a/deal.II/deal.II/source/numerics/assembler.cc +++ b/deal.II/deal.II/source/numerics/assembler.cc @@ -47,13 +47,13 @@ void Equation::assemble (Vector &, template -AssemblerData::AssemblerData (const DoFHandler &dof, - const bool assemble_matrix, - const bool assemble_rhs, - SparseMatrix &matrix, - Vector &rhs_vector, - const Quadrature &quadrature, - const UpdateFlags &update_flags) : +Assembler::AssemblerData::AssemblerData (const DoFHandler &dof, + const bool assemble_matrix, + const bool assemble_rhs, + SparseMatrix &matrix, + Vector &rhs_vector, + const Quadrature &quadrature, + const UpdateFlags &update_flags) : dof(dof), assemble_matrix(assemble_matrix), assemble_rhs(assemble_rhs), @@ -67,10 +67,10 @@ AssemblerData::AssemblerData (const DoFHandler &dof, template -Assembler::Assembler (Triangulation *tria, - const int level, - const int index, - const AssemblerData *local_data) : +Assembler::Assembler (Triangulation *tria, + const int level, + const int index, + const AssemblerData *local_data) : DoFCellAccessor (tria,level,index, &local_data->dof), cell_matrix (dof_handler->get_fe().total_dofs), cell_vector (Vector(dof_handler->get_fe().total_dofs)), @@ -148,7 +148,6 @@ void Assembler::assemble (const Equation &equation) { // explicit instantiations template class Equation; template class Assembler; -template class AssemblerData; template class TriaRawIterator >; template class TriaIterator >; diff --git a/deal.II/deal.II/source/numerics/base.cc b/deal.II/deal.II/source/numerics/base.cc index 3f25d01f2c..387be6b1c5 100644 --- a/deal.II/deal.II/source/numerics/base.cc +++ b/deal.II/deal.II/source/numerics/base.cc @@ -84,7 +84,8 @@ void ProblemBase::assemble (const Equation &equation, // make up sparsity pattern and // compress with constraints constraints.clear (); - dof_handler->make_constraint_matrix (constraints); + dof_handler->make_hanging_node_constraints (constraints); + constraints.close (); dof_handler->make_sparsity_pattern (system_sparsity); constraints.condense (system_sparsity); @@ -95,12 +96,12 @@ void ProblemBase::assemble (const Equation &equation, solution.reinit (dof_handler->n_dofs()); // create assembler - AssemblerData data (*dof_handler, - true, true, //assemble matrix and rhs - system_matrix, - right_hand_side, - quadrature, - update_flags); + 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(), diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 6b237b7d43..9f71473f8f 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -28,10 +28,10 @@ void MatrixCreator::create_mass_matrix (const DoFHandler &dof, UpdateFlags update_flags = update_JxW_values; if (a != 0) update_flags = UpdateFlags (update_flags | update_q_points); - const AssemblerData data (dof, - true, false, // assemble matrix but not rhs - matrix, dummy, - q, update_flags); + const Assembler::AssemblerData data (dof, + true, false, // assemble matrix but not rhs + matrix, dummy, + q, update_flags); TriaActiveIterator > assembler (const_cast*>(&dof.get_tria()), dof.get_tria().begin_active()->level(), @@ -57,10 +57,10 @@ void MatrixCreator::create_mass_matrix (const DoFHandler &dof, const Function * const a) { UpdateFlags update_flags = UpdateFlags(update_q_points | update_JxW_values); - const AssemblerData data (dof, - true, true, - matrix, rhs_vector, - q, update_flags); + const Assembler::AssemblerData data (dof, + true, true, + matrix, rhs_vector, + q, update_flags); TriaActiveIterator > assembler (const_cast*>(&dof.get_tria()), dof.get_tria().begin_active()->level(), @@ -323,10 +323,10 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, update_JxW_values); if (a != 0) update_flags = UpdateFlags(update_flags | update_q_points); - const AssemblerData data (dof, - true, false, // assemble matrix but not rhs - matrix, dummy, - q, update_flags); + const Assembler::AssemblerData data (dof, + true, false, // assemble matrix but not rhs + matrix, dummy, + q, update_flags); TriaActiveIterator > assembler (const_cast*>(&dof.get_tria()), dof.get_tria().begin_active()->level(), @@ -352,10 +352,10 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, UpdateFlags update_flags = UpdateFlags(update_q_points | update_gradients | update_JxW_values); - const AssemblerData data (dof, - true, true, - matrix, rhs_vector, - q, update_flags); + const Assembler::AssemblerData data (dof, + true, true, + matrix, rhs_vector, + q, update_flags); TriaActiveIterator > assembler (const_cast*>(&dof.get_tria()), dof.get_tria().begin_active()->level(), diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index 6faf714ff5..bc6767ce41 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -220,10 +220,10 @@ void VectorTools::create_right_hand_side (const DoFHandler &dof, UpdateFlags update_flags = UpdateFlags(update_q_points | update_JxW_values); SparseMatrix dummy; - const AssemblerData data (dof, - false, true, - dummy, rhs_vector, - quadrature, update_flags); + const Assembler::AssemblerData data (dof, + false, true, + dummy, rhs_vector, + quadrature, update_flags); TriaActiveIterator > assembler (const_cast*>(&dof.get_tria()), dof.get_tria().begin_active()->level(), @@ -360,7 +360,7 @@ void VectorTools::project_boundary_values (const DoFHandler &dof, const FunctionMap &boundary_functions, const Quadrature &q, - map &boundary_values) { + map &boundary_values) { vector dof_to_boundary_mapping; dof.map_dof_to_boundary_indices (boundary_functions, dof_to_boundary_mapping); diff --git a/tests/big-tests/dof/dof_test.cc b/tests/big-tests/dof/dof_test.cc index 1c67685601..cc8a9f83f5 100644 --- a/tests/big-tests/dof/dof_test.cc +++ b/tests/big-tests/dof/dof_test.cc @@ -372,7 +372,8 @@ void TestCases::run (ParameterHandler &prm) { // computing constraints cout << " Computing constraints..." << endl; ConstraintMatrix constraints; - dof->make_constraint_matrix (constraints); + dof->make_hanging_node_constraints (constraints); + constraints.close (); constraints.condense (sparsity); cout << " Writing condensed sparsity pattern..." << endl; diff --git a/tests/big-tests/multigrid/multigrid.cc b/tests/big-tests/multigrid/multigrid.cc index 6270ca3864..f5433c5899 100644 --- a/tests/big-tests/multigrid/multigrid.cc +++ b/tests/big-tests/multigrid/multigrid.cc @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include @@ -336,10 +338,16 @@ void PoissonProblem::assemble (const Equation &equation, // make up sparsity pattern and // compress with constraints constraints.clear (); - dof->DoFHandler::make_constraint_matrix (constraints); + dof->DoFHandler::make_hanging_node_constraints (constraints); + constraints.close (); dof->DoFHandler::make_sparsity_pattern (system_sparsity); constraints.condense (system_sparsity); + MGTransferPrebuilt p; + p.build_matrices (*dof); +// MGSmoother smoother(*dof); + + // reinite system matrix system_matrix.reinit (system_sparsity); // reinit solution vector, preset @@ -347,12 +355,12 @@ void PoissonProblem::assemble (const Equation &equation, solution.reinit (dof->DoFHandler::n_dofs()); // create assembler - AssemblerData data (*dof, - true, true, //assemble matrix and rhs - system_matrix, - right_hand_side, - quadrature, - update_flags); + Assembler::AssemblerData data (*dof, + 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(), @@ -416,13 +424,11 @@ int PoissonProblem::run (const unsigned int level) { cout << ">" << endl; cout << " Making grid... "; - tria->create_hyper_ball (); - HyperBallBoundary boundary_description; - tria->set_boundary (&boundary_description); + tria->create_hypercube (); + tria->refine_global (level+1); tria->begin_active()->set_refine_flag(); (++(++(tria->begin_active())))->set_refine_flag(); tria->execute_coarsening_and_refinement (); - tria->refine_global (level); cout << tria->n_active_cells() << " active cells." << endl; rhs = new RHSPoly(); @@ -575,11 +581,14 @@ int PoissonProblem::run (const unsigned int level) { cout << endl; + const unsigned int n_dofs = dof->DoFHandler::n_dofs(); + dof->clear (); + tria->set_boundary (0); delete fe; delete quadrature; delete boundary_quadrature; - return dof->DoFHandler::n_dofs(); + return n_dofs; }; -- 2.39.5