copy_triangulation(
const dealii::Triangulation<dim, spacedim> &other_tria) override;
+# ifdef DOXYGEN
+ /**
+ * Write and read the data of this object from a stream for the purpose
+ * of serialization. using the [BOOST serialization
+ * library](https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/index.html).
+ */
+ template <class Archive>
+ void
+ serialize(Archive &archive, const unsigned int version);
+# else
+ // This macro defines the serialize() method that is compatible with
+ // the templated save() and load() method that have been implemented.
+ BOOST_SERIALIZATION_SPLIT_MEMBER()
+# endif
+
/**
* Save the triangulation into the given file. This file needs to be
* reachable from all nodes in the computation on a shared network file
virtual types::coarse_cell_id
n_global_coarse_cells() const override;
+ /**
+ * Reset this triangulation to an empty state by deleting all data.
+ *
+ * Note that this operation is only allowed if no subscriptions to this
+ * object exist any more, such as DoFHandler objects using it.
+ */
+ virtual void
+ clear() override;
+
protected:
/**
* MPI communicator to be used for the triangulation. We create a unique
smooth_grid = (dealii::Triangulation<dim, spacedim>::none),
const bool check_for_distorted_cells = false);
- /**
- * Reset this triangulation into a virgin state by deleting all data.
- *
- * Note that this operation is only allowed if no subscriptions to this
- * object exist any more, such as DoFHandler objects using it.
- */
- virtual void
- clear() override;
-
using cell_iterator =
typename dealii::Triangulation<dim, spacedim>::cell_iterator;
Assert(this->n_cells() == 0,
ExcMessage("load() only works if the Triangulation is empty!"));
- // Compute global offset for each rank.
- unsigned int n_locally_owned_cells = this->n_locally_owned_active_cells();
-
- unsigned int global_first_cell = 0;
-
- int ierr = MPI_Exscan(&n_locally_owned_cells,
- &global_first_cell,
- 1,
- MPI_UNSIGNED,
- MPI_SUM,
- this->mpi_communicator);
- AssertThrowMPI(ierr);
-
- global_first_cell *= sizeof(unsigned int);
-
unsigned int version, numcpus, attached_count_fixed,
attached_count_variable, n_global_active_cells;
AssertThrow(version == 4,
ExcMessage("Incompatible version found in .info file."));
- Assert(this->n_global_active_cells() == n_global_active_cells,
- ExcMessage("Number of global active cells differ!"));
// Load description and construct the triangulation.
{
this->create_triangulation(construction_data);
}
+ // Compute global offset for each rank.
+ unsigned int n_locally_owned_cells = this->n_locally_owned_active_cells();
+
+ unsigned int global_first_cell = 0;
+
+ int ierr = MPI_Exscan(&n_locally_owned_cells,
+ &global_first_cell,
+ 1,
+ MPI_UNSIGNED,
+ MPI_SUM,
+ this->mpi_communicator);
+ AssertThrowMPI(ierr);
+
+ global_first_cell *= sizeof(unsigned int);
+
+ Assert(this->n_global_active_cells() == n_global_active_cells,
+ ExcMessage("Number of global active cells differ!"));
+
// clear all of the callback data, as explained in the documentation of
// register_data_attach()
this->cell_attached_data.n_attached_data_sets = 0;
template <int dim, int spacedim>
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
- void DistributedTriangulationBase<dim, spacedim>::clear()
+ void TriangulationBase<dim, spacedim>::clear()
{
dealii::Triangulation<dim, spacedim>::clear();
+
+ number_cache = {};
}
template <int dim, typename TriangulationType>
void
-test(TriangulationType &triangulation)
+test(TriangulationType &triangulation, TriangulationType &triangulation_clean)
{
DoFHandler<dim> dof_handler(triangulation);
dof_handler.distribute_dofs(FE_Q<dim>(2));
print_statistics(triangulation, false);
- std::stringstream stream;
+ std::stringstream stream_0, stream_1;
{
- boost::archive::text_oarchive oa(stream);
- oa << triangulation;
- oa << vector;
+ boost::archive::text_oarchive oa_0(stream_0);
+ boost::archive::text_oarchive oa_1(stream_1);
+ oa_0 << triangulation;
+ oa_0 << vector;
+ oa_1 << triangulation;
+ oa_1 << vector;
}
triangulation.clear();
{
- boost::archive::text_iarchive ia(stream);
- ia >> triangulation;
- ia >> vector_loaded;
+ // load into existing tringulation
+ {
+ boost::archive::text_iarchive ia(stream_0);
+ ia >> triangulation;
+ ia >> vector_loaded;
+ }
+ print_statistics(triangulation, false);
+
+ // Verify that error is 0.
+ VectorType error(vector);
+ error.add(-1, vector_loaded);
+
+ deallog << (error.linfty_norm() < 1e-16 ? "PASSED" : "FAILED") << std::endl;
}
- print_statistics(triangulation, false);
-
- // Verify that error is 0.
- VectorType error(vector);
- error.add(-1, vector_loaded);
- deallog << (error.linfty_norm() < 1e-16 ? "PASSED" : "FAILED") << std::endl;
+ {
+ // load into new tringulation
+ {
+ boost::archive::text_iarchive ia(stream_1);
+ ia >> triangulation_clean;
+ ia >> vector_loaded;
+ }
+ print_statistics(triangulation_clean, false);
+
+ // Verify that error is 0.
+ VectorType error(vector);
+ error.add(-1, vector_loaded);
+
+ deallog << (error.linfty_norm() < 1e-16 ? "PASSED" : "FAILED") << std::endl;
+ }
}
int
GridGenerator::hyper_cube(triangulation);
triangulation.refine_global(3);
- test<dim>(triangulation);
+
+ parallel::shared::Triangulation<dim> triangulation_other(
+ MPI_COMM_WORLD,
+ ::Triangulation<dim>::none,
+ false,
+ parallel::shared::Triangulation<dim>::partition_zorder);
+
+ test<dim>(triangulation, triangulation_other);
}
deallog.pop();
GridGenerator::hyper_cube(triangulation);
triangulation.refine_global(3);
- test<dim>(triangulation);
+ parallel::shared::Triangulation<dim> triangulation_other(
+ MPI_COMM_WORLD,
+ ::Triangulation<dim>::none,
+ false,
+ parallel::shared::Triangulation<dim>::partition_zorder);
+
+ test<dim>(triangulation, triangulation_other);
}
deallog.pop();
}
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::
DEAL:0:2d::PASSED
+DEAL:0:2d::n_levels: 4
+DEAL:0:2d::n_cells: 85
+DEAL:0:2d::n_active_cells: 64
+DEAL:0:2d::has_hanging_nodes: false
+DEAL:0:2d::
+DEAL:0:2d::PASSED
DEAL:0:3d::n_levels: 4
DEAL:0:3d::n_cells: 585
DEAL:0:3d::n_active_cells: 512
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::
DEAL:0:3d::PASSED
+DEAL:0:3d::n_levels: 4
+DEAL:0:3d::n_cells: 585
+DEAL:0:3d::n_active_cells: 512
+DEAL:0:3d::has_hanging_nodes: false
+DEAL:0:3d::
+DEAL:0:3d::PASSED
DEAL:1:2d::n_levels: 4
DEAL:1:2d::n_cells: 85
DEAL:1:2d::has_hanging_nodes: false
DEAL:1:2d::
DEAL:1:2d::PASSED
+DEAL:1:2d::n_levels: 4
+DEAL:1:2d::n_cells: 85
+DEAL:1:2d::n_active_cells: 64
+DEAL:1:2d::has_hanging_nodes: false
+DEAL:1:2d::
+DEAL:1:2d::PASSED
DEAL:1:3d::n_levels: 4
DEAL:1:3d::n_cells: 585
DEAL:1:3d::n_active_cells: 512
DEAL:1:3d::has_hanging_nodes: false
DEAL:1:3d::
DEAL:1:3d::PASSED
+DEAL:1:3d::n_levels: 4
+DEAL:1:3d::n_cells: 585
+DEAL:1:3d::n_active_cells: 512
+DEAL:1:3d::has_hanging_nodes: false
+DEAL:1:3d::
+DEAL:1:3d::PASSED