libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
libMesh::MeshFunction Class Reference

This class provides function-like objects for data distributed over a mesh. More...

#include <mesh_function.h>

Inheritance diagram for libMesh::MeshFunction:
[legend]

Public Member Functions

 MeshFunction (const EquationSystems &eqn_systems, const NumericVector< Number > &vec, const DofMap &dof_map, const std::vector< unsigned int > &vars, const FunctionBase< Number > *master=nullptr)
 Constructor for mesh based functions with vectors as return value. More...
 
 MeshFunction (const EquationSystems &eqn_systems, const NumericVector< Number > &vec, const DofMap &dof_map, const unsigned int var, const FunctionBase< Number > *master=nullptr)
 Constructor for mesh based functions with a number as return value. More...
 
 MeshFunction (MeshFunction &&)=delete
 This class is sometimes responsible for cleaning up the _point_locator, so it can't be default (shallow) copy constructed or move constructed. More...
 
 MeshFunction (const MeshFunction &)=delete
 
MeshFunctionoperator= (const MeshFunction &)=delete
 This class contains const references so it can't be assigned. More...
 
MeshFunctionoperator= (MeshFunction &&)=delete
 
 ~MeshFunction ()
 Destructor. More...
 
virtual void init () override
 Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES method. More...
 
void init (const Trees::BuildType point_locator_build_type)
 The actual initialization process. More...
 
virtual void clear () override
 Clears the function. More...
 
virtual std::unique_ptr< FunctionBase< Number > > clone () const override
 
Number operator() (const Point &p, const Real time=0.) override
 
std::map< const Elem *, Numberdiscontinuous_value (const Point &p, const Real time=0.)
 
Gradient gradient (const Point &p, const Real time=0.)
 
std::map< const Elem *, Gradientdiscontinuous_gradient (const Point &p, const Real time=0.)
 
Tensor hessian (const Point &p, const Real time=0.)
 
void operator() (const Point &p, const Real time, DenseVector< Number > &output) override
 Computes values at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids. More...
 
void operator() (const Point &p, const Real time, DenseVector< Number > &output, const std::set< subdomain_id_type > *subdomain_ids)
 Computes values at coordinate p and for time time, restricting the point to the passed subdomain_ids. More...
 
void discontinuous_value (const Point &p, const Real time, std::map< const Elem *, DenseVector< Number >> &output)
 Similar to operator() with the same parameter list, but with the difference that multiple values on faces are explicitly permitted. More...
 
void discontinuous_value (const Point &p, const Real time, std::map< const Elem *, DenseVector< Number >> &output, const std::set< subdomain_id_type > *subdomain_ids)
 Similar to operator() with the same parameter list, but with the difference that multiple values on faces are explicitly permitted. More...
 
void gradient (const Point &p, const Real time, std::vector< Gradient > &output, const std::set< subdomain_id_type > *subdomain_ids=nullptr)
 Computes gradients at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids. More...
 
void discontinuous_gradient (const Point &p, const Real time, std::map< const Elem *, std::vector< Gradient >> &output)
 Similar to gradient, but with the difference that multiple values on faces are explicitly permitted. More...
 
void discontinuous_gradient (const Point &p, const Real time, std::map< const Elem *, std::vector< Gradient >> &output, const std::set< subdomain_id_type > *subdomain_ids)
 Similar to gradient, but with the difference that multiple values on faces are explicitly permitted. More...
 
void hessian (const Point &p, const Real time, std::vector< Tensor > &output, const std::set< subdomain_id_type > *subdomain_ids=nullptr)
 Computes gradients at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids. More...
 
const PointLocatorBaseget_point_locator (void) const
 
void enable_out_of_mesh_mode (const DenseVector< Number > &value)
 Enables out-of-mesh mode. More...
 
void enable_out_of_mesh_mode (const Number &value)
 Enables out-of-mesh mode. More...
 
