]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce CellAccessor::is_artificial_on_level() 12709/head
authorPeter Munch <peterrmuench@gmail.com>
Wed, 25 Aug 2021 17:42:46 +0000 (19:42 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Thu, 26 Aug 2021 19:25:16 +0000 (21:25 +0200)
include/deal.II/grid/tria_accessor.h
include/deal.II/grid/tria_accessor.templates.h
tests/grid/is_artificial_on_level.cc [new file with mode: 0644]
tests/grid/is_artificial_on_level.with_p4est=true.mpirun=2.output [new file with mode: 0644]

index c1e11bb7aca1fe2d21eea8818db03235039054f1..2dbd0270102abb5735ce9279247789bc92e4a984 100644 (file)
@@ -3750,6 +3750,15 @@ public:
   bool
   is_artificial() const;
 
+  /**
+   * Similar to is_artificial() but checking the conditions on the levels.
+   *
+   * @post The returned value is equal to <code>!is_ghost_on_level() &&
+   * !is_locally_owned_on_level()</code>.
+   */
+  bool
+  is_artificial_on_level() const;
+
   /**
    * Test whether the point @p p is inside this cell. Points on the boundary
    * are counted as being inside the cell.
index 6558059da9e06adc888167e802e86224381ae7a9..b656d517c50f379ea81223c41bfee9c6e3bb27cb 100644 (file)
@@ -3783,6 +3783,19 @@ CellAccessor<dim, spacedim>::is_artificial() const
 
 
 
+template <int dim, int spacedim>
+inline bool
+CellAccessor<dim, spacedim>::is_artificial_on_level() const
+{
+#ifndef DEAL_II_WITH_MPI
+  return false;
+#else
+  return (is_locally_owned_on_level() || is_ghost_on_level()) == false;
+#endif
+}
+
+
+
 template <int dim, int spacedim>
 inline types::subdomain_id
 CellAccessor<dim, spacedim>::subdomain_id() const
diff --git a/tests/grid/is_artificial_on_level.cc b/tests/grid/is_artificial_on_level.cc
new file mode 100644 (file)
index 0000000..a28d0d6
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Test CellAccessor::is_artificial_on_level() on a subdivided hypercube.
+
+#include <deal.II/base/mpi.h>
+
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+int
+main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll                    all;
+
+
+  parallel::distributed::Triangulation<2> tria(
+    MPI_COMM_WORLD,
+    dealii::Triangulation<2>::none,
+    parallel::distributed::Triangulation<2>::construct_multigrid_hierarchy);
+  GridGenerator::subdivided_hyper_cube(tria, 4);
+
+  AssertDimension(Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD), 2);
+
+  const auto rank = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+
+  for (const auto &cell : tria.active_cell_iterators())
+    {
+      if (rank == 0)
+        {
+          if (cell->center()[1] > 0.75)
+            {
+              Assert(cell->is_artificial_on_level(), ExcInternalError());
+            }
+          else
+            {
+              Assert(!cell->is_artificial_on_level(), ExcInternalError());
+            }
+        }
+      else if (rank == 1)
+        {
+          if (cell->center()[1] < 0.25)
+            {
+              Assert(cell->is_artificial_on_level(), ExcInternalError());
+            }
+          else
+            {
+              Assert(!cell->is_artificial_on_level(), ExcInternalError());
+            }
+        }
+      else
+        {
+          Assert(false, ExcInternalError());
+        }
+    }
+
+  deallog << "OK!" << std::endl;
+}
diff --git a/tests/grid/is_artificial_on_level.with_p4est=true.mpirun=2.output b/tests/grid/is_artificial_on_level.with_p4est=true.mpirun=2.output
new file mode 100644 (file)
index 0000000..c5e2304
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL:0::OK!
+
+DEAL:1::OK!
+

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.