template <int dim>
void LaplaceProblem<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void AdvectionProblem<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverRichardson<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverRichardson<Vector<double>> solver(solver_control);
// Here we create the preconditioner,
PreconditionBlockSSOR<SparseMatrix<double>> preconditioner;
template <int dim>
void AdvectionProblem<dim>::solve(Vector<double> &solution)
{
- SolverControl solver_control(1000, 1e-12);
- SolverRichardson<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverRichardson<Vector<double>> solver(solver_control);
// Here we create the preconditioner,
PreconditionBlockSSOR<SparseMatrix<double>> preconditioner;
template <int dim>
void Solver<dim>::assemble_linear_system(LinearSystem &linear_system)
{
- Threads::Task<> rhs_task =
+ Threads::Task<void> rhs_task =
Threads::new_task(&Solver<dim>::assemble_rhs, *this, linear_system.rhs);
auto worker =
&DoFTools::make_hanging_node_constraints;
// Start a side task then continue on the main thread
- Threads::Task<> side_task =
+ Threads::Task<void> side_task =
Threads::new_task(mhnc_p, dof_handler, hanging_node_constraints);
DynamicSparsityPattern dsp(dof_handler.n_dofs(), dof_handler.n_dofs());
template <int dim>
void Solver<dim>::LinearSystem::solve(Vector<double> &solution) const
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(matrix, 1.2);
cg.solve(matrix, solution, rhs, preconditioner);
template <int dim>
void Solver<dim>::assemble_linear_system(LinearSystem &linear_system)
{
- Threads::Task<> rhs_task =
+ Threads::Task<void> rhs_task =
Threads::new_task(&Solver<dim>::assemble_rhs, *this, linear_system.rhs);
auto worker =
&DoFTools::make_hanging_node_constraints;
// Start a side task then continue on the main thread
- Threads::Task<> side_task =
+ Threads::Task<void> side_task =
Threads::new_task(mhnc_p, dof_handler, hanging_node_constraints);
DynamicSparsityPattern dsp(dof_handler.n_dofs(), dof_handler.n_dofs());
template <int dim>
void Solver<dim>::LinearSystem::solve(Vector<double> &solution) const
{
- SolverControl solver_control(5000, 1e-12);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(5000, 1e-12);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(matrix, 1.2);
cg.solve(matrix, solution, rhs, preconditioner);
template <int dim>
void WeightedResidual<dim>::solve_problem()
{
- Threads::TaskGroup<> tasks;
+ Threads::TaskGroup<void> tasks;
tasks +=
Threads::new_task(&WeightedResidual<dim>::solve_primal_problem, *this);
tasks +=
template <int dim>
void MinimalSurfaceProblem<dim>::solve()
{
- SolverControl solver_control(system_rhs.size(),
+ SolverControl solver_control(system_rhs.size(),
system_rhs.l2_norm() * 1e-6);
- SolverCG<> solver(solver_control);
+ SolverCG<Vector<double>> solver(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
solver.solve(system_matrix, newton_update, system_rhs, preconditioner);
// us, and thus the difference between this function and the previous lies
// only in the setup of the assembler and the different iterators in the loop.
//
- // We generate an AffineConstraints<> object for each level containing the
+ // We generate an AffineConstraints object for each level containing the
// boundary and interface dofs as constrained entries. The corresponding
// object is then used to generate the level matrices.
template <int dim>
MappingQ1<dim> mapping;
const unsigned int n_levels = triangulation.n_levels();
- std::vector<AffineConstraints<>> boundary_constraints(n_levels);
+ std::vector<AffineConstraints<double>> boundary_constraints(n_levels);
for (unsigned int level = 0; level < n_levels; ++level)
{
IndexSet dofset;
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from(mg_matrices[0]);
- MGCoarseGridHouseholder<> coarse_grid_solver;
+ MGCoarseGridHouseholder<double, Vector<double>> coarse_grid_solver;
coarse_grid_solver.initialize(coarse_matrix);
// The next component of a multilevel solver or preconditioner is that we
// With all this together, we can finally get about solving the linear
// system in the usual way:
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
solution = 0;
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from(mg_matrices[0]);
- MGCoarseGridHouseholder<> coarse_grid_solver;
+ MGCoarseGridHouseholder<double, Vector<double>> coarse_grid_solver;
coarse_grid_solver.initialize(coarse_matrix);
// The next component of a multilevel solver or preconditioner is that we
// With all this together, we can finally get about solving the linear
// system in the usual way:
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
solution = 0;
@code
const auto op_M = linear_operator(M);
- PreconditionJacobi<> preconditioner_M;
+ PreconditionJacobi<SparseMatrix<double>> preconditioner_M;
preconditioner_M.initialize(M);
ReductionControl reduction_control_M(2000, 1.0e-18, 1.0e-10);
- SolverCG<> solver_M(reduction_control_M);
+ SolverCG<Vector<double>> solver_M(reduction_control_M);
const auto op_M_inv = inverse_operator(op_M, solver_M, preconditioner_M);
@endcode
creating another solver and inverse:
@code
SolverControl solver_control_S(2000, 1.e-12);
- SolverCG<> solver_S(solver_control_S);
+ SolverCG<Vector<double>> solver_S(solver_control_S);
PreconditionIdentity preconditioner_S;
const auto op_S_inv = inverse_operator(op_S, solver_S, preconditioner_S);
iterations that are performed to a fixed small number (in our case 30):
@code
IterationNumberControl iteration_number_control_aS(30, 1.e-18);
- SolverCG<> solver_aS(iteration_number_control_aS);
+ SolverCG<Vector<double>> solver_aS(iteration_number_control_aS);
PreconditionIdentity preconditioner_aS;
const auto preconditioner_S =
inverse_operator(op_aS, solver_aS, preconditioner_aS);
const auto op_M = linear_operator(M);
const auto op_B = linear_operator(B);
- ReductionControl reduction_control_M(2000, 1.0e-18, 1.0e-10);
- SolverCG<> solver_M(reduction_control_M);
- PreconditionJacobi<> preconditioner_M;
+ ReductionControl reduction_control_M(2000, 1.0e-18, 1.0e-10);
+ SolverCG<Vector<double>> solver_M(reduction_control_M);
+ PreconditionJacobi<SparseMatrix<double>> preconditioner_M;
preconditioner_M.initialize(M);
// We now create a preconditioner out of <code>op_aS</code> that
// applies a fixed number of 30 (inexpensive) CG iterations:
- IterationNumberControl iteration_number_control_aS(30, 1.e-18);
- SolverCG<> solver_aS(iteration_number_control_aS);
+ IterationNumberControl iteration_number_control_aS(30, 1.e-18);
+ SolverCG<Vector<double>> solver_aS(iteration_number_control_aS);
const auto preconditioner_S =
inverse_operator(op_aS, solver_aS, PreconditionIdentity());
// preconditioner we just declared.
const auto schur_rhs = transpose_operator(op_B) * op_M_inv * F - G;
- SolverControl solver_control_S(2000, 1.e-12);
- SolverCG<> solver_S(solver_control_S);
+ SolverControl solver_control_S(2000, 1.e-12);
+ SolverCG<Vector<double>> solver_S(solver_control_S);
const auto op_S_inv = inverse_operator(op_S, solver_S, preconditioner_S);
{
SolverControl solver_control(std::max<unsigned int>(src.size(), 200),
1e-8 * src.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
dst = 0;
approximate_schur_complement);
- SolverControl solver_control(solution.block(1).size(),
+ SolverControl solver_control(solution.block(1).size(),
1e-12 * schur_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(schur_complement, solution.block(1), schur_rhs, preconditioner);
// onto the physically reasonable range:
assemble_rhs_S();
{
- SolverControl solver_control(system_matrix.block(2, 2).m(),
+ SolverControl solver_control(system_matrix.block(2, 2).m(),
1e-8 * system_rhs.block(2).l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(system_matrix.block(2, 2),
solution.block(2),
system_rhs.block(2),
Vector<double> & dst,
const Vector<double> &src) const
{
- SolverControl solver_control(src.size(), 1e-6 * src.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(src.size(), 1e-6 * src.l2_norm());
+ SolverCG<Vector<double>> cg(solver_control);
dst = 0;
system_matrix, A_inverse);
// The usual control structures for the solver call are created...
- SolverControl solver_control(solution.block(1).size(),
+ SolverControl solver_control(solution.block(1).size(),
1e-6 * schur_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
// Now to the preconditioner to the Schur complement. As explained in
// the introduction, the preconditioning is done by a mass matrix in the
template <int dim>
void WaveEquation<dim>::solve_u()
{
- SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(matrix_u, solution_u, system_rhs, PreconditionIdentity());
template <int dim>
void WaveEquation<dim>::solve_v()
{
- SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(matrix_v, solution_v, system_rhs, PreconditionIdentity());
void TATForwardProblem<dim>::solve_p()
{
SolverControl solver_control(1000, 1e-8 * system_rhs_p.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(system_matrix, solution_p, system_rhs_p, PreconditionIdentity());
void TATForwardProblem<dim>::solve_v()
{
SolverControl solver_control(1000, 1e-8 * system_rhs_v.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
cg.solve(mass_matrix, solution_v, system_rhs_v, PreconditionIdentity());
template <int dim>
unsigned int SineGordonProblem<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-12 * system_rhs.l2_norm());
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution_update, system_rhs, preconditioner);
template <int dim>
void HeatEquation<dim>::solve_time_step()
{
- SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.0);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void LaplaceProblem<dim>::solve()
{
- SolverControl solver_control(system_rhs.size(),
+ SolverControl solver_control(system_rhs.size(),
1e-12 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
solution,
system_rhs);
- SolverControl solver_control(system_matrix.m(),
+ SolverControl solver_control(system_matrix.m(),
1e-12 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
BlockVector<float> group_error_indicators(n_cells);
{
- Threads::ThreadGroup<> threads;
+ Threads::ThreadGroup<void> threads;
for (unsigned int group = 0; group < parameters.n_groups; ++group)
threads += Threads::new_thread(&EnergyGroup<dim>::estimate_errors,
*energy_groups[group],
const float coarsen_threshold = 0.01 * max_error;
{
- Threads::ThreadGroup<> threads;
+ Threads::ThreadGroup<void> threads;
for (unsigned int group = 0; group < parameters.n_groups; ++group)
threads += Threads::new_thread(&EnergyGroup<dim>::refine_grid,
*energy_groups[group],
std::cout << std::endl << std::endl;
- Threads::ThreadGroup<> threads;
+ Threads::ThreadGroup<void> threads;
for (unsigned int group = 0; group < parameters.n_groups; ++group)
threads +=
Threads::new_thread(&EnergyGroup<dim>::assemble_system_matrix,
// class is the type of the vectors, but the empty angle brackets indicate
// that we simply take the default argument (which is
// <code>Vector@<double@></code>):
- SolverCG<> solver(solver_control);
+ SolverCG<Vector<double>> solver(solver_control);
// Now solve the system of equations. The CG solver takes a preconditioner
// as its fourth argument. We don't feel ready to delve into this yet, so we
template <int dim>
void DGMethod<dim>::solve(Vector<double> &solution)
{
- SolverControl solver_control(1000, 1e-12, false, false);
- SolverRichardson<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12, false, false);
+ SolverRichardson<Vector<double>> solver(solver_control);
PreconditionBlockSSOR<SparseMatrix<double>> preconditioner;
NavierStokesProjection<dim>::diffusion_component_solve(const unsigned int d)
{
SolverControl solver_control(vel_max_its, vel_eps * force[d].l2_norm());
- SolverGMRES<> gmres(solver_control,
- SolverGMRES<>::AdditionalData(vel_Krylov_size));
+ SolverGMRES<Vector<double>> gmres(
+ solver_control,
+ SolverGMRES<Vector<double>>::AdditionalData(vel_Krylov_size));
gmres.solve(vel_it_matrix[d], u_n[d], force[d], prec_velocity[d]);
}
vel_diag_strength, vel_off_diagonals));
SolverControl solvercontrol(vel_max_its, vel_eps * pres_tmp.l2_norm());
- SolverCG<> cg(solvercontrol);
+ SolverCG<Vector<double>> cg(solvercontrol);
cg.solve(pres_iterative, phi_n, pres_tmp, prec_pres_Laplace);
phi_n *= 1.5 / dt;
void LaplaceBeltramiProblem<spacedim>::solve()
{
SolverControl solver_control(solution.size(), 1e-7 * system_rhs.l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void Step4<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
solver.solve(system_matrix, solution, system_rhs, PreconditionIdentity());
// We have made one addition, though: since we suppress output from the
template <int dim>
void Step5<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
solver.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void HDG<dim>::solve()
{
- SolverControl solver_control(system_matrix.m() * 10,
+ SolverControl solver_control(system_matrix.m() * 10,
1e-11 * system_rhs.l2_norm());
- SolverBicgstab<> solver(solver_control);
+ SolverBicgstab<Vector<double>> solver(solver_control);
solver.solve(system_matrix, solution, system_rhs, PreconditionIdentity());
std::cout << " Number of BiCGStab iterations: "
// First solve with the approximation for S
{
SolverControl solver_control(1000, 1e-6 * src.block(1).l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
dst.block(1) = 0.0;
cg.solve(schur_complement_matrix,
// or just apply one preconditioner sweep
if (do_solve_A == true)
{
- SolverControl solver_control(10000, utmp.l2_norm() * 1e-4);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(10000, utmp.l2_norm() * 1e-4);
+ SolverCG<Vector<double>> cg(solver_control);
dst.block(0) = 0.0;
cg.solve(system_matrix.block(0, 0),
// Setup coarse grid solver
FullMatrix<double> coarse_matrix;
coarse_matrix.copy_from(mg_matrices[0]);
- MGCoarseGridHouseholder<> coarse_grid_solver;
+ MGCoarseGridHouseholder<double, Vector<double>> coarse_grid_solver;
coarse_grid_solver.initialize(coarse_matrix);
using Smoother = PreconditionSOR<SparseMatrix<double>>;
{
SolverControl solver_control(1000, 1e-6 * src.block(1).l2_norm());
- SolverCG<> cg(solver_control);
+ SolverCG<Vector<double>> cg(solver_control);
dst.block(1) = 0.0;
cg.solve(pressure_mass_matrix,
In deal.II, it is relatively simple to change the preconditioner. For
example, by changing the existing lines of code
@code
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
@endcode
into
@code
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.0);
@endcode
we can try out different relaxation parameters for SSOR. By using
@code
- PreconditionJacobi<> preconditioner;
+ PreconditionJacobi<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix);
@endcode
we can use Jacobi as a preconditioner. And by using
template <int dim>
void Step6<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
solver.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void WGDarcyEquation<dim>::solve()
{
- SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-8 * system_rhs.l2_norm());
+ SolverCG<Vector<double>> solver(solver_control);
solver.solve(system_matrix, solution, system_rhs, PreconditionIdentity());
constraints.distribute(solution);
}
std::cout << " Solving with GMRES to tol " << solve_tolerance << "..."
<< std::endl;
- SolverGMRES<> solver(solver_control,
- SolverGMRES<>::AdditionalData(50, true));
+ SolverGMRES<Vector<double>> solver(
+ solver_control, SolverGMRES<Vector<double>>::AdditionalData(50, true));
Timer time;
time.start();
{
TimerOutput::Scope scope(timer, "Solve linear system");
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> solver(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> solver(solver_control);
- PreconditionJacobi<> preconditioner;
+ PreconditionJacobi<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix);
solver.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void HelmholtzProblem<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void ElasticProblem<dim>::solve()
{
- SolverControl solver_control(1000, 1e-12);
- SolverCG<> cg(solver_control);
+ SolverControl solver_control(1000, 1e-12);
+ SolverCG<Vector<double>> cg(solver_control);
- PreconditionSSOR<> preconditioner;
+ PreconditionSSOR<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
cg.solve(system_matrix, solution, system_rhs, preconditioner);
template <int dim>
void AdvectionProblem<dim>::solve()
{
- SolverControl solver_control(std::max<std::size_t>(1000,
+ SolverControl solver_control(std::max<std::size_t>(1000,
system_rhs.size() / 10),
1e-10 * system_rhs.l2_norm());
- SolverGMRES<> solver(solver_control);
- PreconditionJacobi<> preconditioner;
+ SolverGMRES<Vector<double>> solver(solver_control);
+ PreconditionJacobi<SparseMatrix<double>> preconditioner;
preconditioner.initialize(system_matrix, 1.0);
solver.solve(system_matrix, solution, system_rhs, preconditioner);