void disable_out_of_mesh_mode (void)
 Disables out-of-mesh mode. More...
 
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 to evaluate at might be slightly outside the mesh (due to numerical rounding issues, for example). More...
 
void unset_point_locator_tolerance ()
 Turn off the user-specified PointLocator tolerance. More...
 
void operator() (const Point &p, DenseVector< Number > &output)
 Evaluation function for time-independent vector-valued functions. More...
 
virtual Number component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 Function to set whether this is a time-dependent function or not. More...
 
bool is_time_dependent () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

const Elemfind_element (const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
 Helper function to reduce code duplication. More...
 
std::set< const Elem * > find_elements (const Point &p, const std::set< subdomain_id_type > *subdomain_ids=nullptr) const
 

Protected Attributes

const EquationSystems_eqn_systems
 The equation systems handler, from which the data are gathered. More...
 
const NumericVector< Number > & _vector
 A reference to the vector that holds the data that is to be interpolated. More...
 
const DofMap_dof_map
 Need access to the DofMap of the other system. More...
 
const std::vector< unsigned int > _system_vars
 The indices of the variables within the other system for which data are to be gathered. More...
 
PointLocatorBase_point_locator
 A point locator is needed to locate the points in the mesh. More...
 
bool _out_of_mesh_mode
 true if out-of-mesh mode is enabled. More...
 
DenseVector< Number_out_of_mesh_value
 Value to return outside the mesh if out-of-mesh mode is enabled. More...
 
const FunctionBase_master
 Const pointer to our master, initialized to nullptr. More...
 
bool _initialized
 When init() was called so that everything is ready for calls to operator() (...), then this bool is true. More...
 
bool _is_time_dependent
 Cache whether or not this function is actually time-dependent. More...
 
const Parallel::Communicator_communicator
 

Detailed Description

This class provides function-like objects for data distributed over a mesh.

Author
Daniel Dreyer
Date
2003

Definition at line 53 of file mesh_function.h.

Constructor & Destructor Documentation

◆ MeshFunction() [1/4]

libMesh::MeshFunction::MeshFunction ( const EquationSystems eqn_systems,
const NumericVector< Number > &  vec,
const DofMap dof_map,
const std::vector< unsigned int > &  vars,
const FunctionBase< Number > *  master = nullptr 
)

Constructor for mesh based functions with vectors as return value.

Optionally takes a master function. If the MeshFunction is to be evaluated outside of the local partition of the mesh, then both the mesh in eqn_systems and the coefficient vector vec should be serialized.

◆ MeshFunction() [2/4]

libMesh::MeshFunction::MeshFunction ( const EquationSystems eqn_systems,
const NumericVector< Number > &  vec,
const DofMap dof_map,
const unsigned int  var,
const FunctionBase< Number > *  master = nullptr 
)

Constructor for mesh based functions with a number as return value.

Optionally takes a master function. If the MeshFunction is to be evaluated outside of the local partition of the mesh, then both the mesh in eqn_systems and the coefficient vector vec should be serialized.

◆ MeshFunction() [3/4]

libMesh::MeshFunction::MeshFunction ( MeshFunction &&  )
delete

This class is sometimes responsible for cleaning up the _point_locator, so it can't be default (shallow) copy constructed or move constructed.

◆ MeshFunction() [4/4]

libMesh::MeshFunction::MeshFunction ( const MeshFunction )
delete

◆ ~MeshFunction()

libMesh::MeshFunction::~MeshFunction ( )

Destructor.

Member Function Documentation

◆ clear()

virtual void libMesh::MeshFunction::clear ( )
overridevirtual

Clears the function.

Reimplemented from libMesh::FunctionBase< Number >.

◆ clone()

virtual std::unique_ptr<FunctionBase<Number> > libMesh::MeshFunction::clone ( ) const
overridevirtual
Returns
A new copy of the function.

The new copy uses the original as a master function to enable simultaneous evaluations of the copies in different threads.

Note
This implies the copy should not be used after the original is destroyed.

Implements libMesh::FunctionBase< Number >.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inherited

◆ component()

Number libMesh::FunctionBase< Number >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
)
virtualinherited
Returns
The vector component i at coordinate p and time time.
Note
Subclasses aren't required to override this, since the default implementation is based on the full vector evaluation, which is often correct.
Subclasses are recommended to override this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.

