1 #include <deal.II/dofs/dof_tools.h> 2 #include <deal.II/lac/dynamic_sparsity_pattern.h> 3 #include <deal.II/lac/sparsity_tools.h> 9 template <
int dim,
typename real,
typename MeshType>
12 return get_dRdX_sparsity_pattern ();
14 template <
int dim,
typename real,
typename MeshType>
17 dealii::DynamicSparsityPattern dsp(locally_relevant_dofs);
18 dealii::DoFTools::make_flux_sparsity_pattern(dof_handler, dsp);
19 dealii::SparsityTools::distribute_sparsity_pattern(dsp, dof_handler.locally_owned_dofs(), mpi_communicator, locally_relevant_dofs);
21 dealii::SparsityPattern sparsity_pattern;
22 sparsity_pattern.copy_from(dsp);
23 return sparsity_pattern;
26 template <
int dim,
typename real,
typename MeshType>
29 return get_dRdW_sparsity_pattern();
31 template <
int dim,
typename real,
typename MeshType>
34 dealii::IndexSet locally_relevant_dofs;
35 dealii::DoFTools::extract_locally_relevant_dofs(high_order_grid->dof_handler_grid, locally_relevant_dofs);
36 dealii::DynamicSparsityPattern dsp(locally_relevant_dofs);
37 dealii::DoFTools::make_flux_sparsity_pattern(high_order_grid->dof_handler_grid, dsp);
38 dealii::SparsityTools::distribute_sparsity_pattern(dsp, high_order_grid->dof_handler_grid.locally_owned_dofs(), mpi_communicator, locally_relevant_dofs);
40 dealii::SparsityPattern sparsity_pattern;
41 sparsity_pattern.copy_from(dsp);
42 return sparsity_pattern;
45 template <
int dim,
typename real,
typename MeshType>
48 const unsigned n_residuals = dof_handler.n_dofs();
49 const unsigned n_nodes_coeff = high_order_grid->dof_handler_grid.n_dofs();
50 const unsigned int n_rows = n_residuals;
51 const unsigned int n_cols = n_nodes_coeff;
53 dealii::DynamicSparsityPattern dsp(n_rows, n_cols);
55 const unsigned int n_node_cell = high_order_grid->fe_system.n_dofs_per_cell();
56 std::vector<dealii::types::global_dof_index> resi_indices;
57 std::vector<dealii::types::global_dof_index> node_indices(n_node_cell);
58 auto cell = dof_handler.begin_active();
59 auto metric_cell = high_order_grid->dof_handler_grid.begin_active();
60 for (; cell != dof_handler.end(); ++cell, ++metric_cell) {
61 if (!cell->is_locally_owned())
continue;
63 const unsigned int n_resi_cell = this->fe_collection[cell->active_fe_index()].n_dofs_per_cell();
64 resi_indices.resize(n_resi_cell);
65 cell->get_dof_indices (resi_indices);
67 metric_cell->get_dof_indices (node_indices);
68 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
69 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
71 for (
unsigned int iface=0; iface < dealii::GeometryInfo<dim>::faces_per_cell; ++iface) {
72 auto current_face = cell->face(iface);
74 if (current_face->at_boundary()) {
76 }
else if (current_face->has_children()) {
79 for (
unsigned int subface_no=0; subface_no < current_face->number_of_children(); ++subface_no) {
80 const auto neighbor_metric_cell = metric_cell->neighbor_child_on_subface (iface, subface_no);
81 neighbor_metric_cell->get_dof_indices (node_indices);
82 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
83 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
86 }
else if (cell->neighbor_is_coarser(iface)) {
89 const auto neighbor_metric_cell = metric_cell->neighbor (iface);
90 neighbor_metric_cell->get_dof_indices (node_indices);
91 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
92 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
98 if (dim == 1 && cell->neighbor(iface)->has_children()) {
99 const auto coarse_unactive_neighbor = metric_cell->neighbor (iface);
100 for (
unsigned int i_child=0; i_child < coarse_unactive_neighbor->n_children(); ++i_child) {
101 const auto neighbor_metric_cell = coarse_unactive_neighbor->child (i_child);
102 for (
unsigned int iface_child=0; iface_child < dealii::GeometryInfo<dim>::faces_per_cell; ++iface_child) {
103 if (neighbor_metric_cell->neighbor(iface_child) == metric_cell) {
104 neighbor_metric_cell->get_dof_indices (node_indices);
105 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
106 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
112 const auto neighbor_metric_cell = metric_cell->neighbor (iface);
113 neighbor_metric_cell->get_dof_indices (node_indices);
114 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
115 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
122 dealii::SparsityTools::distribute_sparsity_pattern(dsp, dof_handler.locally_owned_dofs(), MPI_COMM_WORLD, locally_relevant_dofs);
123 dealii::SparsityPattern sparsity_pattern;
124 sparsity_pattern.copy_from(dsp);
126 return sparsity_pattern;
129 template <
int dim,
typename real,
typename MeshType>
132 return get_dRdXs_sparsity_pattern ();
136 template <
int dim,
typename real,
typename MeshType>
139 const auto &partitionner = high_order_grid->surface_to_volume_indices.get_partitioner();
140 const dealii::IndexSet owned = partitionner->locally_owned_range();
141 dealii::DynamicSparsityPattern dsp(owned);
143 const unsigned n_cols = high_order_grid->surface_nodes.size();
144 std::vector<dealii::types::global_dof_index> node_indices(n_cols);
145 std::iota (std::begin(node_indices), std::end(node_indices), 0);
146 for (
auto row = owned.begin(); row != owned.end(); ++row) {
147 dsp.add_entries(*row, node_indices.begin(), node_indices.end());
151 dealii::SparsityTools::distribute_sparsity_pattern(dsp, high_order_grid->n_locally_owned_surface_nodes_per_mpi, mpi_communicator, owned);
153 dealii::SparsityPattern sparsity_pattern;
154 sparsity_pattern.copy_from(dsp);
155 return sparsity_pattern;
158 template <
int dim,
typename real,
typename MeshType>
161 const unsigned n_residuals = dof_handler.n_dofs();
162 const unsigned n_nodes_coeff = high_order_grid->surface_nodes.size();
163 const unsigned int n_rows = n_residuals;
164 const unsigned int n_cols = n_nodes_coeff;
166 dealii::DynamicSparsityPattern dsp(n_rows, n_cols);
168 std::vector<dealii::types::global_dof_index> resi_indices;
169 std::vector<dealii::types::global_dof_index> node_indices(n_cols);
170 std::iota (std::begin(node_indices), std::end(node_indices), 0);
171 auto cell = dof_handler.begin_active();
172 for (; cell != dof_handler.end(); ++cell) {
173 if (!cell->is_locally_owned())
continue;
175 const unsigned int n_resi_cell = this->fe_collection[cell->active_fe_index()].n_dofs_per_cell();
176 resi_indices.resize(n_resi_cell);
177 cell->get_dof_indices (resi_indices);
179 for (
auto resi_row = resi_indices.begin(); resi_row!=resi_indices.end(); ++resi_row) {
180 dsp.add_entries(*resi_row, node_indices.begin(), node_indices.end());
184 dealii::SparsityTools::distribute_sparsity_pattern(dsp, dof_handler.locally_owned_dofs(), MPI_COMM_WORLD, locally_owned_dofs);
185 dealii::SparsityPattern sparsity_pattern;
186 sparsity_pattern.copy_from(dsp);
188 return sparsity_pattern;
dealii::SparsityPattern get_d2RdWdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdW.
Files for the baseline physics.
dealii::SparsityPattern get_d2RdXdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdX.
dealii::SparsityPattern get_d2RdWdXs_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXsdW.
dealii::SparsityPattern get_dRdX_sparsity_pattern()
Evaluate SparsityPattern of dRdX.
dealii::SparsityPattern get_d2RdWdW_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdWdW.
dealii::SparsityPattern get_dRdXs_sparsity_pattern()
Evaluate SparsityPattern of dRdXs.
DGBase is independent of the number of state variables.
dealii::SparsityPattern get_d2RdXsdXs_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXsdXs.
dealii::SparsityPattern get_dRdW_sparsity_pattern()
Evaluate SparsityPattern of dRdW.