// subdomain, so the first condition checks whether we have a serial
// triangulation, in which case all cells are locally owned. The second
// condition compares the subdomain id in the parallel case.
- return (this->tria->locally_owned_subdomain() ==
- numbers::invalid_subdomain_id ||
- this->subdomain_id() == this->tria->locally_owned_subdomain());
+ const types::subdomain_id locally_owned_subdomain =
+ this->tria->locally_owned_subdomain();
+ return (locally_owned_subdomain == numbers::invalid_subdomain_id ||
+ this->subdomain_id() == locally_owned_subdomain);
#endif
}
// subdomain, so the first condition checks whether we have a serial
// triangulation, in which case all cells are locally owned. The second
// condition compares the subdomain id in the parallel case.
- return (this->tria->locally_owned_subdomain() ==
- numbers::invalid_subdomain_id ||
- this->level_subdomain_id() == this->tria->locally_owned_subdomain());
+ const types::subdomain_id locally_owned_subdomain =
+ this->tria->locally_owned_subdomain();
+ return (locally_owned_subdomain == numbers::invalid_subdomain_id ||
+ this->level_subdomain_id() == locally_owned_subdomain);
#endif
}
// serial triangulation are locally owned and none is ghosted. The second
// and third conditions check whether the cell's subdomain is not the
// locally owned one and not artificial.
- return (this->tria->locally_owned_subdomain() !=
- numbers::invalid_subdomain_id &&
- this->subdomain_id() != this->tria->locally_owned_subdomain() &&
- this->subdomain_id() != numbers::artificial_subdomain_id);
+ const types::subdomain_id locally_owned_subdomain =
+ this->tria->locally_owned_subdomain();
+ const types::subdomain_id subdomain_id = this->subdomain_id();
+ return (locally_owned_subdomain != numbers::invalid_subdomain_id &&
+ subdomain_id != locally_owned_subdomain &&
+ subdomain_id != numbers::artificial_subdomain_id);
#endif
}
CellAccessor<dim, spacedim>::is_ghost_on_level() const
{
#ifndef DEAL_II_WITH_MPI
- return true;
+ return false;
#else
// Serial triangulations report invalid_subdomain_id as their locally owned
// subdomain, so the first condition checks whether we have a serial
// triangulation, in which case all cells are locally owned. The second
// condition compares the subdomain id in the parallel case.
- return (
- this->tria->locally_owned_subdomain() == numbers::invalid_subdomain_id ||
- (this->level_subdomain_id() != this->tria->locally_owned_subdomain() &&
- this->level_subdomain_id() != numbers::artificial_subdomain_id));
+ const types::subdomain_id locally_owned_subdomain =
+ this->tria->locally_owned_subdomain();
+ const types::subdomain_id subdomain_id = this->level_subdomain_id();
+ return (locally_owned_subdomain != numbers::invalid_subdomain_id &&
+ subdomain_id != locally_owned_subdomain &&
+ subdomain_id != numbers::artificial_subdomain_id);
#endif
}
#ifndef DEAL_II_WITH_MPI
return false;
#else
- return (is_locally_owned_on_level() || is_ghost_on_level()) == false;
+ return (this->tria->locally_owned_subdomain() !=
+ numbers::invalid_subdomain_id &&
+ this->level_subdomain_id() == numbers::artificial_subdomain_id);
#endif
}
+template <int dim, int spacedim>
+inline types::subdomain_id
+CellAccessor<dim, spacedim>::level_subdomain_id() const
+{
+ Assert(this->used(), TriaAccessorExceptions::ExcCellNotUsed());
+ return this->tria->levels[this->present_level]
+ ->level_subdomain_ids[this->present_index];
+}
+
+
+
template <int dim, int spacedim>
inline unsigned int
CellAccessor<dim, spacedim>::neighbor_face_no(const unsigned int neighbor) const
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2022 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check CellAccessor::is_locally_owned_on_level and is_ghost_on_level for a
+// serial triangulation (where trivially all cells are locally owned and none
+// is ghosted/artificial), going through a code path that is not tested
+// otherwise
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+
+#include "../tests.h"
+
+
+
+template <int dim>
+void
+test()
+{
+ Triangulation<dim> tr;
+
+ GridGenerator::subdivided_hyper_cube(tr, 2);
+
+ for (const auto &cell : tr.cell_iterators())
+ {
+ if (cell->is_locally_owned_on_level())
+ {
+ deallog << cell << ": locally owned" << std::endl;
+ Assert(!cell->is_ghost_on_level() && !cell->is_artificial_on_level(),
+ ExcInternalError());
+ }
+ if (cell->is_ghost_on_level())
+ {
+ deallog << cell << ": ghost" << std::endl;
+ Assert(!cell->is_locally_owned_on_level() &&
+ !cell->is_artificial_on_level(),
+ ExcInternalError());
+ }
+ if (cell->is_artificial_on_level())
+ {
+ deallog << cell << ": artificial" << std::endl;
+ Assert(!cell->is_locally_owned_on_level() &&
+ !cell->is_ghost_on_level(),
+ ExcInternalError());
+ }
+ }
+}
+
+
+int
+main()
+{
+ initlog();
+ test<2>();
+}