Re: [deal.II] KDTree implementation error

2020-07-24 Thread heena patel
Dear Luca,
 Thank you very much. It now works in both
ways. Thanks for advice.

Regards,
Heena

On Fri, Jul 24, 2020 at 12:31 PM luca.heltai  wrote:

> KDTree needs nanoflann to be available. Did you compile deal.II with
> nanoflann exnabled? Check in the summary.log if DEAL_II_WITH_NANOFLANN is
> ON.
>
> RTree, on the other hand, does not require nanoflann, as it is included
> with boost (and it is faster than nanoflann).
>
> L.
>
> > On 24 Jul 2020, at 10:05, heena patel  wrote:
> >
> > Dear Luca,
> > I am using 9.2 version and the
> implementation I try to follow  from your presentation at SISSA 2018 but it
> gives me error. Following are the lines I added to step-1. I want to
> implement K nearest neighbor. I will work on your suggestion.
> > #include 
> > Point<2>  p;
> >KDTree<2> tree(10,triangulation.get_vertices());
> >auto w = tree.get_closest_points(p, 3);
> >
> > Regards,
> > Heena
> >
> >
> > On Fri, Jul 24, 2020 at 8:30 AM Luca Heltai 
> wrote:
> > If you are using version 9.3pre of deal.II, kdtree was removed. Use
> RTree instead, which is faster and more flexible.
> >
> > Luca
> >
> >> Il giorno 24 lug 2020, alle ore 05:41, heena patel 
> ha scritto:
> >>
> >> 
> >> Dear Bruno,
> >>I had already added kdree.h header file,
> check the question again. But it seems it does not read KDTree; something
> is not compatible between class and header file.
> >>
> >> Regards,
> >> Heena
> >>
> >> On Thu, Jul 23, 2020 at 9:03 PM Bruno Turcksin <
> bruno.turck...@gmail.com> wrote:
> >> Heena,
> >>
> >> You are missing an include. Try adding #include
> 
> >>
> >> Best,
> >>
> >> Bruno
> >>
> >> On Thursday, July 23, 2020 at 2:55:53 PM UTC-4, heena patel wrote:
> >>
> >> Dear all,
> >>   I had tried to implement KDTree in step_1
> tutoria and header file for kdtree is added to the codel. It is as follows:
> >>
> >> void first_grid()
> >> {
> >>
> >>   Triangulation<2> triangulation;
> >>
> >>   GridGenerator::hyper_cube(triangulation);
> >>   triangulation.refine_global(4);
> >>   Point<2>  p;
> >>KDTree<2> tree(10,triangulation.get_vertices());
> >>auto w = tree.get_closest_points(p, 3);
> >>   std::ofstream out("grid-1.svg");
> >>   GridOut   grid_out;
> >>   grid_out.write_svg(triangulation, out);
> >>   std::cout << "Grid written to grid-1.svg" << std::endl;
> >> }
> >>
> >>
> >>
> >> It gives me error as below
> >>
> >> /home/heena/Project/examples/step-1/step-1.cc:76:4: error: ‘KDTree’ was
> not declared in this scope
> >> KDTree<2> tree(10,triangulation.get_vertices());
> >> ^~
> >> /home/heena/Project/examples/step-1/step-1.cc:76:4: note: suggested
> alternative: ‘free’
> >> KDTree<2> tree(10,triangulation.get_vertices());
> >> ^~
> >> free
> >> /home/heena/Project/examples/step-1/step-1.cc:76:14: error: ‘tree’ was
> not declared in this scope
> >> KDTree<2> tree(10,triangulation.get_vertices());
> >>   ^~~~
> >> /home/heena/Project/examples/step-1/step-1.cc:76:14: note: suggested
> alternative: ‘free’
> >> KDTree<2> tree(10,triangulation.get_vertices());
> >>   ^~~~
> >>   free
> >>
> >>
> >>
> >> Is there something missing?
> >>
> >>
> >>
> >> Regards,
> >> Heena
> >>
> >> --
> >> The deal.II project is located at http://www.dealii.org/
> >> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to dealii+unsubscr...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/d761c989-ef92-4603-8c8e-85ec4eeb3766o%40googlegroups.com
> .
> >>
> >> --
> >> The deal.II project is located at http://www.dealii.org/
> >> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to dealii+unsubscr...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/CAG_OxbgYqw02b4TnJAvBgWo7dvjRvf7zr6V%2BcBDKE_5hafCDJA%40mail.gmail.com
> .
> >
> > --
> > The deal.II project is located at http://www.dealii.org/
> > For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to dealii+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> 

Re: [deal.II] KDTree implementation error

2020-07-24 Thread luca.heltai
KDTree needs nanoflann to be available. Did you compile deal.II with nanoflann 
exnabled? Check in the summary.log if DEAL_II_WITH_NANOFLANN is ON.

RTree, on the other hand, does not require nanoflann, as it is included with 
boost (and it is faster than nanoflann).

L.

