libMesh::MeshFunction Class Reference

#include <mesh_function.h>

Inheritance diagram for libMesh::MeshFunction:

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=libmesh_nullptr)
 
 MeshFunction (const EquationSystems &eqn_systems, const NumericVector< Number > &vec, const DofMap &dof_map, const unsigned int var, const FunctionBase< Number > *master=libmesh_nullptr)
 
 ~MeshFunction ()
 
virtual void init () libmesh_override
 
void init (const Trees::BuildType point_locator_build_type)
 
virtual void clear () libmesh_override
 
virtual UniquePtr< FunctionBase< Number > > clone () const libmesh_override
 
Number operator() (const Point &p, const Real time=0.) libmesh_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) libmesh_override
 
void operator() (const Point &p, const Real time, DenseVector< Number > &output, const std::set< subdomain_id_type > *subdomain_ids)
 
void discontinuous_value (const Point &p, const Real time, std::map< const Elem *, DenseVector< Number > > &output)
 
void discontinuous_value (const Point &p, const Real time, std::map< const Elem *, DenseVector< Number > > &output, const std::set< subdomain_id_type > *subdomain_ids)
 
void gradient (const Point &p, const Real time, std::vector< Gradient > &output, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr)
 
void discontinuous_gradient (const Point &p, const Real time, std::map< const Elem *, std::vector< Gradient > > &output)
 
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)
 
void hessian (const Point &p, const Real time, std::vector< Tensor > &output, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr)
 
const PointLocatorBaseget_point_locator (void) const
 
void enable_out_of_mesh_mode (const DenseVector< Number > &value)
 
void enable_out_of_mesh_mode (const Number &value)
 
void disable_out_of_mesh_mode (void)
 
void set_point_locator_tolerance (Real tol)
 
void unset_point_locator_tolerance ()
 
void operator() (const Point &p, DenseVector< Number > &output)
 
virtual Number component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 
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=libmesh_nullptr) const
 
std::set< const Elem * > find_elements (const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
 

Protected Attributes

const EquationSystems_eqn_systems
 
const NumericVector< Number > & _vector
 
const DofMap_dof_map
 
const std::vector< unsigned int > _system_vars
 
PointLocatorBase_point_locator
 
bool _out_of_mesh_mode
 
DenseVector< Number_out_of_mesh_value
 
const FunctionBase_master
 
bool _initialized
 
bool _is_time_dependent
 
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

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 = libmesh_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.

Definition at line 43 of file mesh_function.C.

Referenced by clone().

47  :
48  FunctionBase<Number> (master),
49  ParallelObject (eqn_systems),
50  _eqn_systems (eqn_systems),
51  _vector (vec),
52  _dof_map (dof_map),
53  _system_vars (vars),
55  _out_of_mesh_mode (false),
57 {
58 }
ParallelObject(const Parallel::Communicator &comm_in)
const EquationSystems & _eqn_systems
const NumericVector< Number > & _vector
PointLocatorBase * _point_locator
const DofMap & _dof_map
const class libmesh_nullptr_t libmesh_nullptr
DenseVector< Number > _out_of_mesh_value
const std::vector< unsigned int > _system_vars
libMesh::MeshFunction::MeshFunction ( const EquationSystems eqn_systems,
const NumericVector< Number > &  vec,
const DofMap dof_map,
const unsigned int  var,
const FunctionBase< Number > *  master = libmesh_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.

Definition at line 62 of file mesh_function.C.

66  :
67  FunctionBase<Number> (master),
68  ParallelObject (eqn_systems),
69  _eqn_systems (eqn_systems),
70  _vector (vec),
71  _dof_map (dof_map),
72  _system_vars (1,var),
74  _out_of_mesh_mode (false),
76 {
77  // std::vector<unsigned int> buf (1);
78  // buf[0] = var;
79  // _system_vars (buf);
80 }
ParallelObject(const Parallel::Communicator &comm_in)
const EquationSystems & _eqn_systems
const NumericVector< Number > & _vector
PointLocatorBase * _point_locator
const DofMap & _dof_map
const class libmesh_nullptr_t libmesh_nullptr
DenseVector< Number > _out_of_mesh_value
const std::vector< unsigned int > _system_vars
libMesh::MeshFunction::~MeshFunction ( )

Destructor.

Definition at line 88 of file mesh_function.C.

References libMesh::FunctionBase< Number >::_master, _point_locator, and libmesh_nullptr.

89 {
90  // only delete the point locator when we are the master
91  if (this->_master == libmesh_nullptr)
92  delete this->_point_locator;
93 }
PointLocatorBase * _point_locator
const FunctionBase * _master
const class libmesh_nullptr_t libmesh_nullptr

Member Function Documentation

void libMesh::MeshFunction::clear ( )
virtual

Clears the function.

Reimplemented from libMesh::FunctionBase< Number >.

Definition at line 154 of file mesh_function.C.

References libMesh::FunctionBase< Number >::_initialized, libMesh::FunctionBase< Number >::_master, _point_locator, and libmesh_nullptr.

Referenced by init().

155 {
156  // only delete the point locator when we are the master
157  if ((this->_point_locator != libmesh_nullptr) && (this->_master == libmesh_nullptr))
158  {
159  delete this->_point_locator;
161  }
162  this->_initialized = false;
163 }
PointLocatorBase * _point_locator
const FunctionBase * _master
const class libmesh_nullptr_t libmesh_nullptr
UniquePtr< FunctionBase< Number > > libMesh::MeshFunction::clone ( ) const
virtual

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 that this implies the copy should not be used after the original is destroyed.

Implements libMesh::FunctionBase< Number >.

Definition at line 167 of file mesh_function.C.

References _dof_map, _eqn_systems, _system_vars, _vector, libMesh::FunctionBase< Output >::init(), libMesh::FunctionBase< Number >::initialized(), and MeshFunction().

Referenced by init().

168 {
169  FunctionBase<Number> * mf_clone =
171 
172  if(this->initialized())
173  mf_clone->init();
174 
175  return UniquePtr< FunctionBase<Number> >(mf_clone);
176 }
const EquationSystems & _eqn_systems
const NumericVector< Number > & _vector
const DofMap & _dof_map
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)
Definition: mesh_function.C:43
const std::vector< unsigned int > _system_vars
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshTools::bounding_box(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::MeshTools::processor_bounding_box(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshTools::subdomain_bounding_box(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
virtual 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. Subclasses aren't required to overload this, since the default implementation is based on the full vector evaluation, which is often correct. Subclasses are recommended to overload this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.
void libMesh::MeshFunction::disable_out_of_mesh_mode ( void  )

Disables out-of-mesh mode. This is also the default.

Definition at line 752 of file mesh_function.C.

References _out_of_mesh_mode, _point_locator, libMesh::PointLocatorBase::disable_out_of_mesh_mode(), libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by init().

753 {
754  libmesh_assert (this->initialized());
756  _out_of_mesh_mode = false;
757 }
virtual void disable_out_of_mesh_mode()=0
PointLocatorBase * _point_locator
libmesh_assert(j)
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

Definition at line 215 of file mesh_function.C.

References libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by discontinuous_gradient(), and init().

217 {
218  libmesh_assert (this->initialized());
219 
220  std::map<const Elem *, std::vector<Gradient> > buffer;
221  this->discontinuous_gradient (p, time, buffer);
222  std::map<const Elem *, Gradient> return_value;
223  for (std::map<const Elem *, std::vector<Gradient> >::const_iterator it = buffer.begin(); it != buffer.end(); ++it)
224  return_value[it->first] = it->second[0];
225  // NOTE: If no suitable element is found, then the map return_value is empty. This
226  // puts burden on the user of this function but I don't really see a better way.
227  return return_value;
228 }
libmesh_assert(j)
std::map< const Elem *, Gradient > discontinuous_gradient(const Point &p, const Real time=0.)
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.

Definition at line 480 of file mesh_function.C.

References discontinuous_gradient(), and libmesh_nullptr.

483 {
484  this->discontinuous_gradient (p, time, output, libmesh_nullptr);
485 }
const class libmesh_nullptr_t libmesh_nullptr
std::map< const Elem *, Gradient > discontinuous_gradient(const Point &p, const Real time=0.)
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.

Definition at line 489 of file mesh_function.C.

References _dof_map, _system_vars, libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), find_elements(), libMesh::FunctionBase< Number >::initialized(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

493 {
494  libmesh_assert (this->initialized());
495 
496  // clear the output map
497  output.clear();
498 
499  // get the candidate elements
500  std::set<const Elem *> candidate_element = this->find_elements(p,subdomain_ids);
501 
502  // loop through all candidates, if the set is empty this function will return an
503  // empty map
504  for (std::set<const Elem *>::const_iterator it = candidate_element.begin(); it != candidate_element.end(); ++it)
505  {
506  const Elem * element = (*it);
507 
508  const unsigned int dim = element->dim();
509 
510  // define a temporary vector to store all values
511  std::vector<Gradient> temp_output (cast_int<unsigned int>(this->_system_vars.size()));
512 
513  /*
514  * Get local coordinates to feed these into compute_data().
515  * Note that the fe_type can safely be used from the 0-variable,
516  * since the inverse mapping is the same for all FEFamilies
517  */
518  const Point mapped_point (FEInterface::inverse_map (dim,
519  this->_dof_map.variable_type(0),
520  element,
521  p));
522 
523 
524  // loop over all vars
525  std::vector<Point> point_list (1, mapped_point);
526  for (std::size_t index = 0 ; index < this->_system_vars.size(); ++index)
527  {
528  /*
529  * the data for this variable
530  */
531  const unsigned int var = _system_vars[index];
532  const FEType & fe_type = this->_dof_map.variable_type(var);
533 
534  UniquePtr<FEBase> point_fe (FEBase::build(dim, fe_type));
535  const std::vector<std::vector<RealGradient> > & dphi = point_fe->get_dphi();
536  point_fe->reinit(element, &point_list);
537 
538  // where the solution values for the var-th variable are stored
539  std::vector<dof_id_type> dof_indices;
540  this->_dof_map.dof_indices (element, dof_indices, var);
541 
542  Gradient grad(0.);
543 
544  for (std::size_t i = 0; i < dof_indices.size(); ++i)
545  grad.add_scaled(dphi[i][0], this->_vector(dof_indices[i]));
546 
547  temp_output[index] = grad;
548 
549  // next variable
550  }
551 
552  // Insert temp_output into output
553  output[element] = temp_output;
554  }
555 }
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
const DofMap & _dof_map
libmesh_assert(j)
NumberVectorValue Gradient
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
std::set< const Elem * > find_elements(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
const std::vector< unsigned int > _system_vars
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2022
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
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. map is from element to Number and accounts for double defined values on faces if discontinuous variables are used

Definition at line 190 of file mesh_function.C.

References libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by discontinuous_value(), and init().

192 {
193  libmesh_assert (this->initialized());
194 
195  std::map<const Elem *, DenseVector<Number> > buffer;
196  this->discontinuous_value (p, time, buffer);
197  std::map<const Elem *, Number> return_value;
198  for (std::map<const Elem *, DenseVector<Number> >::const_iterator it = buffer.begin(); it != buffer.end(); ++it)
199  return_value[it->first] = it->second(0);
200  // NOTE: If no suitable element is found, then the map return_value is empty. This
201  // puts burden on the user of this function but I don't really see a better way.
202  return return_value;
203 }
libmesh_assert(j)
std::map< const Elem *, Number > discontinuous_value(const Point &p, const Real time=0.)
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.

Definition at line 326 of file mesh_function.C.

References discontinuous_value(), and libmesh_nullptr.

329 {
330  this->discontinuous_value (p, time, output, libmesh_nullptr);
331 }
const class libmesh_nullptr_t libmesh_nullptr
std::map< const Elem *, Number > discontinuous_value(const Point &p, const Real time=0.)
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.

Build an FEComputeData that contains both input and output data for the specific compute_data method.

Definition at line 335 of file mesh_function.C.

References _dof_map, _eqn_systems, _system_vars, _vector, libMesh::FEInterface::compute_data(), data, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), find_elements(), libMesh::FunctionBase< Number >::initialized(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::FEComputeData::shape, and libMesh::DofMap::variable_type().

339 {
340  libmesh_assert (this->initialized());
341 
342  // clear the output map
343  output.clear();
344 
345  // get the candidate elements
346  std::set<const Elem *> candidate_element = this->find_elements(p,subdomain_ids);
347 
348  // loop through all candidates, if the set is empty this function will return an
349  // empty map
350  for (std::set<const Elem *>::const_iterator it = candidate_element.begin(); it != candidate_element.end(); ++it)
351  {
352  const Elem * element = (*it);
353 
354  const unsigned int dim = element->dim();
355 
356  // define a temporary vector to store all values
357  DenseVector<Number> temp_output (cast_int<unsigned int>(this->_system_vars.size()));
358 
359  /*
360  * Get local coordinates to feed these into compute_data().
361  * Note that the fe_type can safely be used from the 0-variable,
362  * since the inverse mapping is the same for all FEFamilies
363  */
364  const Point mapped_point (FEInterface::inverse_map (dim,
365  this->_dof_map.variable_type(0),
366  element,
367  p));
368 
369 
370  // loop over all vars
371  for (std::size_t index=0; index < this->_system_vars.size(); index++)
372  {
373  /*
374  * the data for this variable
375  */
376  const unsigned int var = _system_vars[index];
377  const FEType & fe_type = this->_dof_map.variable_type(var);
378 
383  {
384  FEComputeData data (this->_eqn_systems, mapped_point);
385 
386  FEInterface::compute_data (dim, fe_type, element, data);
387 
388  // where the solution values for the var-th variable are stored
389  std::vector<dof_id_type> dof_indices;
390  this->_dof_map.dof_indices (element, dof_indices, var);
391 
392  // interpolate the solution
393  {
394  Number value = 0.;
395 
396  for (std::size_t i=0; i<dof_indices.size(); i++)
397  value += this->_vector(dof_indices[i]) * data.shape[i];
398 
399  temp_output(index) = value;
400  }
401 
402  }
403 
404  // next variable
405  }
406 
407  // Insert temp_output into output
408  output[element] = temp_output;
409  }
410 }
const EquationSystems & _eqn_systems
const NumericVector< Number > & _vector
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
const DofMap & _dof_map
libmesh_assert(j)
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Definition: fe_interface.C:808
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
std::set< const Elem * > find_elements(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
IterBase * data
const std::vector< unsigned int > _system_vars
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2022
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.

Definition at line 737 of file mesh_function.C.

References _out_of_mesh_mode, _out_of_mesh_value, _point_locator, libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by enable_out_of_mesh_mode(), and init().

738 {
739  libmesh_assert (this->initialized());
741  _out_of_mesh_mode = true;
742  _out_of_mesh_value = value;
743 }
PointLocatorBase * _point_locator
libmesh_assert(j)
DenseVector< Number > _out_of_mesh_value
virtual void enable_out_of_mesh_mode()=0
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.

Definition at line 745 of file mesh_function.C.

References enable_out_of_mesh_mode().

746 {
747  DenseVector<Number> v(1);
748  v(0) = value;
749  this->enable_out_of_mesh_mode(v);
750 }
void enable_out_of_mesh_mode(const DenseVector< Number > &value)
const Elem * libMesh::MeshFunction::find_element ( const Point p,
const std::set< subdomain_id_type > *  subdomain_ids = libmesh_nullptr 
) const
protected

Helper function to reduce code duplication

Definition at line 627 of file mesh_function.C.

References libMesh::FunctionBase< Number >::_master, _out_of_mesh_mode, _point_locator, _vector, end, libMesh::Elem::find_point_neighbors(), libmesh_nullptr, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::SERIAL, and libMesh::NumericVector< T >::type().

Referenced by gradient(), hessian(), init(), and operator()().

629 {
630  /* Ensure that in the case of a master mesh function, the
631  out-of-mesh mode is enabled either for both or for none. This is
632  important because the out-of-mesh mode is also communicated to
633  the point locator. Since this is time consuming, enable it only
634  in debug mode. */
635 #ifdef DEBUG
636  if (this->_master != libmesh_nullptr)
637  {
638  const MeshFunction * master =
639  cast_ptr<const MeshFunction *>(this->_master);
640  if(_out_of_mesh_mode!=master->_out_of_mesh_mode)
641  libmesh_error_msg("ERROR: If you use out-of-mesh-mode in connection with master mesh " \
642  << "functions, you must enable out-of-mesh mode for both the master and the slave mesh function.");
643  }
644 #endif
645 
646  // locate the point in the other mesh
647  const Elem * element = this->_point_locator->operator()(p,subdomain_ids);
648 
649  // If we have an element, but it's not a local element, then we
650  // either need to have a serialized vector or we need to find a
651  // local element sharing the same point.
652  if (element &&
653  (element->processor_id() != this->processor_id()) &&
654  _vector.type() != SERIAL)
655  {
656  // look for a local element containing the point
657  std::set<const Elem *> point_neighbors;
658  element->find_point_neighbors(p, point_neighbors);
659  element = libmesh_nullptr;
660  std::set<const Elem *>::const_iterator it = point_neighbors.begin();
661  const std::set<const Elem *>::const_iterator end = point_neighbors.end();
662  for (; it != end; ++it)
663  {
664  const Elem * elem = *it;
665  if (elem->processor_id() == this->processor_id())
666  {
667  element = elem;
668  break;
669  }
670  }
671  }
672 
673  return element;
674 }
const NumericVector< Number > & _vector
PointLocatorBase * _point_locator
const FunctionBase * _master
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
ParallelType type() const
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)
Definition: mesh_function.C:43
processor_id_type processor_id() const
std::set< const Elem * > libMesh::MeshFunction::find_elements ( const Point p,
const std::set< subdomain_id_type > *  subdomain_ids = libmesh_nullptr 
) const
protected

Similar to find_element but returns all elements that are close to a point to cover cases where p is on the boundary

Definition at line 676 of file mesh_function.C.

References libMesh::FunctionBase< Number >::_master, _out_of_mesh_mode, _point_locator, _vector, end, libMesh::Elem::find_point_neighbors(), libmesh_nullptr, libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::SERIAL, and libMesh::NumericVector< T >::type().

Referenced by discontinuous_gradient(), discontinuous_value(), and init().

678 {
679  /* Ensure that in the case of a master mesh function, the
680  out-of-mesh mode is enabled either for both or for none. This is
681  important because the out-of-mesh mode is also communicated to
682  the point locator. Since this is time consuming, enable it only
683  in debug mode. */
684 #ifdef DEBUG
685  if (this->_master != libmesh_nullptr)
686  {
687  const MeshFunction * master =
688  cast_ptr<const MeshFunction *>(this->_master);
689  if(_out_of_mesh_mode!=master->_out_of_mesh_mode)
690  libmesh_error_msg("ERROR: If you use out-of-mesh-mode in connection with master mesh " \
691  << "functions, you must enable out-of-mesh mode for both the master and the slave mesh function.");
692  }
693 #endif
694 
695  // locate the point in the other mesh
696  std::set<const Elem *> candidate_elements;
697  std::set<const Elem *> final_candidate_elements;
698  this->_point_locator->operator()(p,candidate_elements,subdomain_ids);
699  for (std::set<const Elem *>::const_iterator elem_it = candidate_elements.begin(); elem_it != candidate_elements.end(); ++elem_it)
700  {
701  const Elem * element = (*elem_it);
702  // If we have an element, but it's not a local element, then we
703  // either need to have a serialized vector or we need to find a
704  // local element sharing the same point.
705  if (element &&
706  (element->processor_id() != this->processor_id()) &&
707  _vector.type() != SERIAL)
708  {
709  // look for a local element containing the point
710  std::set<const Elem *> point_neighbors;
711  element->find_point_neighbors(p, point_neighbors);
712  std::set<const Elem *>::const_iterator it = point_neighbors.begin();
713  const std::set<const Elem *>::const_iterator end = point_neighbors.end();
714  for (; it != end; ++it)
715  {
716  const Elem * elem = *it;
717  if (elem->processor_id() == this->processor_id())
718  {
719  final_candidate_elements.insert(elem);
720  break;
721  }
722  }
723  }
724  else
725  final_candidate_elements.insert(element);
726  }
727 
728  return final_candidate_elements;
729 }
const NumericVector< Number > & _vector
PointLocatorBase * _point_locator
const FunctionBase * _master
const class libmesh_nullptr_t libmesh_nullptr
IterBase * end
ParallelType type() const
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)
Definition: mesh_function.C:43
processor_id_type processor_id() const
const PointLocatorBase & libMesh::MeshFunction::get_point_locator ( void  ) const

Returns the current PointLocator object, for you might want to use it elsewhere. The MeshFunction object must be initialized before.

Definition at line 731 of file mesh_function.C.

References _point_locator, libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by init().

732 {
733  libmesh_assert (this->initialized());
734  return *_point_locator;
735 }
PointLocatorBase * _point_locator
libmesh_assert(j)
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.

Definition at line 205 of file mesh_function.C.

References libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by libMesh::ExactErrorEstimator::find_squared_element_error(), and init().

207 {
208  libmesh_assert (this->initialized());
209 
210  std::vector<Gradient> buf (1);
211  this->gradient(p, time, buf);
212  return buf[0];
213 }
Gradient gradient(const Point &p, const Real time=0.)
libmesh_assert(j)
void libMesh::MeshFunction::gradient ( const Point p,
const Real  time,
std::vector< Gradient > &  output,
const std::set< subdomain_id_type > *  subdomain_ids = libmesh_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.

Definition at line 414 of file mesh_function.C.

References _dof_map, _system_vars, libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), find_element(), libMesh::FunctionBase< Number >::initialized(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

418 {
419  libmesh_assert (this->initialized());
420 
421  const Elem * element = this->find_element(p,subdomain_ids);
422 
423  if (!element)
424  {
425  output.resize(0);
426  }
427  else
428  {
429  // resize the output vector to the number of output values
430  // that the user told us
431  output.resize (this->_system_vars.size());
432 
433 
434  {
435  const unsigned int dim = element->dim();
436 
437 
438  /*
439  * Get local coordinates to feed these into compute_data().
440  * Note that the fe_type can safely be used from the 0-variable,
441  * since the inverse mapping is the same for all FEFamilies
442  */
443  const Point mapped_point (FEInterface::inverse_map (dim,
444  this->_dof_map.variable_type(0),
445  element,
446  p));
447 
448  std::vector<Point> point_list (1, mapped_point);
449 
450  // loop over all vars
451  for (std::size_t index=0; index < this->_system_vars.size(); index++)
452  {
453  /*
454  * the data for this variable
455  */
456  const unsigned int var = _system_vars[index];
457  const FEType & fe_type = this->_dof_map.variable_type(var);
458 
459  UniquePtr<FEBase> point_fe (FEBase::build(dim, fe_type));
460  const std::vector<std::vector<RealGradient> > & dphi = point_fe->get_dphi();
461  point_fe->reinit(element, &point_list);
462 
463  // where the solution values for the var-th variable are stored
464  std::vector<dof_id_type> dof_indices;
465  this->_dof_map.dof_indices (element, dof_indices, var);
466 
467  // interpolate the solution
468  Gradient grad(0.);
469 
470  for (std::size_t i=0; i<dof_indices.size(); i++)
471  grad.add_scaled(dphi[i][0], this->_vector(dof_indices[i]));
472 
473  output[index] = grad;
474  }
475  }
476  }
477 }
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
const DofMap & _dof_map
libmesh_assert(j)
NumberVectorValue Gradient
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
const std::vector< unsigned int > _system_vars
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2022
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
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.

Definition at line 231 of file mesh_function.C.

References libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by libMesh::ExactErrorEstimator::find_squared_element_error(), and init().

233 {
234  libmesh_assert (this->initialized());
235 
236  std::vector<Tensor> buf (1);
237  this->hessian(p, time, buf);
238  return buf[0];
239 }
libmesh_assert(j)
Tensor hessian(const Point &p, const Real time=0.)
void libMesh::MeshFunction::hessian ( const Point p,
const Real  time,
std::vector< Tensor > &  output,
const std::set< subdomain_id_type > *  subdomain_ids = libmesh_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.

Definition at line 560 of file mesh_function.C.

References _dof_map, _system_vars, libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), find_element(), libMesh::FunctionBase< Number >::initialized(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

564 {
565  libmesh_assert (this->initialized());
566 
567  const Elem * element = this->find_element(p,subdomain_ids);
568 
569  if (!element)
570  {
571  output.resize(0);
572  }
573  else
574  {
575  // resize the output vector to the number of output values
576  // that the user told us
577  output.resize (this->_system_vars.size());
578 
579 
580  {
581  const unsigned int dim = element->dim();
582 
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  */
589  const Point mapped_point (FEInterface::inverse_map (dim,
590  this->_dof_map.variable_type(0),
591  element,
592  p));
593 
594  std::vector<Point> point_list (1, mapped_point);
595 
596  // loop over all vars
597  for (std::size_t index=0; index < this->_system_vars.size(); index++)
598  {
599  /*
600  * the data for this variable
601  */
602  const unsigned int var = _system_vars[index];
603  const FEType & fe_type = this->_dof_map.variable_type(var);
604 
605  UniquePtr<FEBase> point_fe (FEBase::build(dim, fe_type));
606  const std::vector<std::vector<RealTensor> > & d2phi =
607  point_fe->get_d2phi();
608  point_fe->reinit(element, &point_list);
609 
610  // where the solution values for the var-th variable are stored
611  std::vector<dof_id_type> dof_indices;
612  this->_dof_map.dof_indices (element, dof_indices, var);
613 
614  // interpolate the solution
615  Tensor hess;
616 
617  for (std::size_t i=0; i<dof_indices.size(); i++)
618  hess.add_scaled(d2phi[i][0], this->_vector(dof_indices[i]));
619 
620  output[index] = hess;
621  }
622  }
623  }
624 }
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
void add_scaled(const TypeTensor< T2 > &, const T)
Definition: type_tensor.h:744
const DofMap & _dof_map
libmesh_assert(j)
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
NumberTensorValue Tensor
const std::vector< unsigned int > _system_vars
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2022
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
virtual void libMesh::MeshFunction::init ( )
inlinevirtual

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 96 of file mesh_function.h.

References clear(), clone(), disable_out_of_mesh_mode(), discontinuous_gradient(), discontinuous_value(), enable_out_of_mesh_mode(), find_element(), find_elements(), get_point_locator(), gradient(), hessian(), init(), libmesh_nullptr, libMesh::Trees::NODES, operator()(), libMesh::Real, set_point_locator_tolerance(), and unset_point_locator_tolerance().

Referenced by init().

96 { this->init(Trees::NODES); }
virtual void init() libmesh_override
Definition: mesh_function.h:96
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

Definition at line 98 of file mesh_function.C.

References _eqn_systems, libMesh::FunctionBase< Number >::_initialized, libMesh::FunctionBase< Number >::_master, _point_locator, _system_vars, libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), libmesh_nullptr, mesh, and libMesh::MeshBase::sub_point_locator().

99 {
100  // are indices of the desired variable(s) provided?
101  libmesh_assert_greater (this->_system_vars.size(), 0);
102 
103  // Don't do twice...
104  if (this->_initialized)
105  {
107  return;
108  }
109 
110  /*
111  * set up the PointLocator: either someone else
112  * is the master (go and get the address of his
113  * point locator) or this object is the master
114  * (build the point locator on our own).
115  */
116  if (this->_master != libmesh_nullptr)
117  {
118  // we aren't the master
119  const MeshFunction * master =
120  cast_ptr<const MeshFunction *>(this->_master);
121 
122  if (master->_point_locator == libmesh_nullptr)
123  libmesh_error_msg("ERROR: When the master-servant concept is used, the master has to be initialized first!");
124 
125  else
126  {
127  this->_point_locator = master->_point_locator;
128  }
129  }
130  else
131  {
132  // we are the master: build the point locator
133 
134  // constant reference to the other mesh
135  const MeshBase & mesh = this->_eqn_systems.get_mesh();
136 
137  // build the point locator. Only \p TREE version available
138  //UniquePtr<PointLocatorBase> ap (PointLocatorBase::build (TREE, mesh));
139  //this->_point_locator = ap.release();
140  // this->_point_locator = new PointLocatorTree (mesh, point_locator_build_type);
141  this->_point_locator = mesh.sub_point_locator().release();
142 
143  // Point locator no longer needs to be initialized.
144  // this->_point_locator->init();
145  }
146 
147 
148  // ready for use
149  this->_initialized = true;
150 }
const EquationSystems & _eqn_systems
PointLocatorBase * _point_locator
MeshBase & mesh
const FunctionBase * _master
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
const MeshBase & get_mesh() const
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)
Definition: mesh_function.C:43
const std::vector< unsigned int > _system_vars
bool libMesh::FunctionBase< Number >::initialized ( ) const
inherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Referenced by clone(), disable_out_of_mesh_mode(), discontinuous_gradient(), discontinuous_value(), enable_out_of_mesh_mode(), get_point_locator(), gradient(), hessian(), and operator()().

bool libMesh::FunctionBase< Number >::is_time_dependent ( ) const
inherited
Returns
true when the function this object represents is actually time-dependent, false otherwise.
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
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::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::MeshTools::processor_bounding_box(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:679
const Parallel::Communicator & _communicator
void libMesh::FunctionBase< Number >::operator() ( const Point p,
DenseVector< Number > &  output 
)
inherited

Return function for vectors. Returns in output the values of the data at the coordinate p.

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

Implements libMesh::FunctionBase< Number >.

Definition at line 180 of file mesh_function.C.

References libMesh::FunctionBase< Number >::initialized(), and libMesh::libmesh_assert().

Referenced by init(), and operator()().

182 {
183  libmesh_assert (this->initialized());
184 
185  DenseVector<Number> buf (1);
186  this->operator() (p, time, buf);
187  return buf(0);
188 }
Number operator()(const Point &p, const Real time=0.) libmesh_override
libmesh_assert(j)
void libMesh::MeshFunction::operator() ( const Point p,
const Real  time,
DenseVector< Number > &  output 
)
virtual

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 >.

Definition at line 242 of file mesh_function.C.

References libmesh_nullptr, and operator()().

245 {
246  this->operator() (p, time, output, libmesh_nullptr);
247 }
const class libmesh_nullptr_t libmesh_nullptr
Number operator()(const Point &p, const Real time=0.) libmesh_override
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.

Build an FEComputeData that contains both input and output data for the specific compute_data method.

Definition at line 249 of file mesh_function.C.

References _dof_map, _eqn_systems, _out_of_mesh_value, _system_vars, _vector, libMesh::FEInterface::compute_data(), data, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), find_element(), libMesh::FunctionBase< Number >::initialized(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::DenseVector< T >::resize(), libMesh::FEComputeData::shape, and libMesh::DofMap::variable_type().

253 {
254  libmesh_assert (this->initialized());
255 
256  const Elem * element = this->find_element(p,subdomain_ids);
257 
258  if (!element)
259  {
260  output = _out_of_mesh_value;
261  }
262  else
263  {
264  // resize the output vector to the number of output values
265  // that the user told us
266  output.resize (cast_int<unsigned int>
267  (this->_system_vars.size()));
268 
269 
270  {
271  const unsigned int dim = element->dim();
272 
273 
274  /*
275  * Get local coordinates to feed these into compute_data().
276  * Note that the fe_type can safely be used from the 0-variable,
277  * since the inverse mapping is the same for all FEFamilies
278  */
279  const Point mapped_point (FEInterface::inverse_map (dim,
280  this->_dof_map.variable_type(0),
281  element,
282  p));
283 
284 
285  // loop over all vars
286  for (std::size_t index=0; index < this->_system_vars.size(); index++)
287  {
288  /*
289  * the data for this variable
290  */
291  const unsigned int var = _system_vars[index];
292  const FEType & fe_type = this->_dof_map.variable_type(var);
293 
298  {
299  FEComputeData data (this->_eqn_systems, mapped_point);
300 
301  FEInterface::compute_data (dim, fe_type, element, data);
302 
303  // where the solution values for the var-th variable are stored
304  std::vector<dof_id_type> dof_indices;
305  this->_dof_map.dof_indices (element, dof_indices, var);
306 
307  // interpolate the solution
308  {
309  Number value = 0.;
310 
311  for (std::size_t i=0; i<dof_indices.size(); i++)
312  value += this->_vector(dof_indices[i]) * data.shape[i];
313 
314  output(index) = value;
315  }
316 
317  }
318 
319  // next variable
320  }
321  }
322  }
323 }
const Elem * find_element(const Point &p, const std::set< subdomain_id_type > *subdomain_ids=libmesh_nullptr) const
const EquationSystems & _eqn_systems
const NumericVector< Number > & _vector
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
const DofMap & _dof_map
void resize(const unsigned int n)
Definition: dense_vector.h:338
libmesh_assert(j)
DenseVector< Number > _out_of_mesh_value
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Definition: fe_interface.C:808
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:556
IterBase * data
const std::vector< unsigned int > _system_vars
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2022
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 99 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), find_element(), find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:677
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.

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).

Definition at line 759 of file mesh_function.C.

References _point_locator, and libMesh::PointLocatorBase::set_close_to_point_tol().

Referenced by init().

760 {
762 }
virtual void set_close_to_point_tol(Real close_to_point_tol)
PointLocatorBase * _point_locator
void libMesh::MeshFunction::unset_point_locator_tolerance ( )

Turn off the user-specified PointLocator tolerance.

Definition at line 764 of file mesh_function.C.

References _point_locator, and libMesh::PointLocatorBase::unset_close_to_point_tol().

Referenced by init().

765 {
767 }
PointLocatorBase * _point_locator
virtual void unset_close_to_point_tol()

Member Data Documentation

const DofMap& libMesh::MeshFunction::_dof_map
protected

Need access to the DofMap of the other system.

Definition at line 318 of file mesh_function.h.

Referenced by clone(), discontinuous_gradient(), discontinuous_value(), gradient(), hessian(), and operator()().

const EquationSystems& libMesh::MeshFunction::_eqn_systems
protected

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

Definition at line 307 of file mesh_function.h.

Referenced by clone(), discontinuous_value(), init(), and operator()().

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 178 of file function_base.h.

Referenced by clear(), and init().

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

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

Definition at line 183 of file function_base.h.

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

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

Definition at line 172 of file function_base.h.

Referenced by clear(), find_element(), find_elements(), init(), and ~MeshFunction().

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 336 of file mesh_function.h.

Referenced by disable_out_of_mesh_mode(), enable_out_of_mesh_mode(), find_element(), and find_elements().

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 342 of file mesh_function.h.

Referenced by enable_out_of_mesh_mode(), and operator()().

PointLocatorBase* libMesh::MeshFunction::_point_locator
protected
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 324 of file mesh_function.h.

Referenced by clone(), discontinuous_gradient(), discontinuous_value(), gradient(), hessian(), init(), and operator()().

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

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

Definition at line 313 of file mesh_function.h.

Referenced by clone(), discontinuous_value(), find_element(), find_elements(), and operator()().


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