Reimplemented in SolutionFunction, SolutionFunction, and SolutionFunction.

Definition at line 227 of file function_base.h.

230 {
231  DenseVector<Output> outvec(i+1);
232  (*this)(p, time, outvec);
233  return outvec(i);
234 }

◆ disable_out_of_mesh_mode()

void libMesh::MeshFunction::disable_out_of_mesh_mode ( void  )

Disables out-of-mesh mode.

This is also the default.

◆ discontinuous_gradient() [1/3]

std::map<const Elem *, Gradient> libMesh::MeshFunction::discontinuous_gradient ( const Point p,
const Real  time = 0. 
)
Returns
A map of first derivatives (gradients) of variable 0 at point p and for time. map is from element to Gradient and accounts for double defined values on faces if the gradient is discontinuous

◆ discontinuous_gradient() [2/3]

void libMesh::MeshFunction::discontinuous_gradient ( const Point p,
const Real  time,
std::map< const Elem *, std::vector< Gradient >> &  output 
)

Similar to gradient, but with the difference that multiple values on faces are explicitly permitted.

This is useful for evaluating gradients on faces where the values to the left and right are different.

◆ discontinuous_gradient() [3/3]

void libMesh::MeshFunction::discontinuous_gradient ( const Point p,
const Real  time,
std::map< const Elem *, std::vector< Gradient >> &  output,
const std::set< subdomain_id_type > *  subdomain_ids 
)

Similar to gradient, but with the difference that multiple values on faces are explicitly permitted.

This is useful for evaluating gradients on faces where the values to the left and right are different.

◆ discontinuous_value() [1/3]

std::map<const Elem *, Number> libMesh::MeshFunction::discontinuous_value ( const Point p,
const Real  time = 0. 
)
Returns
A map of values of variable 0 at point p and for time.

The std::map is from element to Number and accounts for doubly-defined values on faces if discontinuous variables are used.

◆ discontinuous_value() [2/3]

void libMesh::MeshFunction::discontinuous_value ( const Point p,
const Real  time,
std::map< const Elem *, DenseVector< Number >> &  output 
)

Similar to operator() with the same parameter list, but with the difference that multiple values on faces are explicitly permitted.

This is useful for discontinuous shape functions that are evaluated on faces.

◆ discontinuous_value() [3/3]

void libMesh::MeshFunction::discontinuous_value ( const Point p,
const Real  time,
std::map< const Elem *, DenseVector< Number >> &  output,
const std::set< subdomain_id_type > *  subdomain_ids 
)

Similar to operator() with the same parameter list, but with the difference that multiple values on faces are explicitly permitted.

This is useful for discontinuous shape functions that are evaluated on faces.

◆ enable_out_of_mesh_mode() [1/2]

void libMesh::MeshFunction::enable_out_of_mesh_mode ( const DenseVector< Number > &  value)

Enables out-of-mesh mode.

In this mode, if asked for a point that is not contained in any element, the MeshFunction will return the given value instead of crashing. This mode is off per default. If you use a master mesh function and you want to enable this mode, you will have to enable it for the master mesh function as well and for all mesh functions that have the same master mesh function. You may, however, specify different values.

◆ enable_out_of_mesh_mode() [2/2]

void libMesh::MeshFunction::enable_out_of_mesh_mode ( const Number value)

Enables out-of-mesh mode.