> On 24 Jul 2020, at 10:05, heena patel  wrote:
> 
> Dear Luca,
> I am using 9.2 version and the implementation 
> I try to follow  from your presentation at SISSA 2018 but it gives me error. 
> Following are the lines I added to step-1. I want to implement K nearest 
> neighbor. I will work on your suggestion.
> #include 
> Point<2>  p;
>KDTree<2> tree(10,triangulation.get_vertices());
>auto w = tree.get_closest_points(p, 3);
> 
> Regards,
> Heena
> 
> 
> On Fri, Jul 24, 2020 at 8:30 AM Luca Heltai  wrote:
> If you are using version 9.3pre of deal.II, kdtree was removed. Use RTree 
> instead, which is faster and more flexible. 
> 
> Luca
> 
>> Il giorno 24 lug 2020, alle ore 05:41, heena patel  ha 
>> scritto:
>> 
>> 
>> Dear Bruno,
>>I had already added kdree.h header file, 
>> check the question again. But it seems it does not read KDTree; something is 
>> not compatible between class and header file.
>> 
>> Regards,
>> Heena
>> 
>> On Thu, Jul 23, 2020 at 9:03 PM Bruno Turcksin  
>> wrote:
>> Heena,
>> 
>> You are missing an include. Try adding #include 
>> 
>> Best,
>> 
>> Bruno
>> 
>> On Thursday, July 23, 2020 at 2:55:53 PM UTC-4, heena patel wrote:
>> 
>> Dear all,
>>   I had tried to implement KDTree in step_1 tutoria 
>> and header file for kdtree is added to the codel. It is as follows:
>> 
>> void first_grid()
>> {
>> 
>>   Triangulation<2> triangulation;
>> 
>>   GridGenerator::hyper_cube(triangulation);
>>   triangulation.refine_global(4);
>>   Point<2>  p;
>>KDTree<2> tree(10,triangulation.get_vertices());
>>auto w = tree.get_closest_points(p, 3);
>>   std::ofstream out("grid-1.svg");
>>   GridOut   grid_out;
>>   grid_out.write_svg(triangulation, out);
>>   std::cout << "Grid written to grid-1.svg" << std::endl;
>> }
>> 
>> 
>> 
>> It gives me error as below 
>> 
>> /home/heena/Project/examples/step-1/step-1.cc:76:4: error: ‘KDTree’ was not 
>> declared in this scope
>> KDTree<2> tree(10,triangulation.get_vertices());
>> ^~
>> /home/heena/Project/examples/step-1/step-1.cc:76:4: note: suggested 
>> alternative: ‘free’
>> KDTree<2> tree(10,triangulation.get_vertices());
>> ^~
>> free
>> /home/heena/Project/examples/step-1/step-1.cc:76:14: error: ‘tree’ was not 
>> declared in this scope
>> KDTree<2> tree(10,triangulation.get_vertices());
>>   ^~~~
>> /home/heena/Project/examples/step-1/step-1.cc:76:14: note: suggested 
>> alternative: ‘free’
>> KDTree<2> tree(10,triangulation.get_vertices());
>>   ^~~~
>>   free
>> 
>> 
>> 
>> Is there something missing?
>> 
>> 
>> 
>> Regards,
>> Heena
>> 
>> -- 
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see 
>> https://groups.google.com/d/forum/dealii?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/d761c989-ef92-4603-8c8e-85ec4eeb3766o%40googlegroups.com.
>> 
>> -- 
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see 
>> https://groups.google.com/d/forum/dealii?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/CAG_OxbgYqw02b4TnJAvBgWo7dvjRvf7zr6V%2BcBDKE_5hafCDJA%40mail.gmail.com.
> 
> -- 
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to dealii+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/82AC7F19-2444-4E74-90B0-DCAC8F3722C2%40gmail.com.
> 
> -- 
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> 

Re: [deal.II] KDTree implementation error

2020-07-24 Thread luca.heltai
Dear Heena, 

here is a snippet to achieve what you want:


#include 
namespace bgi = boost::geometry::index;

…


Point<2>  p0;
const auto tree = pack_rtree(tria.get_vertices());

for (const auto  : tree | bgi::adaptors::queried(bgi::nearest(p0, 3)))
// do something with p
std::cout << p << std::endl;

or, if you need the indices of the points:

const auto tree_of_indices = pack_rtree_of_indices(tria.get_vertices());

for (const auto  : tree_of_indices | bgi::adaptors::queried(bgi::nearest(p0, 
3)))
// do something with i
std::cout << “Closest vertex has index "<< i << std::endl;


see 

https://github.com/dealii/dealii/blob/master/tests/boost/rtree_03.cc

for the example above.

L.

