This is the setup_system() function that has been changed just for the system_matrix in step-37.
dof_handler and fe are the names of the CG version and the DG versions end with "_DG"
system_matrix.clear();
mg_matrices.clear_elements();
dof_handler.distribute_dofs(fe);
dof_handler.distribute_mg_dofs();
dof_handler_DG.distribute_mg_dofs();
pcout << "Number of degrees of freedom: " << dof_handler.n_dofs()
<< std::endl;
const IndexSet locally_relevant_dofs =
DoFTools::extract_locally_relevant_dofs(dof_handler);
const IndexSet locally_relevant_dofs_DG =
DoFTools::extract_locally_relevant_dofs(dof_handler_DG);
constraints.clear();
constraints.reinit(locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler, constraints);
//VectorTools::interpolate_boundary_values(
//mapping, dof_handler, 0, Functions::ZeroFunction<dim>(), constraints);
constraints.close();
constraints_DG.clear();
constraints_DG.reinit(locally_relevant_dofs_DG);
DoFTools::make_hanging_node_constraints(dof_handler_DG, constraints_DG);
constraints_DG.close();
const std::vector<const DoFHandler<dim> *> dof_handlers = {&dof_handler_DG, &dof_handler};
const std::vector<const AffineConstraints<double> *> constraints_list = {&constraints_DG, &constraints};
setup_time += time.wall_time();
time_details << "Distribute DoFs & B.C. (CPU/wall) " << time.cpu_time()
<< "s/" << time.wall_time() << 's' << std::endl;
time.restart();
{
typename MatrixFree<dim, double>::AdditionalData additional_data;
additional_data.tasks_parallel_scheme =
MatrixFree<dim, double>::AdditionalData::none;
additional_data.mapping_update_flags =
(update_values | update_gradients | update_JxW_values | update_quadrature_points);
additional_data.mapping_update_flags_boundary_faces =
(update_values | update_JxW_values | update_quadrature_points);
std::shared_ptr<MatrixFree<dim, double>> system_mf_storage(
new MatrixFree<dim, double>());
system_mf_storage->reinit(mapping,
dof_handlers,
constraints_list,
QGauss<1>(fe.degree + 1),
additional_data);
system_matrix.initialize(system_mf_storage);
system_mf_storage->initialize_dof_vector(alpha_solution,1);
system_mf_storage->initialize_dof_vector(system_rhs,1);
}