Skip to content

Commit

Permalink
Update tests with respect to locally_owned_dofs_per_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
kronbichler committed Jun 3, 2019
1 parent 22f3cdd commit 2435251
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 145 deletions.
8 changes: 5 additions & 3 deletions tests/matrix_free/dg_pbc_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ test()
SolverControl control(1000, 1e-12 * std::sqrt(rhs.size()));
SolverCG<LinearAlgebra::distributed::Vector<double>> solver(control);
solver.solve(mf, sol, rhs, PreconditionIdentity());

const std::vector<IndexSet> locally_owned_dofs_per_processor =
dof.locally_owned_dofs_per_processor();
// gather all data at root
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
{
Expand All @@ -107,14 +110,13 @@ test()
++i)
{
MPI_Recv(sol_gather_ptr,
dof.locally_owned_dofs_per_processor()[i].n_elements(),
locally_owned_dofs_per_processor[i].n_elements(),
MPI_DOUBLE,
i,
i,
MPI_COMM_WORLD,
MPI_STATUS_IGNORE);
sol_gather_ptr +=
dof.locally_owned_dofs_per_processor()[i].n_elements();
sol_gather_ptr += locally_owned_dofs_per_processor[i].n_elements();
}
solution_gather0.print(deallog.get_file_stream());
}
Expand Down
17 changes: 10 additions & 7 deletions tests/mpi/dof_handler_number_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,22 @@ test()
++i)
AssertThrow(dof_handler.n_locally_owned_dofs_per_processor()[i] <= N,
ExcInternalError());
AssertThrow(std::accumulate(
dof_handler.n_locally_owned_dofs_per_processor().begin(),
dof_handler.n_locally_owned_dofs_per_processor().end(),
0U) == N,
const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dof_handler.n_locally_owned_dofs_per_processor();
AssertThrow(std::accumulate(n_locally_owned_dofs_per_processor.begin(),
n_locally_owned_dofs_per_processor.end(),
0U) == N,
ExcInternalError());

const std::vector<IndexSet> locally_owned_dofs_per_processor =
dof_handler.locally_owned_dofs_per_processor();
IndexSet all(N), really_all(N);
// poor man's union operation
for (unsigned int i = 0;
i < dof_handler.n_locally_owned_dofs_per_processor().size();
for (unsigned int i = 0; i < n_locally_owned_dofs_per_processor.size();
++i)
for (unsigned int j = 0; j < N; ++j)
if (dof_handler.locally_owned_dofs_per_processor()[i].is_element(j))
if (locally_owned_dofs_per_processor[i].is_element(j))
{
AssertThrow(all.is_element(j) == false, ExcInternalError());
all.add_index(j);
Expand Down
11 changes: 6 additions & 5 deletions tests/mpi/mg_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,19 @@ test()
deallog << "Levels: " << tr.n_global_levels() << std::endl;
std::cout << "Levels: " << tr.n_global_levels() << std::endl;

const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
deallog << "n_locally_owned_dofs_per_processor:" << std::endl;
for (unsigned int i = 0;
i < dofh.n_locally_owned_dofs_per_processor().size();
++i)
deallog << dofh.n_locally_owned_dofs_per_processor()[i] << std::endl;
for (unsigned int i = 0; i < n_locally_owned_dofs_per_processor.size(); ++i)
deallog << n_locally_owned_dofs_per_processor[i] << std::endl;

deallog << "locally_owned_mg_dofs_per_processor:" << std::endl;
for (unsigned int lvl = 0; lvl < tr.n_global_levels(); ++lvl)
{
deallog << "level " << lvl << ":" << std::endl;

const std::vector<IndexSet> &vec =
const std::vector<IndexSet> vec =
dofh.locally_owned_mg_dofs_per_processor(lvl);

for (unsigned int i = 0; i < vec.size(); ++i)
Expand Down
5 changes: 4 additions & 1 deletion tests/mpi/p4est_2d_dofhandler_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ test()
static const FE_Q<dim> fe(2);
dofh.distribute_dofs(fe);

const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 0)
{
deallog << "dofh.n_dofs() " << dofh.n_locally_owned_dofs_per_processor()
deallog << "dofh.n_dofs() " << n_locally_owned_dofs_per_processor
<< std::endl;
deallog << "dofh.n_locally_owned_dofs() " << dofh.n_locally_owned_dofs()
<< std::endl;
Expand Down
6 changes: 4 additions & 2 deletions tests/mpi/p4est_2d_dofhandler_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ test()
static const FE_Q<dim> fe(2);
dofh.distribute_dofs(fe);

std::vector<types::global_dof_index> n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 0)
{
deallog << "dofh.n_dofs() "
<< dofh.n_locally_owned_dofs_per_processor() << std::endl;
deallog << "dofh.n_dofs() " << n_locally_owned_dofs_per_processor
<< std::endl;
deallog << "dofh.n_locally_owned_dofs() "
<< dofh.n_locally_owned_dofs() << std::endl;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/mpi/p4est_2d_dofhandler_03.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ test()
static const FE_Q<dim> fe(2);
dofh.distribute_dofs(fe);

std::vector<types::global_dof_index> n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 0)
{
deallog << "dofh.n_dofs() "
<< dofh.n_locally_owned_dofs_per_processor() << std::endl;
deallog << "dofh.n_dofs() " << n_locally_owned_dofs_per_processor
<< std::endl;
deallog << "dofh.n_locally_owned_dofs() "
<< dofh.n_locally_owned_dofs() << std::endl;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/mpi/p4est_2d_dofhandler_04.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ test()
static const FE_Q<dim> fe(2);
dofh.distribute_dofs(fe);

std::vector<types::global_dof_index> n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 0)
{
deallog << "dofh.n_dofs() "
<< dofh.n_locally_owned_dofs_per_processor() << std::endl;
deallog << "dofh.n_dofs() " << n_locally_owned_dofs_per_processor
<< std::endl;
deallog << "dofh.n_locally_owned_dofs() "
<< dofh.n_locally_owned_dofs() << std::endl;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/mpi/p4est_2d_renumber_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ test()
IndexSet dof_set;
DoFTools::extract_locally_active_dofs(dofh, dof_set);

const std::vector<IndexSet> owned_dofs =
dofh.locally_owned_dofs_per_processor();
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
{
dof_set.print(deallog);
Expand All @@ -88,7 +90,7 @@ test()
++i)
{
deallog << "Dofs owned by processor " << i << ": ";
dofh.locally_owned_dofs_per_processor()[i].print(deallog);
owned_dofs[i].print(deallog);
deallog << std::endl;
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/mpi/p4est_data_out_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ test()
data_out.add_data_vector(x, "x");
data_out.build_patches();

std::vector<types::global_dof_index> n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 0)
{
for (unsigned int i = 0;
i < dofh.n_locally_owned_dofs_per_processor().size();
for (unsigned int i = 0; i < n_locally_owned_dofs_per_processor.size();
++i)
deallog << dofh.n_locally_owned_dofs_per_processor()[i] << std::endl;
deallog << n_locally_owned_dofs_per_processor[i] << std::endl;
data_out.write_vtu(deallog.get_file_stream());
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/mpi/p4est_get_subdomain_association.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ test()
static const FE_Q<dim> fe(2);
dofh.distribute_dofs(fe);

const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dofh.n_locally_owned_dofs_per_processor();
if (myid == 1)
{
deallog << "dofh.n_dofs() " << dofh.n_locally_owned_dofs_per_processor()
deallog << "dofh.n_dofs() " << n_locally_owned_dofs_per_processor
<< std::endl;
deallog << "dofh.n_locally_owned_dofs() " << dofh.n_locally_owned_dofs()
<< std::endl;
Expand Down
2 changes: 1 addition & 1 deletion tests/mpi/periodicity_04.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ check(const unsigned int orientation, bool reverse)
unsigned int myid = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
constraints.print(deallog.get_file_stream());

const std::vector<IndexSet> &locally_owned_dofs_vector =
const std::vector<IndexSet> locally_owned_dofs_vector =
dof_handler.locally_owned_dofs_per_processor();
IndexSet locally_active_dofs;
DoFTools::extract_locally_active_dofs(dof_handler, locally_active_dofs);
Expand Down
2 changes: 1 addition & 1 deletion tests/mpi/periodicity_07.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ test(const unsigned numRefinementLevels = 2)
IndexSet locally_active_dofs;
DoFTools::extract_locally_active_dofs(dof_handler, locally_active_dofs);

const std::vector<IndexSet> &locally_owned_dofs =
const std::vector<IndexSet> locally_owned_dofs =
dof_handler.locally_owned_dofs_per_processor();

std::map<types::global_dof_index, Point<dim>> supportPoints;
Expand Down
8 changes: 5 additions & 3 deletions tests/mpi/renumber_cuthill_mckee.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ test()
std::copy(renumbering.begin(),
renumbering.end(),
complete_renumbering.begin());
unsigned int offset = renumbering.size();
unsigned int offset = renumbering.size();
const std::vector<IndexSet> dofs_per_proc =
dofh.locally_owned_dofs_per_processor();
for (unsigned int i = 1; i < nprocs; ++i)
{
if (myid == i)
Expand All @@ -87,14 +89,14 @@ test()
MPI_COMM_WORLD);
else if (myid == 0)
MPI_Recv(&complete_renumbering[offset],
dofh.locally_owned_dofs_per_processor()[i].n_elements(),
dofs_per_proc[i].n_elements(),
Utilities::MPI::internal::mpi_type_id(
&complete_renumbering[0]),
i,
i,
MPI_COMM_WORLD,
MPI_STATUSES_IGNORE);
offset += dofh.locally_owned_dofs_per_processor()[i].n_elements();
offset += dofs_per_proc[i].n_elements();
}

if (myid == 0)
Expand Down
8 changes: 5 additions & 3 deletions tests/mpi/renumber_cuthill_mckee_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ test()
std::copy(renumbering.begin(),
renumbering.end(),
complete_renumbering.begin());
unsigned int offset = renumbering.size();
unsigned int offset = renumbering.size();
const std::vector<IndexSet> locally_owned_dofs_per_processor =
dofh.locally_owned_dofs_per_processor();
for (unsigned int i = 1; i < nprocs; ++i)
{
if (myid == i)
Expand All @@ -90,14 +92,14 @@ test()
MPI_COMM_WORLD);
else if (myid == 0)
MPI_Recv(&complete_renumbering[offset],
dofh.locally_owned_dofs_per_processor()[i].n_elements(),
locally_owned_dofs_per_processor[i].n_elements(),
Utilities::MPI::internal::mpi_type_id(
&complete_renumbering[0]),
i,
i,
MPI_COMM_WORLD,
MPI_STATUSES_IGNORE);
offset += dofh.locally_owned_dofs_per_processor()[i].n_elements();
offset += locally_owned_dofs_per_processor[i].n_elements();
}

if (myid == 0)
Expand Down
5 changes: 4 additions & 1 deletion tests/mpi/step-40_cuthill_mckee_MPI-subset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,13 @@ namespace Step40
pcout << " Number of degrees of freedom: " << dof_handler.n_dofs()
<< std::endl
<< " ";
const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dof_handler.n_locally_owned_dofs_per_processor();
for (unsigned int i = 0;
i < Utilities::MPI::n_mpi_processes(mpi_communicator);
++i)
pcout << dof_handler.n_locally_owned_dofs_per_processor()[i] << '+';
pcout << n_locally_owned_dofs_per_processor[i] << '+';
pcout << std::endl;

assemble_system();
Expand Down
25 changes: 13 additions & 12 deletions tests/sharedtria/dof_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ test()
// }
// deallog << " sum: " << sum << std::endl;

const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dof_handler.n_locally_owned_dofs_per_processor();
Assert(dof_handler.n_locally_owned_dofs() ==
dof_handler.n_locally_owned_dofs_per_processor()
[triangulation.locally_owned_subdomain()],
n_locally_owned_dofs_per_processor[triangulation
.locally_owned_subdomain()],
ExcInternalError());
Assert(dof_handler.n_locally_owned_dofs() ==
dof_handler.locally_owned_dofs().n_elements(),
Expand All @@ -125,21 +128,19 @@ test()
const unsigned int N = dof_handler.n_dofs();

Assert(dof_handler.n_locally_owned_dofs() <= N, ExcInternalError());
Assert(std::accumulate(
dof_handler.n_locally_owned_dofs_per_processor().begin(),
dof_handler.n_locally_owned_dofs_per_processor().end(),
0U) == N,
Assert(std::accumulate(n_locally_owned_dofs_per_processor.begin(),
n_locally_owned_dofs_per_processor.end(),
0U) == N,
ExcInternalError());

const std::vector<IndexSet> locally_owned_dofs_per_processor =
dof_handler.locally_owned_dofs_per_processor();
IndexSet all(N);
for (unsigned int i = 0;
i < dof_handler.locally_owned_dofs_per_processor().size();
++i)
for (unsigned int i = 0; i < locally_owned_dofs_per_processor.size(); ++i)
{
IndexSet intersect =
all & dof_handler.locally_owned_dofs_per_processor()[i];
IndexSet intersect = all & locally_owned_dofs_per_processor[i];
Assert(intersect.n_elements() == 0, ExcInternalError());
all.add_indices(dof_handler.locally_owned_dofs_per_processor()[i]);
all.add_indices(locally_owned_dofs_per_processor[i]);
}

Assert(all == complete_index_set(N), ExcInternalError());
Expand Down
25 changes: 13 additions & 12 deletions tests/sharedtria/dof_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ test()
// }
// deallog << " sum: " << sum << std::endl;

const std::vector<types::global_dof_index>
n_locally_owned_dofs_per_processor =
dof_handler.n_locally_owned_dofs_per_processor();
Assert(dof_handler.n_locally_owned_dofs() ==
dof_handler.n_locally_owned_dofs_per_processor()
[triangulation.locally_owned_subdomain()],
n_locally_owned_dofs_per_processor[triangulation
.locally_owned_subdomain()],
ExcInternalError());
Assert(dof_handler.n_locally_owned_dofs() ==
dof_handler.locally_owned_dofs().n_elements(),
Expand All @@ -125,21 +128,19 @@ test()
const unsigned int N = dof_handler.n_dofs();

Assert(dof_handler.n_locally_owned_dofs() <= N, ExcInternalError());
Assert(std::accumulate(
dof_handler.n_locally_owned_dofs_per_processor().begin(),
dof_handler.n_locally_owned_dofs_per_processor().end(),
0U) == N,
Assert(std::accumulate(n_locally_owned_dofs_per_processor.begin(),
n_locally_owned_dofs_per_processor.end(),
0U) == N,
ExcInternalError());

const std::vector<IndexSet> locally_owned_dofs_per_processor =
dof_handler.locally_owned_dofs_per_processor();
IndexSet all(N);
for (unsigned int i = 0;
i < dof_handler.locally_owned_dofs_per_processor().size();
++i)
for (unsigned int i = 0; i < locally_owned_dofs_per_processor.size(); ++i)
{
IndexSet intersect =
all & dof_handler.locally_owned_dofs_per_processor()[i];
IndexSet intersect = all & locally_owned_dofs_per_processor[i];
Assert(intersect.n_elements() == 0, ExcInternalError());
all.add_indices(dof_handler.locally_owned_dofs_per_processor()[i]);
all.add_indices(locally_owned_dofs_per_processor[i]);
}
Assert(all == complete_index_set(N), ExcInternalError());
}
Expand Down

0 comments on commit 2435251

Please sign in to comment.