20 #ifndef LIBMESH_MESHFREE_INTERPOLATION_H 21 #define LIBMESH_MESHFREE_INTERPOLATION_H 29 #ifdef LIBMESH_HAVE_NANOFLANN 31 # include "libmesh/nanoflann.hpp" 92 friend std::ostream &
operator << (std::ostream & os,
105 {
return cast_int<unsigned int>(
_names.size()); }
135 virtual void add_field_data (
const std::vector<std::string> & field_names,
136 const std::vector<Point> & pts,
137 const std::vector<Number> & vals);
152 const std::vector<Point> & tgt_pts,
153 std::vector<Number> & tgt_vals)
const = 0;
179 template <
unsigned int KDDim>
184 #ifdef LIBMESH_HAVE_NANOFLANN 191 template <
unsigned int PLDim>
195 const std::vector<Point> &
_pts;
218 libmesh_assert_equal_to (size, PLDim);
219 libmesh_assert_less (idx_p2,
_pts.size());
227 const coord_t d0=p1[0] - p2(0);
228 const coord_t d1=p1[1] - p2(1);
229 const coord_t d2=p1[2] - p2(2);
231 return d0*d0 + d1*d1 + d2*d2;
236 const coord_t d0=p1[0] - p2(0);
237 const coord_t d1=p1[1] - p2(1);
239 return d0*d0 + d1*d1;
244 const coord_t d0=p1[0] - p2(0);
250 libmesh_error_msg(
"ERROR: unknown size " << size);
263 libmesh_assert_less (dim, (
int) PLDim);
264 libmesh_assert_less (
idx,
_pts.size());
265 libmesh_assert_less (dim, 3);
269 if (dim==0)
return p(0);
270 if (dim==1)
return p(1);
284 template <
class BBOX>
297 typedef nanoflann::KDTreeSingleIndexAdaptor<nanoflann::L2_Simple_Adaptor<Real, PointListAdaptor<KDDim>>,
302 #endif // LIBMESH_HAVE_NANOFLANN 314 const std::vector<size_t> & src_indices,
315 const std::vector<Real> & src_dist_sqr,
316 std::vector<Number>::iterator & out_it)
const;
333 const unsigned int n_interp_pts = 8,
334 const Real power = 2) :
336 #
if LIBMESH_HAVE_NANOFLANN
347 virtual void clear()
override;
354 const std::vector<Point> & tgt_pts,
355 std::vector<Number> & tgt_vals)
const override;
361 #endif // #define LIBMESH_MESHFREE_INTERPOLATION_H
unsigned int n_field_variables() const
const std::vector< std::string > & field_variables() const
virtual void interpolate(const Point &pt, const std::vector< size_t > &src_indices, const std::vector< Real > &src_dist_sqr, std::vector< Number >::iterator &out_it) const
virtual void add_field_data(const std::vector< std::string > &field_names, const std::vector< Point > &pts, const std::vector< Number > &vals)
virtual void gather_remote_data()
std::vector< Number > _vals
virtual void prepare_for_use()
if(!eq) SETERRQ2(((PetscObject) dm) -> comm, PETSC_ERR_ARG_WRONG, "DM of type %s, not of type %s",((PetscObject) dm) ->type, DMLIBMESH)
virtual void construct_kd_tree()
virtual void clear() override
size_t kdtree_get_point_count() const
coord_t kdtree_distance(const coord_t *p1, const size_t idx_p2, size_t size) const
coord_t kdtree_get_pt(const size_t idx, int dim) const
std::vector< Point > & get_source_points()
const std::vector< Point > & _pts
virtual void interpolate_field_data(const std::vector< std::string > &field_names, const std::vector< Point > &tgt_pts, std::vector< Number > &tgt_vals) const =0
virtual void interpolate_field_data(const std::vector< std::string > &field_names, const std::vector< Point > &tgt_pts, std::vector< Number > &tgt_vals) const override
ParallelizationStrategy _parallelization_strategy
std::vector< Number > _src_vals
PointListAdaptor(const std::vector< Point > &pts)
std::vector< Point > _src_pts
PointListAdaptor< KDDim > _point_list_adaptor
void print_info(std::ostream &os=libMesh::out) const
Base class which defines the mesh-free interpolation interface.
friend std::ostream & operator<<(std::ostream &os, const MeshfreeInterpolation &mfi)
std::vector< Number > & get_source_vals()
An object whose state is distributed along a set of processors.
InverseDistanceInterpolation(const libMesh::Parallel::Communicator &comm_in, const unsigned int n_interp_pts=8, const Real power=2)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< Real, PointListAdaptor< KDDim > >, PointListAdaptor< KDDim >, KDDim > kd_tree_t
void set_field_variables(const std::vector< std::string > &names)
std::vector< std::string > _names
std::unique_ptr< kd_tree_t > _kd_tree
MeshfreeInterpolation(const libMesh::Parallel::Communicator &comm_in)
OStreamProxy out(std::cout)
A geometric point in (x,y,z) space.
const unsigned int _n_interp_pts
bool kdtree_get_bbox(BBOX &) const