From 2144b116727b4d58aff563e41158a0f698b0474c Mon Sep 17 00:00:00 2001 From: frohne Date: Tue, 18 Oct 2011 19:13:38 +0000 Subject: [PATCH] Active-Set-method works with constraints git-svn-id: https://svn.dealii.org/trunk@24637 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-41/step-41.cc | 60 ++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/deal.II/examples/step-41/step-41.cc b/deal.II/examples/step-41/step-41.cc index 9d32583279..6ae88cbfd3 100644 --- a/deal.II/examples/step-41/step-41.cc +++ b/deal.II/examples/step-41/step-41.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -260,7 +261,7 @@ template double Obstacle::value (const Point &p, const unsigned int /*component*/) const { - return p.square() - 0.5; + return 2.0*p.square() - 0.5; } @@ -378,7 +379,8 @@ void Step4::setup_system () << std::endl; CompressedSparsityPattern c_sparsity(dof_handler.n_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, c_sparsity); + DoFTools::make_sparsity_pattern (dof_handler, c_sparsity, constraints, false); +// c_sparsity.compress (); sparsity_pattern.copy_from(c_sparsity); system_matrix.reinit (sparsity_pattern); @@ -582,8 +584,6 @@ void Step4::assemble_system () local_dof_indices, system_matrix, system_rhs); } - - std::cout<< "Norm of RHS: " << system_rhs.l2_norm () <::projection_active_set () double obstacle_value = obstacle.value (point); if (solution (index_x) >= obstacle_value && resid_vector (index_x) <= 0) { - constraints.add_line (index_x); constraints.set_inhomogeneity (index_x, obstacle_value); - solution (index_x) = obstacle_value; + solution (index_x) = 0; active_set (index_x) = 1; } } @@ -694,18 +693,16 @@ void Step4::solve () { ReductionControl reduction_control (100, 1e-12, 1e-2); SolverCG<> solver (reduction_control); + SolverBicgstab<> solver_bicgstab (reduction_control); PreconditionSSOR > precondition; - precondition.initialize (system_matrix, 1.5); + precondition.initialize (system_matrix, 1.2); + solver.solve (system_matrix, solution, system_rhs, precondition); - // PreconditionIdentity()); - // We have made one addition, - // though: since we suppress output - // from the linear solvers, we have - // to print the number of - // iterations by hand. + std::cout << "Initial error: " << reduction_control.initial_value() <::run () make_grid(); setup_system (); - std::cout<< "Update Active Set in Dim = " << dim <(), + constraints); + constraints.close (); + ConstraintMatrix constraints_complete (constraints); + assemble_system (); + + system_matrix_complete.copy_from (system_matrix); + system_rhs_complete = system_rhs; + + std::cout<< "Update Active Set:" <::run () break; } - std::cout<< "Update Active Set in Dim = " << dim <