Hi Behrooz,

I must admit that I’ve not been able to follow why you want to store Points 
when you’re interested in global vertex indices, but I’ll try to give a little 
help where I can.
In case its of any help to you, I believe that you should be able to get the 
coordinate of the vertex with a known global index with the help of the 
Triangulation::get_vertices() 
<https://dealii.org/current/doxygen/deal.II/classTriangulation.html#afb3059d54432e0d739534e5330bb7b3a>
 function.

> By the way,  to be more specific, a simple command like the following :
> std::pair <Point<dim>, Point<dim>> mypair (vertices[v], vertices[v]);
> (in conjunction with vertices[v] = cell->face(f)->vertex(v);)
> makes a pair of coordinates of vertices.

In terms of the question “can I do this?”, what you’ve written here is 
reasonable. If vertices[v] stores a Point<dim>, which is exactly what is 
returned by cell->face(f)->vertex(v) ...

> However, when I modify it towards vertex_index(v), it doesn't work:
> vertices[v] = cell->face(f)->vertex_index(v);
> std::pair <Point<dim>, Point<dim>> mypair (vertices[v], vertices[v]);
> Perhaps something according to Point<dim> needs be modified.

… but this doesn’t make sense. Specifically, this:
> vertices[v] = cell->face(f)->vertex_index(v);

A call to cell->face(f)->vertex_index(v) returns the global index of a vertex 
(so, effectively an integer) and unless the data type stored by “vertices” has 
changed, you’re trying to assign an integer to a Point. This cannot work.

> std::set <Point<dim>> set1;

This cannot work without a little work from your side. The problem is that 
std::set <https://en.cppreference.com/w/cpp/container/set> orders its entries, 
and to do this it requires a comparator. One way to do this is to define 
operator < in the class that is to be stored in the set, but we do not provide 
such an operator. Thankfully, you can create a custom comparator for Points and 
declare that comparator as the one to be used by the std::set to order the 
entries. There’s a somewhat comprehensive post on the subject at this link 
<https://stackoverflow.com/a/46128321>. I wonder though if you rather want to 
make this a vector of Points, because the order in which you enter them into 
the set would not be preserved. That means that if you somehow extract and 
store the global index at the same time, then the entries in the containers are 
not stores in the same order.

> By the way could anyone kindly enlighten me about the Point<dim> and required 
> steps to make a pair of and cast intended data into a set? Specially why 
> Point<dim, double> is a preferred type (in the case of vertices) to other 
> data types? 

I guess that I answered half of this question, but to answer your question on 
the relation of Points and vertices: Well, we choose to use the Point class to 
describe the physical coordinates points in space, and the vector that defines 
the coordinate has an end-point at the origin. The Tensor class looks similar 
in structure (and has an overlap of functionality), but represents other 
mathematical constructs such as a vector with both its end-points being allowed 
to be anywhere in space. You can read more about the conceptual difference in 
the introduction to the Point class documentation 
<https://dealii.org/current/doxygen/deal.II/classPoint.html>.

I hope that this helps at least a bit, and that you manage to implement what 
you’re trying to do here.

Best,
Jean-Paul

