Re: [deal.II] Making a pair of extracted data and cast into a set

2020-10-13 Thread Behrooz Karami
Dear Jean-Paul,

Thanks very much for your explanations.
I managed to achieve my objective. You were right, one of the crucial 
points I had to take into account was the compatibility of data structures. 
Defining a new operator was another to the point advice, as some of the 
errors were laid on this ground. Thanks again.

Best, 
Behrooz



On Friday, October 9, 2020 at 11:56:36 PM UTC+2 Jean-Paul Pelteret wrote:

> 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() 
> 
>  function.
>
> By the way,  to be more specific, a simple command like the following :
> std::pair , Point> 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, 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> mypair (vertices[v], vertices[v]);
> Perhaps something according to Point 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 > set1;
>
>
> This cannot work without a little work from your side. The problem is that 
> std::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 . 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 and 
 required steps to make a pair of and cast intended data into a set? 
 Specially why Point 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 
> .
>
> 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 > set1;
>> std::set > set2;
>>
>> and then making 

Re: [deal.II] Making a pair of extracted data and cast into a set

2020-10-09 Thread Jean-Paul Pelteret
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() 

 function.

> By the way,  to be more specific, a simple command like the following :
> std::pair , Point> 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, 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> mypair (vertices[v], vertices[v]);
> Perhaps something according to Point 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 > set1;

This cannot work without a little work from your side. The problem is that 
std::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 
. 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 and required 
> steps to make a pair of and cast intended data into a set? Specially why 
> Point 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 
.

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 > set1;
> std::set > set2;
> 
> and then making a pair of sets:
> std::pair  pairs;
> 
> and finally making a set of pairs:
> std::set  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) 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 
>  wrote:
> Behrooz,
> 
> Can you elaborate some more on what you are trying to achieve?
> The 

Re: [deal.II] Making a pair of extracted data and cast into a set

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

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





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 > set1;
> std::set > set2;
>
> and then making a pair of sets:
> std::pair  pairs;
>
> and finally making a set of pairs:
> std::set  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) 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 
> 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. 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::faces_per_cell; 
>>> ++f)
>>> if (...)  
>>> for (unsigned int v=0; v < 
>>> GeometryInfo::vertices_per_face; ++v) 
>>> {
>>> if (...)
>>> {
>>>  Point 
>>> vertices[GeometryInfo::vertices_per_face];   
>>>  
>>> //vertices[v] = 
>>> cell->face(f)->vertex(v);
>>> std::cout<<"  vertex_id: 
>>> "vertex_index(v)<>> //std::cout<<"  coords: "<< 
>>> cell->face(f)->vertex(v)<>> }
>>>}
>>>
>>> However I have not yet been able to construct the required data 
>>> structure to get that.
>>> Specially the nature of Point 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, my new guess is that I probably need 
>>> to loop over vertex_indices(), i.e. 
>>> vertices[GeometryInfo::vertex_indices()]. 
>>>
>>> By the way could anyone kindly enlighten me about the Point and 
>>> required steps to make a pair of and cast intended data into a set? 
>>> Specially why Point 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/
>>> For mailing list/forum options, see 
>>> https://groups.google.com/d/forum/dealii?hl=en
>>> --- 
>>> You 

Re: [deal.II] Making a pair of extracted data and cast into a set

2020-10-08 Thread Behrooz Karami
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 > set1;
std::set > set2;

and then making a pair of sets:
std::pair  pairs;

and finally making a set of pairs:
std::set  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) 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 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. 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::faces_per_cell; 
>> ++f)
>> if (...)  
>> for (unsigned int v=0; v < 
>> GeometryInfo::vertices_per_face; ++v) 
>> {
>> if (...)
>> {
>>  Point 
>> vertices[GeometryInfo::vertices_per_face];   
>>  
>> //vertices[v] = 
>> cell->face(f)->vertex(v);
>> std::cout<<"  vertex_id: 
>> "vertex_index(v)<> //std::cout<<"  coords: "<< 
>> cell->face(f)->vertex(v)<> }
>>}
>>
>> However I have not yet been able to construct the required data structure 
>> to get that.
>> Specially the nature of Point 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, my new guess is that I probably need 
>> to loop over vertex_indices(), i.e. 
>> vertices[GeometryInfo::vertex_indices()]. 
>>
>> By the way could anyone kindly enlighten me about the Point and 
>> required steps to make a pair of and cast intended data into a set? 
>> Specially why Point 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/
>> 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+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
>>  
>> 
>> .
>>
>

-- 
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 

Re: [deal.II] Making a pair of extracted data and cast into a set

2020-10-08 Thread Daniel Arndt
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. 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.kar...@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::faces_per_cell;
> ++f)
> if (...)
> for (unsigned int v=0; v <
> GeometryInfo::vertices_per_face; ++v)
> {
> if (...)
> {
>  Point
> vertices[GeometryInfo::vertices_per_face];
>
> //vertices[v] =
> cell->face(f)->vertex(v);
> std::cout<<"  vertex_id:
> "vertex_index(v)< //std::cout<<"  coords: "<<
> cell->face(f)->vertex(v)< }
>}
>
> However I have not yet been able to construct the required data structure
> to get that.
> Specially the nature of Point 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, my new guess is that I probably need
> to loop over vertex_indices(), i.e.
> vertices[GeometryInfo::vertex_indices()].
>
> By the way could anyone kindly enlighten me about the Point and
> required steps to make a pair of and cast intended data into a set?
> Specially why Point 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/
> 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/b192e1e9-4905-4e40-9e32-17d8a4a3ee62n%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/CAOYDWb%2B%2BmCustRajVHPe79-k4_XohBLKxAsgaAp%3DsNw915a5iA%40mail.gmail.com.


[deal.II] Making a pair of extracted data and cast into a set

2020-10-08 Thread Behrooz Karami
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::faces_per_cell; 
++f)
if (...)  
for (unsigned int v=0; v < 
GeometryInfo::vertices_per_face; ++v) 
{
if (...)
{
 Point 
vertices[GeometryInfo::vertices_per_face];   
 
//vertices[v] = 
cell->face(f)->vertex(v);
std::cout<<"  vertex_id: 
"vertex_index(v)vertex(v)< 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, my new guess is that I probably need to 
loop over vertex_indices(), i.e. 
vertices[GeometryInfo::vertex_indices()]. 

By the way could anyone kindly enlighten me about the Point and 
required steps to make a pair of and cast intended data into a set? 
Specially why Point 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/
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/b192e1e9-4905-4e40-9e32-17d8a4a3ee62n%40googlegroups.com.