#include <deal.II/grid/grid_generator.h>
+#include "../tests.h"
+
// Flag to toggle between hexes and simplices.
// #define HEX
const unsigned int n_mpi_processes;
const unsigned int this_mpi_process;
- ConditionalOStream pcout;
-
#ifdef HEX
MappingQGeneric<dim, dim> mapping;
#else
: mpi_communicator(MPI_COMM_WORLD)
, n_mpi_processes(Utilities::MPI::n_mpi_processes(mpi_communicator))
, this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator))
- , pcout(std::cout, (this_mpi_process == 0))
#ifdef HEX
, mapping(1)
, fe(FE_Q<dim>(1), dim)
SolverControl solver_control(solution.size(), 1e-8 * system_rhs.l2_norm());
PETScWrappers::SolverCG cg(solver_control, mpi_communicator);
+ // PreconditionBlockJacobi depends on the processor count
PETScWrappers::PreconditionBlockJacobi preconditioner(system_matrix);
+ const unsigned int lower = n_mpi_processes == 1 ? 8 : 26;
+ const unsigned int upper = n_mpi_processes == 1 ? 12 : 30;
+
+ check_solver_within_range(
+ cg.solve(system_matrix, solution, system_rhs, preconditioner),
+ solver_control.last_step(),
+ lower,
+ upper);
- cg.solve(system_matrix, solution, system_rhs, preconditioner);
Vector<double> localized_solution(solution);
hanging_node_constraints.distribute(localized_solution);
triangulation, std::vector<unsigned int>(dim, n_subdivisions), a, b);
#endif
- pcout << " Number of active cells: "
- << triangulation.n_active_cells() << std::endl;
+ deallog << " Number of active cells: "
+ << triangulation.n_active_cells() << std::endl;
setup_system();
- pcout << " Number of degrees of freedom: " << dof_handler.n_dofs()
- << " (by partition:";
+ deallog << " Number of degrees of freedom: " << dof_handler.n_dofs()
+ << " (by partition:";
for (unsigned int p = 0; p < n_mpi_processes; ++p)
- pcout << (p == 0 ? ' ' : '+')
- << (DoFTools::count_dofs_with_subdomain_association(dof_handler,
- p));
- pcout << ")" << std::endl;
+ deallog << (p == 0 ? ' ' : '+')
+ << (DoFTools::count_dofs_with_subdomain_association(dof_handler,
+ p));
+ deallog << ")" << std::endl;
assemble_system();
- const unsigned int n_iterations = solve();
-
- pcout << " Solver converged in " << n_iterations << " iterations."
- << std::endl;
-
+ solve();
output_results();
}
} // namespace Step17
int
main(int argc, char **argv)
{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ mpi_initlog();
+
try
{
using namespace dealii;
using namespace Step17;
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
-
ElasticProblem<2> elastic_problem;
elastic_problem.run();
}
- Number of active cells: 200
- Number of degrees of freedom: 242 (by partition: 242)
- Solver converged in 10 iterations.
+
+DEAL:: Number of active cells: 200
+DEAL:: Number of degrees of freedom: 242 (by partition: 242)
+DEAL::Solver stopped within 8 - 12 iterations
- Number of active cells: 200
- Number of degrees of freedom: 242 (by partition: 74+58+58+52)
- Solver converged in 28 iterations.
+
+DEAL:: Number of active cells: 200
+DEAL:: Number of degrees of freedom: 242 (by partition: 74+58+58+52)
+DEAL::Solver stopped within 26 - 30 iterations
#include <fstream>
#include <iostream>
+#include "../tests.h"
+
// Flag to toggle between hex and simplex.
// #define HEX
LA::MPI::SparseMatrix system_matrix;
LA::MPI::Vector locally_relevant_solution;
LA::MPI::Vector system_rhs;
-
- ConditionalOStream pcout;
};
template <int dim>
#endif
, fe(2)
, dof_handler(triangulation)
- , pcout(std::cout,
- (Utilities::MPI::this_mpi_process(mpi_communicator) == 0))
{}
template <int dim>
#endif
preconditioner.initialize(system_matrix, data);
- solver.solve(system_matrix,
- completely_distributed_solution,
- system_rhs,
- preconditioner);
+ check_solver_within_range(solver.solve(system_matrix,
+ completely_distributed_solution,
+ system_rhs,
+ preconditioner),
+ solver_control.last_step(),
+ 5,
+ 9);
constraints.distribute(completely_distributed_solution);
quadrature_formula,
VectorTools::NormType::L2_norm);
- pcout << VectorTools::compute_global_error(triangulation,
- difference,
- VectorTools::NormType::L2_norm)
- << std::endl;
+ deallog << VectorTools::compute_global_error(triangulation,
+ difference,
+ VectorTools::NormType::L2_norm)
+ << std::endl;
}
template <int dim>
void
LaplaceProblem<dim>::run()
{
- pcout << "Running with "
+ deallog << "Running with "
#ifdef USE_PETSC_LA
- << "PETSc"
+ << "PETSc"
#else
- << "Trilinos"
+ << "Trilinos"
#endif
- << " on " << Utilities::MPI::n_mpi_processes(mpi_communicator)
- << " MPI rank(s)..." << std::endl;
+ << " on " << Utilities::MPI::n_mpi_processes(mpi_communicator)
+ << " MPI rank(s)..." << std::endl;
const unsigned int n_subdivisions = 16;
Point<dim> a, b;
setup_system();
- pcout << " Number of active cells: "
- << triangulation.n_global_active_cells() << std::endl
- << " Number of degrees of freedom: " << dof_handler.n_dofs()
- << std::endl;
+ deallog << " Number of active cells: "
+ << triangulation.n_global_active_cells() << std::endl
+ << " Number of degrees of freedom: " << dof_handler.n_dofs()
+ << std::endl;
assemble_system();
solve();
int
main(int argc, char *argv[])
{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ mpi_initlog();
+
try
{
using namespace dealii;
using namespace Step40;
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
LaplaceProblem<2> laplace_problem_2d;
laplace_problem_2d.run();
-Running with PETSc on 1 MPI rank(s)...
- Number of active cells: 512
- Number of degrees of freedom: 1089
-0.0124965
+
+DEAL::Running with PETSc on 1 MPI rank(s)...
+DEAL:: Number of active cells: 512
+DEAL:: Number of degrees of freedom: 1089
+DEAL::Solver stopped within 5 - 9 iterations
+DEAL::0.0124965
-Running with PETSc on 4 MPI rank(s)...
- Number of active cells: 512
- Number of degrees of freedom: 1089
-0.0124965
+
+DEAL::Running with PETSc on 4 MPI rank(s)...
+DEAL:: Number of active cells: 512
+DEAL:: Number of degrees of freedom: 1089
+DEAL::Solver stopped within 5 - 9 iterations
+DEAL::0.0124965