42 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
44 typedef dealii::LinearAlgebra::distributed::Vector<typename Preconditioner::MultigridNumber>
47 CheckMultigrid(Operator
const & underlying_operator_in,
48 std::shared_ptr<Preconditioner> preconditioner_in,
49 MPI_Comm
const & mpi_comm_in)
50 : underlying_operator(underlying_operator_in),
51 preconditioner(preconditioner_in),
79 VectorType initial_solution;
80 underlying_operator.initialize_dof_vector(initial_solution);
81 VectorType solution_after_mg_cycle(initial_solution), tmp(initial_solution);
83 for(
unsigned int i = 0; i < initial_solution.locally_owned_size(); ++i)
84 initial_solution.local_element(i) = (double)rand() / RAND_MAX;
86 underlying_operator.vmult(tmp, initial_solution);
88 preconditioner->vmult(solution_after_mg_cycle, tmp);
89 solution_after_mg_cycle += initial_solution;
95 VectorTypeMG initial_solution_float;
96 initial_solution_float = initial_solution;
97 VectorTypeMG solution_after_smoothing, tmp_float;
98 solution_after_smoothing = initial_solution;
101 preconditioner->apply_smoother_on_fine_level(solution_after_smoothing, tmp_float);
102 solution_after_smoothing += initial_solution_float;
107 write_output(initial_solution, solution_after_mg_cycle, solution_after_smoothing);
116 write_output(VectorType
const & initial_solution,
117 VectorType
const & solution_after_mg_cycle,
118 VectorTypeMG
const & solution_after_smoothing)
const
121 output_data.filename =
"smoothing";
122 unsigned int const dof_index = underlying_operator.get_dof_index();
124 underlying_operator.get_matrix_free().get_dof_handler(dof_index).get_fe().degree;
128 unsigned int const n_components =
129 underlying_operator.get_matrix_free().get_dof_handler(dof_index).get_fe().n_components();
130 dealii::DoFHandler<dim>
const & dof_handler =
131 underlying_operator.get_matrix_free().get_dof_handler(dof_index);
132 if(n_components == 1)
134 vector_writer.add_data_vector(initial_solution, dof_handler, {
"initial"});
135 vector_writer.add_data_vector(solution_after_mg_cycle, dof_handler, {
"after_mg_cycle"});
136 vector_writer.add_data_vector(solution_after_smoothing, dof_handler, {
"after_smoothing"});
140 std::vector<bool> component_is_part_of_vector(dim,
true);
141 std::vector<std::string> component_names(dim,
"initial");
143 vector_writer.add_data_vector(initial_solution,
146 component_is_part_of_vector);
148 std::fill(component_names.begin(), component_names.end(),
"after_mg_cycle");
149 vector_writer.add_data_vector(solution_after_mg_cycle,
152 component_is_part_of_vector);
154 std::fill(component_names.begin(), component_names.end(),
"after_smoothing");
155 vector_writer.add_data_vector(solution_after_smoothing,
158 component_is_part_of_vector);
161 vector_writer.write_pvtu();
165 Operator
const & underlying_operator;
167 std::shared_ptr<Preconditioner> preconditioner;