8 #ifndef INCLUDE_IDEAL_II_DOFS_SLAB_DOF_TOOLS_HH_
9 #define INCLUDE_IDEAL_II_DOFS_SLAB_DOF_TOOLS_HH_
11 #include <ideal.II/dofs/slab_dof_handler.hh>
13 #include <ideal.II/fe/fe_dg.hh>
15 #include <deal.II/base/types.h>
17 #include <deal.II/dofs/dof_tools.h>
19 #include <deal.II/lac/dynamic_sparsity_pattern.h>
27 upwind_temporal_pattern(DoFHandler<dim> &dof,
28 dealii::DynamicSparsityPattern &time_dsp)
30 dealii::DoFTools::make_sparsity_pattern(*dof.temporal(), time_dsp);
31 if (dof.fe_support_type() ==
32 spacetime::DG_FiniteElement<dim>::support_type::Lobatto)
34 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
35 ii < dof.n_dofs_time();
36 ii += dof.dofs_per_cell_time())
38 time_dsp.add(ii, ii - 1);
41 else if (dof.fe_support_type() ==
42 spacetime::DG_FiniteElement<dim>::support_type::RadauLeft)
44 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
45 ii < dof.n_dofs_time();
46 ii += dof.dofs_per_cell_time())
48 for (dealii::types::global_dof_index l = 0;
49 l < dof.dofs_per_cell_time();
52 time_dsp.add(ii, ii - l - 1);
56 else if (dof.fe_support_type() ==
57 spacetime::DG_FiniteElement<dim>::support_type::RadauRight)
59 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
60 ii < dof.n_dofs_time();
61 ii += dof.dofs_per_cell_time())
63 for (dealii::types::global_dof_index k = 0;
64 k < dof.dofs_per_cell_time();
67 time_dsp.add(ii + k, ii - 1);
74 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
75 ii < dof.n_dofs_time();
76 ii += dof.dofs_per_cell_time())
79 for (dealii::types::global_dof_index k = 0;
80 k < dof.dofs_per_cell_time();
83 for (dealii::types::global_dof_index l = 0;
84 l < dof.dofs_per_cell_time();
87 time_dsp.add(ii + k, ii - l - 1);
95 downwind_temporal_pattern(DoFHandler<dim> &dof,
96 dealii::DynamicSparsityPattern &time_dsp)
98 dealii::DoFTools::make_sparsity_pattern(*dof.temporal(), time_dsp);
99 if (dof.fe_support_type() ==
100 spacetime::DG_FiniteElement<dim>::support_type::Lobatto)
102 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
103 ii < dof.n_dofs_time();
104 ii += dof.dofs_per_cell_time())
106 time_dsp.add(ii - 1, ii);
109 else if (dof.fe_support_type() ==
110 spacetime::DG_FiniteElement<dim>::support_type::RadauRight)
112 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
113 ii < dof.n_dofs_time();
114 ii += dof.dofs_per_cell_time())
116 for (dealii::types::global_dof_index k = 0;
117 k < dof.dofs_per_cell_time();
120 time_dsp.add(ii - 1, ii + k);
124 else if (dof.fe_support_type() ==
125 spacetime::DG_FiniteElement<dim>::support_type::RadauLeft)
127 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
128 ii < dof.n_dofs_time();
129 ii += dof.dofs_per_cell_time())
131 for (dealii::types::global_dof_index l = 0;
132 l < dof.dofs_per_cell_time();
135 time_dsp.add(ii - l - 1, ii);
142 for (dealii::types::global_dof_index ii = dof.dofs_per_cell_time();
143 ii < dof.n_dofs_time();
144 ii += dof.dofs_per_cell_time())
147 for (dealii::types::global_dof_index k = 0;
148 k < dof.dofs_per_cell_time();
151 for (dealii::types::global_dof_index l = 0;
152 l < dof.dofs_per_cell_time();
155 time_dsp.add(ii - l - 1, ii + k);
199 dealii::DynamicSparsityPattern &st_dsp,
200 std::shared_ptr<dealii::AffineConstraints<double>> space_constraints =
201 std::make_shared<dealii::AffineConstraints<double>>(),
202 const bool keep_constrained_dofs =
true)
204 dealii::DynamicSparsityPattern space_dsp(dof.
n_dofs_space());
205 dealii::DoFTools::make_sparsity_pattern(*dof.
spatial(),
208 keep_constrained_dofs);
210 dealii::DynamicSparsityPattern time_dsp(dof.
n_dofs_time());
211 internal::upwind_temporal_pattern(dof, time_dsp);
213 for (
auto &space_entry : space_dsp)
215 for (
auto &time_entry : time_dsp)
242 const dealii::Table<2, dealii::DoFTools::Coupling> &space_couplings,
243 dealii::DynamicSparsityPattern &st_dsp,
244 std::shared_ptr<dealii::AffineConstraints<double>> space_constraints =
245 std::make_shared<dealii::AffineConstraints<double>>(),
246 const bool keep_constrained_dofs =
true)
248 dealii::DynamicSparsityPattern space_dsp(dof.
n_dofs_space());
249 dealii::DoFTools::make_sparsity_pattern(*dof.
spatial(),
253 keep_constrained_dofs);
255 dealii::DynamicSparsityPattern time_dsp(dof.
n_dofs_time());
256 internal::upwind_temporal_pattern(dof, time_dsp);
258 for (
auto &space_entry : space_dsp)
260 for (
auto &time_entry : time_dsp)
307 dealii::DynamicSparsityPattern &st_dsp,
308 std::shared_ptr<dealii::AffineConstraints<double>> space_constraints =
309 std::make_shared<dealii::AffineConstraints<double>>(),
310 const bool keep_constrained_dofs =
true)
312 dealii::DynamicSparsityPattern space_dsp(dof.
n_dofs_space());
313 dealii::DoFTools::make_sparsity_pattern(*dof.
spatial(),
316 keep_constrained_dofs);
318 dealii::DynamicSparsityPattern time_dsp(dof.
n_dofs_time());
319 internal::downwind_temporal_pattern(dof, time_dsp);
321 for (
auto &space_entry : space_dsp)
323 for (
auto &time_entry : time_dsp)
350 const dealii::Table<2, dealii::DoFTools::Coupling> &space_couplings,
351 dealii::DynamicSparsityPattern &st_dsp,
352 std::shared_ptr<dealii::AffineConstraints<double>> space_constraints =
353 std::make_shared<dealii::AffineConstraints<double>>(),
354 const bool keep_constrained_dofs =
true)
356 dealii::DynamicSparsityPattern space_dsp(dof.
n_dofs_space());
357 dealii::DoFTools::make_sparsity_pattern(*dof.
spatial(),
361 keep_constrained_dofs);
363 dealii::DynamicSparsityPattern time_dsp(dof.
n_dofs_time());
364 internal::downwind_temporal_pattern(dof, time_dsp);
366 for (
auto &space_entry : space_dsp)
368 for (
auto &time_entry : time_dsp)
391 template <
int dim,
typename Number>
395 std::shared_ptr<dealii::AffineConstraints<Number>> spacetime_constraints)
397 auto space_constraints =
398 std::make_shared<dealii::AffineConstraints<Number>>();
399 dealii::DoFTools::make_hanging_node_constraints(*dof_handler.
spatial(),
403 for (
unsigned int time_dof = 0; time_dof < dof_handler.
n_dofs_time();
406 for (
unsigned int i = 0; i < n_space_dofs; i++)
408 if (space_constraints->is_constrained(i))
411 std::pair<dealii::types::global_dof_index, double>> *entries =
412 space_constraints->get_constraint_entries(i);
413 spacetime_constraints->add_line(i + time_dof * n_space_dofs);
415 if (entries->size() > 0)
417 for (
auto entry : *entries)
419 spacetime_constraints->add_entry(
420 i + time_dof * n_space_dofs,
421 entry.first + time_dof * n_space_dofs,
427 spacetime_constraints->set_inhomogeneity(
428 i + time_dof * n_space_dofs,
429 space_constraints->get_inhomogeneity(i));
448 template <
int dim,
typename Number>
451 dealii::IndexSet &space_relevant_dofs,
453 std::shared_ptr<dealii::AffineConstraints<Number>> spacetime_constraints)
455 auto space_constraints =
456 std::make_shared<dealii::AffineConstraints<Number>>();
457 space_constraints->reinit(space_relevant_dofs);
458 dealii::DoFTools::make_hanging_node_constraints(*dof_handler.
spatial(),
462 for (
unsigned int time_dof = 0; time_dof < dof_handler.
n_dofs_time();
465 for (
auto id = space_relevant_dofs.begin();
466 id != space_relevant_dofs.end();
469 if (space_constraints->is_constrained(*
id))
472 std::pair<dealii::types::global_dof_index, double>> *entries =
473 space_constraints->get_constraint_entries(*
id);
475 spacetime_constraints->add_line(*
id + time_dof * n_space_dofs);
477 if (entries->size() > 0)
479 for (
auto entry : *entries)
481 spacetime_constraints->add_entry(
482 *
id + time_dof * n_space_dofs,
483 entry.first + time_dof * n_space_dofs,
489 spacetime_constraints->set_inhomogeneity(
490 *
id + time_dof * n_space_dofs,
491 space_constraints->get_inhomogeneity(*
id));
509 dealii::IndexSet space_relevant_dofs;
510 dealii::DoFTools::extract_locally_relevant_dofs(*dof_handler.
spatial(),
511 space_relevant_dofs);
513 dealii::IndexSet spacetime_relevant_dofs(space_relevant_dofs.size() *
516 for (dealii::types::global_dof_index time_dof_index = 0;
520 spacetime_relevant_dofs.add_indices(
526 return spacetime_relevant_dofs;
Actual DoFHandler for a specific slab.
Definition: slab_dof_handler.hh:43
unsigned int n_dofs_time()
Number of temporal degrees of fredom on this slab.
std::shared_ptr< dealii::DoFHandler< dim > > spatial()
The underlying spatial dof handler.
unsigned int n_dofs_space()
Number of spatial degrees of fredom on this slab.