periods in $x$ and $y$ directions. This matches the output our program
generates:
@code
-examples/\step-36> make run
-============================ Running \step-36
+step-36$ ./step-36
Number of active cells: 1024
Number of degrees of freedom: 1089
+ Spurious eigenvalues are all in the interval [1536,1536]
Solver converged in 67 iterations.
Eigenvalue 0 : 4.93877
Eigenvalue 3 : 19.8027
Eigenvalue 4 : 24.837
- Job done. @endcode These eigenvalues are exactly the ones that
+ Job done.
+@endcode
+These eigenvalues are exactly the ones that
correspond to pairs $(m,n)=(1,1)$, $(1,2)$ and $(2,1)$, $(2,2)$, and
$(3,1)$. A visualization of the corresponding eigenfunctions would
look like this:
If in addition we also increase the mesh refinement by one level, we get the
following results:
@code
-examples/\step-36> make run
-============================ Running \step-36
+step-36$ ./step-36
Number of active cells: 4096
Number of degrees of freedom: 4225
Secondly, we switch back to the deal.II matrix and vector definitions in the
main class:
@code
- SparsityPattern sparsity_pattern;
- SparseMatrix<double> stiffness_matrix, mass_matrix;
- std::vector<Vector<double> > eigenfunctions;
- std::vector<std::complex<double>> eigenvalues;
+ SparsityPattern sparsity_pattern;
+ SparseMatrix<double> stiffness_matrix, mass_matrix;
+ std::vector<Vector<double>> eigenfunctions;
+ std::vector<std::complex<double>> eigenvalues;
@endcode
and initialize them as usual in <code>make_grid_and_dofs()</code>:
@code
- sparsity_pattern.reinit (dof_handler.n_dofs(),
- dof_handler.n_dofs(),
- dof_handler.max_couplings_between_dofs());
+ sparsity_pattern.reinit(dof_handler.n_dofs(),
+ dof_handler.n_dofs(),
+ dof_handler.max_couplings_between_dofs());
- DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
- constraints.condense (sparsity_pattern);
+ DoFTools::make_sparsity_pattern(dof_handler, sparsity_pattern);
+ constraints.condense(sparsity_pattern);
sparsity_pattern.compress();
- stiffness_matrix.reinit (sparsity_pattern);
- mass_matrix.reinit (sparsity_pattern);
+ stiffness_matrix.reinit(sparsity_pattern);
+ mass_matrix.reinit(sparsity_pattern);
@endcode
For solving the eigenvalue problem with ARPACK, we finally need to modify
<code>solve()</code>:
@code
template <int dim>
- unsigned int EigenvalueProblem<dim>::solve ()
+ unsigned int EigenvalueProblem<dim>::solve()
{
- SolverControl solver_control (dof_handler.n_dofs(), 1e-9);
+ SolverControl solver_control(dof_handler.n_dofs(), 1e-9);
SparseDirectUMFPACK inverse;
- inverse.initialize (stiffness_matrix);
+ inverse.initialize(stiffness_matrix);
- const unsigned int num_arnoldi_vectors = 2*eigenvalues.size() + 2;
+ const unsigned int num_arnoldi_vectors = 2 * eigenvalues.size() + 2;
ArpackSolver::AdditionalData additional_data(num_arnoldi_vectors);
- ArpackSolver eigensolver (solver_control, additional_data);
- eigensolver.solve (stiffness_matrix,
- mass_matrix,
- inverse,
- eigenvalues,
- eigenfunctions,
- eigenvalues.size());
+ ArpackSolver eigensolver(solver_control, additional_data);
+ eigensolver.solve(stiffness_matrix,
+ mass_matrix,
+ inverse,
+ eigenvalues,
+ eigenfunctions,
+ eigenvalues.size());
- for (unsigned int i=0; i<eigenfunctions.size(); ++i)
- eigenfunctions[i] /= eigenfunctions[i].linfty_norm ();
+ for (unsigned int i = 0; i < eigenfunctions.size(); ++i)
+ eigenfunctions[i] /= eigenfunctions[i].linfty_norm();
- return solver_control.last_step ();
+ return solver_control.last_step();
}
@endcode
Note how we have used an exact decomposition (using SparseDirectUMFPACK) as a