libMesh
meshless_interpolation_function.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
20 #ifndef LIBMESH_MESHLESS_INTERPOLATION_FUNCTION_H
21 #define LIBMESH_MESHLESS_INTERPOLATION_FUNCTION_H
22 
23 // libMesh Includes
24 #include "libmesh/function_base.h"
25 #include "libmesh/meshfree_interpolation.h"
26 #include "libmesh/threads.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <memory>
31 
32 namespace libMesh
33 {
34 
35 
36 
37 // Forward Declarations
38 template <typename T>
40 
41 
42 // ------------------------------------------------------------
43 // MeshlessInterpolationFunction class definition
45 {
46 private:
48  mutable std::vector<Point> _pts;
49  mutable std::vector<Number> _vals;
51 
52 public:
53 
58  Threads::spin_mutex & mutex) :
59  _mfi (mfi),
60  _mutex(mutex)
61  {}
62 
63 
67  void init ();
68 
72  void clear ();
73 
77  virtual std::unique_ptr<FunctionBase<Number>> clone () const;
78 
83  Number operator() (const Point & p,
84  const Real time=0.);
85 
90  void operator() (const Point & p,
91  const Real time,
92  DenseVector<Number> & output);
93 
94 };
95 
96 
97 
98 // ------------------------------------------------------------
99 // MeshlessInterpolationFunction inline methods
100 inline
102  const Real /* time */)
103 {
104  _pts.clear();
105  _pts.push_back(p);
106  _vals.resize(1);
107 
108  Threads::spin_mutex::scoped_lock lock(_mutex);
109 
111  _pts, _vals);
112 
113  return _vals.front();
114 }
115 
116 
117 
118 inline
120  const Real time,
121  DenseVector<Number> & output)
122 {
123  output.resize(1);
124  output(0) = (*this)(p, time);
125 }
126 
127 
128 
129 inline
131 {
132 }
133 
134 
135 
136 inline
138 {
139 }
140 
141 
142 
143 inline
144 std::unique_ptr<FunctionBase<Number>>
146 {
147  return std::make_unique<MeshlessInterpolationFunction>(_mfi, _mutex);
148 }
149 
150 
151 } // namespace libMesh
152 
153 
154 #endif // LIBMESH_MESHLESS_INTERPOLATION_FUNCTION_H
const std::vector< std::string > & field_variables() const
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:374
void init()
The actual initialization process.
The libMesh namespace provides an interface to certain functionality in the library.
Number operator()(const Point &p, const Real time=0.)
virtual void interpolate_field_data(const std::vector< std::string > &field_names, const std::vector< Point > &tgt_pts, std::vector< Number > &tgt_vals) const =0
Interpolate source data at target points.
Base class to support various mesh-free interpolation methods.
MeshlessInterpolationFunction(const MeshfreeInterpolation &mfi, Threads::spin_mutex &mutex)
Constructor.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Defines a dense vector for use in Finite Element-type computations.
virtual std::unique_ptr< FunctionBase< Number > > clone() const
Returns a new deep copy of the function.
Base class for functors that can be evaluated at a point and (optionally) time.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39