From 5375f260ea0762aeb09863815a9c14fb096ac27c Mon Sep 17 00:00:00 2001 From: Pasquale Africa Date: Mon, 3 Jul 2023 19:51:46 +0000 Subject: [PATCH] Deprecate Triangulation::CellStatus --- .../minor/20230703PasqualeClaudioAfrica | 3 + examples/step-68/step-68.cc | 14 +-- include/deal.II/base/quadrature_point_data.h | 3 +- .../cell_data_transfer.templates.h | 12 +- .../distributed/fully_distributed_tria.h | 2 +- include/deal.II/grid/cell_status.h | 21 ++-- .../{data_transfer.h => data_serializer.h} | 105 ++++++++++-------- include/deal.II/grid/tria.h | 91 +++++++++------ source/distributed/cell_weights.cc | 8 +- source/distributed/fully_distributed_tria.cc | 3 +- .../repartitioning_policy_tools.cc | 2 +- source/distributed/solution_transfer.cc | 12 +- source/distributed/tria.cc | 98 ++++++++-------- source/grid/CMakeLists.txt | 4 +- .../{data_transfer.cc => data_serializer.cc} | 81 ++++++++------ ...ansfer.inst.in => data_serializer.inst.in} | 3 +- source/grid/grid_tools.cc | 4 +- source/grid/tria.cc | 55 ++++----- source/particles/particle_handler.cc | 14 +-- tests/mpi/attach_data_01.cc | 16 +-- tests/mpi/attach_data_02.cc | 16 +-- tests/mpi/cell_weights_03.cc | 3 +- tests/mpi/cell_weights_04.cc | 3 +- tests/mpi/cell_weights_05.cc | 3 +- tests/mpi/cell_weights_06.cc | 3 +- tests/mpi/p4est_save_05.cc | 4 +- tests/mpi/p4est_save_07.cc | 4 +- tests/mpi/repartition_02.cc | 16 +-- tests/particles/particle_weights_01.cc | 8 +- tests/particles/step-68.cc | 14 +-- 30 files changed, 343 insertions(+), 282 deletions(-) create mode 100644 doc/news/changes/minor/20230703PasqualeClaudioAfrica rename include/deal.II/grid/{data_transfer.h => data_serializer.h} (71%) rename source/grid/{data_transfer.cc => data_serializer.cc} (94%) rename source/grid/{data_transfer.inst.in => data_serializer.inst.in} (85%) diff --git a/doc/news/changes/minor/20230703PasqualeClaudioAfrica b/doc/news/changes/minor/20230703PasqualeClaudioAfrica new file mode 100644 index 0000000000..05f34b8489 --- /dev/null +++ b/doc/news/changes/minor/20230703PasqualeClaudioAfrica @@ -0,0 +1,3 @@ +Deprecated: The CellStatus enumeration has been deprecated in the Triangulation class and moved to the global deal.II namespace. As a consequence, all references to Triangulation, parallel::distributed::Triangulation::CellStatus, and similar should be updated to use CellStatus directly. Also, the enumeration values have been renamed: CELL_PERSIST -> cell_will_persist, CELL_REFINE -> cell_will_be_refined, CELL_COARSEN -> children_will_be_coarsened, CELL_INVALID -> cell_invalid). +
+(Pasquale Claudio Africa, 2023/07/03) diff --git a/examples/step-68/step-68.cc b/examples/step-68/step-68.cc index 5622a782dd..38bd36561b 100644 --- a/examples/step-68/step-68.cc +++ b/examples/step-68/step-68.cc @@ -345,21 +345,21 @@ namespace Step68 const unsigned int particle_weight = 10; // This example does not use adaptive refinement, therefore every cell - // should have the status `CELL_PERSIST`. However this function can also - // be used to distribute load during refinement, therefore we consider - // refined or coarsened cells as well. + // should have the status `CellStatus::cell_will_persist`. However this + // function can also be used to distribute load during refinement, therefore + // we consider refined or coarsened cells as well. unsigned int n_particles_in_cell = 0; switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: n_particles_in_cell = particle_handler.n_particles_in_cell(cell); break; - case CELL_INVALID: + case CellStatus::cell_invalid: break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: for (const auto &child : cell->child_iterators()) n_particles_in_cell += particle_handler.n_particles_in_cell(child); break; diff --git a/include/deal.II/base/quadrature_point_data.h b/include/deal.II/base/quadrature_point_data.h index 0aad2b2eb7..5dabd69336 100644 --- a/include/deal.II/base/quadrature_point_data.h +++ b/include/deal.II/base/quadrature_point_data.h @@ -993,7 +993,8 @@ namespace parallel const boost::iterator_range::const_iterator> &data_range) { - Assert((status != CELL_COARSEN), ExcNotImplemented()); + Assert((status != CellStatus::children_will_be_coarsened), + ExcNotImplemented()); (void)status; matrix_dofs = diff --git a/include/deal.II/distributed/cell_data_transfer.templates.h b/include/deal.II/distributed/cell_data_transfer.templates.h index 26fd05b13a..cd81b30ddb 100644 --- a/include/deal.II/distributed/cell_data_transfer.templates.h +++ b/include/deal.II/distributed/cell_data_transfer.templates.h @@ -256,14 +256,14 @@ namespace parallel { switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: // Cell either persists, or will be refined, and its children do // not exist yet in the latter case. *it_output = (**it_input)[cell->active_cell_index()]; break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: { // Cell is parent whose children will get coarsened to. // Decide data to store on parent by provided strategy. @@ -335,14 +335,14 @@ namespace parallel for (; it_input != cell_data.cend(); ++it_input, ++it_output) switch (status) { - case CELL_PERSIST: - case CELL_COARSEN: + case CellStatus::cell_will_persist: + case CellStatus::children_will_be_coarsened: // Cell either persists, or has been coarsened. // Thus, cell has no (longer) children. (**it_output)[cell->active_cell_index()] = *it_input; break; - case CELL_REFINE: + case CellStatus::cell_will_be_refined: { // Cell has been refined, and is now parent of its children. // Thus, distribute parent's data on its children. diff --git a/include/deal.II/distributed/fully_distributed_tria.h b/include/deal.II/distributed/fully_distributed_tria.h index 4e4319ae25..084ff11056 100644 --- a/include/deal.II/distributed/fully_distributed_tria.h +++ b/include/deal.II/distributed/fully_distributed_tria.h @@ -282,7 +282,7 @@ namespace parallel * will change in the private member vector local_cell_relations. * * As no adaptive mesh refinement is supported at the moment for this - * class, all cells will be flagged with the CellStatus CELL_PERSIST. + * class, all cells will be flagged with CellStatus::cell_will_persist. * These relations will currently only be used for serialization. * * The stored vector will have a size equal to the number of locally owned diff --git a/include/deal.II/grid/cell_status.h b/include/deal.II/grid/cell_status.h index b10b3fc9c2..071dc69e1a 100644 --- a/include/deal.II/grid/cell_status.h +++ b/include/deal.II/grid/cell_status.h @@ -21,31 +21,32 @@ DEAL_II_NAMESPACE_OPEN /** - * Used to inform functions in derived classes how the cell with the given - * cell_iterator is going to change. Note that this may me different than - * the refine_flag() and coarsen_flag() in the cell_iterator in parallel - * calculations because of refinement constraints that this machine does not - * see. + * The elements of this `enum` are used to inform functions how a specific cell + * is going to change. This is used in the course of transferring data from one + * mesh to a refined or coarsened version of the mesh, for example. Note that + * this may me different than the refine_flag() and coarsen_flag() set on a + * cell, for example in parallel calculations, because of refinement constraints + * that an individual machine does not see. */ -enum CellStatus +enum class CellStatus : unsigned int { /** * The cell will not be refined or coarsened and might or might not move * to a different processor. */ - CELL_PERSIST, + cell_will_persist, /** * The cell will be or was refined. */ - CELL_REFINE, + cell_will_be_refined, /** * The children of this cell will be or were coarsened into this cell. */ - CELL_COARSEN, + children_will_be_coarsened, /** * Invalid status. Will not occur for the user. */ - CELL_INVALID + cell_invalid }; DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/grid/data_transfer.h b/include/deal.II/grid/data_serializer.h similarity index 71% rename from include/deal.II/grid/data_transfer.h rename to include/deal.II/grid/data_serializer.h index 5eac21a8d4..9291d0b241 100644 --- a/include/deal.II/grid/data_transfer.h +++ b/include/deal.II/grid/data_serializer.h @@ -13,8 +13,8 @@ // // --------------------------------------------------------------------- -#ifndef dealii_tria_data_transfer_h -#define dealii_tria_data_transfer_h +#ifndef dealii_tria_data_serializer_h +#define dealii_tria_data_serializer_h #include @@ -35,49 +35,54 @@ DEAL_II_NAMESPACE_OPEN -template -DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -struct CellAttachedData +namespace internal { - using cell_iterator = TriaIterator>; - - /** - * Number of functions that get attached to the Triangulation through - * register_data_attach() for example SolutionTransfer. - */ - unsigned int n_attached_data_sets; - /** - * Number of functions that need to unpack their data after a call from - * load(). + * A structure that binds information about data attached to cells. */ - unsigned int n_attached_deserialize; - - using pack_callback_t = - std::function(cell_iterator, CellStatus)>; - - /** - * These callback functions will be stored in the order in which they - * have been registered with the register_data_attach() function. - */ - std::vector pack_callbacks_fixed; - std::vector pack_callbacks_variable; -}; + template + DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) + struct CellAttachedData + { + using cell_iterator = TriaIterator>; + + /** + * Number of functions that get attached to the Triangulation through + * register_data_attach() for example SolutionTransfer. + */ + unsigned int n_attached_data_sets; + + /** + * Number of functions that need to unpack their data after a call from + * load(). + */ + unsigned int n_attached_deserialize; + + using pack_callback_t = + std::function(cell_iterator, CellStatus)>; + + /** + * These callback functions will be stored in the order in which they + * have been registered with the register_data_attach() function. + */ + std::vector pack_callbacks_fixed; + std::vector pack_callbacks_variable; + }; +} // namespace internal /** * A structure that stores information about the data that has been, or * will be, attached to cells via the register_data_attach() function * and later retrieved via notify_ready_to_unpack(). * - * This class in the private scope of parallel::DistributedTriangulationBase - * is dedicated to the data transfer across repartitioned meshes - * and to/from the file system. + * This internalclass is dedicated to the data serialization and transfer across + * repartitioned meshes and to/from the file system. * - * It is designed to store all data buffers intended for transfer. + * It is designed to store all data buffers intended for serialization. */ template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -class DataTransfer +class CellAttachedDataSerializer { public: using cell_iterator = TriaIterator>; @@ -89,10 +94,10 @@ public: */ using cell_relation_t = typename std::pair; - DataTransfer(const MPI_Comm &mpi_communicator); + CellAttachedDataSerializer(); /** - * Prepare data transfer by calling the pack callback functions on each + * Prepare data serialization by calling the pack callback functions on each * cell in @p cell_relations. * * All registered callback functions in @p pack_callbacks_fixed will write @@ -102,23 +107,26 @@ public: void pack_data( const std::vector &cell_relations, - const std::vector::pack_callback_t> + const std::vector< + typename internal::CellAttachedData::pack_callback_t> &pack_callbacks_fixed, - const std::vector::pack_callback_t> - &pack_callbacks_variable); + const std::vector< + typename internal::CellAttachedData::pack_callback_t> + & pack_callbacks_variable, + const MPI_Comm &mpi_communicator); /** * Unpack the CellStatus information on each entry of * @p cell_relations. * * Data has to be previously transferred with execute_transfer() - * or read from the file system via load(). + * or deserialized from the file system via load(). */ void unpack_cell_status(std::vector &cell_relations) const; /** - * Unpack previously transferred data on each cell registered in + * Unpack previously serialized data on each cell registered in * @p cell_relations with the provided @p unpack_callback function. * * The parameter @p handle corresponds to the position where the @@ -127,7 +135,7 @@ public: * function that has been registered previously. * * Data has to be previously transferred with execute_transfer() - * or read from the file system via load(). + * or deserialized from the file system via load(). */ void unpack_data( @@ -140,7 +148,7 @@ public: &unpack_callback) const; /** - * Transfer data to file system. + * Serialize data to file system. * * The data will be written in a separate file, whose name * consists of the stem @p filename and an attached identifier @@ -156,10 +164,11 @@ public: void save(const unsigned int global_first_cell, const unsigned int global_num_cells, - const std::string &filename) const; + const std::string &filename, + const MPI_Comm & mpi_communicator) const; /** - * Transfer data from file system. + * Deserialize data from file system. * * The data will be read from separate file, whose name * consists of the stem @p filename and an attached identifier @@ -182,7 +191,8 @@ public: const unsigned int local_num_cells, const std::string &filename, const unsigned int n_attached_deserialize_fixed, - const unsigned int n_attached_deserialize_variable); + const unsigned int n_attached_deserialize_variable, + const MPI_Comm & mpi_communicator); /** * Clears all containers and associated data, and resets member @@ -211,23 +221,20 @@ public: std::vector sizes_fixed_cumulative; /** - * Consecutive buffers designed for the fixed size transfer + * Consecutive buffers designed for the fixed size serialization * functions. */ std::vector src_data_fixed; std::vector dest_data_fixed; /** - * Consecutive buffers designed for the variable size transfer + * Consecutive buffers designed for the variable size serialization * functions. */ std::vector src_sizes_variable; std::vector dest_sizes_variable; std::vector src_data_variable; std::vector dest_data_variable; - -private: - const MPI_Comm &mpi_communicator; }; DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index a828d99bb0..79be01f4d7 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -2033,7 +2033,27 @@ public: * @{ */ - using CellStatus = ::dealii::CellStatus; + /** + * Alias for backward compatibility. + * + * @deprecated This enumeration has been moved to the global namespace. + * Use ::dealii::CellStatus instead. Also, its values have been renamed + * (CELL_PERSIST -> cell_will_persist, + * CELL_REFINE -> cell_will_be_refined, + * CELL_COARSEN -> children_will_be_coarsened, + * CELL_INVALID -> cell_invalid). + */ + enum CellStatus + { + CELL_PERSIST DEAL_II_DEPRECATED = + static_cast(::dealii::CellStatus::cell_will_persist), + CELL_REFINE DEAL_II_DEPRECATED = + static_cast(::dealii::CellStatus::cell_will_be_refined), + CELL_COARSEN DEAL_II_DEPRECATED = static_cast( + ::dealii::CellStatus::children_will_be_coarsened), + CELL_INVALID DEAL_II_DEPRECATED = + static_cast(::dealii::CellStatus::cell_invalid) + }; /** * A structure used to accumulate the results of the `weight` signal slot @@ -2176,7 +2196,8 @@ public: * load of this cell. * * In serial and parallel shared applications, partitioning happens after - * refinement. So all cells will have the `CELL_PERSIST` status. + * refinement. So all cells will have the `CellStatus::cell_will_persist` + * status. * * In parallel distributed applications, partitioning happens during * refinement. If this cell is going to be coarsened, the signal is called @@ -2199,7 +2220,7 @@ public: * parallel::CellWeights class. */ boost::signals2::signal> weight; @@ -3515,32 +3536,31 @@ public: * * Specifically, the values for this argument mean the following: * - * - `CELL_PERSIST`: The cell won't be refined/coarsened, but might be - * moved to a different processor. If this is the case, the callback + * - `CellStatus::cell_will_persist`: The cell won't be refined/coarsened, but + * might be moved to a different processor. If this is the case, the callback * will want to pack up the data on this cell into an array and store * it at the provided address for later unpacking wherever this cell * may land. - * - `CELL_REFINE`: This cell will be refined into 4 or 8 cells (in 2d - * and 3d, respectively). However, because these children don't exist - * yet, you cannot access them at the time when the callback is - * called. Thus, in local_cell_relations, the corresponding - * p4est quadrants of the children cells are linked to the deal.II - * cell which is going to be refined. To be specific, only the very - * first child is marked with `CELL_REFINE`, whereas the others will be - * marked with `CELL_INVALID`, which indicates that these cells will be + * - `CellStatus::cell_will_be_refined`: This cell will be refined into 4 or 8 + * cells (in 2d and 3d, respectively). However, because these children don't + * exist yet, you cannot access them at the time when the callback is called. + * Thus, in local_cell_relations, the corresponding p4est quadrants of the + * children cells are linked to the deal.II cell which is going to be refined. + * To be specific, only the very first child is marked with + * `CellStatus::cell_will_be_refined`, whereas the others will be marked with + * `CellStatus::cell_invalid`, which indicates that these cells will be * ignored by default during the packing or unpacking process. This * ensures that data is only transferred once onto or from the parent - * cell. If the callback is called with `CELL_REFINE`, the callback - * will want to pack up the data on this cell into an array and store - * it at the provided address for later unpacking in a way so that - * it can then be transferred to the children of the cell that will - * then be available. In other words, if the data the callback - * will want to pack up corresponds to a finite element field, then - * the prolongation from parent to (new) children will have to happen - * during unpacking. - * - `CELL_COARSEN`: The children of this cell will be coarsened into the - * given cell. These children still exist, so if this is the value - * given to the callback as second argument, the callback will want + * cell. If the callback is called with `CellStatus::cell_will_be_refined`, + * the callback will want to pack up the data on this cell into an array and + * store it at the provided address for later unpacking in a way so that it + * can then be transferred to the children of the cell that will then be + * available. In other words, if the data the callback will want to pack up + * corresponds to a finite element field, then the prolongation from parent to + * (new) children will have to happen during unpacking. + * - `CellStatus::children_will_be_coarsened`: The children of this cell will + * be coarsened into the given cell. These children still exist, so if this is + * the value given to the callback as second argument, the callback will want * to transfer data from the children to the current parent cell and * pack it up so that it can later be unpacked again on a cell that * then no longer has any children (and may also be located on a @@ -3548,11 +3568,11 @@ public: * will want to pack up corresponds to a finite element field, then * it will need to do the restriction from children to parent at * this point. - * - `CELL_INVALID`: See `CELL_REFINE`. + * - `CellStatus::cell_invalid`: See `CellStatus::cell_will_be_refined`. * * @note If this function is used for serialization of data * using save() and load(), then the cell status argument with which - * the callback is called will always be `CELL_PERSIST`. + * the callback is called will always be `CellStatus::cell_will_persist`. * * The callback function is expected to return a memory chunk of the * format `std::vector`, representing the packed data on a @@ -3575,7 +3595,8 @@ public: unsigned int register_data_attach( const std::function(const cell_iterator &, - const CellStatus)> &pack_callback, + const ::dealii::CellStatus)> + & pack_callback, const bool returns_variable_size_data); /** @@ -3615,8 +3636,9 @@ public: * locally owned cell (if the cell was not refined), or the immediate * parent if it was refined during execute_coarsening_and_refinement(). * Therefore, contrary to during register_data_attach(), you can now - * access the children if the status is `CELL_REFINE` but no longer for - * callbacks with status `CELL_COARSEN`. + * access the children if the status is `CellStatus::cell_will_be_refined` but + * no longer for callbacks with status + * `CellStatus::children_will_be_coarsened`. * * The first argument to this function, `handle`, corresponds to * the return value of register_data_attach(). (The precise @@ -3631,11 +3653,11 @@ public: const unsigned int handle, const std::function< void(const cell_iterator &, - const CellStatus, + const ::dealii::CellStatus, const boost::iterator_range::const_iterator> &)> &unpack_callback); - CellAttachedData cell_attached_data; + internal::CellAttachedData cell_attached_data; protected: /** @@ -3683,10 +3705,11 @@ protected: * respective CellStatus. To update its contents, use the * update_cell_relations() member function. */ - std::vector::cell_relation_t> + std::vector< + typename CellAttachedDataSerializer::cell_relation_t> local_cell_relations; - DataTransfer data_transfer; + CellAttachedDataSerializer data_serializer; /** * @} */ diff --git a/source/distributed/cell_weights.cc b/source/distributed/cell_weights.cc index e54a17c4f5..1fa00597a6 100644 --- a/source/distributed/cell_weights.cc +++ b/source/distributed/cell_weights.cc @@ -189,13 +189,13 @@ namespace parallel unsigned int fe_index = numbers::invalid_unsigned_int; switch (status) { - case CELL_PERSIST: - case CELL_REFINE: - case CELL_INVALID: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: + case CellStatus::cell_invalid: fe_index = cell->future_fe_index(); break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: #ifdef DEBUG for (const auto &child : cell->child_iterators()) Assert(child->is_active() && child->coarsen_flag_set(), diff --git a/source/distributed/fully_distributed_tria.cc b/source/distributed/fully_distributed_tria.cc index ee1ad3f816..175f2214e1 100644 --- a/source/distributed/fully_distributed_tria.cc +++ b/source/distributed/fully_distributed_tria.cc @@ -445,7 +445,8 @@ namespace parallel for (const auto &cell : this->active_cell_iterators()) if (cell->is_locally_owned()) - this->local_cell_relations.emplace_back(cell, CELL_PERSIST); + this->local_cell_relations.emplace_back( + cell, ::dealii::CellStatus::cell_will_persist); } diff --git a/source/distributed/repartitioning_policy_tools.cc b/source/distributed/repartitioning_policy_tools.cc index 73fdb4f0b2..c5e5f074ff 100644 --- a/source/distributed/repartitioning_policy_tools.cc +++ b/source/distributed/repartitioning_policy_tools.cc @@ -296,7 +296,7 @@ namespace RepartitioningPolicyTools for (const auto &cell : tria->active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) weights[partitioner->global_to_local(cell->global_active_cell_index())] = - weighting_function(cell, CELL_PERSIST); + weighting_function(cell, CellStatus::cell_will_persist); // determine weight of all the cells locally owned by this process std::uint64_t process_local_weight = 0; diff --git a/source/distributed/solution_transfer.cc b/source/distributed/solution_transfer.cc index 107ce34ff7..6018dcd97d 100644 --- a/source/distributed/solution_transfer.cc +++ b/source/distributed/solution_transfer.cc @@ -324,14 +324,14 @@ namespace parallel { switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: { fe_index = cell->future_fe_index(); break; } - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: { // In case of coarsening, we need to find a suitable FE index // for the parent cell. We choose the 'least dominant fe' @@ -392,14 +392,14 @@ namespace parallel { switch (status) { - case CELL_PERSIST: - case CELL_COARSEN: + case CellStatus::cell_will_persist: + case CellStatus::children_will_be_coarsened: { fe_index = cell->active_fe_index(); break; } - case CELL_REFINE: + case CellStatus::cell_will_be_refined: { // After refinement, this particular cell is no longer active, // and its children have inherited its FE index. However, to diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 0d36591536..b0fb1e1ec9 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -1620,7 +1620,7 @@ namespace // this active cell didn't change // save pair into corresponding position add_single_cell_relation( - cell_rel, tree, idx, dealii_cell, CELL_PERSIST); + cell_rel, tree, idx, dealii_cell, CellStatus::cell_will_persist); } else if (p4est_has_children) // based on the conditions above, we know that // dealii_cell has no children @@ -1649,9 +1649,10 @@ namespace dealii::internal::p4est::functions::quadrant_childrenv( &p4est_cell, p4est_child); - // mark first child with CELL_REFINE and the remaining children with - // CELL_INVALID, but associate them all with the parent cell unpack - // algorithm will be called only on CELL_REFINE flagged quadrant + // mark first child with CellStatus::cell_will_be_refined and the + // remaining children with CellStatus::cell_invalid, but associate them + // all with the parent cell unpack algorithm will be called only on + // CellStatus::cell_will_be_refined flagged quadrant int child_idx; CellStatus cell_status; for (unsigned int i = 0; i < GeometryInfo::max_children_per_cell; @@ -1662,7 +1663,8 @@ namespace &p4est_child[i], dealii::internal::p4est::functions::quadrant_compare); - cell_status = (i == 0) ? CELL_REFINE : CELL_INVALID; + cell_status = (i == 0) ? CellStatus::cell_will_be_refined : + CellStatus::cell_invalid; add_single_cell_relation( cell_rel, tree, child_idx, dealii_cell, cell_status); @@ -1674,7 +1676,11 @@ namespace // its children got coarsened into this cell in p4est, // but the dealii_cell still has its children add_single_cell_relation( - cell_rel, tree, idx, dealii_cell, CELL_COARSEN); + cell_rel, + tree, + idx, + dealii_cell, + CellStatus::children_will_be_coarsened); } } } // namespace @@ -1868,13 +1874,13 @@ namespace parallel const typename dealii::internal::p4est::types::gloidx *previous_global_first_quadrant) { - Assert(this->data_transfer.sizes_fixed_cumulative.size() > 0, + Assert(this->data_serializer.sizes_fixed_cumulative.size() > 0, ExcMessage("No data has been packed!")); // Resize memory according to the data that we will receive. - this->data_transfer.dest_data_fixed.resize( + this->data_serializer.dest_data_fixed.resize( parallel_forest->local_num_quadrants * - this->data_transfer.sizes_fixed_cumulative.back()); + this->data_serializer.sizes_fixed_cumulative.back()); // Execute non-blocking fixed size transfer. typename dealii::internal::p4est::types::transfer_context @@ -1885,14 +1891,14 @@ namespace parallel previous_global_first_quadrant, parallel_forest->mpicomm, 0, - this->data_transfer.dest_data_fixed.data(), - this->data_transfer.src_data_fixed.data(), - this->data_transfer.sizes_fixed_cumulative.back()); + this->data_serializer.dest_data_fixed.data(), + this->data_serializer.src_data_fixed.data(), + this->data_serializer.sizes_fixed_cumulative.back()); - if (this->data_transfer.variable_size_data_stored) + if (this->data_serializer.variable_size_data_stored) { // Resize memory according to the data that we will receive. - this->data_transfer.dest_sizes_variable.resize( + this->data_serializer.dest_sizes_variable.resize( parallel_forest->local_num_quadrants); // Execute fixed size transfer of data sizes for variable size @@ -1902,23 +1908,23 @@ namespace parallel previous_global_first_quadrant, parallel_forest->mpicomm, 1, - this->data_transfer.dest_sizes_variable.data(), - this->data_transfer.src_sizes_variable.data(), + this->data_serializer.dest_sizes_variable.data(), + this->data_serializer.src_sizes_variable.data(), sizeof(unsigned int)); } dealii::internal::p4est::functions::transfer_fixed_end(tf_context); // Release memory of previously packed data. - this->data_transfer.src_data_fixed.clear(); - this->data_transfer.src_data_fixed.shrink_to_fit(); + this->data_serializer.src_data_fixed.clear(); + this->data_serializer.src_data_fixed.shrink_to_fit(); - if (this->data_transfer.variable_size_data_stored) + if (this->data_serializer.variable_size_data_stored) { // Resize memory according to the data that we will receive. - this->data_transfer.dest_data_variable.resize( - std::accumulate(this->data_transfer.dest_sizes_variable.begin(), - this->data_transfer.dest_sizes_variable.end(), + this->data_serializer.dest_data_variable.resize( + std::accumulate(this->data_serializer.dest_sizes_variable.begin(), + this->data_serializer.dest_sizes_variable.end(), std::vector::size_type(0))); # if DEAL_II_P4EST_VERSION_GTE(2, 0, 65, 0) @@ -1928,10 +1934,10 @@ namespace parallel // at all, which is mandatory if one of our processes does not own // any quadrant. This bypasses the assertion from being triggered. // - see: https://github.com/cburstedde/p4est/issues/48 - if (this->data_transfer.src_sizes_variable.size() == 0) - this->data_transfer.src_sizes_variable.resize(1); - if (this->data_transfer.dest_sizes_variable.size() == 0) - this->data_transfer.dest_sizes_variable.resize(1); + if (this->data_serializer.src_sizes_variable.size() == 0) + this->data_serializer.src_sizes_variable.resize(1); + if (this->data_serializer.dest_sizes_variable.size() == 0) + this->data_serializer.dest_sizes_variable.resize(1); # endif // Execute variable size transfer. @@ -1940,16 +1946,16 @@ namespace parallel previous_global_first_quadrant, parallel_forest->mpicomm, 1, - this->data_transfer.dest_data_variable.data(), - this->data_transfer.dest_sizes_variable.data(), - this->data_transfer.src_data_variable.data(), - this->data_transfer.src_sizes_variable.data()); + this->data_serializer.dest_data_variable.data(), + this->data_serializer.dest_sizes_variable.data(), + this->data_serializer.src_data_variable.data(), + this->data_serializer.src_sizes_variable.data()); // Release memory of previously packed data. - this->data_transfer.src_sizes_variable.clear(); - this->data_transfer.src_sizes_variable.shrink_to_fit(); - this->data_transfer.src_data_variable.clear(); - this->data_transfer.src_data_variable.shrink_to_fit(); + this->data_serializer.src_sizes_variable.clear(); + this->data_serializer.src_sizes_variable.shrink_to_fit(); + this->data_serializer.src_data_variable.clear(); + this->data_serializer.src_data_variable.shrink_to_fit(); } } @@ -2022,12 +2028,12 @@ namespace parallel << this->n_cells(0) << std::endl; } - // each cell should have been flagged `CELL_PERSIST` + // each cell should have been flagged `CellStatus::cell_will_persist` for (const auto &cell_rel : this->local_cell_relations) { (void)cell_rel; Assert((cell_rel.second == // cell_status - CELL_PERSIST), + CellStatus::cell_will_persist), ExcInternalError()); } @@ -3385,10 +3391,11 @@ namespace parallel // pack data before triangulation gets updated if (this->cell_attached_data.n_attached_data_sets > 0) { - this->data_transfer.pack_data( + this->data_serializer.pack_data( this->local_cell_relations, this->cell_attached_data.pack_callbacks_fixed, - this->cell_attached_data.pack_callbacks_variable); + this->cell_attached_data.pack_callbacks_variable, + this->get_communicator()); } // finally copy back from local part of tree to deal.II @@ -3418,7 +3425,7 @@ namespace parallel previous_global_first_quadrant.data()); // also update the CellStatus information on the new mesh - this->data_transfer.unpack_cell_status(this->local_cell_relations); + this->data_serializer.unpack_cell_status(this->local_cell_relations); } # ifdef DEBUG @@ -3558,10 +3565,11 @@ namespace parallel // pack data before triangulation gets updated if (this->cell_attached_data.n_attached_data_sets > 0) { - this->data_transfer.pack_data( + this->data_serializer.pack_data( this->local_cell_relations, this->cell_attached_data.pack_callbacks_fixed, - this->cell_attached_data.pack_callbacks_variable); + this->cell_attached_data.pack_callbacks_variable, + this->get_communicator()); } try @@ -4234,19 +4242,19 @@ namespace parallel switch (status) { - case CELL_PERSIST: + case CellStatus::cell_will_persist: // cell remains unchanged cell->clear_refine_flag(); cell->clear_coarsen_flag(); break; - case CELL_REFINE: + case CellStatus::cell_will_be_refined: // cell will be refined cell->clear_coarsen_flag(); cell->set_refine_flag(); break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: // children of this cell will be coarsened for (const auto &child : cell->child_iterators()) { @@ -4255,7 +4263,7 @@ namespace parallel } break; - case CELL_INVALID: + case CellStatus::cell_invalid: // do nothing as cell does not exist yet break; diff --git a/source/grid/CMakeLists.txt b/source/grid/CMakeLists.txt index fb2c6554b6..ef3e81893f 100644 --- a/source/grid/CMakeLists.txt +++ b/source/grid/CMakeLists.txt @@ -32,7 +32,7 @@ endif() set(_unity_include_src cell_id.cc - data_transfer.cc + data_serializer.cc grid_refinement.cc intergrid_map.cc manifold.cc @@ -71,7 +71,7 @@ setup_source_list("${_unity_include_src}" set(_inst cell_id.inst.in - data_transfer.inst.in + data_serializer.inst.in grid_generator_cgal.inst.in grid_generator_from_name.inst.in grid_generator.inst.in diff --git a/source/grid/data_transfer.cc b/source/grid/data_serializer.cc similarity index 94% rename from source/grid/data_transfer.cc rename to source/grid/data_serializer.cc index 0f9c6c8a18..ad6f61c3f8 100644 --- a/source/grid/data_transfer.cc +++ b/source/grid/data_serializer.cc @@ -17,7 +17,7 @@ #include -#include +#include #include #include @@ -27,20 +27,22 @@ DEAL_II_NAMESPACE_OPEN template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -DataTransfer::DataTransfer(const MPI_Comm &mpi_communicator) +CellAttachedDataSerializer::CellAttachedDataSerializer() : variable_size_data_stored(false) - , mpi_communicator(mpi_communicator) {} template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::pack_data( +void CellAttachedDataSerializer::pack_data( const std::vector &cell_relations, - const std::vector::pack_callback_t> + const std::vector< + typename internal::CellAttachedData::pack_callback_t> &pack_callbacks_fixed, - const std::vector::pack_callback_t> - &pack_callbacks_variable) + const std::vector< + typename internal::CellAttachedData::pack_callback_t> + & pack_callbacks_variable, + const MPI_Comm &mpi_communicator) { Assert(src_data_fixed.size() == 0, ExcMessage("Previously packed data has not been released yet!")); @@ -94,14 +96,14 @@ void DataTransfer::pack_data( // Assertions about the tree structure. switch (cell_status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: // double check the condition that we will only ever attach // data to active cells when we get here Assert(dealii_cell->is_active(), ExcInternalError()); break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: // double check the condition that we will only ever attach // data to cells with children when we get here. however, we // can only tolerate one level of coarsening at a time, so @@ -113,7 +115,7 @@ void DataTransfer::pack_data( Assert(dealii_cell->child(c)->is_active(), ExcInternalError()); break; - case CELL_INVALID: + case CellStatus::cell_invalid: // do nothing on invalid cells break; @@ -128,10 +130,10 @@ void DataTransfer::pack_data( // room for an array that holds information about how many // bytes each of the variable size callback functions will // write. - // On cells flagged with CELL_INVALID, only its CellStatus + // On cells flagged with CellStatus::cell_invalid, only its CellStatus // will be stored. const unsigned int n_fixed_size_data_sets_on_cell = - 1 + ((cell_status == CELL_INVALID) ? + 1 + ((cell_status == CellStatus::cell_invalid) ? 0 : ((variable_size_data_stored ? 1 : 0) + n_callbacks_fixed)); data_cell_fixed_it->resize(n_fixed_size_data_sets_on_cell); @@ -147,8 +149,8 @@ void DataTransfer::pack_data( ++data_fixed_it; // Proceed with all registered callback functions. - // Skip cells with the CELL_INVALID flag. - if (cell_status != CELL_INVALID) + // Skip cells with the CellStatus::cell_invalid flag. + if (cell_status != CellStatus::cell_invalid) { // Pack fixed size data. for (auto callback_it = pack_callbacks_fixed.cbegin(); @@ -165,7 +167,9 @@ void DataTransfer::pack_data( if (variable_size_data_stored) { const unsigned int n_variable_size_data_sets_on_cell = - ((cell_status == CELL_INVALID) ? 0 : n_callbacks_variable); + ((cell_status == CellStatus::cell_invalid) ? + 0 : + n_callbacks_variable); data_cell_variable_it->resize( n_variable_size_data_sets_on_cell); @@ -225,7 +229,7 @@ void DataTransfer::pack_data( // Generate a vector which stores the sizes of each callback function, // including the packed CellStatus transfer. // Find the very first cell that we wrote to with all callback - // functions (i.e. a cell that was not flagged with CELL_INVALID) + // functions (i.e. a cell that was not flagged with CellStatus::cell_invalid) // and store the sizes of each buffer. // // To deal with the case that at least one of the processors does not @@ -264,9 +268,7 @@ void DataTransfer::pack_data( // of all callback functions across all processors, in case one // of them does not own any cells at all. std::vector global_sizes_fixed(local_sizes_fixed.size()); - Utilities::MPI::max(local_sizes_fixed, - this->mpi_communicator, - global_sizes_fixed); + Utilities::MPI::max(local_sizes_fixed, mpi_communicator, global_sizes_fixed); // Construct cumulative sizes, since this is the only information // we need from now on. @@ -315,7 +317,7 @@ void DataTransfer::pack_data( std::back_inserter(src_data_fixed)); // If we only packed the CellStatus information - // (i.e. encountered a cell flagged CELL_INVALID), + // (i.e. encountered a cell flagged CellStatus::cell_invalid), // fill the remaining space with invalid entries. // We can skip this if there is nothing else to pack. if ((data_cell_fixed.size() == 1) && (sizes_fixed_cumulative.size() > 1)) @@ -355,8 +357,9 @@ void DataTransfer::pack_data( template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::unpack_cell_status( - std::vector::cell_relation_t> +void CellAttachedDataSerializer::unpack_cell_status( + std::vector< + typename CellAttachedDataSerializer::cell_relation_t> &cell_relations) const { Assert(sizes_fixed_cumulative.size() > 0, @@ -390,8 +393,9 @@ void DataTransfer::unpack_cell_status( template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::unpack_data( - const std::vector::cell_relation_t> +void CellAttachedDataSerializer::unpack_data( + const std::vector< + typename CellAttachedDataSerializer::cell_relation_t> & cell_relations, const unsigned int handle, const std::function< @@ -489,7 +493,7 @@ void DataTransfer::unpack_data( // of the current cell. data_increment = *dest_sizes_it; - if (cell_status != CELL_INVALID) + if (cell_status != CellStatus::cell_invalid) { // Extract the corresponding values for offset and size from // the cumulative sizes array stored in the fixed size @@ -521,22 +525,22 @@ void DataTransfer::unpack_data( switch (cell_status) { - case CELL_PERSIST: - case CELL_COARSEN: + case CellStatus::cell_will_persist: + case CellStatus::children_will_be_coarsened: unpack_callback(dealii_cell, cell_status, boost::make_iterator_range(dest_data_it, dest_data_it + size)); break; - case CELL_REFINE: + case CellStatus::cell_will_be_refined: unpack_callback(dealii_cell->parent(), cell_status, boost::make_iterator_range(dest_data_it, dest_data_it + size)); break; - case CELL_INVALID: + case CellStatus::cell_invalid: // Skip this cell. break; @@ -554,9 +558,11 @@ void DataTransfer::unpack_data( template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::save(const unsigned int global_first_cell, - const unsigned int global_num_cells, - const std::string &filename) const +void CellAttachedDataSerializer::save( + const unsigned int global_first_cell, + const unsigned int global_num_cells, + const std::string &filename, + const MPI_Comm & mpi_communicator) const { Assert(sizes_fixed_cumulative.size() > 0, ExcMessage("No data has been packed!")); @@ -778,13 +784,14 @@ void DataTransfer::save(const unsigned int global_first_cell, template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::load( +void CellAttachedDataSerializer::load( const unsigned int global_first_cell, const unsigned int global_num_cells, const unsigned int local_num_cells, const std::string &filename, const unsigned int n_attached_deserialize_fixed, - const unsigned int n_attached_deserialize_variable) + const unsigned int n_attached_deserialize_variable, + const MPI_Comm & mpi_communicator) { Assert(dest_data_fixed.size() == 0, ExcMessage("Previously loaded data has not been released yet!")); @@ -994,7 +1001,7 @@ void DataTransfer::load( template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) -void DataTransfer::clear() +void CellAttachedDataSerializer::clear() { variable_size_data_stored = false; @@ -1024,6 +1031,6 @@ void DataTransfer::clear() } // explicit instantiations -#include "data_transfer.inst" +#include "data_serializer.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/source/grid/data_transfer.inst.in b/source/grid/data_serializer.inst.in similarity index 85% rename from source/grid/data_transfer.inst.in rename to source/grid/data_serializer.inst.in index d4eb339a87..d99a5d4775 100644 --- a/source/grid/data_transfer.inst.in +++ b/source/grid/data_serializer.inst.in @@ -18,6 +18,7 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension - template class DataTransfer; + template class CellAttachedDataSerializer; #endif } diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 79cc106903..e2920086f7 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -3914,7 +3914,7 @@ namespace GridTools for (const auto &cell : triangulation.active_cell_iterators()) if (cell->is_locally_owned()) cell_weights[cell->active_cell_index()] = - triangulation.signals.weight(cell, CELL_PERSIST); + triangulation.signals.weight(cell, CellStatus::cell_will_persist); // If this is a parallel triangulation, we then need to also // get the weights for all other cells. We have asserted above @@ -4014,7 +4014,7 @@ namespace GridTools for (const auto &cell : triangulation.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) cell_weights[cell->active_cell_index()] = - triangulation.signals.weight(cell, CELL_PERSIST); + triangulation.signals.weight(cell, CellStatus::cell_will_persist); // If this is a parallel triangulation, we then need to also // get the weights for all other cells. We have asserted above diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 21fcd7fa43..b463257179 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -11065,7 +11065,6 @@ Triangulation::Triangulation( const MeshSmoothing smooth_grid, const bool check_for_distorted_cells) : cell_attached_data({0, 0, {}, {}}) - , data_transfer(get_communicator()) , smooth_grid(smooth_grid) , anisotropic_refinement(false) , check_for_distorted_cells(check_for_distorted_cells) @@ -11092,7 +11091,6 @@ DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) Triangulation::Triangulation( Triangulation &&tria) noexcept : Subscriptor(std::move(tria)) - , data_transfer(get_communicator()) , smooth_grid(tria.smooth_grid) , reference_cells(std::move(tria.reference_cells)) , periodic_face_pairs_level_0(std::move(tria.periodic_face_pairs_level_0)) @@ -11189,7 +11187,7 @@ void Triangulation::clear() reference_cells.clear(); cell_attached_data = {0, 0, {}, {}}; - data_transfer.clear(); + data_serializer.clear(); } @@ -14826,7 +14824,8 @@ template DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim)) unsigned int Triangulation::register_data_attach( const std::function(const cell_iterator &, - const CellStatus)> &pack_callback, + const ::dealii::CellStatus)> + & pack_callback, const bool returns_variable_size_data) { unsigned int handle = numbers::invalid_unsigned_int; @@ -14858,14 +14857,14 @@ void Triangulation::notify_ready_to_unpack( const unsigned int handle, const std::function< void(const cell_iterator &, - const CellStatus, + const ::dealii::CellStatus, const boost::iterator_range::const_iterator> &)> &unpack_callback) { // perform unpacking - this->data_transfer.unpack_data(this->local_cell_relations, - handle, - unpack_callback); + this->data_serializer.unpack_data(this->local_cell_relations, + handle, + unpack_callback); // decrease counters --this->cell_attached_data.n_attached_data_sets; @@ -14885,11 +14884,11 @@ void Triangulation::notify_ready_to_unpack( // everybody got their data, time for cleanup! this->cell_attached_data.pack_callbacks_fixed.clear(); this->cell_attached_data.pack_callbacks_variable.clear(); - this->data_transfer.clear(); + this->data_serializer.clear(); // reset all cell_status entries after coarsening/refinement for (auto &cell_rel : this->local_cell_relations) - cell_rel.second = CELL_PERSIST; + cell_rel.second = ::dealii::CellStatus::cell_will_persist; } } @@ -14908,16 +14907,20 @@ void Triangulation::save_attached_data( if (this->cell_attached_data.n_attached_data_sets > 0) { // pack attached data first - tria->data_transfer.pack_data( + tria->data_serializer.pack_data( tria->local_cell_relations, tria->cell_attached_data.pack_callbacks_fixed, - tria->cell_attached_data.pack_callbacks_variable); + tria->cell_attached_data.pack_callbacks_variable, + this->get_communicator()); // then store buffers in file - tria->data_transfer.save(global_first_cell, global_num_cells, filename); + tria->data_serializer.save(global_first_cell, + global_num_cells, + filename, + this->get_communicator()); // and release the memory afterwards - tria->data_transfer.clear(); + tria->data_serializer.clear(); } // clear all of the callback data, as explained in the documentation of @@ -14943,21 +14946,23 @@ void Triangulation::load_attached_data( // load saved data, if any was stored if (this->cell_attached_data.n_attached_deserialize > 0) { - this->data_transfer.load(global_first_cell, - global_num_cells, - local_num_cells, - filename, - n_attached_deserialize_fixed, - n_attached_deserialize_variable); - - this->data_transfer.unpack_cell_status(this->local_cell_relations); - - // the CellStatus of all stored cells should always be CELL_PERSIST. + this->data_serializer.load(global_first_cell, + global_num_cells, + local_num_cells, + filename, + n_attached_deserialize_fixed, + n_attached_deserialize_variable, + this->get_communicator()); + + this->data_serializer.unpack_cell_status(this->local_cell_relations); + + // the CellStatus of all stored cells should always be + // CellStatus::cell_will_persist. for (const auto &cell_rel : this->local_cell_relations) { (void)cell_rel; Assert((cell_rel.second == // cell_status - CELL_PERSIST), + ::dealii::CellStatus::cell_will_persist), ExcInternalError()); } } diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 5bad34b832..e6c489be0b 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -2299,8 +2299,8 @@ namespace Particles switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: // If the cell persist or is refined store all particles of the // current cell. { @@ -2315,7 +2315,7 @@ namespace Particles } break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: // If this cell is the parent of children that will be coarsened, // collect the particles of all children. { @@ -2356,7 +2356,7 @@ namespace Particles return; const auto cell_to_store_particles = - (status != CELL_REFINE) ? cell : cell->child(0); + (status != CellStatus::cell_will_be_refined) ? cell : cell->child(0); // deserialize particles and insert into local storage if (data_range.begin() != data_range.end()) @@ -2380,13 +2380,13 @@ namespace Particles // now update particle storage location and properties if necessary switch (status) { - case CELL_PERSIST: + case CellStatus::cell_will_persist: { // all particles are correctly inserted } break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: { // all particles are in correct cell, but their reference location // has changed @@ -2400,7 +2400,7 @@ namespace Particles } break; - case CELL_REFINE: + case CellStatus::cell_will_be_refined: { // we need to find the correct child to store the particles and // their reference location has changed diff --git a/tests/mpi/attach_data_01.cc b/tests/mpi/attach_data_01.cc index a844f2c269..38e9ddf6b9 100644 --- a/tests/mpi/attach_data_01.cc +++ b/tests/mpi/attach_data_01.cc @@ -42,15 +42,15 @@ pack_function( static int some_number = 0; deallog << "packing cell " << cell->id() << " with data=" << some_number << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_COARSEN) + if (status == CellStatus::children_will_be_coarsened) { Assert(cell->has_children(), ExcInternalError()); } @@ -76,15 +76,15 @@ unpack_function( deallog << "unpacking cell " << cell->id() << " with data=" << intdata << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_REFINE) + if (status == CellStatus::cell_will_be_refined) { Assert(cell->has_children(), ExcInternalError()); } diff --git a/tests/mpi/attach_data_02.cc b/tests/mpi/attach_data_02.cc index ff1c2895e2..55ca370c3e 100644 --- a/tests/mpi/attach_data_02.cc +++ b/tests/mpi/attach_data_02.cc @@ -57,15 +57,15 @@ pack_function( << " with data size =" << buffer.size() << " accumulated data=" << std::accumulate(some_vector.begin(), some_vector.end(), 0) << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_COARSEN) + if (status == CellStatus::children_will_be_coarsened) { Assert(cell->has_children(), ExcInternalError()); } @@ -107,15 +107,15 @@ unpack_function( << " accumulated data=" << std::accumulate(intdatavector.begin(), intdatavector.end(), 0) << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_REFINE) + if (status == CellStatus::cell_will_be_refined) { Assert(cell->has_children(), ExcInternalError()); } diff --git a/tests/mpi/cell_weights_03.cc b/tests/mpi/cell_weights_03.cc index ad2b8ae2c1..d0353f93bc 100644 --- a/tests/mpi/cell_weights_03.cc +++ b/tests/mpi/cell_weights_03.cc @@ -80,7 +80,8 @@ test() std::vector integrated_weights(numproc, 0); for (const auto &cell : tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) - integrated_weights[myid] += cell_weight(cell, CELL_PERSIST); + integrated_weights[myid] += + cell_weight(cell, CellStatus::cell_will_persist); Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights); if (myid == 0) diff --git a/tests/mpi/cell_weights_04.cc b/tests/mpi/cell_weights_04.cc index 2c46ce8ba3..819c339b56 100644 --- a/tests/mpi/cell_weights_04.cc +++ b/tests/mpi/cell_weights_04.cc @@ -74,7 +74,8 @@ test() std::vector integrated_weights(numproc, 0); for (const auto &cell : tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) - integrated_weights[myid] += cell_weight(cell, CELL_PERSIST); + integrated_weights[myid] += + cell_weight(cell, CellStatus::cell_will_persist); Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights); if (myid == 0) diff --git a/tests/mpi/cell_weights_05.cc b/tests/mpi/cell_weights_05.cc index 0a942ed7c2..c49902d7c0 100644 --- a/tests/mpi/cell_weights_05.cc +++ b/tests/mpi/cell_weights_05.cc @@ -94,7 +94,8 @@ test() std::vector integrated_weights(numproc, 0); for (const auto &cell : tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) - integrated_weights[myid] += cell_weight(cell, CELL_PERSIST); + integrated_weights[myid] += + cell_weight(cell, CellStatus::cell_will_persist); Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights); if (myid == 0) diff --git a/tests/mpi/cell_weights_06.cc b/tests/mpi/cell_weights_06.cc index aa3f764589..9295b03957 100644 --- a/tests/mpi/cell_weights_06.cc +++ b/tests/mpi/cell_weights_06.cc @@ -93,7 +93,8 @@ test() std::vector integrated_weights(numproc, 0); for (const auto &cell : tr.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) - integrated_weights[myid] += cell_weight(cell, CELL_PERSIST); + integrated_weights[myid] += + cell_weight(cell, CellStatus::cell_will_persist); Utilities::MPI::sum(integrated_weights, MPI_COMM_WORLD, integrated_weights); if (myid == 0) diff --git a/tests/mpi/p4est_save_05.cc b/tests/mpi/p4est_save_05.cc index 7a7352407a..a51d22214f 100644 --- a/tests/mpi/p4est_save_05.cc +++ b/tests/mpi/p4est_save_05.cc @@ -59,7 +59,7 @@ pack_function( << std::accumulate(some_vector.begin(), some_vector.end(), 0) << std::endl; - Assert((status == CELL_PERSIST), ExcInternalError()); + Assert((status == CellStatus::cell_will_persist), ExcInternalError()); ++some_number; return buffer; @@ -97,7 +97,7 @@ unpack_function( << std::accumulate(intdatavector.begin(), intdatavector.end(), 0) << std::endl; - Assert((status == CELL_PERSIST), ExcInternalError()); + Assert((status == CellStatus::cell_will_persist), ExcInternalError()); } diff --git a/tests/mpi/p4est_save_07.cc b/tests/mpi/p4est_save_07.cc index 972a1b5158..292ae1f4cb 100644 --- a/tests/mpi/p4est_save_07.cc +++ b/tests/mpi/p4est_save_07.cc @@ -62,7 +62,7 @@ pack_function( << std::accumulate(some_vector.begin(), some_vector.end(), 0) << std::endl; - Assert((status == CELL_PERSIST), ExcInternalError()); + Assert((status == CellStatus::cell_will_persist), ExcInternalError()); ++some_number; return buffer; @@ -100,7 +100,7 @@ unpack_function( << std::accumulate(intdatavector.begin(), intdatavector.end(), 0) << std::endl; - Assert((status == CELL_PERSIST), ExcInternalError()); + Assert((status == CellStatus::cell_will_persist), ExcInternalError()); } diff --git a/tests/mpi/repartition_02.cc b/tests/mpi/repartition_02.cc index 953d09ad87..6ba53adb83 100644 --- a/tests/mpi/repartition_02.cc +++ b/tests/mpi/repartition_02.cc @@ -42,15 +42,15 @@ pack_function( static int some_number = cell->index(); deallog << "packing cell " << cell->id() << " with data=" << some_number << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_COARSEN) + if (status == CellStatus::children_will_be_coarsened) { Assert(cell->has_children(), ExcInternalError()); } @@ -76,15 +76,15 @@ unpack_function( deallog << "unpacking cell " << cell->id() << " with data=" << number << " status="; - if (status == CELL_PERSIST) + if (status == CellStatus::cell_will_persist) deallog << "PERSIST"; - else if (status == CELL_REFINE) + else if (status == CellStatus::cell_will_be_refined) deallog << "REFINE"; - else if (status == CELL_COARSEN) + else if (status == CellStatus::children_will_be_coarsened) deallog << "COARSEN"; deallog << std::endl; - if (status == CELL_REFINE) + if (status == CellStatus::cell_will_be_refined) { Assert(cell->has_children(), ExcInternalError()); } diff --git a/tests/particles/particle_weights_01.cc b/tests/particles/particle_weights_01.cc index 884408207d..d459c3ffec 100644 --- a/tests/particles/particle_weights_01.cc +++ b/tests/particles/particle_weights_01.cc @@ -78,15 +78,15 @@ test() unsigned int n_particles_in_cell = 0; switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: n_particles_in_cell = particle_handler.n_particles_in_cell(cell); break; - case CELL_INVALID: + case CellStatus::cell_invalid: break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: for (const auto &child : cell->child_iterators()) n_particles_in_cell += particle_handler.n_particles_in_cell(child); diff --git a/tests/particles/step-68.cc b/tests/particles/step-68.cc index 69210d0f99..16701af078 100644 --- a/tests/particles/step-68.cc +++ b/tests/particles/step-68.cc @@ -273,21 +273,21 @@ namespace Step68 const unsigned int particle_weight = 10; // This example does not use adaptive refinement, therefore every cell - // should have the status `CELL_PERSIST`. However this function can also - // be used to distribute load during refinement, therefore we consider - // refined or coarsened cells as well. + // should have the status `CellStatus::cell_will_persist`. However this + // function can also be used to distribute load during refinement, therefore + // we consider refined or coarsened cells as well. unsigned int n_particles_in_cell = 0; switch (status) { - case CELL_PERSIST: - case CELL_REFINE: + case CellStatus::cell_will_persist: + case CellStatus::cell_will_be_refined: n_particles_in_cell = particle_handler.n_particles_in_cell(cell); break; - case CELL_INVALID: + case CellStatus::cell_invalid: break; - case CELL_COARSEN: + case CellStatus::children_will_be_coarsened: for (const auto &child : cell->child_iterators()) n_particles_in_cell += particle_handler.n_particles_in_cell(child); break; -- 2.39.5