#ifdef DEAL_II_WITH_MPI
#ifdef DEBUG
- // make sure that there are not outstanding requests from updating ghost
- // values or compress
- int flag = 1;
- int ierr = MPI_Testall (update_ghost_values_requests.size(),
- &update_ghost_values_requests[0],
+ if (Utilities::System::job_supports_mpi())
+ {
+ // make sure that there are not outstanding requests from updating
+ // ghost values or compress
+ int flag = 1;
+ int ierr = MPI_Testall (update_ghost_values_requests.size(),
+ &update_ghost_values_requests[0],
+ &flag, MPI_STATUSES_IGNORE);
+ Assert (ierr == MPI_SUCCESS, ExcInternalError());
+ Assert (flag == 1,
+ ExcMessage("MPI found unfinished update_ghost_values() requests"
+ "when calling swap, which is not allowed"));
+ ierr = MPI_Testall (compress_requests.size(), &compress_requests[0],
&flag, MPI_STATUSES_IGNORE);
- Assert (ierr == MPI_SUCCESS, ExcInternalError());
- Assert (flag == 1,
- ExcMessage("MPI found unfinished update_ghost_values() requests"
- "when calling swap, which is not allowed"));
- ierr = MPI_Testall (compress_requests.size(), &compress_requests[0],
- &flag, MPI_STATUSES_IGNORE);
- Assert (ierr == MPI_SUCCESS, ExcInternalError());
- Assert (flag == 1,
- ExcMessage("MPI found unfinished compress() requests "
- "when calling swap, which is not allowed"));
+ Assert (ierr == MPI_SUCCESS, ExcInternalError());
+ Assert (flag == 1,
+ ExcMessage("MPI found unfinished compress() requests "
+ "when calling swap, which is not allowed"));
+ }
#endif
std::swap (compress_requests, v.compress_requests);
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/lac/constraint_matrix.h>
-#include <deal.II/lac/sparse_matrix.h>
-#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
-#include <deal.II/lac/trilinos_vector.h>
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/numerics/vector_tools.h>
-#include <deal.II/distributed/tria.h>
#include <deal.II/lac/parallel_vector.h>
#include <deal.II/matrix_free/matrix_free.h>
{
using namespace dealii;
- const unsigned int dimension = 2;
const unsigned int fe_degree = 4;
double ExactSolution<dim>::value (const Point<dim> &p,
const unsigned int /* component */) const
{
- double t = this->get_time ();
-
- const double m = 0.5;
- const double c1 = 0.;
- const double c2 = 0.;
- const double factor = (m / std::sqrt(1.-m*m) *
- std::sin(std::sqrt(1.-m*m)*t+c2));
- double result = 1.;
- for (unsigned int d=0; d<dim; ++d)
- result *= -4. * std::atan (factor / std::cosh(m*p[d]+c1));
- return result;
+ return 4.*std::exp(-p.square()*10);
}
private:
void make_grid_and_dofs ();
- void output_results (const unsigned int timestep_number);
+ void output_norm ();
-#ifdef DEAL_II_WITH_P4EST
- parallel::distributed::Triangulation<dim> triangulation;
-#else
Triangulation<dim> triangulation;
-#endif
FE_Q<dim> fe;
DoFHandler<dim> dof_handler;
ConstraintMatrix constraints;
template <int dim>
SineGordonProblem<dim>::SineGordonProblem ()
:
-#ifdef DEAL_II_WITH_P4EST
- triangulation (MPI_COMM_WORLD),
-#endif
fe (QGaussLobatto<1>(fe_degree+1)),
dof_handler (triangulation),
- n_global_refinements (8-2*dim),
+ n_global_refinements (2),
time (-10),
- final_time (-9),
+ final_time (-9.5),
cfl_number (.1/fe_degree),
- output_timestep_skip (200)
+ output_timestep_skip (1)
{}
triangulation.refine_global (n_global_refinements);
deallog << " Number of global active cells: "
-#ifdef DEAL_II_WITH_P4EST
- << triangulation.n_global_active_cells()
-#else
<< triangulation.n_active_cells()
-#endif
<< std::endl;
dof_handler.distribute_dofs (fe);
QGaussLobatto<1> quadrature (fe_degree+1);
typename MatrixFree<dim>::AdditionalData additional_data;
- additional_data.mpi_communicator = MPI_COMM_WORLD;
additional_data.tasks_parallel_scheme =
MatrixFree<dim>::AdditionalData::partition_partition;
template <int dim>
void
- SineGordonProblem<dim>::output_results (const unsigned int timestep_number)
+ SineGordonProblem<dim>::output_norm ()
{
constraints.distribute (solution);
solution.update_ghost_values();
norm_per_cell,
QGauss<dim>(fe_degree+1),
VectorTools::L2_norm);
- const double solution_norm =
- std::sqrt(Utilities::MPI::sum (norm_per_cell.norm_sqr(), MPI_COMM_WORLD));
+ const double solution_norm = norm_per_cell.norm_sqr();
- deallog << " Time:"
- << std::setw(8) << std::setprecision(3) << time
+ deallog << " Time: "
+ << std::setw(6) << std::setprecision(3) << time
<< ", solution norm: "
- << std::setprecision(5) << std::setw(7) << solution_norm
+ << std::setprecision(9) << std::setw(13) << solution_norm
<< std::endl;
}
{
make_grid_and_dofs();
- const double local_min_cell_diameter =
+ const double min_cell_diameter =
triangulation.last()->diameter()/std::sqrt(dim);
- const double global_min_cell_diameter
- = -Utilities::MPI::max(-local_min_cell_diameter, MPI_COMM_WORLD);
- time_step = cfl_number * global_min_cell_diameter;
+ time_step = cfl_number * min_cell_diameter;
time_step = (final_time-time)/(int((final_time-time)/time_step));
deallog << " Time step size: " << time_step << ", finest cell: "
- << global_min_cell_diameter << std::endl << std::endl;
+ << min_cell_diameter << std::endl << std::endl;
VectorTools::interpolate (dof_handler,
VectorTools::interpolate (dof_handler,
ExactSolution<dim> (1, time-time_step),
old_solution);
- output_results (0);
+ output_norm ();
std::vector<parallel::distributed::Vector<double>*> previous_solutions;
previous_solutions.push_back(&old_solution);
old_solution.swap (solution);
sine_gordon_op.apply (solution, previous_solutions);
- if (timestep_number % output_timestep_skip == 0)
- output_results(timestep_number / output_timestep_skip);
+ output_norm();
}
- output_results(timestep_number / output_timestep_skip + 1);
deallog << std::endl
<< " Performed " << timestep_number << " time steps."
int main (int argc, char **argv)
{
- Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
-
- unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
- deallog.push(Utilities::int_to_string(myid));
-
- if (myid == 0)
- {
- std::ofstream logfile("output");
- deallog.attach(logfile);
- deallog << std::setprecision(4);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- {
- deallog.push("2d");
- Step48::SineGordonProblem<2> sg_problem;
- sg_problem.run ();
- deallog.pop();
- }
- {
- deallog.push("3d");
- Step48::SineGordonProblem<3> sg_problem;
- sg_problem.run ();
- deallog.pop();
- }
- }
- else
- {
- deallog.depth_console(0);
- {
- Step48::SineGordonProblem<2> sg_problem;
- sg_problem.run ();
- }
- {
- Step48::SineGordonProblem<3> sg_problem;
- sg_problem.run ();
- }
- }
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog << std::setprecision(4);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Step48::SineGordonProblem<2> sg_problem;
+ sg_problem.run ();
}