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