Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : #ifndef LIBMESH_FE_COMPUTE_DATA_H 20 : #define LIBMESH_FE_COMPUTE_DATA_H 21 : 22 : // Local includes 23 : #include "libmesh/libmesh.h" 24 : #include "libmesh/fe_base.h" // required for the type OutputGradient. 25 : 26 : // C++ includes 27 : #include <vector> 28 : 29 : namespace libMesh 30 : { 31 : 32 : // Forward declarations 33 : class EquationSystems; 34 : class Point; 35 : 36 : /** 37 : * class \p FEComputeData hides arbitrary data to be passed to and from 38 : * children of \p FEBase through the \p FEInterface::compute_data() 39 : * method. This enables the efficient computation of data on 40 : * the finite element level, while maintaining library integrity. 41 : * - With special finite elements disabled (like infinite elements), 42 : * this class wraps the return values of all shape functions 43 : * from \p FEInterface::shape() in a \p std::vector<Number>. 44 : * - With infinite elements enabled, this class returns a vector of physically 45 : * correct shape functions, both for finite and infinite elements. 46 : * 47 : * \author Daniel Dreyer 48 : * \date 2003 49 : * \brief Helper class used with FEInterface::compute_data(). 50 : */ 51 : class FEComputeData 52 : { 53 : public: 54 : /** 55 : * Constructor. Takes the required input data and clears 56 : * the output data using \p clear(). 57 : */ 58 1493087 : FEComputeData (const EquationSystems & es, 59 1493087 : const Point & pin) : 60 1254137 : equation_systems(es), 61 1254137 : p(pin), 62 1612562 : _need_dshape(false) 63 : { 64 1493087 : this->clear(); 65 1493087 : } 66 : 67 : /** 68 : * Const reference to the \p EquationSystems object 69 : * that contains simulation-specific data. 70 : */ 71 : const EquationSystems & equation_systems; 72 : 73 : /** 74 : * Holds the point where the data are to be computed 75 : */ 76 : const Point & p; 77 : 78 : /** 79 : * Storage for the computed shape function values. 80 : */ 81 : std::vector<Number> shape; 82 : 83 : /** 84 : * Storage for the computed shape derivative values. 85 : */ 86 : std::vector<Gradient> dshape; 87 : 88 : /** 89 : * Storage for local to global mapping at \p p. 90 : * This is needed when the gradient in physical 91 : * coordinates is of interest. 92 : * FIXME: What kind of type should one use for it? 93 : * The matrix-class don't look as if they were made for it 94 : * and neither are the TensorTool-members. 95 : */ 96 : std::vector<std::vector<Real>> local_transform; 97 : 98 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 99 : /** 100 : * Storage for the computed phase lag 101 : */ 102 : Real phase; 103 : 104 : /** 105 : * The wave speed. 106 : */ 107 : Real speed; 108 : 109 : /** 110 : * The frequency to evaluate shape functions 111 : * including the wave number depending terms. 112 : * Use imaginary contributions for exponential damping 113 : */ 114 : Number frequency; 115 : #endif 116 : 117 : /** 118 : * Clears the output data completely. 119 : */ 120 : void clear (); 121 : 122 : /** 123 : * Inits the output data to default values, provided 124 : * the fields are correctly resized. 125 : */ 126 : void init (); 127 : 128 : /** 129 : * Enable the computation of shape gradients (dshape). 130 : */ 131 : void enable_derivative (); 132 : 133 : /** 134 : * Disable the computation of shape gradients (dshape). 135 : * Default is disabled. 136 : */ 137 : void disable_derivative () 138 : {_need_dshape=false; } 139 : 140 : /** 141 : * Check whether derivatives should be computed or not. 142 : */ 143 2250332 : bool need_derivative () 144 46831955 : {return _need_dshape; } 145 : 146 : private: 147 : /** 148 : * variable indicating whether the shape-derivative should be computed or not. 149 : * Default is false to save time and be compatible with elements where derivatives 150 : * are not implemented/ cannot be computed. 151 : */ 152 : bool _need_dshape; 153 : 154 : }; 155 : 156 : 157 : } // namespace libMesh 158 : 159 : #endif // LIBMESH_FE_COMPUTE_DATA_H