24 #include "libmesh/libmesh_common.h" 25 #include "libmesh/reference_counted_object.h" 26 #include "libmesh/parallel_object.h" 27 #include "libmesh/mesh.h" 28 #ifdef LIBMESH_HAVE_NANOFLANN 29 # include "libmesh/nanoflann.hpp" 51 template <
unsigned int KDDim>
59 template <
unsigned int KDDim>
60 class PointMesh :
public ReferenceCountedObject<PointMesh<KDDim> >,
65 #ifdef LIBMESH_HAVE_NANOFLANN 74 template <
unsigned int PLDim>
75 class PointListAdaptor
80 const std::vector<PointParticle*> &_pts;
84 PointListAdaptor (
const std::vector<PointParticle*> &
particles)
92 typedef std::size_t size_t;
97 inline size_t kdtree_get_point_count()
const {
return _pts.size(); }
103 inline coord_t kdtree_distance(
const coord_t *p1,
const size_t idx_p2,
size_t size)
const 105 libmesh_assert_equal_to (size, PLDim);
106 libmesh_assert_less (idx_p2, _pts.size());
109 const Point &p2( _pts[idx_p2]->point() );
115 const coord_t d0=p1[0] - p2(0);
116 const coord_t d1=p1[1] - p2(1);
117 const coord_t d2=p1[2] - p2(2);
118 return d0*d0 + d1*d1 + d2*d2;
123 const coord_t d0=p1[0] - p2(0);
124 const coord_t d1=p1[1] - p2(1);
125 return d0*d0 + d1*d1;
130 const coord_t d0=p1[0] - p2(0);
134 libmesh_error_msg(
"ERROR: unknown size " << size);
145 inline coord_t kdtree_get_pt(
const size_t idx,
int dim)
const 147 libmesh_assert_less (dim, (
int) PLDim);
148 libmesh_assert_less (idx, _pts.size());
149 libmesh_assert_less (dim, 3);
151 const Point &p(_pts[idx]->point() );
152 if (dim==0)
return p(0);
153 if (dim==1)
return p(1);
163 template <
class BBOX>
164 bool kdtree_get_bbox(BBOX & )
const {
return false; }
169 typedef nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<Real,PointListAdaptor<KDDim> >,
170 PointListAdaptor<KDDim>,
177 mutable UniquePtr<kd_tree_t> _kd_tree;
179 #endif // LIBMESH_HAVE_NANOFLANN 196 const Real& search_radius_p,
197 const Real& search_radius_e);
206 std::vector<PolymerChain>& polymer_chains,
207 const Real& search_radius_p,
208 const Real& search_radius_e);
217 const Real& search_radius_p,
218 const Real& search_radius_e);
252 std::vector<PointParticle*>
particles()
const {
return _particles; }
267 std::size_t
num_chains()
const{
return _polymer_chain -> n_chains(); }
272 std::size_t
num_bonds()
const {
return _polymer_chain->n_bonds(); }
287 {
return _elem_neighbor_list; }
296 const std::size_t elem_id = elem->id();
297 return _elem_neighbor_list[elem_id];
308 const std::size_t elem_id = elem->id();
309 return _local_elem_neighbor_list[elem_id];
331 std::vector<std::pair<std::size_t,Real> >& IndicesDists);
367 const bool is_sorted,
368 std::vector<std::size_t>& n_list);
388 void reinit(
const bool& with_hi,
389 bool& neighbor_list_update_flag);
425 _search_radius_p = rp;
426 _search_radius_e = re;
440 { _periodic_boundary = &_periodic_bdry; }
447 {
return _periodic_boundary; }
485 Real _search_radius_p;
488 Real _search_radius_e;
491 std::vector<PointParticle*> _particles;
494 std::vector<RigidParticle*> _rigid_particles;
497 std::size_t _num_point_particles;
500 std::size_t _num_rigid_particles;
507 PointListAdaptor<KDDim> _point_list_adaptor;
515 std::map<const std::size_t, std::vector<std::size_t> > _elem_neighbor_list;
516 std::map<const std::size_t, std::vector<std::size_t> > _local_elem_neighbor_list;
522 std::vector<Real> _velocity_magnitude;
525 Real _max_velocity_magnitude;
528 Real _min_velocity_magnitude;
virtual void reinit_neighbor_vector()
Definition: point_mesh.C:511
virtual void construct_kd_tree()
Definition: point_mesh.C:305
Definition: particle_mesh.h:76
void add_periodic_boundary(PMPeriodicBoundary &_periodic_bdry)
Definition: point_mesh.h:439
const Real & maximum_bead_velocity() const
Definition: point_mesh.h:466
PMPeriodicBoundary * pm_periodic_boundary()
Definition: point_mesh.h:446
const void write_initial_surface_node_pos() const
Definition: point_mesh.C:1070
PolymerChain * polymer_chain() const
Definition: point_mesh.h:258
virtual void build_particle_neighbor_list()
Definition: point_mesh.C:431
const std::vector< std::size_t > elem_neighbor_list(const Elem *elem)
Definition: point_mesh.h:294
virtual void build_particle_neighbor_list_naively()
Definition: point_mesh.C:462
std::size_t num_chains() const
Definition: point_mesh.h:267
Definition: brownian_system.h:58
Definition: pm_periodic_boundary.h:46
Real search_radius(const std::string &p_e) const
Definition: point_mesh.C:970
std::vector< PointParticle * > particles() const
Definition: point_mesh.h:252
void set_bead_velocity(const std::vector< Real > &vel)
Definition: point_mesh.C:1051
std::size_t num_bonds() const
Definition: point_mesh.h:272
std::size_t num_particles() const
Definition: point_mesh.h:264
Definition: polymer_chain.h:47
void update_particle_mesh(ParticleMesh< KDDim > *particle_mesh) const
Definition: point_mesh.C:918
void set_search_radius(const Real rp, const Real re)
Definition: point_mesh.h:423
const std::vector< std::size_t > local_elem_neighbor_list(const Elem *elem)
Definition: point_mesh.h:306
~PointMesh()
Definition: point_mesh.C:161
const Real & minimum_bead_velocity() const
Definition: point_mesh.h:471
virtual void build_elem_neighbor_list()
Definition: point_mesh.C:622
bool is_sorted() const
Definition: point_mesh.h:278
virtual void clear_kd_tree()
Definition: point_mesh.C:329
PointMesh(libMesh::ParticleMesh< KDDim > &particle_mesh, const Real &search_radius_p, const Real &search_radius_e)
Definition: point_mesh.C:47
void reinit(const bool &with_hi, bool &neighbor_list_update_flag)
Definition: point_mesh.C:830
Definition: point_particle.h:54
void print_elem_neighbor_list(std::ostream &out=libMesh::out) const
Definition: point_mesh.C:1016
const std::map< const std::size_t, std::vector< std::size_t > > & elem_neighbor_list() const
Definition: point_mesh.h:286
void print_point_info() const
Definition: point_mesh.C:989
Definition: particle_mesh.h:57