libMesh
mesh_function.C
Go to the documentation of this file.
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 
20 // Local Includes
21 #include "libmesh/mesh_function.h"
22 #include "libmesh/dense_vector.h"
23 #include "libmesh/equation_systems.h"
24 #include "libmesh/numeric_vector.h"
25 #include "libmesh/dof_map.h"
26 #include "libmesh/point_locator_tree.h"
27 #include "libmesh/fe_base.h"
28 #include "libmesh/fe_interface.h"
29 #include "libmesh/fe_compute_data.h"
30 #include "libmesh/mesh_base.h"
31 #include "libmesh/point.h"
32 #include "libmesh/elem.h"
33 #include "libmesh/int_range.h"
34 #include "libmesh/fe_map.h"
35 
36 namespace libMesh
37 {
38 
39 
40 //------------------------------------------------------------------
41 // MeshFunction methods
43  const NumericVector<Number> & vec,
44  const DofMap & dof_map,
45  std::vector<unsigned int> vars,
46  const FunctionBase<Number> * master) :
47  FunctionBase<Number> (master),
48  ParallelObject (eqn_systems),
49  _eqn_systems (eqn_systems),
50  _vector (vec),
51  _dof_map (dof_map),
52  _system_vars (std::move(vars)),
53  _out_of_mesh_mode (false)
54 {
55 }
56 
57 
58 
60  const NumericVector<Number> & vec,
61  const DofMap & dof_map,
62  const unsigned int var,
63  const FunctionBase<Number> * master) :
64  FunctionBase<Number> (master),
65  ParallelObject (eqn_systems),
66  _eqn_systems (eqn_systems),
67  _vector (vec),
68  _dof_map (dof_map),
69  _system_vars (1,var),
70  _out_of_mesh_mode (false)
71 {
72 }
73 
75  FunctionBase<Number> (mf._master),
76  ParallelObject (mf._eqn_systems),
77  _eqn_systems (mf._eqn_systems),
78  _vector (mf._vector),
79  _dof_map (mf._dof_map),
80  _system_vars (mf._system_vars),
81  _out_of_mesh_mode (mf._out_of_mesh_mode)
82 {
83  // Initialize the mf and set the point locator if the
84  // input mf had done so.
85  if(mf.initialized())
86  {
87  this->MeshFunction::init();
88 
91 
92  }
93 
94  if (mf._subdomain_ids)
96  std::make_unique<std::set<subdomain_id_type>>
97  (*mf._subdomain_ids);
98 }
99 
100 MeshFunction::~MeshFunction () = default;
101 
102 
103 
105 {
106  // are indices of the desired variable(s) provided?
107  libmesh_assert_greater (this->_system_vars.size(), 0);
108 
109  // Don't do twice...
110  if (this->_initialized)
111  {
113  return;
114  }
115 
116  // The Mesh owns the "master" PointLocator, while handing us a
117  // PointLocator "proxy" that forwards all requests to the master.
118  const MeshBase & mesh = this->_eqn_systems.get_mesh();
120 
121  // ready for use
122  this->_initialized = true;
123 }
124 
125 
126 
127 #ifdef LIBMESH_ENABLE_DEPRECATED
128 void MeshFunction::init (const Trees::BuildType /*point_locator_build_type*/)
129 {
130  libmesh_deprecated();
131 
132  // Call the init() taking no args instead. Note: this is backwards
133  // compatible because the argument was not used for anything
134  // previously anyway.
135  this->init();
136 }
137 #endif // LIBMESH_ENABLE_DEPRECATED
138 
139 
140 
141 void
143 {
144  // only delete the point locator when we are the master
145  if (_point_locator && !_master)
146  _point_locator.reset();
147 
148  this->_initialized = false;
149 }
150 
151 
152 
153 std::unique_ptr<FunctionBase<Number>> MeshFunction::clone () const
154 {
155  return std::make_unique<MeshFunction>(*this);
156 }
157 
158 
159 
161  const Real time)
162 {
163  libmesh_assert (this->initialized());
164 
165  DenseVector<Number> buf (1);
166  this->operator() (p, time, buf);
167  return buf(0);
168 }
169 
170 std::map<const Elem *, Number> MeshFunction::discontinuous_value (const Point & p,
171  const Real time)
172 {
173  libmesh_assert (this->initialized());
174 
175  std::map<const Elem *, DenseVector<Number>> buffer;
176  this->discontinuous_value (p, time, buffer);
177  std::map<const Elem *, Number> return_value;
178  for (const auto & [elem, vec] : buffer)
179  return_value[elem] = vec(0);
180  // NOTE: If no suitable element is found, then the map return_value is empty. This
181  // puts burden on the user of this function but I don't really see a better way.
182  return return_value;
183 }
184 
186  const Real time)
187 {
188  libmesh_assert (this->initialized());
189 
190  std::vector<Gradient> buf (1);
191  this->gradient(p, time, buf);
192  return buf[0];
193 }
194 
195 std::map<const Elem *, Gradient> MeshFunction::discontinuous_gradient (const Point & p,
196  const Real time)
197 {
198  libmesh_assert (this->initialized());
199 
200  std::map<const Elem *, std::vector<Gradient>> buffer;
201  this->discontinuous_gradient (p, time, buffer);
202  std::map<const Elem *, Gradient> return_value;
203  for (const auto & [elem, vec] : buffer)
204  return_value[elem] = vec[0];
205  // NOTE: If no suitable element is found, then the map return_value is empty. This
206  // puts burden on the user of this function but I don't really see a better way.
207  return return_value;
208 }
209 
210 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
212  const Real time)
213 {
214  libmesh_assert (this->initialized());
215 
216  std::vector<Tensor> buf (1);
217  this->hessian(p, time, buf);
218  return buf[0];
219 }
220 #endif
221 
223  const Real time,
224  DenseVector<Number> & output)
225 {
226  this->operator() (p, time, output, this->_subdomain_ids.get());
227 }
228 
230  const Real,
231  DenseVector<Number> & output,
232  const std::set<subdomain_id_type> * subdomain_ids)
233 {
234  libmesh_assert (this->initialized());
235 
236  const Elem * element = this->find_element(p,subdomain_ids);
237 
238  if (!element)
239  {
240  // We'd better be in out_of_mesh_mode if we couldn't find an
241  // element in the mesh
243  output = _out_of_mesh_value;
244  }
245  else
246  {
247  // resize the output vector to the number of output values
248  // that the user told us
249  output.resize (cast_int<unsigned int>
250  (this->_system_vars.size()));
251 
252 
253  {
254  const unsigned int dim = element->dim();
255 
256 
257  // Get local coordinates to feed these into compute_data().
258  // Note that the fe_type can safely be used from the 0-variable,
259  // since the inverse mapping is the same for all FEFamilies
260  const Point mapped_point (FEMap::inverse_map (dim, element,
261  p));
262 
263  // loop over all vars
264  for (auto index : index_range(this->_system_vars))
265  {
266  // the data for this variable
267  const unsigned int var = _system_vars[index];
268 
269  if (var == libMesh::invalid_uint)
270  {
272  index < _out_of_mesh_value.size());
273  output(index) = _out_of_mesh_value(index);
274  continue;
275  }
276 
277  const FEType & fe_type = this->_dof_map.variable_type(var);
278 
279  // Build an FEComputeData that contains both input and output data
280  // for the specific compute_data method.
281  {
282  FEComputeData data (this->_eqn_systems, mapped_point);
283 
284  FEInterface::compute_data (dim, fe_type, element, data);
285 
286  // where the solution values for the var-th variable are stored
287  std::vector<dof_id_type> dof_indices;
288  this->_dof_map.dof_indices (element, dof_indices, var);
289 
290  // interpolate the solution
291  {
292  Number value = 0.;
293 
294  for (auto i : index_range(dof_indices))
295  value += this->_vector(dof_indices[i]) * data.shape[i];
296 
297  output(index) = value;
298  }
299 
300  }
301 
302  // next variable
303  }
304  }
305  }
306 }
307 
308 
310  const Real time,
311  std::map<const Elem *, DenseVector<Number>> & output)
312 {
313  this->discontinuous_value (p, time, output, this->_subdomain_ids.get());
314 }
315 
316 
317 
319  const Real,
320  std::map<const Elem *, DenseVector<Number>> & output,
321  const std::set<subdomain_id_type> * subdomain_ids)
322 {
323  libmesh_assert (this->initialized());
324 
325  // clear the output map
326  output.clear();
327 
328  // get the candidate elements
329  std::set<const Elem *> candidate_element = this->find_elements(p,subdomain_ids);
330 
331  // loop through all candidates, if the set is empty this function will return an
332  // empty map
333  for (const auto & element : candidate_element)
334  {
335  const unsigned int dim = element->dim();
336 
337  // define a temporary vector to store all values
338  DenseVector<Number> temp_output (cast_int<unsigned int>(this->_system_vars.size()));
339 
340  // Get local coordinates to feed these into compute_data().
341  // Note that the fe_type can safely be used from the 0-variable,
342  // since the inverse mapping is the same for all FEFamilies
343  const Point mapped_point (FEMap::inverse_map (dim, element, p));
344 
345  // loop over all vars
346  for (auto index : index_range(this->_system_vars))
347  {
348  // the data for this variable
349  const unsigned int var = _system_vars[index];
350 
351  if (var == libMesh::invalid_uint)
352  {
354  index < _out_of_mesh_value.size());
355  temp_output(index) = _out_of_mesh_value(index);
356  continue;
357  }
358 
359  const FEType & fe_type = this->_dof_map.variable_type(var);
360 
361  // Build an FEComputeData that contains both input and output data
362  // for the specific compute_data method.
363  {
364  FEComputeData data (this->_eqn_systems, mapped_point);
365 
366  FEInterface::compute_data (dim, fe_type, element, data);
367 
368  // where the solution values for the var-th variable are stored
369  std::vector<dof_id_type> dof_indices;
370  this->_dof_map.dof_indices (element, dof_indices, var);
371 
372  // interpolate the solution
373  {
374  Number value = 0.;
375 
376  for (auto i : index_range(dof_indices))
377  value += this->_vector(dof_indices[i]) * data.shape[i];
378 
379  temp_output(index) = value;
380  }
381 
382  }
383 
384  // next variable
385  }
386 
387  // Insert temp_output into output
388  output[element] = temp_output;
389  }
390 }
391 
392 
393 
395  const Real time,
396  std::vector<Gradient> & output)
397 {
398  this->gradient(p, time, output, this->_subdomain_ids.get());
399 }
400 
401 
402 
404  const Real,
405  std::vector<Gradient> & output,
406  const std::set<subdomain_id_type> * subdomain_ids)
407 {
408  libmesh_assert (this->initialized());
409 
410  const Elem * element = this->find_element(p,subdomain_ids);
411 
412  if (!element)
413  output.resize(0);
414  else
415  this->_gradient_on_elem(p, element, output);
416 }
417 
418 
420  const Real time,
421  std::map<const Elem *, std::vector<Gradient>> & output)
422 {
423  this->discontinuous_gradient (p, time, output, this->_subdomain_ids.get());
424 }
425 
426 
427 
429  const Real,
430  std::map<const Elem *, std::vector<Gradient>> & output,
431  const std::set<subdomain_id_type> * subdomain_ids)
432 {
433  libmesh_assert (this->initialized());
434 
435  // clear the output map
436  output.clear();
437 
438  // get the candidate elements
439  std::set<const Elem *> candidate_element = this->find_elements(p,subdomain_ids);
440 
441  // loop through all candidates, if the set is empty this function will return an
442  // empty map
443  for (const auto & element : candidate_element)
444  {
445  // define a temporary vector to store all values
446  std::vector<Gradient> temp_output (cast_int<unsigned int>(this->_system_vars.size()));
447 
448  this->_gradient_on_elem(p, element, temp_output);
449 
450  // Insert temp_output into output
451  output.emplace(element, std::move(temp_output));
452  }
453 }
454 
455 
456 
458  const Elem * element,
459  std::vector<Gradient> & output)
460 {
461  libmesh_assert(element);
462 
463  // resize the output vector to the number of output values
464  // that the user told us
465  output.resize (this->_system_vars.size());
466 
467  const unsigned int dim = element->dim();
468 
469  // Get local coordinates to feed these into compute_data().
470  // Note that the fe_type can safely be used from the 0-variable,
471  // since the inverse mapping is the same for all FEFamilies
472  const Point mapped_point (FEMap::inverse_map (dim, element,
473  p));
474 
475  std::vector<Point> point_list (1, mapped_point);
476 
477  // loop over all vars
478  for (auto index : index_range(this->_system_vars))
479  {
480  // the data for this variable
481  const unsigned int var = _system_vars[index];
482 
483  if (var == libMesh::invalid_uint)
484  {
486  index < _out_of_mesh_value.size());
487  output[index] = Gradient(_out_of_mesh_value(index));
488  continue;
489  }
490 
491  const FEType & fe_type = this->_dof_map.variable_type(var);
492 
493  // where the solution values for the var-th variable are stored
494  std::vector<dof_id_type> dof_indices;
495  this->_dof_map.dof_indices (element, dof_indices, var);
496 
497  // interpolate the solution
498  Gradient grad(0.);
499 
500  // for performance-reasons, we use different algorithms now.
501  // TODO: Check that both give the same result for finite elements.
502  // Otherwive it is wrong...
503  if (!element->infinite())
504  {
505  std::unique_ptr<FEBase> point_fe (FEBase::build(dim, fe_type));
506  const std::vector<std::vector<RealGradient>> & dphi = point_fe->get_dphi();
507  point_fe->reinit(element, &point_list);
508 
509  for (auto i : index_range(dof_indices))
510  grad.add_scaled(dphi[i][0], this->_vector(dof_indices[i]));
511 
512  }
513 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
514  else
515  {
516  // Build an FEComputeData that contains both input and output data
517  // for the specific compute_data method.
518  //
519  // TODO: enable this for a vector of points as well...
520  FEComputeData data (this->_eqn_systems, mapped_point);
521  data.enable_derivative();
522  FEInterface::compute_data (dim, fe_type, element, data);
523 
524  // grad [x] = data.dshape[i](v) * dv/dx * dof_index [i]
525  // sum over all indices
526  for (auto i : index_range(dof_indices))
527  {
528  // local coordinates
529  for (std::size_t v=0; v<dim; v++)
530  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
531  {
532  // FIXME: this needs better syntax: It is matrix-vector multiplication.
533  grad(xyz) += data.local_transform[v][xyz]
534  * data.dshape[i](v)
535  * this->_vector(dof_indices[i]);
536  }
537  }
538  }
539 #endif
540  output[index] = grad;
541  }
542 }
543 
544 
545 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
546 void MeshFunction::hessian (const Point & p,
547  const Real time,
548  std::vector<Tensor> & output)
549 {
550  this->hessian(p, time, output, this->_subdomain_ids.get());
551 }
552 
553 
554 
555 void MeshFunction::hessian (const Point & p,
556  const Real,
557  std::vector<Tensor> & output,
558  const std::set<subdomain_id_type> * subdomain_ids)
559 {
560  libmesh_assert (this->initialized());
561 
562  const Elem * element = this->find_element(p,subdomain_ids);
563 
564  if (!element)
565  {
566  output.resize(0);
567  }
568  else
569  {
570  if(element->infinite())
571  libmesh_warning("Warning: Requested the Hessian of an Infinite element."
572  << "Second derivatives for Infinite elements"
573  << " are not yet implemented!"
574  << std::endl);
575 
576  // resize the output vector to the number of output values
577  // that the user told us
578  output.resize (this->_system_vars.size());
579 
580 
581  {
582  const unsigned int dim = element->dim();
583 
584 
585  // Get local coordinates to feed these into compute_data().
586  // Note that the fe_type can safely be used from the 0-variable,
587  // since the inverse mapping is the same for all FEFamilies
588  const Point mapped_point (FEMap::inverse_map (dim, element,
589  p));
590 
591  std::vector<Point> point_list (1, mapped_point);
592 
593  // loop over all vars
594  for (auto index : index_range(this->_system_vars))
595  {
596  // the data for this variable
597  const unsigned int var = _system_vars[index];
598 
599  if (var == libMesh::invalid_uint)
600  {
602  index < _out_of_mesh_value.size());
603  output[index] = Tensor(_out_of_mesh_value(index));
604  continue;
605  }
606  const FEType & fe_type = this->_dof_map.variable_type(var);
607 
608  std::unique_ptr<FEBase> point_fe (FEBase::build(dim, fe_type));
609  const std::vector<std::vector<RealTensor>> & d2phi =
610  point_fe->get_d2phi();
611  point_fe->reinit(element, &point_list);
612 
613  // where the solution values for the var-th variable are stored
614  std::vector<dof_id_type> dof_indices;
615  this->_dof_map.dof_indices (element, dof_indices, var);
616 
617  // interpolate the solution
618  Tensor hess;
619 
620  for (auto i : index_range(dof_indices))
621  hess.add_scaled(d2phi[i][0], this->_vector(dof_indices[i]));
622 
623  output[index] = hess;
624  }
625  }
626  }
627 }
628 #endif
629 
631  const std::set<subdomain_id_type> * subdomain_ids) const
632 {
633  // Ensure that in the case of a master mesh function, the
634  // out-of-mesh mode is enabled either for both or for none. This is
635  // important because the out-of-mesh mode is also communicated to
636  // the point locator. Since this is time consuming, enable it only
637  // in debug mode.
638 #ifdef DEBUG
639  if (this->_master != nullptr)
640  {
641  const MeshFunction * master =
642  cast_ptr<const MeshFunction *>(this->_master);
643  libmesh_error_msg_if(_out_of_mesh_mode!=master->_out_of_mesh_mode,
644  "ERROR: If you use out-of-mesh-mode in connection with master mesh "
645  "functions, you must enable out-of-mesh mode for both the master and the slave mesh function.");
646  }
647 #endif
648 
649  // locate the point in the other mesh
650  const Elem * element = (*_point_locator)(p, subdomain_ids);
651 
652  // Make sure that the element found is evaluable
653  return this->check_found_elem(element, p);
654 }
655 
656 std::set<const Elem *> MeshFunction::find_elements(const Point & p,
657  const std::set<subdomain_id_type> * subdomain_ids) const
658 {
659  // Ensure that in the case of a master mesh function, the
660  // out-of-mesh mode is enabled either for both or for none. This is
661  // important because the out-of-mesh mode is also communicated to
662  // the point locator. Since this is time consuming, enable it only
663  // in debug mode.
664 #ifdef DEBUG
665  if (this->_master != nullptr)
666  {
667  const MeshFunction * master =
668  cast_ptr<const MeshFunction *>(this->_master);
669  libmesh_error_msg_if(_out_of_mesh_mode!=master->_out_of_mesh_mode,
670  "ERROR: If you use out-of-mesh-mode in connection with master mesh "
671  "functions, you must enable out-of-mesh mode for both the master and the slave mesh function.");
672  }
673 #endif
674 
675  // locate the point in the other mesh
676  std::set<const Elem *> candidate_elements;
677  std::set<const Elem *> final_candidate_elements;
678  (*_point_locator)(p, candidate_elements, subdomain_ids);
679 
680  // For each candidate Elem, if it is evaluable, add it to the set of
681  // final candidate Elems.
682  for (const auto & element : candidate_elements)
683  final_candidate_elements.insert(this->check_found_elem(element, p));
684 
685  return final_candidate_elements;
686 }
687 
688 const Elem *
689 MeshFunction::check_found_elem(const Elem * element, const Point & p) const
690 {
691  // If the PointLocator did not find an Element containing Point p,
692  // OR if the PointLocator found a local element containting Point p,
693  // we can simply return it.
694  if (!element || (element->processor_id() == this->processor_id()))
695  return element;
696 
697  // Otherwise, the PointLocator returned a valid but non-local
698  // element. Therefore, we have to do some further checks:
699  //
700  // 1.) If we have a SERIAL _vector, then we can just return the
701  // non-local element, because all the DOFs are available.
702  if (_vector.type() == SERIAL)
703  return element;
704 
705  // 2.) If we have a GHOSTED _vector, then we can return a non-local
706  // Element provided that all of its DOFs are ghosted on this
707  // processor. That should be faster than the other option, which
708  // is to search through all the Elem's point_neighbors() for a
709  // suitable local Elem.
710  if (_vector.type() == GHOSTED && _dof_map.is_evaluable(*element))
711  return element;
712 
713  // 3.) If we have a PARALLEL vector, then we search the non-local
714  // Elem's point neighbors for a local one to return instead. If
715  // we don't eventually find one, we just return nullptr.
716  std::set<const Elem *> point_neighbors;
717  element->find_point_neighbors(p, point_neighbors);
718  element = nullptr;
719  for (const auto & elem : point_neighbors)
720  if (elem->processor_id() == this->processor_id())
721  {
722  element = elem;
723  break;
724  }
725 
726  return element;
727 }
728 
730 {
731  libmesh_assert (this->initialized());
732  return *_point_locator;
733 }
734 
736 {
737  libmesh_assert (this->initialized());
738  return *_point_locator;
739 }
740 
742 {
743  libmesh_assert (this->initialized());
744  _point_locator->enable_out_of_mesh_mode();
745  _out_of_mesh_mode = true;
747 }
748 
750 {
751  DenseVector<Number> v(1);
752  v(0) = value;
753  this->enable_out_of_mesh_mode(v);
754 }
755 
757 {
758  libmesh_assert (this->initialized());
759  _point_locator->disable_out_of_mesh_mode();
760  _out_of_mesh_mode = false;
761 }
762 
764 {
765  _point_locator->set_close_to_point_tol(tol);
766  _point_locator->set_contains_point_tol(tol);
767 }
768 
770 {
771  _point_locator->unset_close_to_point_tol();
772 }
773 
774 void MeshFunction::set_subdomain_ids(const std::set<subdomain_id_type> * subdomain_ids)
775 {
776  if (subdomain_ids)
777  _subdomain_ids = std::make_unique<std::set<subdomain_id_type>>(*subdomain_ids);
778  else
779  _subdomain_ids.reset();
780 }
781 
782 } // namespace libMesh
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:196
std::unique_ptr< std::set< subdomain_id_type > > _subdomain_ids
A default set of subdomain ids in which to search for points.
This is the EquationSystems class.
const EquationSystems & _eqn_systems
The equation systems handler, from which the data are gathered.
virtual std::unique_ptr< FunctionBase< Number > > clone() const override
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:629
BuildType
enum defining how to build the tree.
Definition: tree_base.h:58
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.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:310
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:1638
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2164
unsigned int dim
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1628
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
const DofMap & _dof_map
Need access to the DofMap of the other system.
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:396
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
Helper function to reduce code duplication.
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2220
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
MeshBase & mesh
const FunctionBase * _master
Const pointer to our master, initialized to nullptr.
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
Gradient gradient(const Point &p, const Real time=0.)
std::vector< Gradient > dshape
Storage for the computed shape derivative values.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
~MeshFunction()
Destructor.
std::vector< std::vector< Real > > local_transform
Storage for local to global mapping at p.
The libMesh namespace provides an interface to certain functionality in the library.
void disable_out_of_mesh_mode()
Disables out-of-mesh mode.
Real get_close_to_point_tol() const
Get the close-to-point tolerance.
This is the MeshBase class.
Definition: mesh_base.h:75
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.
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:179
DenseVector< Number > _out_of_mesh_value
Value to return outside the mesh if out-of-mesh mode is enabled.
void enable_out_of_mesh_mode(const DenseVector< Number > &value)
Enables out-of-mesh mode.
virtual void clear() override
Clears the function.
std::set< const Elem * > find_elements(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
std::map< const Elem *, Number > discontinuous_value(const Point &p, const Real time=0.)
void find_point_neighbors(const Point &p, std::set< const Elem *> &neighbor_set) const
This function finds all active elements (including this one) which are in the same manifold as this e...
Definition: elem.C:993
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data...
NumberVectorValue Gradient
void unset_point_locator_tolerance()
Turn off the user-specified PointLocator tolerance.
virtual void init() override
Override the FunctionBase::init() member function.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libmesh_assert(ctx)
const PointLocatorBase & get_point_locator() const
This is the base class for point locators.
An object whose state is distributed along a set of processors.
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:851
std::vector< Number > shape
Storage for the computed shape function values.
ParallelType type() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
NumberTensorValue Tensor
virtual unsigned short dim() const =0
virtual Number operator()(const Point &p, const Real time=0.) override
bool initialized() const
MeshFunction(const EquationSystems &eqn_systems, const NumericVector< Number > &vec, const DofMap &dof_map, std::vector< unsigned int > vars, const FunctionBase< Number > *master=nullptr)
Constructor for mesh based functions with vectors as return value.
Definition: mesh_function.C:42
const MeshBase & get_mesh() const
static const bool value
Definition: xdr_io.C:54
virtual unsigned int size() const override final
Definition: dense_vector.h:104
virtual bool infinite() const =0
This class provides function-like objects for data distributed over a mesh.
Definition: mesh_function.h:54
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...
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...
processor_id_type processor_id() const
void enable_derivative()
Enable the computation of shape gradients (dshape).
processor_id_type processor_id() const
Definition: dof_object.h:905
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:39
Tensor hessian(const Point &p, const Real time=0.)
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
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::unique_ptr< PointLocatorBase > _point_locator
A point locator is needed to locate the points in the mesh.
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2612
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.