From: Luca Heltai Date: Thu, 10 Aug 2017 22:11:21 +0000 (-0600) Subject: Assemble flags. X-Git-Tag: v9.0.0-rc1~1271^2~13 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9defde42f1025f120aaad6176b3191e4ef355542;p=dealii.git Assemble flags. --- diff --git a/include/deal.II/meshworker/assemble_flags.h b/include/deal.II/meshworker/assemble_flags.h new file mode 100644 index 0000000000..fa157b17f5 --- /dev/null +++ b/include/deal.II/meshworker/assemble_flags.h @@ -0,0 +1,209 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2016 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#ifndef dealii__assemble_flags_h +#define dealii__assemble_flags_h + + +#include +#include +#include +#include +#include + +#include + + +DEAL_II_NAMESPACE_OPEN + +/*!@addtogroup MeshWorker */ +/*@{*/ + +/** + * The enum type given to the MeshLoop function, telling that function which + * elements need to be assembled. + * + * You can select more than one flag by concatenation using the bitwise or + * operator|(AssembleFlags,AssembleFlags). + * + *

Use of these flags flags

+ * + * More information on the use of this type both in user code as well as + * internally can be found in the documentation modules on + * @ref AssembleFlags "The interplay of AssembleFlags, Mapping, and FiniteElement in FEValues" + * and + * @ref FE_vs_Mapping_vs_FEValues "How Mapping, FiniteElement, and FEValues work together". + */ +enum AssembleFlags +{ + //! No update + assemble_default = 0, + //! Own cells + /** + * Assemble on cells. + */ + assemble_own_cells = 0x0001, + //! Ghost cells + /** + * Assemble on ghost cells. + */ + assemble_ghost_cells = 0x0002, + //! Own faces once + /** + * Assemble on own interior faces, visiting each face only once + */ + assemble_own_interior_faces_once = 0x0004, + //! Own faces both + /** + * Assemble on own interior faces, visiting each internal face twice + */ + assemble_own_interior_faces_both = 0x0008, + //! Ghost faces once + /** + * Assemble on faces between a locally owned cell and a ghost cell, making + * sure that only one of the processes will assemble these faces (from the + * finer side or the process with the lower mpi rank + */ + assemble_ghost_faces_once = 0x0010, + //! Ghost faces both + /** + * Assemble on faces between a locally owned cell and a ghost cell, both + * processes will assemble these faces. Note that these faces are never + * assembled from both sides on a single process. + */ + assemble_ghost_faces_both = 0x0020, + //! Assemble cells before faces + /** + * Assemble cells integrals before face integrals. + */ + assemble_cells_first = 0x0040, + //! Assemble boundary faces + /** + * Assemble on boundary faces + */ + assemble_boundary_faces = 0x0080, + //! Assemble own interior aces + /** + * Assemble own interior faces, either interior ones or on the boundary. + */ + assemble_own_interior_faces = assemble_own_interior_faces_both | assemble_own_interior_faces_once, + //! Assemble own faces + /** + * Assemble own faces, either interior ones or on the boundary. + */ + assemble_own_faces = assemble_own_interior_faces | assemble_boundary_faces, + //! Assemble ghost faces + /** + * Assemble ghost faces + */ + assemble_ghost_faces = assemble_ghost_faces_both | assemble_ghost_faces_once, +}; + + +/** + * Output operator which outputs update flags as a set of or'd text values. + * + * @ref AssembleFlags + */ +template +inline +StreamType &operator << (StreamType &s, AssembleFlags u) +{ + s << " AssembleFlags"; + if (u & assemble_own_cells ) s << "|own_cells" ; + if (u & assemble_own_interior_faces_once ) s << "|own_faces_once" ; + if (u & assemble_own_interior_faces_both ) s << "|own_faces_both" ; + if (u & assemble_ghost_cells ) s << "|ghost_cells" ; + if (u & assemble_ghost_faces_once ) s << "|ghost_faces_once" ; + if (u & assemble_ghost_faces_both ) s << "|ghost_faces_both" ; + if (u & assemble_boundary_faces ) s << "|boundary_faces" ; + return s; +} + + +/** + * Global operator which returns an object in which all bits are set which are + * either set in the first or the second argument. This operator exists since + * if it did not then the result of the bit-or operator | would be an + * integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type AssembleFlags. + * + * @ref AssembleFlags + */ +inline +AssembleFlags +operator | (AssembleFlags f1, AssembleFlags f2) +{ + return static_cast ( + static_cast (f1) | + static_cast (f2)); +} + + + + +/** + * Global operator which sets the bits from the second argument also in the + * first one. + * + * @ref AssembleFlags + */ +inline +AssembleFlags & +operator |= (AssembleFlags &f1, AssembleFlags f2) +{ + f1 = f1 | f2; + return f1; +} + + +/** + * Global operator which returns an object in which all bits are set which are + * set in the first as well as the second argument. This operator exists since + * if it did not then the result of the bit-and operator & would be + * an integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type AssembleFlags. + * + * @ref AssembleFlags + */ +inline +AssembleFlags +operator & (AssembleFlags f1, AssembleFlags f2) +{ + return static_cast ( + static_cast (f1) & + static_cast (f2)); +} + + +/** + * Global operator which clears all the bits in the first argument if they are + * not also set in the second argument. + * + * @ref AssembleFlags + */ +inline +AssembleFlags & +operator &= (AssembleFlags &f1, AssembleFlags f2) +{ + f1 = f1 & f2; + return f1; +} + +/*@}*/ + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/tests/meshworker/mesh_loop_01.cc b/tests/meshworker/mesh_loop_01.cc new file mode 100644 index 0000000000..d4da345483 --- /dev/null +++ b/tests/meshworker/mesh_loop_01.cc @@ -0,0 +1,32 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2007 - 2016 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// test assemble_flags.h + +#include "../tests.h" +#include + +#include + + +int main() +{ + initlog(); + AssembleFlags flag = assemble_own_cells | assemble_boundary_faces; + + deallog.get_file_stream() << flag << std::endl; +} diff --git a/tests/meshworker/mesh_loop_01.output b/tests/meshworker/mesh_loop_01.output new file mode 100644 index 0000000000..d2f09a5396 --- /dev/null +++ b/tests/meshworker/mesh_loop_01.output @@ -0,0 +1,2 @@ + + AssembleFlags|own_cells|boundary_faces