In this mode, if asked for a point that is not contained in any element, the MeshFunction will return the given value instead of crashing. This mode is off per default. If you use a master mesh function and you want to enable this mode, you will have to enable it for the master mesh function as well and for all mesh functions that have the same master mesh function. You may, however, specify different values.

◆ find_element()

const Elem* libMesh::MeshFunction::find_element ( const Point p,
const std::set< subdomain_id_type > *  subdomain_ids = nullptr 
) const
protected

Helper function to reduce code duplication.

◆ find_elements()

std::set<const Elem *> libMesh::MeshFunction::find_elements ( const Point p,
const std::set< subdomain_id_type > *  subdomain_ids = nullptr 
) const
protected
Returns
All elements that are close to a point p.

This is similar to find_element() but covers cases where p is on the boundary.

◆ get_point_locator()

const PointLocatorBase& libMesh::MeshFunction::get_point_locator ( void  ) const
Returns
The current PointLocator object, for use elsewhere.
Note
The MeshFunction object must be initialized before this is called.

◆ gradient() [1/2]

Gradient libMesh::MeshFunction::gradient ( const Point p,
const Real  time = 0. 
)
Returns
The first derivatives of variable 0 at point p and for time, which defaults to zero.

◆ gradient() [2/2]

void libMesh::MeshFunction::gradient ( const Point p,
const Real  time,
std::vector< Gradient > &  output,
const std::set< subdomain_id_type > *  subdomain_ids = nullptr 
)

Computes gradients at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids.

This is useful in cases where there are multiple dimensioned elements, for example.

◆ hessian() [1/2]

Tensor libMesh::MeshFunction::hessian ( const Point p,
const Real  time = 0. 
)
Returns
The second derivatives of variable 0 at point p and for time, which defaults to zero.

◆ hessian() [2/2]

void libMesh::MeshFunction::hessian ( const Point p,
const Real  time,
std::vector< Tensor > &  output,
const std::set< subdomain_id_type > *  subdomain_ids = nullptr 
)

Computes gradients at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids.

This is useful in cases where there are multiple dimensioned elements, for example.

◆ init() [1/2]

virtual void libMesh::MeshFunction::init ( )
overridevirtual

Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES method.

specifies the method to use when building a PointLocator

Reimplemented from libMesh::FunctionBase< Number >.

Definition at line 110 of file mesh_function.h.

References init(), and libMesh::Trees::NODES.

Referenced by init().

110 { this->init(Trees::NODES); }
virtual void init() override
Override the FunctionBase::init() member function by calling our own and specifying the Trees::NODES ...

◆ init() [2/2]

void libMesh::MeshFunction::init ( const Trees::BuildType  point_locator_build_type)

The actual initialization process.

Takes an optional argument which specifies the method to use when building a PointLocator

◆ initialized()

bool libMesh::FunctionBase< Number >::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 205 of file function_base.h.

