libMesh
mesh_function.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
35 namespace libMesh
36 {
37 
38 
39 // Forward Declarations
40 template <typename T> class DenseVector;
41 class EquationSystems;
42 template <typename T> class NumericVector;
43 class DofMap;
44 class PointLocatorBase;
45 
53 class MeshFunction : public FunctionBase<Number>,
54  public ParallelObject
55 {
56 public:
57 
66  MeshFunction (const EquationSystems & eqn_systems,
67  const NumericVector<Number> & vec,
68  const DofMap & dof_map,
69  const std::vector<unsigned int> & vars,
70  const FunctionBase<Number> * master=libmesh_nullptr);
71 
80  MeshFunction (const EquationSystems & eqn_systems,
81  const NumericVector<Number> & vec,
82  const DofMap & dof_map,
83  const unsigned int var,
84  const FunctionBase<Number> * master=libmesh_nullptr);
85 
89  ~MeshFunction ();
90 
96  virtual void init () libmesh_override { this->init(Trees::NODES); }
97 
102  void init (const Trees::BuildType point_locator_build_type);
103 
107  virtual void clear () libmesh_override;
108 
118  virtual UniquePtr<FunctionBase<Number>> clone () const libmesh_override;
119 
124  Number operator() (const Point & p,
125  const Real time=0.) libmesh_override;
126 
135  std::map<const Elem *, Number> discontinuous_value (const Point & p,
136  const Real time=0.);
137 
142  Gradient gradient (const Point & p,
143  const Real time=0.);
144 
151  std::map<const Elem *, Gradient> discontinuous_gradient (const Point & p,
152  const Real time=0.);
153 
154 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
155 
159  Tensor hessian (const Point & p,
160  const Real time=0.);
161 #endif
162 
169  void operator() (const Point & p,
170  const Real time,
171  DenseVector<Number> & output) libmesh_override;
172 
178  void operator() (const Point & p,
179  const Real time,
180  DenseVector<Number> & output,
181  const std::set<subdomain_id_type> * subdomain_ids);
182 
188  void discontinuous_value (const Point & p,
189  const Real time,
190  std::map<const Elem *, DenseVector<Number>> & output);
191 
197  void discontinuous_value (const Point & p,
198  const Real time,
199  std::map<const Elem *, DenseVector<Number>> & output,
200  const std::set<subdomain_id_type> * subdomain_ids);
201 
208  void gradient (const Point & p,
209  const Real time,
210  std::vector<Gradient> & output,
211  const std::set<subdomain_id_type> * subdomain_ids = libmesh_nullptr);
212 
218  void discontinuous_gradient (const Point & p,
219  const Real time,
220  std::map<const Elem *, std::vector<Gradient>> & output);
221 
227  void discontinuous_gradient (const Point & p,
228  const Real time,
229  std::map<const Elem *, std::vector<Gradient>> & output,
230  const std::set<subdomain_id_type> * subdomain_ids);
231 
238  void hessian (const Point & p,
239  const Real time,
240  std::vector<Tensor> & output,
241  const std::set<subdomain_id_type> * subdomain_ids = libmesh_nullptr);
242 
249  const PointLocatorBase & get_point_locator (void) const;
250 
262 
273  void enable_out_of_mesh_mode(const Number & value);
274 
278  void disable_out_of_mesh_mode(void);
279 
287 
292 
293 protected:
294 
298  const Elem * find_element(const Point & p,
299  const std::set<subdomain_id_type> * subdomain_ids = libmesh_nullptr) const;
300 
307  std::set<const Elem *> find_elements(const Point & p,
308  const std::set<subdomain_id_type> * subdomain_ids = libmesh_nullptr) const;
309 
315 
321 
325  const DofMap & _dof_map;
326 
331  const std::vector<unsigned int> _system_vars;
332 
338 
344 
350 };
351 
352 
353 
354 
355 // ------------------------------------------------------------
356 // MeshFunction inline methods
357 
358 
359 } // namespace libMesh
360 
361 
362 #endif // LIBMESH_MESH_FUNCTION_H
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
Helper function to reduce code duplication.
This is the EquationSystems class.
const EquationSystems & _eqn_systems
The equation systems handler, from which the data are gathered.
const NumericVector< Number > & _vector
A reference to the vector that holds the data that is to be interpolated.
bool _out_of_mesh_mode
true if out-of-mesh mode is enabled.
PointLocatorBase * _point_locator
A point locator is needed to locate the points in the mesh.
const DofMap & _dof_map
Need access to the DofMap of the other system.
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
const class libmesh_nullptr_t libmesh_nullptr
Gradient gradient(const Point &p, const Real time=0.)
const PointLocatorBase & get_point_locator(void) const
~MeshFunction()
Destructor.
Definition: mesh_function.C:88
The libMesh namespace provides an interface to certain functionality in the library.
Number operator()(const Point &p, const Real time=0.) libmesh_override
void disable_out_of_mesh_mode(void)
Disables out-of-mesh mode.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
DenseVector< Number > _out_of_mesh_value
Value to return outside the mesh if out-of-mesh mode is enabled.
virtual UniquePtr< FunctionBase< Number > > clone() const libmesh_override
void enable_out_of_mesh_mode(const DenseVector< Number > &value)
Enables out-of-mesh mode.
std::map< const Elem *, Number > discontinuous_value(const Point &p, const Real time=0.)
void unset_point_locator_tolerance()
Turn off the user-specified PointLocator tolerance.
virtual void clear() libmesh_override
Clears the function.
This is the base class for point locators.
This class forms the base class for all other classes that are expected to be implemented in parallel...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::set< const Elem * > find_elements(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
static const bool value
Definition: xdr_io.C:108
BuildType
enum defining how to build the tree.
Definition: tree_base.h:55
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:53
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...
This is the base class for functor-like classes.
std::map< const Elem *, Gradient > discontinuous_gradient(const Point &p, const Real time=0.)
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
Tensor hessian(const Point &p, const Real time=0.)
virtual void init() libmesh_override
Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES ...
Definition: mesh_function.h:96
MeshFunction(const EquationSystems &eqn_systems, const NumericVector< Number > &vec, const DofMap &dof_map, const std::vector< unsigned int > &vars, const FunctionBase< Number > *master=libmesh_nullptr)
Constructor for mesh based functions with vectors as return value.
Definition: mesh_function.C:43
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
const std::vector< unsigned int > _system_vars
The indices of the variables within the other system for which data are to be gathered.