From 3a4f90ef5f7344bb38c57f2d1ee36011ab3411a0 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Mon, 28 Mar 2016 20:15:40 +0200 Subject: [PATCH] extend tests/mpi/periodicity_01 to complex-valued PETSc --- tests/mpi/periodicity_01.cc | 64 +++++-- ...icity_01.with_petsc=true.mpirun=3.output.2 | 163 ++++++++++++++++++ ...icity_01.with_petsc=true.mpirun=5.output.2 | 163 ++++++++++++++++++ ...icity_01.with_petsc=true.mpirun=7.output.2 | 163 ++++++++++++++++++ 4 files changed, 536 insertions(+), 17 deletions(-) create mode 100644 tests/mpi/periodicity_01.with_petsc=true.mpirun=3.output.2 create mode 100644 tests/mpi/periodicity_01.with_petsc=true.mpirun=5.output.2 create mode 100644 tests/mpi/periodicity_01.with_petsc=true.mpirun=7.output.2 diff --git a/tests/mpi/periodicity_01.cc b/tests/mpi/periodicity_01.cc index b64c039f85..fae79441fb 100644 --- a/tests/mpi/periodicity_01.cc +++ b/tests/mpi/periodicity_01.cc @@ -81,7 +81,7 @@ namespace Step40 void solve (); void refine_grid (); void get_point_value (const Point point, const int proc, - Vector &value) const; + Vector &value) const; void check_periodicity (const unsigned int cycle) const; void output_results (const unsigned int cycle) const; @@ -192,8 +192,8 @@ namespace Step40 const unsigned int dofs_per_cell = fe.dofs_per_cell; const unsigned int n_q_points = quadrature_formula.size(); - FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); - Vector cell_rhs (dofs_per_cell); + FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); + Vector cell_rhs (dofs_per_cell); std::vector local_dof_indices (dofs_per_cell); @@ -203,14 +203,14 @@ namespace Step40 for (; cell!=endc; ++cell) if (cell->is_locally_owned()) { - cell_matrix = 0; - cell_rhs = 0; + cell_matrix = PetscScalar(); + cell_rhs = PetscScalar(); fe_values.reinit (cell); for (unsigned int q_point=0; q_point void LaplaceProblem::get_point_value - (const Point point, const int proc, Vector &value) const + (const Point point, const int proc, Vector &value) const { typename DoFHandler::active_cell_iterator cell = GridTools::find_active_cell_around_point (dof_handler, point); @@ -305,15 +310,34 @@ namespace Step40 point, value); std::vector tmp (value.size()); + std::vector tmp2 (value.size()); +#ifdef PETSC_USE_COMPLEX + std::vector tmpI (value.size()); + std::vector tmp2I (value.size()); + + for (unsigned int i=0; i tmp2 (value.size()); MPI_Reduce(&(tmp[0]), &(tmp2[0]), value.size(), MPI_DOUBLE, MPI_SUM, proc, mpi_communicator); +#ifdef PETSC_USE_COMPELX + MPI_Reduce(&(tmpI[0]), &(tmp2I[0]), value.size(), MPI_DOUBLE, + MPI_SUM, proc, mpi_communicator); + + for (unsigned int i=0; i(tmp2[i],tmp2I[i]); +#else for (unsigned int i=0; i @@ -330,8 +354,8 @@ namespace Step40 for (unsigned int i=1; i< n_points; i++) { - Vector value1(1); - Vector value2(1); + Vector value1(1); + Vector value2(1); Point <2> point1; point1(0)=1.*i/n_points; @@ -345,13 +369,15 @@ namespace Step40 if (Utilities::MPI::this_mpi_process(mpi_communicator)==0) { - pcout << point1 << "\t" << value1[0] << std::endl; + pcout << point1 << "\t" << PetscRealPart(value1[0]) << std::endl; if (std::abs(value2[0]-value1[0])>1e-8) { std::cout< value1(1); - Vector value2(1); - Vector value3(1); - Vector value4(1); + Vector value1(1); + Vector value2(1); + Vector value3(1); + Vector value4(1); Point <3> point1; point1(0)=1.*i/n_points; @@ -395,20 +421,24 @@ namespace Step40 if (Utilities::MPI::this_mpi_process(mpi_communicator)==0) { - pcout << point1 << "\t" << value1[0] << std::endl; + pcout << point1 << "\t" << PetscRealPart(value1[0]) << std::endl; if (std::abs(value2[0]-value1[0])>1e-8) { std::cout<1e-8) { std::cout<