[petsc-users] DMNetworkGetEdgeRange() in parallel

Abhyankar, Shrirang G. abhyshr at mcs.anl.gov
Mon Feb 23 11:20:14 CST 2015


What's the issue with having a single global vector? The global/local vector will have all the variables for the edges followed by all the variables for the vertices.

In any case, DMNetwork does not support having separate global vectors for edges and vertices.

Shri

From: Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>>
Date: Mon, 23 Feb 2015 10:46:02 -0600
To: Shri <abhyshr at mcs.anl.gov<mailto:abhyshr at mcs.anl.gov>>
Cc: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>, "petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>" <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>
Subject: Re: [petsc-users] DMNetworkGetEdgeRange() in parallel

Yes, that's what I need. If I added a variable to the edges with DMNetworkAddNumVariables<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.htmlhttp://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.htmlhttp://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.html>(), my global vector that DMCreateGlobalVector<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMCreateGlobalVector.html>() creates would have the edge variables that I don't want to have mixed with the variables I added in the vertices. I want them to be in a separate vectors. Therefore, I create a vector with  DMCreateGlobalVector<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMCreateGlobalVector.html>() with the variables I added in the vertices. Now I want another vector with "other" variables in the edges, and this vector has to be partitioned the same way the edges are.

Thanks
Miguel

On Mon, Feb 23, 2015 at 10:33 AM, Abhyankar, Shrirang G. <abhyshr at mcs.anl.gov<mailto:abhyshr at mcs.anl.gov>> wrote:
Miguel,
  It's not entirely clear what you are trying to do and what solver you intend to use eventually. The way DMNetwork is set up currently (following from DMPlex) is that you can assign degrees of freedom for each vertex and edge using DMNetworkAddNumVariables<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.htmlhttp://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.htmlhttp://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkAddNumVariables.html>. Once the DM is setup and/or distributed, one create global vector(s) of the appropriate size using DMCreateGlobalVector<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMCreateGlobalVector.html>. During a residual evaluation, one first gets the local vectors from the DM and then does a DMGlobalToLocalBegin/End<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMGlobalToLocalBegin.html> to copy the contents of the global vector to the local vector. You can then use a VecGetArray() on this local vector to access the elements of the vector. While iterating over the local edges/vertices, DMNetworkGetVariableOffset<http://www.mcs.anl.gov/petsc/petsc-master/docs/manualpages/DM/DMNetworkGetVariableOffset.html> gives you the location of the first element in the local vector for that particular edge/vertex point. This is how it is done in the DMNetwork example pf.c.

Now back to your question, are you creating your "global petsc vector" using DMCreateGlobalVector()? Do you wish to have vectors of different sizes associated with a DMNetwork?

Shri


From: Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>>
Date: Mon, 23 Feb 2015 09:27:51 -0600
To: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Cc: Shri <abhyshr at mcs.anl.gov<mailto:abhyshr at mcs.anl.gov>>, "petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>" <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>

Subject: Re: [petsc-users] DMNetworkGetEdgeRange() in parallel

I'm iterating through local edges given in DMNetworkGetEdgeRange(). For each edge, I extract or modify its corresponding value in a global petsc vector. Therefore that vector must have as many components as edges there are in the network. To extract the value in the vector, I use VecGetArray() and a variable counter that is incremented in each iteration. The array that I obtain in VecGetArray() has to be the same size than the edge range. That variable counter starts as 0, so if the array that I obtained in VecGetArray() is x_array, x_array[0] must be the component in the global vector that corresponds with the start edge given in DMNetworkGetEdgeRange()

I need that global petsc vector because I will use it in other operations, it's not just data. Sorry for the confusion. Thanks in advance.

Miguel


On Mon, Feb 23, 2015 at 9:09 AM, Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>> wrote:
On Mon, Feb 23, 2015 at 8:42 AM, Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>> wrote:

Thanks, that will help me. Now what I would like to have is the following: if I have two processors and ten edges, the partitioning results in the first processor having the edges 0-4 and the second processor, the edges 5-9. I also have a global vector with as many components as edges, 10. How can I partition it so the first processor also has the 0-4 components and the second, the 5-9 components of the vector?

I think it would help to know what you want to accomplish. This is how you are proposing to do it.'

If you just want to put data on edges, DMNetwork has a facility for that already.

  Thanks,

     Matt


Miguel

On Feb 23, 2015 8:08 AM, "Abhyankar, Shrirang G." <abhyshr at mcs.anl.gov<mailto:abhyshr at mcs.anl.gov>> wrote:
Miguel,
   One possible way is to store the global numbering of any edge/vertex in the "component" attached to it. Once the mesh gets partitioned, the components are also distributed so you can easily retrieve the global number of any edge/vertex by accessing its component. This is what is done in the DMNetwork example pf.c although the global numbering is not used for anything.

Shri
From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Date: Mon, 23 Feb 2015 07:54:34 -0600
To: Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>>
Cc: "petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>" <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>>
Subject: Re: [petsc-users] DMNetworkGetEdgeRange() in parallel

On Sun, Feb 22, 2015 at 3:59 PM, Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>> wrote:
Thanks. Once I obtain that Index Set with the routine DMPlexCreateCellNumbering() (I assume that the edges in DMNetwork correspond to cells in DMPlex) can I use it to partition a vector with as many components as edges I have in my network?

I do not completely understand the question.

If you want a partition of the edges, you can use DMPlexCreatePartition() and its friend DMPlexDistribute(). What
are you trying to do?

   Matt

Thanks
Miguel

On Sun, Feb 22, 2015 at 12:15 PM, Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>> wrote:
On Sun, Feb 22, 2015 at 11:01 AM, Miguel Angel Salazar de Troya <salazardetroya at gmail.com<mailto:salazardetroya at gmail.com>> wrote:
Hi

I noticed that the routine DMNetworkGetEdgeRange() returns the local indices for the edge range. Is there any way to obtain the global indices? So if my network has 10 edges, the processor 1 has the 0-4 edges and the processor 2, the 5-9 edges, how can I obtain this information?

One of the points of DMPlex is we do not require a global numbering. Everything is numbered
locally, and the PetscSF maps local numbers to local numbers in order to determine ownership.

If you want to create a global numbering for some reason, you can using DMPlexCreatePointNumbering().
There are also cell and vertex versions that we use for output, so you could do it just for edges as well.

  Thanks,

     Matt

Thanks
Miguel

--
Miguel Angel Salazar de Troya
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360<tel:%28217%29%20550-2360>
salaza11 at illinois.edu<mailto:salaza11 at illinois.edu>




--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener



--
Miguel Angel Salazar de Troya
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360<tel:%28217%29%20550-2360>
salaza11 at illinois.edu<mailto:salaza11 at illinois.edu>




--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener



--
Miguel Angel Salazar de Troya
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360
salaza11 at illinois.edu<mailto:salaza11 at illinois.edu>




--
Miguel Angel Salazar de Troya
Graduate Research Assistant
Department of Mechanical Science and Engineering
University of Illinois at Urbana-Champaign
(217) 550-2360
salaza11 at illinois.edu<mailto:salaza11 at illinois.edu>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150223/e87f4783/attachment-0001.html>


More information about the petsc-users mailing list