#include <grid/dof_constraints.h>
int dim=2; // Work in two dimensions, could also be three
-SparseMatrixStruct<double> smstruct;
+SparseMatrixStruct<double> sparsity_pattern;
DoFHandler<dim> dof;
ConstraintMatrix<dim> hanging_nodes;
hanging_nodes.clear();
-dof.make_sparsity_pattern(smstruct);
+dof.make_sparsity_pattern(sparsity_pattern);
dof.make_hanging_nodes_constraints(hanging_nodes);
dof.constraints.close();
hanging_nodes.condense(matrix_structure);
cells have non-zero values.
</li>
<li>
-<a href="#block">Block sparse matrices</a> where the matrix is assumed to
-consist of blocks on the diagonal.
-</li>
-<li>
<a href="#sparse">Sparse matrices</a>, i.e. matrices where the majority of
cells has zero value.
</li>
int dim=2; // For example
-SparseMatrixStruct<double> smstruct;
+SparseMatrixStruct<double> sparsity_pattern;
SparseMatrix<double> sm;
DoFHandler<dim> dof;
// Your degrees of freedom must already be distributed
-smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
-
-// If your grid is locally refined, <a href="matrix_structure.html#smstruct">condense the hanging nodes</a> into the
-// structure.
-
-smstruct.compress();
-
-sm.reinit(smstruct);
-</code>
-</pre>
-
-<h3><a name="block">The block sparse matrix</a></h3>
-
-<p>
-A block matrix is assumed to consist of blocks on the diagonal with all
-the blocks having the same size.
-It is initialized using
-<code>BlockSparseMatrix::reinit(const SparseMatrixStruct &sparsity)</code>
-Since this is a sparse matrix, i.e. a matrix that can be
-stored efficiently, we need to generate a matrix structure first, like for the
-sparse matrix. In fact, the block sparse matrix is just a specialization of
-the sparse matrix.
-</p>
-
-<p class="Example">
-<span class="example">Example:</span> We show the include files you need,
-the definitions and the function calls. Make sure to use them in their
-appropriate places.
-</p>
-<pre class="example">
-<code>
-#include <grid/dof.h>
-#include <lac/blocksparsematrix.h>
-
-int dim=2; // 2 Dimensions, could also be three
-SparseMatrixStruct<double> smstruct;
-DoFHandler<dim> dof;
-BlockSparseMatrix<double> A;
-
-
-// Your degrees of freedom must already be distributed
-
-smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
+sparsity_pattern.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
-// If your grid is locally refined, <a href="matrix_structure.html#smstruct">condense the hanging nodes</a> into the
+// If your grid is locally refined, <a href="matrix_structure.html#sparsity_pattern">condense the hanging nodes</a> into the
// structure.
-smstruct.compress();
+sparsity_pattern.compress();
-A.reinit(smstruct);
+sm.reinit(sparsity_pattern);
</code>
</pre>
</p>
<p class="Example">
-<a name="smstruct"><span class="example">Example:</span></a> We show the include files you need,
+<a name="sparsity_pattern"><span class="example">Example:</span></a> We show the include files you need,
the definitions and the function calls. Make sure to use them in their
appropriate places. This example initializes a sparse square matrix structure.
</p>
int dim=2; // For example
-SparseMatrixStruct<double> smstruct;
+SparseMatrixStruct<double> sparsity_pattern;
DoFHandler<dim> dof;
ConstraintMatrix hanging_nodes; // Only necessary for locally refined grids
// Your degrees of freedom must already be distributed
-smstruct.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
+sparsity_pattern.reinit(dof.n_dofs(),dof.n_dofs(),dof.max_couplings_between_dofs());
// Condense the <a href="hanging_nodes.html">hanging nodes</a> into
// the matrix, taking into account the constraints to the hanging nodes.
// on locally refined grids.
// You can skip this part if your grid is not locally refined.
-dof.make_sparsity_pattern(smstruct);
+dof.make_sparsity_pattern(sparsity_pattern);
hanging_nodes.clear();
dof.make_constraint_matrix(hanging_nodes);
-hanging_nodes.condense(smstruct);
+hanging_nodes.condense(sparsity_pattern);
</code>
</pre>
</p>
<p class="Example">
-<span class="example">Example:</span> Starting from <a href="#smstruct">the example above</a>, we
-compress our matrix structure <code>smstruct</code>.
+<span class="example">Example:</span> Starting from <a href="#sparsity_pattern">the example above</a>, we
+compress our matrix structure <code>sparsity_pattern</code>.
</p>
<pre class="example">
<code>
-smstruct.compress();
+sparsity_pattern.compress();
</code>
</pre>
fevalues.reinit(c, stb);
elmat.clear();
elvec.clear();
- c->get_dof_indices(indices);
+ c->get_dof_indices(indices);
- for (unsigned k=0;k<qc.n_quadrature_points;++k)
+ for (unsigned k=0;k<qc.n_quadrature_points;++k)
{
- for (unsigned i=0;i<fe.total_dofs;++i)
+ for (unsigned i=0;i<fe.total_dofs;++i)
{
const Point<2> dv = fevalues.shape_grad(i,k);
- for (unsigned j=0;j<fe.total_dofs;++j)
+ for (unsigned j=0;j<fe.total_dofs;++j)
{
const Point<2> du = fevalues.shape_grad(j,k);
}
}
// ...and insert the local matrix into the global one.
- for (unsigned i=0;i<fe.total_dofs;++i)
+ for (unsigned i=0;i<fe.total_dofs;++i)
{
f(indices[i]) += elvec(i);
- for (unsigned j=0;j<fe.total_dofs;++j)
+ for (unsigned j=0;j<fe.total_dofs;++j)
{
A.add(indices[i], indices[j], elmat(i,j));
}