> 
> 
> 
> 
> On Friday, October 9, 2020 at 6:11:11 AM UTC+2 Behrooz Karami wrote:
> Dear Daniel,
> 
> Thanks very much for your reply. Actually what I want to do is very simple.
> 
> Consider that the above code gives me 3 nodal indices as: 1, 4 and 5.
> First, I need to be able to cast them into a set or vector. We can call it 
> set1.
> Then assume that I have another set, e.g. set2, which is composed of those 
> nodes (same coordinates), however consecutively renumbered to 101, 102 and 
> 103.
> 
> Second step I am trying to achieve is to create a pair between the components 
> of those two sets (set1 and set2).  The new set, e.g. set3, would be in fact 
> a set of pairs which includes just three pairs namely (1,101) , (4, 102) and 
> (5, 103). Pairs should be constructed in a one-to-one manner, for example we 
> do not want to have something like (1, 102).
> 
> So basically to me it seems that I need first to make a set of points, very 
> roughly like:
> std::set <Point<dim>> set1;
> std::set <Point<dim>> set2;
> 
> and then making a pair of sets:
> std::pair <set1, set2> pairs;
> 
> and finally making a set of pairs:
> std::set <pairs> set3;
> 
> However, I haven't yet been able to figure out a proper and correct method to 
> do that. I get various errors (some notably related to Point<dim>) and I do 
> not understand what is missing or what is misdefined. Hope I could have been 
> able to clarify it a bit more.
>  
> Thanks again,
> Behrooz
> 
> On Thursday, October 8, 2020 at 2:39:25 PM UTC+2 d.arnd...@gmail.com 
> <applewebdata://C8825833-9A00-4276-8B05-5C4C2127FD12> wrote:
> Behrooz,
> 
> Can you elaborate some more on what you are trying to achieve?
> The (pseudo-)code you posted looks OK apart from vertices being declared in 
> the innermost loop.
> You probably want it to be outside the loop over the vertices of a face.
> 
> The API for Point can be found at 
> https://www.dealii.org/current/doxygen/deal.II/classPoint.html 
> <https://www.dealii.org/current/doxygen/deal.II/classPoint.html>. In 
> particular, it is derived from Tensor.
> 
> In the end, it should not be a problem to create a std::vector of storage 
> type Point (if you are interested in the position of vertices)
> or unsigned int (if you are interested in the index of the vertices) and 
> push_back into it.
> 
> Best,
> Daniel
> 
> 
> Am Do., 8. Okt. 2020 um 04:48 Uhr schrieb Behrooz Karami <be.k...@gmail.com 
> <>>:
> Hi everyone,
> 
> I am trying to cast extracted vertex_indices into a set (or vector). Before 
> that it is needed to make a pair of those indices (just doubling) and to cast 
> the pairs into a set  for further manipulations.
> 
> I get the vertex information mainly through following lines of code:
> 
> for (auto cell : triangulation.active_cell_iterators())
>           for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)    
>                     if (...)  
>                     for (unsigned int v=0; v < 
> GeometryInfo<dim>::vertices_per_face; ++v) 
>                             {                                
>                                 if (...)    
>                                         {    
>                                              Point<dim> 
> vertices[GeometryInfo<dim>::vertices_per_face];                               
>  
>                                             //vertices[v] = 
> cell->face(f)->vertex(v);    
>                                             std::cout<<"  vertex_id: 
> "<<cell->face(f)->vertex_index(v)<<std::endl;
>                                             //std::cout<<"  coords: "<< 
> cell->face(f)->vertex(v)<<std::endl;
>                                         }
>                                }    
> 
> However I have not yet been able to construct the required data structure to 
> get that.
> Specially the nature of Point<dim> is not yet clear to me. It looks to have 
> some similarities with vectors. 
> 
> Though std::cout yields vertex IDs, I am not sure how to store them (as well 
> as vertex coords., face IDs, etc) into a set or vector. 
> Having a look on GeometryInfo<dim>, my new guess is that I probably need to 
> loop over vertex_indices(), i.e. 
> vertices[GeometryInfo<dim>::vertex_indices()]. 
> 
> By the way could anyone kindly enlighten me about the Point<dim> and required 
> steps to make a pair of and cast intended data into a set? Specially why 
> Point<dim, double> is a preferred type (in the case of vertices) to other 
> data types? 
> 
> Thanks very much,
> Behrooz
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> <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+un...@googlegroups.com <>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/b192e1e9-4905-4e40-9e32-17d8a4a3ee62n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/dealii/b192e1e9-4905-4e40-9e32-17d8a4a3ee62n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> -- 
> The deal.II project is located at http://www.dealii.org/ 
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://groups.google.com/d/forum/dealii?hl=en 
> <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 
> <mailto:dealii+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/c0a31673-5f54-41d7-8350-4accc6e54984n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/dealii/c0a31673-5f54-41d7-8350-4accc6e54984n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/49755FE3-3D5C-413C-904A-9A03E0ED52FB%40gmail.com.

Reply via email to