| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2020 - 2025 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
|
| 16 |
#ifndef dealii_matrix_free_evaluation_flags_h |
| 17 |
#define dealii_matrix_free_evaluation_flags_h |
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/numbers.h> |
| 22 |
|
| 23 |
|
| 24 |
DEAL_II_NAMESPACE_OPEN |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* @brief The namespace for the EvaluationFlags enum |
| 30 |
* |
| 31 |
* This namespace contains the enum EvaluationFlags used in FEEvaluation |
| 32 |
* to control evaluation and integration of values, gradients, etc.. |
| 33 |
*/ |
| 34 |
namespace EvaluationFlags |
| 35 |
{ |
| 36 |
/** |
| 37 |
* @brief The EvaluationFlags enum |
| 38 |
* |
| 39 |
* This enum contains a set of flags used by FEEvaluation::integrate(), |
| 40 |
* FEEvaluation::evaluate() and others to determine if values, gradients, |
| 41 |
* hessians, or a combination of them is being used. |
| 42 |
*/ |
| 43 |
enum EvaluationFlags |
| 44 |
{ |
| 45 |
/** |
| 46 |
* Do not use or compute anything. |
| 47 |
*/ |
| 48 |
nothing = 0, |
| 49 |
/** |
| 50 |
* Use or evaluate values. |
| 51 |
*/ |
| 52 |
values = 0x1, |
| 53 |
/** |
| 54 |
* Use or evaluate gradients. |
| 55 |
*/ |
| 56 |
gradients = 0x2, |
| 57 |
/** |
| 58 |
* Use or evaluate hessians. |
| 59 |
*/ |
| 60 |
hessians = 0x4 |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
/** |
| 65 |
* Global operator which returns an object in which all bits are set which are |
| 66 |
* either set in the first or the second argument. This operator exists since |
| 67 |
* if it did not then the result of the bit-or <tt>operator |</tt> would be an |
| 68 |
* integer which would in turn trigger a compiler warning when we tried to |
| 69 |
* assign it to an object of type UpdateFlags. |
| 70 |
* |
| 71 |
* @ref EvaluationFlags |
| 72 |
*/ |
| 73 |
DEAL_II_HOST_DEVICE inline EvaluationFlags |
| 74 |
operator|(const EvaluationFlags f1, const EvaluationFlags f2) |
| 75 |
{ |
| 76 |
return static_cast<EvaluationFlags>(static_cast<unsigned int>(f1) | |
| 77 |
static_cast<unsigned int>(f2)); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
/** |
| 83 |
* Global operator which sets the bits from the second argument also in the |
| 84 |
* first one. |
| 85 |
* |
| 86 |
* @ref EvaluationFlags |
| 87 |
*/ |
| 88 |
DEAL_II_HOST_DEVICE inline EvaluationFlags & |
| 89 |
operator|=(EvaluationFlags &f1, const EvaluationFlags f2) |
| 90 |
{ |
| 91 |
f1 = f1 | f2; |
| 92 |
return f1; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
/** |
| 97 |
* Global operator which returns an object in which all bits are set which are |
| 98 |
* set in the first as well as the second argument. This operator exists since |
| 99 |
* if it did not then the result of the bit-and <tt>operator &</tt> would be |
| 100 |
* an integer which would in turn trigger a compiler warning when we tried to |
| 101 |
* assign it to an object of type UpdateFlags. |
| 102 |
* |
| 103 |
* @ref EvaluationFlags |
| 104 |
*/ |
| 105 |
DEAL_II_HOST_DEVICE inline EvaluationFlags |
| 106 |
operator&(const EvaluationFlags f1, const EvaluationFlags f2) |
| 107 |
{ |
| 108 |
return static_cast<EvaluationFlags>(static_cast<unsigned int>(f1) & |
| 109 |
static_cast<unsigned int>(f2)); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
/** |
| 114 |
* Global operator which clears all the bits in the first argument if they are |
| 115 |
* not also set in the second argument. |
| 116 |
* |
| 117 |
* @ref EvaluationFlags |
| 118 |
*/ |
| 119 |
DEAL_II_HOST_DEVICE inline EvaluationFlags & |
| 120 |
operator&=(EvaluationFlags &f1, const EvaluationFlags f2) |
| 121 |
{ |
| 122 |
f1 = f1 & f2; |
| 123 |
return f1; |
| 124 |
} |
| 125 |
|
| 126 |
} // namespace EvaluationFlags |
| 127 |
|
| 128 |
|
| 129 |
DEAL_II_NAMESPACE_CLOSE |
| 130 |
|
| 131 |
#endif |