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 : #ifndef MESHFREE_INTERPOLATION_FUNCTION_H 19 : #define MESHFREE_INTERPOLATION_FUNCTION_H 20 : 21 : // libMesh Includes 22 : #include "libmesh/function_base.h" 23 : #include "libmesh/meshfree_interpolation.h" 24 : #include "libmesh/threads.h" 25 : 26 : // C++ includes 27 : #include <cstddef> 28 : #include <memory> 29 : #include <vector> 30 : 31 : namespace libMesh 32 : { 33 : 34 : // Forward Declarations 35 : template <typename T> class DenseVector; 36 : 37 : // ------------------------------------------------------------ 38 : // MeshfreeInterpolationFunction class definition 39 : class MeshfreeInterpolationFunction : public FunctionBase<Number> 40 : { 41 : public: 42 : /** 43 : * Constructor. Requires a MeshfreeInterpolation object. 44 : */ 45 : MeshfreeInterpolationFunction(const MeshfreeInterpolation & mfi, 46 : Threads::spin_mutex & mutex); 47 : 48 : /** 49 : * Move and copy constructors. 50 : */ 51 : MeshfreeInterpolationFunction(MeshfreeInterpolationFunction &&) = default; 52 : MeshfreeInterpolationFunction(const MeshfreeInterpolationFunction &) = default; 53 : 54 : /** 55 : * Destructor. 56 : */ 57 0 : virtual ~MeshfreeInterpolationFunction() = default; 58 : 59 : /** 60 : * Delete assignment operators. 61 : */ 62 : MeshfreeInterpolationFunction & operator=(const MeshfreeInterpolationFunction &) = delete; 63 : MeshfreeInterpolationFunction & operator=(MeshfreeInterpolationFunction &&) = delete; 64 : 65 : /** 66 : * The actual initialization process. 67 : */ 68 : void init(); 69 : 70 : /** 71 : * Clears the function. 72 : */ 73 : void clear(); 74 : 75 : /** 76 : * Returns a new deep copy of the function. 77 : */ 78 : virtual std::unique_ptr<FunctionBase<Number>> clone() const; 79 : 80 : /** 81 : * @returns the value at point p and time 82 : * time, which defaults to zero. 83 : */ 84 : Number operator()(const Point & p, const Real time = 0.); 85 : 86 : /** 87 : * Like before, but returns the values in a 88 : * writable reference. 89 : */ 90 : void operator()(const Point & p, const Real time, DenseVector<Number> & output); 91 : 92 : private: 93 : const MeshfreeInterpolation & _mfi; 94 : mutable std::vector<Point> _pts; 95 : mutable std::vector<Number> _vals; 96 : Threads::spin_mutex & _mutex; 97 : }; 98 : 99 : } // namespace libMesh 100 : 101 : #endif // MESHFREE_INTERPOLATION_FUNCTION_H