]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix comment and add a test 15572/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 20 Mar 2024 15:55:05 +0000 (11:55 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 20 Mar 2024 15:55:33 +0000 (11:55 -0400)
include/deal.II/base/init_finalize.h
tests/base/init_finalize.cc [new file with mode: 0644]
tests/base/init_finalize.wit_mpi=true.with_p4est=true.output [new file with mode: 0644]

index 57045746ddd40aeb7f3f0183e43c83f2578de54c..85d3b8dcf26ae89e58161de1e940e0845cfd6175 100644 (file)
@@ -79,8 +79,8 @@ operator|(const InitializeLibrary f1, const InitializeLibrary f2)
 
 
 /**
- * Global operator which sets the bits from the second argument also in the
- * first one.
+ * Global operator which returns an object in which all bits are set that are
+ * set both in the first and second argument.
  */
 inline InitializeLibrary
 operator&(const InitializeLibrary f1, const InitializeLibrary f2)
diff --git a/tests/base/init_finalize.cc b/tests/base/init_finalize.cc
new file mode 100644 (file)
index 0000000..0b87253
--- /dev/null
@@ -0,0 +1,47 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2024 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 that InitFinalize can initialize/finalize only the selected library
+
+#include <deal.II/base/init_finalize.h>
+
+#include <Kokkos_Core.hpp>
+#include <p4est_vtk.h>
+
+#include "../tests.h"
+
+int
+main(int argc, char *argv[])
+{
+  MPI_Init(&argc, &argv);
+  Kokkos::initialize(argc, argv);
+  mpi_initlog();
+  {
+    // Only initialize P4EST. If it tries to initialize MPI or Kokkos, we will
+    // get an error.
+    InitFinalize init_finalize(argc, argv, InitializeLibrary::P4EST);
+    // p4est_is_initialized was introduced in version 2.8. Instead we create the
+    // connectivity. If P4EST was not initialized the code below will crash.
+    auto *conn = p4est_connectivity_new_unitsquare();
+    p4est_connectivity_destroy(conn);
+  }
+  deallog << "OK" << std::endl;
+
+  Kokkos::finalize();
+
+  MPI_Finalize();
+
+  return 0;
+}
diff --git a/tests/base/init_finalize.wit_mpi=true.with_p4est=true.output b/tests/base/init_finalize.wit_mpi=true.with_p4est=true.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::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.