21 #include "libmesh/elem.h" 22 #include "libmesh/libmesh_logging.h" 23 #include "libmesh/location_maps.h" 24 #include "libmesh/mesh_base.h" 25 #include "libmesh/node.h" 26 #include "libmesh/parallel.h" 37 const unsigned int chunkmax = 1024;
38 const Real chunkfloat = 1024.0;
54 LOG_SCOPE(
"init()",
"LocationMap");
61 _lower_bound.resize(LIBMESH_DIM, std::numeric_limits<Real>::max());
63 _upper_bound.resize(LIBMESH_DIM, -std::numeric_limits<Real>::max());
65 for (
auto & node :
mesh.node_ptr_range())
66 for (
unsigned int i=0; i != LIBMESH_DIM; ++i)
69 _lower_bound[i] = std::min(_lower_bound[i],
71 _upper_bound[i] = std::max(_upper_bound[i],
90 this->_map.emplace(this->key(this->point_of(t)), &t);
111 template <
typename T>
115 LOG_SCOPE(
"find()",
"LocationMap");
118 unsigned int pointkey = this->key(p);
121 for (
const auto & pr :
as_range(_map.equal_range(pointkey)))
126 for (
int xoffset = -1; xoffset != 2; ++xoffset)
128 for (
int yoffset = -1; yoffset != 2; ++yoffset)
130 for (
int zoffset = -1; zoffset != 2; ++zoffset)
132 auto key_pos = _map.equal_range(pointkey +
133 xoffset*chunkmax*chunkmax +
136 for (
const auto & pr :
as_range(key_pos))
148 template <
typename T>
151 Real xscaled = 0., yscaled = 0., zscaled = 0.;
153 Real deltax = _upper_bound[0] - _lower_bound[0];
156 xscaled = (p(0) - _lower_bound[0])/deltax;
160 Real deltay = _upper_bound[1] - _lower_bound[1];
163 yscaled = (p(1) - _lower_bound[1])/deltay;
168 Real deltaz = _upper_bound[2] - _lower_bound[2];
171 zscaled = (p(2) - _lower_bound[2])/deltaz;
174 unsigned int n0 =
static_cast<unsigned int> (chunkfloat * xscaled),
175 n1 = static_cast<unsigned int> (chunkfloat * yscaled),
176 n2 =
static_cast<unsigned int> (chunkfloat * zscaled);
178 return chunkmax*chunkmax*n0 + chunkmax*n1 + n2;
187 for (
auto & node :
mesh.node_ptr_range())
197 for (
auto & elem :
mesh.active_element_ptr_range())
T * find(const Point &, const Real tol=TOLERANCE)
A Node is like a Point, but with more information.
static constexpr Real TOLERANCE
This is the base class from which all geometric element types are derived.
const Parallel::Communicator & comm() const
Point point_of(const T &) const
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
virtual bool is_serial() const
void min(const T &r, T &o, Request &req) const
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Data structures that enable location-based lookups The key is a hash of the Point location...
unsigned int key(const Point &)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Point vertex_average() const