libMesh
Loading...
Searching...
No Matches
mesh_function.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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_MESH_FUNCTION_H
21#define LIBMESH_MESH_FUNCTION_H
22
23// Local Includes
24#include "libmesh/function_base.h"
25#include "libmesh/dense_vector.h"
26#include "libmesh/vector_value.h"
27#include "libmesh/tensor_value.h"
28#include "libmesh/tree_base.h"
29#include "libmesh/parallel_object.h"
30
31// C++ includes
32#include <cstddef>
33#include <vector>
34#include <memory>
35
36namespace libMesh
37{
38
39
40// Forward Declarations
41template <typename T> class DenseVector;
42class EquationSystems;
43template <typename T> class NumericVector;
44class DofMap;
45class PointLocatorBase;
46
54class MeshFunction : public FunctionBase<Number>,
55 public ParallelObject
56{
57public:
58
67 MeshFunction (const EquationSystems & eqn_systems,
68 const NumericVector<Number> & vec,
69 const DofMap & dof_map,
70 std::vector<unsigned int> vars,
71 const FunctionBase<Number> * master=nullptr);
72
81 MeshFunction (const EquationSystems & eqn_systems,
82 const NumericVector<Number> & vec,
83 const DofMap & dof_map,
84 const unsigned int var,
85 const FunctionBase<Number> * master=nullptr);
86
90 MeshFunction (const MeshFunction & mf);
91
98 MeshFunction (MeshFunction &&) = default;
101
106
110 virtual void init () override;
111
115 virtual void clear () override;
116
126 virtual std::unique_ptr<FunctionBase<Number>> clone () const override;
127
132 virtual Number operator() (const Point & p,
133 const Real time=0.) override;
134
143 std::map<const Elem *, Number> discontinuous_value (const Point & p,
144 const Real time=0.);
145
150 Gradient gradient (const Point & p,
151 const Real time=0.);
152
159 std::map<const Elem *, Gradient> discontinuous_gradient (const Point & p,
160 const Real time=0.);
161
162#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
167 Tensor hessian (const Point & p,
168 const Real time=0.);
169#endif
170
177 virtual void operator() (const Point & p,
178 const Real time,
179 DenseVector<Number> & output) override;
180
186 void operator() (const Point & p,
187 const Real time,
188 DenseVector<Number> & output,
189 const std::set<subdomain_id_type> * subdomain_ids);
190
196 void discontinuous_value (const Point & p,
197 const Real time,
198 std::map<const Elem *, DenseVector<Number>> & output);
199
205 void discontinuous_value (const Point & p,
206 const Real time,
207 std::map<const Elem *, DenseVector<Number>> & output,
208 const std::set<subdomain_id_type> * subdomain_ids);
209
215 void gradient (const Point & p,
216 const Real time,
217 std::vector<Gradient> & output);
218
225 void gradient (const Point & p,
226 const Real time,
227 std::vector<Gradient> & output,
228 const std::set<subdomain_id_type> * subdomain_ids);
229
235 void discontinuous_gradient (const Point & p,
236 const Real time,
237 std::map<const Elem *, std::vector<Gradient>> & output);
238
244 void discontinuous_gradient (const Point & p,
245 const Real time,
246 std::map<const Elem *, std::vector<Gradient>> & output,
247 const std::set<subdomain_id_type> * subdomain_ids);
248
254 void hessian (const Point & p,
255 const Real time,
256 std::vector<Tensor> & output);
257
264 void hessian (const Point & p,
265 const Real time,
266 std::vector<Tensor> & output,
267 const std::set<subdomain_id_type> * subdomain_ids);
268
275 const PointLocatorBase & get_point_locator () const;
277
289
301
306
314
319
327 void set_subdomain_ids(const std::set<subdomain_id_type> * subdomain_ids);
328
329protected:
330
334 const Elem * find_element(const Point & p,
335 const std::set<subdomain_id_type> * subdomain_ids = nullptr) const;
336
343 std::set<const Elem *> find_elements(const Point & p,
344 const std::set<subdomain_id_type> * subdomain_ids = nullptr) const;
345
352 const Elem * check_found_elem(const Elem * element, const Point & p) const;
353
358 void _gradient_on_elem (const Point & p,
359 const Elem * element,
360 std::vector<Gradient> & output);
361
367
373
378
383 const std::vector<unsigned int> _system_vars;
384
389 std::unique_ptr<PointLocatorBase> _point_locator;
390
394 std::unique_ptr<std::set<subdomain_id_type>> _subdomain_ids;
395
401
407};
408
409
410} // namespace libMesh
411
412
413#endif // LIBMESH_MESH_FUNCTION_H
Defines a dense vector for use in Finite Element-type computations.
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
This is the base class from which all geometric element types are derived.
Definition elem.h:96
This is the EquationSystems class.
Base class for functors that can be evaluated at a point and (optionally) time.
This class provides function-like objects for data distributed over a mesh.
Tensor hessian(const Point &p, const Real time=0.)
const EquationSystems & _eqn_systems
The equation systems handler, from which the data are gathered.
std::map< const Elem *, Number > discontinuous_value(const Point &p, const Real time=0.)
std::unique_ptr< PointLocatorBase > _point_locator
A point locator is needed to locate the points in the mesh.
const std::vector< unsigned int > _system_vars
The indices of the variables within the other system for which data are to be gathered.
void set_subdomain_ids(const std::set< subdomain_id_type > *subdomain_ids)
Choose a default list of subdomain ids to be searched for points.
std::set< const Elem * > find_elements(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
virtual void init() override
Override the FunctionBase::init() member function.
MeshFunction & operator=(const MeshFunction &)=delete
MeshFunction(MeshFunction &&)=default
Special functions.
std::unique_ptr< std::set< subdomain_id_type > > _subdomain_ids
A default set of subdomain ids in which to search for points.
~MeshFunction()
Destructor.
void set_point_locator_tolerance(Real tol)
We may want to specify a tolerance for the PointLocator to use, since in some cases the point we want...
void _gradient_on_elem(const Point &p, const Elem *element, std::vector< Gradient > &output)
Helper function for finding a gradient as evaluated from a specific element.
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
void disable_out_of_mesh_mode()
Disables out-of-mesh mode.
virtual void clear() override
Clears the function.
DenseVector< Number > _out_of_mesh_value
Value to return outside the mesh if out-of-mesh mode is enabled.
Gradient gradient(const Point &p, const Real time=0.)
const NumericVector< Number > & _vector
A reference to the vector that holds the data that is to be interpolated.
const PointLocatorBase & get_point_locator() const
virtual std::unique_ptr< FunctionBase< Number > > clone() const override
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
Helper function to reduce code duplication.
void enable_out_of_mesh_mode(const DenseVector< Number > &value)
Enables out-of-mesh mode.
void unset_point_locator_tolerance()
Turn off the user-specified PointLocator tolerance.
const DofMap & _dof_map
Need access to the DofMap of the other system.
std::map< const Elem *, Gradient > discontinuous_gradient(const Point &p, const Real time=0.)
virtual Number operator()(const Point &p, const Real time=0.) override
const Elem * check_found_elem(const Elem *element, const Point &p) const
Helper function that is called by MeshFunction::find_element() and MeshFunction::find_elements() to e...
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
An object whose state is distributed along a set of processors.
This is the base class for point locators.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition xdr_io.C:55