DOLFINx 0.10.0.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
option.h
1// Copyright (C) 2024 Paul T. Kühner
2//
3// This file is part of DOLFINX (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <cstdint>
10#include <type_traits>
11
12namespace dolfinx::refinement
13{
15enum class Option : std::uint8_t
16{
17 none = 0b00,
18 parent_facet = 0b01,
21 = 0b10,
22 parent_cell_and_facet = 0b11 /*< Both cell and facet parent data */
23};
24
27inline constexpr Option operator|(Option a, Option b)
28{
29 using bitmask_t = std::underlying_type_t<Option>;
30 bitmask_t a_native = static_cast<bitmask_t>(a);
31 bitmask_t b_native = static_cast<bitmask_t>(b);
32 return static_cast<Option>(a_native | b_native);
33}
34
36inline constexpr bool option_parent_facet(Option a)
37{
38 using bitmask_t = std::underlying_type_t<Option>;
39 bitmask_t a_native = static_cast<bitmask_t>(a);
40 bitmask_t facet_native = static_cast<bitmask_t>(Option::parent_facet);
41 return (a_native & facet_native) == facet_native;
42}
43
45inline constexpr bool option_parent_cell(Option a)
46{
47 using bitmask_t = std::underlying_type_t<Option>;
48 bitmask_t a_native = static_cast<bitmask_t>(a);
49 bitmask_t facet_native = static_cast<bitmask_t>(Option::parent_cell);
50 return (a_native & facet_native) == facet_native;
51}
52} // namespace dolfinx::refinement
Mesh refinement algorithms.
Definition dolfinx_refinement.h:8
constexpr Option operator|(Option a, Option b)
Combine two refinement options into one, both flags will be set for the resulting option.
Definition option.h:27
constexpr bool option_parent_cell(Option a)
Check if parent_cell flag is set.
Definition option.h:45
Option
Options for data to compute during mesh refinement.
Definition option.h:16
constexpr bool option_parent_facet(Option a)
Check if parent_facet flag is set.
Definition option.h:36