// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
{
- return 100;
+ return 1;
}
template <int dim>
GridGenerator::subdivided_hyper_cube(tr, 16);
- tr.signals.cell_weight.connect(
- std::bind(&cell_weight<dim>, std::placeholders::_1, std::placeholders::_2));
+ tr.signals.cell_weight.connect(&cell_weight<dim>);
tr.refine_global(1);
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/filtered_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria.h>
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
{
const unsigned int cell_weight =
- (cell->center()[0] < 0.5 || cell->center()[1] < 0.5 ? 0 : 3 * 1000);
+ (cell->center()[0] < 0.5 || cell->center()[1] < 0.5 ? 1 : 4);
return cell_weight;
}
tr.refine_global(1);
- tr.signals.cell_weight.connect(
- std::bind(&cell_weight<dim>, std::placeholders::_1, std::placeholders::_2));
+ tr.signals.cell_weight.connect(&cell_weight<dim>);
tr.repartition();
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
<< " locally owned active cells" << std::endl;
// let each processor sum up its weights
- std::vector<double> integrated_weights(numproc, 0.0);
- for (typename Triangulation<dim>::active_cell_iterator cell =
- tr.begin_active();
- cell != tr.end();
- ++cell)
- if (cell->is_locally_owned())
- integrated_weights[myid] +=
- 1000 + cell_weight<dim>(
- cell, parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+ std::vector<unsigned int> integrated_weights(numproc, 0);
+ for (const auto &cell :
+ tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ integrated_weights[myid] +=
+ cell_weight<dim>(cell,
+ parallel::distributed::Triangulation<dim>::CELL_PERSIST);
Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights);
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": " << integrated_weights[p] << " weight"
<< std::endl;
DEAL:2d::processor 2: 128 locally owned active cells
DEAL:2d::processor 3: 92 locally owned active cells
DEAL:2d::processor 4: 88 locally owned active cells
-DEAL:2d::processor 0: 360000. weight
-DEAL:2d::processor 1: 356000. weight
-DEAL:2d::processor 2: 356000. weight
-DEAL:2d::processor 3: 368000. weight
-DEAL:2d::processor 4: 352000. weight
+DEAL:2d::processor 0: 360 weight
+DEAL:2d::processor 1: 356 weight
+DEAL:2d::processor 2: 356 weight
+DEAL:2d::processor 3: 368 weight
+DEAL:2d::processor 4: 352 weight
DEAL:3d::processor 0: 11472 locally owned active cells
DEAL:3d::processor 1: 3480 locally owned active cells
DEAL:3d::processor 2: 7168 locally owned active cells
DEAL:3d::processor 3: 7784 locally owned active cells
DEAL:3d::processor 4: 2864 locally owned active cells
-DEAL:3d::processor 0: 1.14720e+07 weight
-DEAL:3d::processor 1: 1.14720e+07 weight
-DEAL:3d::processor 2: 1.14640e+07 weight
-DEAL:3d::processor 3: 1.14800e+07 weight
-DEAL:3d::processor 4: 1.14560e+07 weight
+DEAL:3d::processor 0: 11472 weight
+DEAL:3d::processor 1: 11472 weight
+DEAL:3d::processor 2: 11464 weight
+DEAL:3d::processor 3: 11480 weight
+DEAL:3d::processor 4: 11456 weight
// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/filtered_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria.h>
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
{
const unsigned int cell_weight =
- (cell->center()[0] < 0.5 || cell->center()[1] < 0.5 ? 0 : 999 * 1000);
+ (cell->center()[0] < 0.5 || cell->center()[1] < 0.5 ? 1 : 1000);
return cell_weight;
}
GridGenerator::subdivided_hyper_cube(tr, 16);
- tr.signals.cell_weight.connect(
- std::bind(&cell_weight<dim>, std::placeholders::_1, std::placeholders::_2));
+ tr.signals.cell_weight.connect(&cell_weight<dim>);
tr.refine_global(1);
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
<< " locally owned active cells" << std::endl;
// let each processor sum up its weights
- std::vector<double> integrated_weights(numproc, 0.0);
- for (typename Triangulation<dim>::active_cell_iterator cell =
- tr.begin_active();
- cell != tr.end();
- ++cell)
- if (cell->is_locally_owned())
- integrated_weights[myid] +=
- 1000 + cell_weight<dim>(
- cell, parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+ std::vector<unsigned int> integrated_weights(numproc, 0);
+ for (const auto &cell :
+ tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ integrated_weights[myid] +=
+ cell_weight<dim>(cell,
+ parallel::distributed::Triangulation<dim>::CELL_PERSIST);
Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights);
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": " << integrated_weights[p] << " weight"
<< std::endl;
DEAL:2d::processor 2: 52 locally owned active cells
DEAL:2d::processor 3: 48 locally owned active cells
DEAL:2d::processor 4: 52 locally owned active cells
-DEAL:2d::processor 0: 5.27680e+07 weight
-DEAL:2d::processor 1: 5.20000e+07 weight
-DEAL:2d::processor 2: 5.20000e+07 weight
-DEAL:2d::processor 3: 4.80000e+07 weight
-DEAL:2d::processor 4: 5.20000e+07 weight
+DEAL:2d::processor 0: 52768 weight
+DEAL:2d::processor 1: 52000 weight
+DEAL:2d::processor 2: 52000 weight
+DEAL:2d::processor 3: 48000 weight
+DEAL:2d::processor 4: 52000 weight
DEAL:3d::processor 0: 13920 locally owned active cells
DEAL:3d::processor 1: 1640 locally owned active cells
DEAL:3d::processor 2: 13920 locally owned active cells
DEAL:3d::processor 3: 1648 locally owned active cells
DEAL:3d::processor 4: 1640 locally owned active cells
-DEAL:3d::processor 0: 1.64429e+09 weight
-DEAL:3d::processor 1: 1.64000e+09 weight
-DEAL:3d::processor 2: 1.64429e+09 weight
-DEAL:3d::processor 3: 1.64800e+09 weight
-DEAL:3d::processor 4: 1.64000e+09 weight
+DEAL:3d::processor 0: 1644288 weight
+DEAL:3d::processor 1: 1640000 weight
+DEAL:3d::processor 2: 1644288 weight
+DEAL:3d::processor 3: 1648000 weight
+DEAL:3d::processor 4: 1640000 weight
// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/filtered_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria.h>
const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
{
- return (
- // bottom left corner
- (cell->center()[0] < 1) && (cell->center()[1] < 1) &&
- (dim == 3 ? (cell->center()[2] < 1) : true) ?
- // one cell has more weight than all others together
- Utilities::pow(16, dim) * 1000 :
- 0);
+ unsigned int weight = 1;
+
+ // one cell in bottom left corner has more weight than all others together
+ if ((cell->center()[0] < 1) && (cell->center()[1] < 1) &&
+ (dim == 3 ? (cell->center()[2] < 1) : true))
+ weight += Utilities::pow(16, dim);
+
+ return weight;
}
template <int dim>
// repartition the mesh; attach different weights to all cells
- tr.signals.cell_weight.connect(
- std::bind(&cell_weight<dim>, std::placeholders::_1, std::placeholders::_2));
+ tr.signals.cell_weight.connect(&cell_weight<dim>);
tr.repartition();
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
<< " locally owned active cells" << std::endl;
// let each processor sum up its weights
- std::vector<double> integrated_weights(numproc, 0.0);
- for (typename Triangulation<dim>::active_cell_iterator cell =
- tr.begin_active();
- cell != tr.end();
- ++cell)
- if (cell->is_locally_owned())
- integrated_weights[myid] +=
- 1000 + cell_weight<dim>(
- cell, parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+ std::vector<unsigned int> integrated_weights(numproc, 0);
+ for (const auto &cell :
+ tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ integrated_weights[myid] +=
+ cell_weight<dim>(cell,
+ parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+
Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights);
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": " << integrated_weights[p] << " weight"
<< std::endl;
DEAL:2d::processor 0: 1 locally owned active cells
-DEAL:2d::processor 1: 85 locally owned active cells
-DEAL:2d::processor 2: 170 locally owned active cells
-DEAL:2d::processor 0: 257000. weight
-DEAL:2d::processor 1: 85000.0 weight
-DEAL:2d::processor 2: 170000. weight
+DEAL:2d::processor 1: 84 locally owned active cells
+DEAL:2d::processor 2: 171 locally owned active cells
+DEAL:2d::processor 0: 257 weight
+DEAL:2d::processor 1: 84 weight
+DEAL:2d::processor 2: 171 weight
DEAL:3d::processor 0: 1 locally owned active cells
-DEAL:3d::processor 1: 1365 locally owned active cells
-DEAL:3d::processor 2: 2730 locally owned active cells
-DEAL:3d::processor 0: 4.09700e+06 weight
-DEAL:3d::processor 1: 1.36500e+06 weight
-DEAL:3d::processor 2: 2.73000e+06 weight
+DEAL:3d::processor 1: 1364 locally owned active cells
+DEAL:3d::processor 2: 2731 locally owned active cells
+DEAL:3d::processor 0: 4097 weight
+DEAL:3d::processor 1: 1364 weight
+DEAL:3d::processor 2: 2731 weight
DEAL:2d::processor 0: 1 locally owned active cells
DEAL:2d::processor 1: 0 locally owned active cells
-DEAL:2d::processor 2: 51 locally owned active cells
+DEAL:2d::processor 2: 50 locally owned active cells
DEAL:2d::processor 3: 102 locally owned active cells
-DEAL:2d::processor 4: 102 locally owned active cells
-DEAL:2d::processor 0: 257000. weight
+DEAL:2d::processor 4: 103 locally owned active cells
+DEAL:2d::processor 0: 257 weight
DEAL:2d::processor 1: 0 weight
-DEAL:2d::processor 2: 51000.0 weight
-DEAL:2d::processor 3: 102000. weight
-DEAL:2d::processor 4: 102000. weight
+DEAL:2d::processor 2: 50 weight
+DEAL:2d::processor 3: 102 weight
+DEAL:2d::processor 4: 103 weight
DEAL:3d::processor 0: 1 locally owned active cells
DEAL:3d::processor 1: 0 locally owned active cells
-DEAL:3d::processor 2: 819 locally owned active cells
+DEAL:3d::processor 2: 818 locally owned active cells
DEAL:3d::processor 3: 1638 locally owned active cells
-DEAL:3d::processor 4: 1638 locally owned active cells
-DEAL:3d::processor 0: 4.09700e+06 weight
+DEAL:3d::processor 4: 1639 locally owned active cells
+DEAL:3d::processor 0: 4097 weight
DEAL:3d::processor 1: 0 weight
-DEAL:3d::processor 2: 819000. weight
-DEAL:3d::processor 3: 1.63800e+06 weight
-DEAL:3d::processor 4: 1.63800e+06 weight
+DEAL:3d::processor 2: 818 weight
+DEAL:3d::processor 3: 1638 weight
+DEAL:3d::processor 4: 1639 weight
// ---------------------------------------------------------------------
//
-// Copyright (C) 2009 - 2020 by the deal.II authors
+// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/filtered_iterator.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/grid/tria.h>
const typename parallel::distributed::Triangulation<dim>::cell_iterator &cell,
const typename parallel::distributed::Triangulation<dim>::CellStatus status)
{
- return (
- // bottom left corner
- (cell->center()[0] < 1) && (cell->center()[1] < 1) &&
- (dim == 3 ? (cell->center()[2] < 1) : true) ?
- // one cell has more weight than all others together
- n_global_active_cells * 1000 :
- 0);
+ unsigned int weight = 1;
+
+ // one cell in bottom left corner has more weight than all others together
+ if ((cell->center()[0] < 1) && (cell->center()[1] < 1) &&
+ (dim == 3 ? (cell->center()[2] < 1) : true))
+ weight += n_global_active_cells;
+
+ return weight;
}
template <int dim>
// repartition the mesh; attach different weights to all cells
n_global_active_cells = tr.n_global_active_cells();
- tr.signals.cell_weight.connect(
- std::bind(&cell_weight<dim>, std::placeholders::_1, std::placeholders::_2));
+ tr.signals.cell_weight.connect(&cell_weight<dim>);
tr.repartition();
const auto n_locally_owned_active_cells_per_processor =
Utilities::MPI::all_gather(tr.get_communicator(),
tr.n_locally_owned_active_cells());
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": "
<< n_locally_owned_active_cells_per_processor[p]
<< " locally owned active cells" << std::endl;
// let each processor sum up its weights
- std::vector<double> integrated_weights(numproc, 0.0);
- for (typename Triangulation<dim>::active_cell_iterator cell =
- tr.begin_active();
- cell != tr.end();
- ++cell)
- if (cell->is_locally_owned())
- integrated_weights[myid] +=
- 1000 + cell_weight<dim>(
- cell, parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+ std::vector<unsigned int> integrated_weights(numproc, 0);
+ for (const auto &cell :
+ tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell())
+ integrated_weights[myid] +=
+ cell_weight<dim>(cell,
+ parallel::distributed::Triangulation<dim>::CELL_PERSIST);
+
Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights);
- if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ if (myid == 0)
for (unsigned int p = 0; p < numproc; ++p)
deallog << "processor " << p << ": " << integrated_weights[p] << " weight"
<< std::endl;
DEAL:2d::processor 0: 0 locally owned active cells
-DEAL:2d::processor 1: 88 locally owned active cells
-DEAL:2d::processor 2: 168 locally owned active cells
+DEAL:2d::processor 1: 84 locally owned active cells
+DEAL:2d::processor 2: 172 locally owned active cells
DEAL:2d::processor 0: 0 weight
-DEAL:2d::processor 1: 344000. weight
-DEAL:2d::processor 2: 168000. weight
+DEAL:2d::processor 1: 340 weight
+DEAL:2d::processor 2: 172 weight
DEAL:3d::processor 0: 0 locally owned active cells
DEAL:3d::processor 1: 1368 locally owned active cells
DEAL:3d::processor 2: 2728 locally owned active cells
DEAL:3d::processor 0: 0 weight
-DEAL:3d::processor 1: 5.46400e+06 weight
-DEAL:3d::processor 2: 2.72800e+06 weight
+DEAL:3d::processor 1: 5464 weight
+DEAL:3d::processor 2: 2728 weight
// ---------------------------------------------------------------------
//
-// Copyright (C) 2018 - 2021 by the deal.II authors
+// Copyright (C) 2018 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// repartitioning the triangulation. The expected accumulated weight on
// each processor should correlate to the sum of all degrees of
// freedom on all cells of the corresponding subdomain.
-// We employ a large proportionality factor on our weighting function
-// to neglect the standard weight of '1000' per cell.
//
// This test works on a parallel::distributed::Triangulation.
const parallel::CellWeights<dim> cell_weights(
- dh, parallel::CellWeights<dim>::ndofs_weighting({100000, 1}));
+ dh, parallel::CellWeights<dim>::ndofs_weighting({1, 1}));
tria.repartition();
DEAL:0:2d::OK
DEAL:0:3d::Number of cells before repartitioning: 32
DEAL:0:3d:: Cumulative dofs per cell: 464
-DEAL:0:3d::Number of cells after repartitioning: 24
-DEAL:0:3d:: Cumulative dofs per cell: 400
+DEAL:0:3d::Number of cells after repartitioning: 16
+DEAL:0:3d:: Cumulative dofs per cell: 336
DEAL:0:3d::ExcMessage("Triangulation associated with the DoFHandler has changed!")
DEAL:0:3d::OK
DEAL:1:2d::OK
DEAL:1:3d::Number of cells before repartitioning: 32
DEAL:1:3d:: Cumulative dofs per cell: 256
-DEAL:1:3d::Number of cells after repartitioning: 40
-DEAL:1:3d:: Cumulative dofs per cell: 320
+DEAL:1:3d::Number of cells after repartitioning: 48
+DEAL:1:3d:: Cumulative dofs per cell: 384
DEAL:1:3d::ExcMessage("Triangulation associated with the DoFHandler has changed!")
DEAL:1:3d::OK
// ---------------------------------------------------------------------
//
-// Copyright (C) 2018 - 2021 by the deal.II authors
+// Copyright (C) 2018 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// repartitioning the triangulation. The expected accumulated weight on
// each processor should correlate to the sum of all degrees of
// freedom on all cells of the corresponding subdomain.
-// We employ a large proportionality factor on our weighting function
-// to neglect the standard weight of '1000' per cell.
//
// This test works on a parallel::distributed::Triangulation.
//
const parallel::CellWeights<dim> cell_weights(
- dh, parallel::CellWeights<dim>::ndofs_weighting({100000, 1}));
+ dh, parallel::CellWeights<dim>::ndofs_weighting({1, 1}));
tria.repartition();
// ---------------------------------------------------------------------
//
-// Copyright (C) 2018 - 2021 by the deal.II authors
+// Copyright (C) 2018 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// repartitioning the triangulation. The expected accumulated weight on
// each processor should correlate to the sum of all degrees of
// freedom on all cells of the corresponding subdomain.
-// We employ a large proportionality factor on our weighting function
-// to neglect the standard weight of '1000' per cell.
//
// This test works on a parallel::shared::Triangulation with METIS
// as a partitioner. Cell weighting with ZOLTAN was not available
const parallel::CellWeights<dim> cell_weights(
- dh, parallel::CellWeights<dim>::ndofs_weighting({100000, 1}));
+ dh, parallel::CellWeights<dim>::ndofs_weighting({1, 1}));
// we didn't mark any cells, but we want to repartition our domain
tria.execute_coarsening_and_refinement();
// ---------------------------------------------------------------------
//
-// Copyright (C) 2019 - 2021 by the deal.II authors
+// Copyright (C) 2019 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// repartitioning the triangulation. The expected accumulated weight on
// each processor should correlate to the sum of all degrees of
// freedom on all cells of the corresponding subdomain.
-// We employ a large proportionality factor on our weighting function
-// to neglect the standard weight of '1000' per cell.
//
// This test works on a parallel::shared::Triangulation with METIS
// as a partitioner. Cell weighting with ZOLTAN was not available
const parallel::CellWeights<dim> cell_weights(
- dh, parallel::CellWeights<dim>::ndofs_weighting({100000, 1}));
+ dh, parallel::CellWeights<dim>::ndofs_weighting({1, 1}));
// we didn't mark any cells, but we want to repartition our domain
tria.execute_coarsening_and_refinement();