111 std::vector<types::global_cell_index> idxs_to_be_agglomerated = {0, 1, 2, 3};
113 std::vector<typename Triangulation<dim>::active_cell_iterator>
114 cells_to_be_agglomerated;
117 idxs_to_be_agglomerated,
118 cells_to_be_agglomerated);
120 std::vector<types::global_cell_index> idxs_to_be_agglomerated2 = {4, 5, 6, 7};
122 std::vector<typename Triangulation<dim>::active_cell_iterator>
123 cells_to_be_agglomerated2;
125 idxs_to_be_agglomerated2,
126 cells_to_be_agglomerated2);
128 std::vector<types::global_cell_index> idxs_to_be_agglomerated3 = {8,
133 std::vector<typename Triangulation<dim>::active_cell_iterator>
134 cells_to_be_agglomerated3;
136 idxs_to_be_agglomerated3,
137 cells_to_be_agglomerated3);
139 std::vector<types::global_cell_index> idxs_to_be_agglomerated4 = {12,
144 std::vector<typename Triangulation<dim>::active_cell_iterator>
145 cells_to_be_agglomerated4;
147 idxs_to_be_agglomerated4,
148 cells_to_be_agglomerated4);
150 ah = std::make_unique<AgglomerationHandler<dim>>(*cached_tria);
151 ah->define_agglomerate(cells_to_be_agglomerated);
152 ah->define_agglomerate(cells_to_be_agglomerated2);
153 ah->define_agglomerate(cells_to_be_agglomerated3);
154 ah->define_agglomerate(cells_to_be_agglomerated4);
155 ah->distribute_agglomerated_dofs(dg_fe);
156 ah->create_agglomeration_sparsity_pattern(sparsity);
167 std::ofstream out(
"grid_coarsen.vtk");
170 std::cout <<
"Grid written " << std::endl;
179 const unsigned int f)
181 if (cell->face(f)->at_boundary())
183 std::cout <<
"at boundary" << std::endl;
187 std::vector<types::global_dof_index> local_dof_indices_bdary_cell(
189 const double hf = cell->face(f)->measure();
196 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
198 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
202 fe_face.
shape_grad(j, q_index) * normals[q_index] -
203 fe_face.
shape_grad(i, q_index) * normals[q_index] *
207 fe_face.
JxW(q_index);
213 cell->get_dof_indices(local_dof_indices_bdary_cell);
214 system_matrix.add(local_dof_indices_bdary_cell, cell_matrix);
219 fe_face1.
reinit(cell->neighbor(f), cell->neighbor_of_neighbor(f));
222 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
223 std::vector<types::global_dof_index> local_dof_indices1(dofs_per_cell);
225 const double hf = cell->face(f)->measure();
237 std::cout << normals[q_index] << std::endl;
238 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
240 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
243 (-0.5 * fe_face.
shape_grad(i, q_index) * normals[q_index] *
245 0.5 * fe_face.
shape_grad(j, q_index) * normals[q_index] *
249 fe_face.
JxW(q_index);
256 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
258 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
261 (+0.5 * fe_face.
shape_grad(i, q_index) * normals[q_index] *
263 0.5 * fe_face1.
shape_grad(j, q_index) * normals[q_index] *
267 fe_face1.
JxW(q_index);
274 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
276 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
279 (+0.5 * fe_face1.
shape_grad(i, q_index) * normals[q_index] *
281 0.5 * fe_face.
shape_grad(j, q_index) * normals[q_index] *
283 (penalty / hf) * fe_face1.
shape_value(i, q_index) *
285 fe_face1.
JxW(q_index);
292 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
294 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
297 (-0.5 * fe_face1.
shape_grad(i, q_index) * normals[q_index] *
299 0.5 * fe_face1.
shape_grad(j, q_index) * normals[q_index] *
301 (penalty / hf) * fe_face1.
shape_value(i, q_index) *
303 fe_face1.
JxW(q_index);
309 cell->get_dof_indices(local_dof_indices);
315 std::cout <<
"Neighbor is " << neigh_dh->active_cell_index() << std::endl;
316 neigh_dh->get_dof_indices(local_dof_indices1);
318 system_matrix.add(local_dof_indices, A_00);
319 system_matrix.add(local_dof_indices, local_dof_indices1, A_01);
320 system_matrix.add(local_dof_indices1, local_dof_indices, A_10);
321 system_matrix.add(local_dof_indices1, A_11);
331 sparsity.copy_from(dsp);
333 system_matrix.reinit(sparsity);
334 solution.reinit(classical_dh.n_dofs());
335 system_rhs.reinit(classical_dh.n_dofs());
337 const unsigned int quadrature_degree = 3;
361 const unsigned int dofs_per_cell = dg_fe.n_dofs_per_cell();
366 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
550 for (
const auto &cell : classical_dh.active_cell_iterators())
552 std::cout <<
"Standard cell with idx: " << cell->active_cell_index()
560 const unsigned int n_qpoints = q_points.size();
561 std::vector<double> rhs(n_qpoints);
562 rhs_function->value_list(q_points, rhs);
566 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
568 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
570 cell_matrix(i, j) += fe_values.
shape_grad(i, q_index) *
572 fe_values.
JxW(q_index);
574 cell_rhs(i) += fe_values.
shape_value(i, q_index) * rhs[q_index] *
575 fe_values.
JxW(q_index);
580 cell->get_dof_indices(local_dof_indices);
581 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
583 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
585 system_matrix.add(local_dof_indices[i],
586 local_dof_indices[j],
589 system_rhs(local_dof_indices[i]) += cell_rhs(i);
608 for (
const auto f : cell->face_indices())
614 std::cout <<
"Face index " << f <<
" is admissible!" << std::endl;
616 distribute_jumps_and_averages(fe_face, fe_face1, cell, f);