206 {
207  return (this->_initialized);
208 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...

◆ is_time_dependent()

bool libMesh::FunctionBase< Number >::is_time_dependent ( ) const
inherited
Returns
true when the function this object represents is actually time-dependent, false otherwise.

Definition at line 219 of file function_base.h.

220 {
221  return (this->_is_time_dependent);
222 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::MeshBase::partition().

94  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ operator()() [1/4]

void libMesh::FunctionBase< Number >::operator() ( const Point p,
DenseVector< Number > &  output 
)
inherited

Evaluation function for time-independent vector-valued functions.

Sets output values in the passed-in output DenseVector.

Definition at line 240 of file function_base.h.

242 {
243  // Call the time-dependent function with t=0.
244  this->operator()(p, 0., output);
245 }
virtual Number operator()(const Point &p, const Real time=0.)=0

◆ operator()() [2/4]

Number libMesh::MeshFunction::operator() ( const Point p,
const Real  time = 0. 
)
overridevirtual
Returns
The value of variable 0 at point p and for time, which defaults to zero.

Implements libMesh::FunctionBase< Number >.

◆ operator()() [3/4]

void libMesh::MeshFunction::operator() ( const Point p,
const Real  time,
DenseVector< Number > &  output 
)
overridevirtual

Computes values at coordinate p and for time time, which defaults to zero, optionally restricting the point to the passed subdomain_ids.

This is useful in cases where there are multiple dimensioned elements, for example.

Implements libMesh::FunctionBase< Number >.

◆ operator()() [4/4]

void libMesh::MeshFunction::operator() ( const Point p,
const Real  time,
DenseVector< Number > &  output,
const std::set< subdomain_id_type > *  subdomain_ids 
)

Computes values at coordinate p and for time time, restricting the point to the passed subdomain_ids.

This is useful in cases where there are multiple dimensioned elements, for example.

◆ operator=() [1/2]

MeshFunction& libMesh::MeshFunction::operator= ( const MeshFunction )
delete

This class contains const references so it can't be assigned.

◆ operator=() [2/2]

MeshFunction& libMesh::MeshFunction::operator= ( MeshFunction &&  )
delete

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inherited

◆ set_is_time_dependent()

void libMesh::FunctionBase< Number >::set_is_time_dependent ( bool  is_time_dependent)
inherited

Function to set whether this is a time-dependent function or not.

This is intended to be only used by subclasses who cannot natively determine time-dependence. In such a case, this function should be used immediately following construction.

Definition at line 212 of file function_base.h.

213 {
215 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ set_point_locator_tolerance()

void libMesh::MeshFunction::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 to evaluate at might be slightly outside the mesh (due to numerical rounding issues, for example).

◆ unset_point_locator_tolerance()

void libMesh::MeshFunction::unset_point_locator_tolerance ( )

Turn off the user-specified PointLocator tolerance.

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _dof_map

const DofMap& libMesh::MeshFunction::_dof_map
protected

Need access to the DofMap of the other system.

Definition at line 339 of file mesh_function.h.

◆ _eqn_systems

const EquationSystems& libMesh::MeshFunction::_eqn_systems
protected

The equation systems handler, from which the data are gathered.

Definition at line 328 of file mesh_function.h.

◆ _initialized

bool libMesh::FunctionBase< Number >::_initialized
protectedinherited

When init() was called so that everything is ready for calls to operator() (...), then this bool is true.

Definition at line 179 of file function_base.h.

◆ _is_time_dependent

bool libMesh::FunctionBase< Number >::_is_time_dependent
protectedinherited

Cache whether or not this function is actually time-dependent.

Definition at line 184 of file function_base.h.

◆ _master

const FunctionBase* libMesh::FunctionBase< Number >::_master
protectedinherited

Const pointer to our master, initialized to nullptr.

There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.

Definition at line 173 of file function_base.h.

◆ _out_of_mesh_mode

bool libMesh::MeshFunction::_out_of_mesh_mode
protected

true if out-of-mesh mode is enabled.

See enable_out_of_mesh_mode() for more details. Default is false.

Definition at line 357 of file mesh_function.h.

◆ _out_of_mesh_value

DenseVector<Number> libMesh::MeshFunction::_out_of_mesh_value
protected

Value to return outside the mesh if out-of-mesh mode is enabled.

See enable_out_of_mesh_mode() for more details.

Definition at line 363 of file mesh_function.h.

◆ _point_locator

PointLocatorBase* libMesh::MeshFunction::_point_locator
protected

A point locator is needed to locate the points in the mesh.

Definition at line 351 of file mesh_function.h.

◆ _system_vars

const std::vector<unsigned int> libMesh::MeshFunction::_system_vars
protected

The indices of the variables within the other system for which data are to be gathered.

Definition at line 345 of file mesh_function.h.

◆ _vector

const NumericVector<Number>& libMesh::MeshFunction::_vector
protected

A reference to the vector that holds the data that is to be interpolated.

Definition at line 334 of file mesh_function.h.


The documentation for this class was generated from the following file: