libMesh::PointLocatorBase Class Referenceabstract

#include <point_locator_base.h>

Inheritance diagram for libMesh::PointLocatorBase:

Public Member Functions

virtual ~PointLocatorBase ()
 
virtual void clear ()=0
 
virtual void init ()=0
 
virtual const Elemoperator() (const Point &p) const =0
 
bool initialized () const
 
virtual void enable_out_of_mesh_mode (void)=0
 
virtual void disable_out_of_mesh_mode (void)=0
 

Static Public Member Functions

static AutoPtr< PointLocatorBasebuild (const PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=NULL)
 
static std::string get_info ()
 
static void print_info (std::ostream &out=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Protected Types

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts
 

Protected Member Functions

 PointLocatorBase (const MeshBase &mesh, const PointLocatorBase *master)
 
void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

const PointLocatorBase_master
 
const MeshBase_mesh
 
bool _initialized
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic
< unsigned int > 
_n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 

Detailed Description

This is the base class for point locators. They locate points in space: given a mesh they return the element and local coordinates for a given point in global coordinates.

Author
Daniel Dreyer, 2003

Definition at line 57 of file point_locator_base.h.

Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information. The log is identified by the class name.

Definition at line 113 of file reference_counter.h.

Constructor & Destructor Documentation

libMesh::PointLocatorBase::PointLocatorBase ( const MeshBase mesh,
const PointLocatorBase master 
)
protected

Constructor. Protected so that this base class cannot be explicitly instantiated. Takes a master PointLocator that helps in saving memory.

Definition at line 36 of file point_locator_base.C.

37  :
38  _master (master),
39  _mesh (mesh),
40  _initialized (false)
41 {
42 }
libMesh::PointLocatorBase::~PointLocatorBase ( )
virtual

Destructor.

Definition at line 48 of file point_locator_base.C.

49 {
50 }

Member Function Documentation

AutoPtr< PointLocatorBase > libMesh::PointLocatorBase::build ( const PointLocatorType  t,
const MeshBase mesh,
const PointLocatorBase master = NULL 
)
static

Builds an PointLocator for the mesh mesh. Optionally takes a master PointLocator to save memory. An AutoPtr<PointLocatorBase> is returned to prevent memory leak. This way the user need not remember to delete the object.

Definition at line 56 of file point_locator_base.C.

References libMesh::err, libMeshEnums::LIST, and libMeshEnums::TREE.

Referenced by libMesh::MeshBase::point_locator(), and libMesh::MeshBase::sub_point_locator().

59 {
60  switch (t)
61  {
62  case TREE:
63  {
64  AutoPtr<PointLocatorBase> ap(new PointLocatorTree(mesh,
65  master));
66  return ap;
67  }
68 
69  case LIST:
70  {
71  AutoPtr<PointLocatorBase> ap(new PointLocatorList(mesh,
72  master));
73  return ap;
74  }
75 
76  default:
77  {
78  libMesh::err << "ERROR: Bad PointLocatorType = " << t << std::endl;
79  libmesh_error();
80  }
81  }
82 
83  libmesh_error();
84  AutoPtr<PointLocatorBase> ap(NULL);
85  return ap;
86 }
virtual void libMesh::PointLocatorBase::clear ( )
pure virtual

Clears the PointLocator.

Implemented in libMesh::PointLocatorList, and libMesh::PointLocatorTree.

virtual void libMesh::PointLocatorBase::disable_out_of_mesh_mode ( void  )
pure virtual

Disables out-of-mesh mode (default). If asked to find a point that is contained in no mesh at all, the point locator will now crash.

Implemented in libMesh::PointLocatorTree, and libMesh::PointLocatorList.

Referenced by libMesh::MeshFunction::disable_out_of_mesh_mode().

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
virtual void libMesh::PointLocatorBase::enable_out_of_mesh_mode ( void  )
pure virtual

Enables out-of-mesh mode. In this mode, if asked to find a point that is contained in no mesh at all, the point locator will return a NULL pointer instead of crashing. Per default, this mode is off.

Implemented in libMesh::PointLocatorTree, and libMesh::PointLocatorList.

Referenced by libMesh::MeshFunction::enable_out_of_mesh_mode(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), and libMesh::System::point_value().

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.

Definition at line 163 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectedinherited

Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.

Definition at line 176 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
virtual void libMesh::PointLocatorBase::init ( )
pure virtual

Initializes the point locator, so that the operator() methods can be used. Pure virtual.

Implemented in libMesh::PointLocatorTree, and libMesh::PointLocatorList.

bool libMesh::PointLocatorBase::initialized ( ) const
inline
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 150 of file point_locator_base.h.

References _initialized.

Referenced by libMesh::PointLocatorTree::init(), and libMesh::PointLocatorList::init().

151 {
152  return (this->_initialized);
153 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
virtual const Elem* libMesh::PointLocatorBase::operator() ( const Point p) const
pure virtual

Locates the element in which the point with global coordinates p is located. Pure virtual.

Implemented in libMesh::PointLocatorTree, and libMesh::PointLocatorList.

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

89 {
91 }

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

bool libMesh::PointLocatorBase::_initialized
protected

true when properly initialized, false otherwise.

Definition at line 142 of file point_locator_base.h.

Referenced by libMesh::PointLocatorTree::init(), libMesh::PointLocatorList::init(), and initialized().

const PointLocatorBase* libMesh::PointLocatorBase::_master
protected

Const pointer to our master, initialized to NULL if none given. When using multiple PointLocators, one can be assigned master and be in charge of something that all can have access to.

Definition at line 132 of file point_locator_base.h.

Referenced by libMesh::PointLocatorList::clear(), libMesh::PointLocatorTree::clear(), libMesh::PointLocatorTree::init(), and libMesh::PointLocatorList::init().

const MeshBase& libMesh::PointLocatorBase::_mesh
protected

constant reference to the mesh in which the point is looked for.

Definition at line 137 of file point_locator_base.h.

Referenced by libMesh::PointLocatorTree::init(), and libMesh::PointLocatorList::init().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:01 UTC

Hosted By:
SourceForge.net Logo