[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
Dear Bruno,

Thanks. That's even better and even in just a single line of code. ;)

MPI_Bcast(&position, 1, MPI_DOUBLE, max_rank, mpi_com);

Best,
Seyed Ali

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
Dear Bruno,

Thanks. That's even better and even in just a single line of code. ;)

MPI_Bcast(&position, 1, MPI_DOUBLE, max_rank, mpi_com);



Best,
Seyed Ali

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
Dear Bruno,

Thanks. That's even better and saves us the unnecessary loop. ;)

Best,
Seyed Ali

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread Bruno Turcksin
Seyed,

you probably want to use MPI_Bcast instead of your code (see 
http://mpitutorial.com/tutorials/mpi-broadcast-and-collective-communication/)

Best,

Bruno

On Wednesday, March 8, 2017 at 9:51:50 AM UTC-5, Seyed Ali Mohseni wrote:
>
> Dear all,
>
> I was able to solve the MPI variable problem. 
>
> For the users who may have the same issue once:
>
> if ( this_mpi_process == max_rank )
> {
>  for (unsigned int i = 0; i < n_mpi_processes; ++i)
>  {
>   if ( i != max_rank )
>MPI_Send(&position, 1, MPI_DOUBLE, i, 0, mpi_com);
>  }
> }
> else
> {
>  MPI_Recv(&position, 1, MPI_DOUBLE, max_rank, 0, mpi_com, 
> MPI_STATUS_IGNORE);
>  printf("Process %d received number from process %d\n", 
> this_mpi_process, max_rank);
> }
>
> A double variable called position (just as an example here, you have to 
> pass x,y,z, so 3 variables) can be defined earlier which has then to be 
> filled on the rank equal to max_rank. 
>
> Finally, I can proceed. The code was tested for ranks 1 to 16 and works 
> perfectly. Every time the maximum value and position remains correct and 
> unchanged, but the maximum rank (max_rank) changes dependent on the core 
> numbers.
>
> Thank you a lot. 
> The community here is extraordinary. ;)
>
> Best regards,
> S. A. Mohseni
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
Dear all,

I was able to solve the MPI variable problem. 

For the users who may have the same issue once:

if ( this_mpi_process == max_rank )
{
 for (unsigned int i = 0; i < n_mpi_processes; ++i)
 {
  if ( i != max_rank )
   MPI_Send(&position, 1, MPI_DOUBLE, i, 0, mpi_com);
 }
}
else
{
 MPI_Recv(&position, 1, MPI_DOUBLE, max_rank, 0, mpi_com, 
MPI_STATUS_IGNORE);
 printf("Process %d received number from process %d\n", 
this_mpi_process, max_rank);
}

A double variable called position (just as an example here, you have to 
pass x,y,z, so 3 variables) can be defined earlier which has then to be 
filled on the rank equal to max_rank. 

Finally, I can proceed. The code was tested for ranks 1 to 16 and works 
perfectly. Every time the maximum value and position remains correct and 
unchanged, but the maximum rank (max_rank) changes dependent on the core 
numbers.

Thank you a lot. 
The community here is extraordinary. ;)

Best regards,
S. A. Mohseni

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
Dear all,

I was able to solve the MPI variable problem. 

For the users who may have the same issue once:

if ( this_mpi_process == max_rank )
{
 for (unsigned int i = 0; i < n_mpi_processes; ++i)
 {
  if ( i != max_rank )
   MPI_Send(&position, 1, MPI_DOUBLE, i, 0, mpi_com);
 }
}
else
{
 MPI_Recv(&position, 1, MPI_DOUBLE, max_rank, 0, mpi_com, 
MPI_STATUS_IGNORE);
 printf("Process %d received number from process %d\n", 
this_mpi_process, max_rank);
}

A double variable called position (just as an example here, you have to 
pass x,y,z, so 3 variables) has been defined earlier which was filled on 
the rank equal to max_rank. 

Finally, I can proceed. The code was tested for ranks 1 to 16 and works 
perfectly. Every time the maximum value and position remains correct and 
unchanged, but the maximum rank (max_rank) changes dependent on the core 
numbers.

Thank you a lot. 
The community here is extraordinary. ;)

Best regards,
S. A. Mohseni

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: MeshWorker clarifications

2017-03-08 Thread Franco Milicchio
I have made available the snippet for this example here 
 with the possibility of 
using either the MeshWorker or not (just change the #define).

As far as I see, the code is copied and pasted correctly.

The right hand sides *are the same*, but *matrices differ*.

Thanks for any pointers!
Franco

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
@Daniel:

- n_vertices() only gives you the number of vertices for one process, not 
> the global one. In particular, you can't rely on the fact that this is the 
> same for all processes. Furthermore, you (probably) don't initialize all 
> the values of your struct. This might be the reason for the large numbers 
> you are observing.
>

Exactly. I fixed the large numbers by setting all entries initially 0. I 
also had that in mind, but assumed that we already initialize everything 
the moment we assign its size.

Here the solution for whom it may be interesting. 

int disp_size = triangulation.n_vertices();

struct
{
double value* = 0*;
int rank *= 0*;
} in[disp_size], out[disp_size];

Surprisingly, n_vertices() gives me exactly the number of the total 
vertices. I checked it. Is it not always like this? And what would be the 
command to obtain the global one?

@ Jean-Paul: Ah, ok. I assumed there are special MPI_Send functions 
implemented in deal.II which I could use such as Utilities::MPI::max() for 
instance.

BR,
Seyed Ali

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread Jean-Paul Pelteret
Dear Seyed,
 

> Extra question: Can we store variables or copy them to all processors? 
> Since I am filling a variable in a locally owned cell, currently on rank 3. 
> Then my other ranks, especially the root rank 0 has no clue of the values 
> which are set. Hence, there has to be a possibility to copy data to other 
> processors or let them know about the content?
>
 
This falls into the category of standard, but very much nontrivial, MPI 
questions that are unrelated to deal.II itself. How you would implement the 
point-to-point 
communication 
 of data 
depends very much on, amongst other things, the type of data that is being 
transferred, and how/to which processes the information is being broadcast 
and received. 

So I would highly recommend that you take a look at the documentation 
 for the MPI library that you are using 
and perhaps also go through a couple of tutorials that focus on MPI and 
its communication models itself. Otherwise, there are examples 
 in the 
source code and tests 
 
that you can use to better understand how you might implement whatever it 
is that you're trying to do.

Regards,
Jean-Paul

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[deal.II] Re: Access specific element within a distributed triangulation

2017-03-08 Thread 'Seyed Ali Mohseni' via deal.II User Group
@Prof. Bangerth: I will try to learn debugging parallel code and also to 
follow your words of advice. Please do not apologize since I don't think 
you ever became rude. I mean, after 1 emails I would definitely not be 
as calm as you. Thank you.  :) 

@Daniel: Thumbs up. From your words I realize, there is still a lot to 
learn about deal.II yet. To be honest, I always try to solve it in a simple 
way than I extend it to the general case such as 3D, DG elements, etc. 
Thank you for all the help.

Extra question: Can we store variables or copy them to all processors? 
Since I am filling a variable in a locally owned cell, currently on rank 3. 
Then my other ranks, especially the root rank 0 has no clue of the values 
which are set. Hence, there has to be a possibility to copy data to other 
processors or let them know about the content?

Kind regards,
Seyed Ali
 

-- 
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.
For more options, visit https://groups.google.com/d/optout.