> On 24 Jul 2020, at 10:05, heena patel  wrote:
> 
> Dear Luca,
> I am using 9.2 version and the implementation 
> I try to follow  from your presentation at SISSA 2018 but it gives me error. 
> Following are the lines I added to step-1. I want to implement K nearest 
> neighbor. I will work on your suggestion.
> #include 
> Point<2>  p;
>KDTree<2> tree(10,triangulation.get_vertices());
>auto w = tree.get_closest_points(p, 3);
> 
> Regards,
> Heena
> 
> 
> On Fri, Jul 24, 2020 at 8:30 AM Luca Heltai  wrote:
> If you are using version 9.3pre of deal.II, kdtree was removed. Use RTree 
> instead, which is faster and more flexible. 
> 
> Luca
> 
>> Il giorno 24 lug 2020, alle ore 05:41, heena patel  ha 
>> scritto:
>> 
>> 
>> Dear Bruno,
>>I had already added kdree.h header file, 
>> check the question again. But it seems it does not read KDTree; something is 
>> not compatible between class and header file.
>> 
>> Regards,
>> Heena
>> 
>> On Thu, Jul 23, 2020 at 9:03 PM Bruno Turcksin  
>> wrote:
>> Heena,
>> 
>> You are missing an include. Try adding #include 
>> 
>> Best,
>> 
>> Bruno
>> 
>> On Thursday, July 23, 2020 at 2:55:53 PM UTC-4, heena patel wrote:
>> 
>> Dear all,
>>   I had tried to implement KDTree in step_1 tutoria 
>> and header file for kdtree is added to the codel. It is as follows:
>> 
>> void first_grid()
>> {
>> 
>>   Triangulation<2> triangulation;
>> 
>>   GridGenerator::hyper_cube(triangulation);
>>   triangulation.refine_global(4);
>>   Point<2>  p;
>>KDTree<2> tree(10,triangulation.get_vertices());
>>auto w = tree.get_closest_points(p, 3);
>>   std::ofstream out("grid-1.svg");
>>   GridOut   grid_out;
>>   grid_out.write_svg(triangulation, out);
>>   std::cout << "Grid written to grid-1.svg" << std::endl;
>> }
>> 
>> 
>> 
>> It gives me error as below 
>> 
>> /home/heena/Project/examples/step-1/step-1.cc:76:4: error: ‘KDTree’ was not 
>> declared in this scope
>> KDTree<2> tree(10,triangulation.get_vertices());
>> ^~
>> /home/heena/Project/examples/step-1/step-1.cc:76:4: note: suggested 
>> alternative: ‘free’
>> KDTree<2> tree(10,triangulation.get_vertices());
>> ^~
>> free
>> /home/heena/Project/examples/step-1/step-1.cc:76:14: error: ‘tree’ was not 
>> declared in this scope
>> KDTree<2> tree(10,triangulation.get_vertices());
>>   ^~~~
>> /home/heena/Project/examples/step-1/step-1.cc:76:14: note: suggested 
>> alternative: ‘free’
>> KDTree<2> tree(10,triangulation.get_vertices());
>>   ^~~~
>>   free
>> 
>> 
>> 
>> Is there something missing?
>> 
>> 
>> 
>> Regards,
>> Heena
>> 
>> -- 
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see 
>> https://groups.google.com/d/forum/dealii?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/d761c989-ef92-4603-8c8e-85ec4eeb3766o%40googlegroups.com.
>> 
>> -- 
>> The deal.II project is located at http://www.dealii.org/
>> For mailing list/forum options, see 
>> https://groups.google.com/d/forum/dealii?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "deal.II User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to dealii+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/CAG_OxbgYqw02b4TnJAvBgWo7dvjRvf7zr6V%2BcBDKE_5hafCDJA%40mail.gmail.com.
> 
> -- 
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to dealii+unsubscr...@googlegroups.com.
> To view this discussion on the 

[deal.II] KDTree implementation error

2020-07-23 Thread heena patel

Dear all,
  I had tried to implement KDTree in step_1 tutoria 
and header file for kdtree is added to the codel. It is as follows:

void first_grid()
{

  Triangulation<2> triangulation;

  GridGenerator::hyper_cube(triangulation);
  triangulation.refine_global(4);


*  Point<2>  p;   KDTree<2> tree(10,triangulation.get_vertices());   auto w 
= tree.get_closest_points(p, 3);*
  std::ofstream out("grid-1.svg");
  GridOut   grid_out;
  grid_out.write_svg(triangulation, out);
  std::cout << "Grid written to grid-1.svg" << std::endl;
}



*It gives me error as below *

/home/heena/Project/examples/step-1/step-1.cc:76:4: error: ‘KDTree’ was not 
declared in this scope
KDTree<2> tree(10,triangulation.get_vertices());
^~
/home/heena/Project/examples/step-1/step-1.cc:76:4: note: suggested 
alternative: ‘free’
KDTree<2> tree(10,triangulation.get_vertices());
^~
free
/home/heena/Project/examples/step-1/step-1.cc:76:14: error: ‘tree’ was not 
declared in this scope
KDTree<2> tree(10,triangulation.get_vertices());
  ^~~~
/home/heena/Project/examples/step-1/step-1.cc:76:14: note: suggested 
alternative: ‘free’
KDTree<2> tree(10,triangulation.get_vertices());
  ^~~~
  free



Is there something missing?



Regards,
Heena

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/03a99ffc-c95e-4198-9aed-f175d703f103o%40googlegroups.com.