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/mesh_tools.h"
26#include "libmesh/node.h"
27#include "libmesh/parallel.h"
38const unsigned int chunkmax = 1024;
39const Real chunkfloat = 1024.0;
55 LOG_SCOPE(
"init()",
"LocationMap");
71 this->_map.emplace(this->key(this->point_of(t)), &t);
96 LOG_SCOPE(
"find()",
"LocationMap");
99 unsigned int pointkey = this->key(p);
102 for (
const auto & pr :
as_range(_map.equal_range(pointkey)))
107 for (
int xoffset = -1; xoffset != 2; ++xoffset)
109 for (
int yoffset = -1; yoffset != 2; ++yoffset)
111 for (
int zoffset = -1; zoffset != 2; ++zoffset)
113 auto key_pos = _map.equal_range(pointkey +
114 xoffset*chunkmax*chunkmax +
117 for (
const auto & pr :
as_range(key_pos))
132 Real xscaled = 0., yscaled = 0., zscaled = 0.;
134 const Real deltax = _bbox.max()(0) - _bbox.min()(0);
137 xscaled = (p(0) - _bbox.min()(0))/deltax;
141 const Real deltay = _bbox.max()(1) - _bbox.min()(1);
144 yscaled = (p(1) - _bbox.min()(1))/deltay;
149 const Real deltaz = _bbox.max()(2) - _bbox.min()(2);
152 zscaled = (p(2) - _bbox.min()(2))/deltaz;
155 unsigned int n0 =
static_cast<unsigned int> (chunkfloat * xscaled),
156 n1 =
static_cast<unsigned int> (chunkfloat * yscaled),
157 n2 =
static_cast<unsigned int> (chunkfloat * zscaled);
159 return chunkmax*chunkmax*n0 + chunkmax*n1 + n2;
168 for (
auto & node :
mesh.node_ptr_range())
178 for (
auto & elem :
mesh.active_element_ptr_range())
This is the base class from which all geometric element types are derived.
Point vertex_average() const
Data structures that enable location-based lookups The key is a hash of the Point location.
Point point_of(const T &) const
T * find(const Point &, const Real tol=TOLERANCE)
unsigned int key(const Point &)
This is the MeshBase class.
virtual bool is_serial() const
A Node is like a Point, but with more information.
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real