#include <deal.II/base/logstream.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/precondition.h>
template<int dim>
void HeatEquation<dim>::setup_system()
{
-//TODO: we need to take care of constraints here! :-)
-
dof_handler.distribute_dofs(fe);
std::cout << std::endl
<< std::endl
<< std::endl;
- sparsity_pattern.reinit(dof_handler.n_dofs(),
- dof_handler.n_dofs(),
- dof_handler.max_couplings_between_dofs());
+ constraints.clear ();
+ DoFTools::make_hanging_node_constraints (dof_handler,
+ constraints);
+ constraints.close();
+
+ CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
DoFTools::make_sparsity_pattern(dof_handler,
- sparsity_pattern);
- sparsity_pattern.compress();
+ c_sparsity,
+ constraints,
+ /*keep_constrained_dofs = */ true);
+ sparsity_pattern.copy_from(c_sparsity);
mass_matrix.reinit(sparsity_pattern);
laplace_matrix.reinit(sparsity_pattern);
MatrixCreator::create_mass_matrix(dof_handler,
QGauss<dim>(fe.degree+1),
- mass_matrix);
+ mass_matrix,
+ (const Function<dim>*)0,
+ constraints);
MatrixCreator::create_laplace_matrix(dof_handler,
QGauss<dim>(fe.degree+1),
- laplace_matrix);
+ laplace_matrix,
+ (const Function<dim>*)0,
+ constraints);
solution.reinit(dof_handler.n_dofs());
old_solution.reinit(dof_handler.n_dofs());
system_rhs.reinit(dof_handler.n_dofs());
-
- constraints.close();
}
cg.solve(system_matrix, solution, system_rhs, preconditioner);
+ constraints.distribute(solution);
+
std::cout << " " << solver_control.last_step()
<< " CG iterations." << std::endl;
}
template<int dim>
void HeatEquation<dim>::run()
{
- const unsigned int initial_global_refinement = (dim == 2 ? 4 : 2);
- const unsigned int n_adaptive_pre_refinement_steps = 3;
+ const unsigned int initial_global_refinement = (dim == 2 ? 1 : 2);
+ const unsigned int n_adaptive_pre_refinement_steps = 1;
GridGenerator::hyper_L (triangulation);
triangulation.refine_global (initial_global_refinement);
system_rhs);
}
+ constraints.condense (system_rhs);
+
solve_time_step();
output_results();