<div dir="ltr">No worries. Thanks for your responses. I'm assuming you suggested to use DMNetworkIsGhostVertex() and not modify its value for the case in which I were using the global vectors and not the local vectors, where it is possible, as Matt suggested.<div><br></div><div>Miguel</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 11:22 AM, Abhyankar, Shrirang G. <span dir="ltr"><<a href="mailto:abhyshr@mcs.anl.gov" target="_blank">abhyshr@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
From:  Miguel Angel Salazar de Troya <<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>><br>
Date:  Mon, 29 Sep 2014 16:55:14 -0500<br>
To:  Shri <<a href="mailto:abhyshr@mcs.anl.gov">abhyshr@mcs.anl.gov</a>><br>
Cc:  "<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>" <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<span class="">Subject:  Re: [petsc-users] DMPlex with spring elements<br>
<br>
<br>
</span><span class="">>Hi all<br>
>I'm bumping this post because I have more questions related to the same<br>
>problem.<br>
><br>
>I am looping over the edges of my DMNetwork, then I obtain the vertices<br>
>that make up each edge with DMNetworkGetConnectedNode(). Each of these<br>
>vertices have two variables (or actually, two degrees of freedom for my<br>
>problem). My intentions are to modify the solution vector entries that<br>
>are affected by these variables in each vertex. I would call the function<br>
>DMNetworkGetVariableOffset() to do this. What happens if one of the<br>
>vertices is a ghost vertex? Can I still modify the solution vector? My<br>
>problem is that the edge has information to provide to these nodes.<br>
><br>
><br>
<br>
</span>Sorry for the delay. I think you would want to use<br>
<a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMNetworkIsG
hostVertex.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMNetworkIsG<br>
hostVertex.html</a> and not modify the value for the ghost vertex.<br>
<br>
Shri<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
>Thanks<br>
>Miguel<br>
><br>
><br>
><br>
>On Fri, Sep 26, 2014 at 12:33 PM, Miguel Angel Salazar de Troya<br>
><<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>> wrote:<br>
><br>
>I understand. Thanks a lot.<br>
>Miguel<br>
><br>
><br>
>On Fri, Sep 26, 2014 at 10:53 AM, Abhyankar, Shrirang G.<br>
><<a href="mailto:abhyshr@mcs.anl.gov">abhyshr@mcs.anl.gov</a>> wrote:<br>
><br>
>What Matt is saying is that there are two interfaces in PETSc for setting<br>
>the residual evaluation routine:<br>
><br>
>i) SNESSetFunction takes in a function pointer for the residual evaluation<br>
>routine that has the prototype<br>
>                 PetscErrorCode xyzroutine(SNES snes, Vec X, Vec F, void*<br>
>ctx);<br>
><br>
>X and F are the "global" solution and residual vectors. To compute the<br>
>global residual evaluation, typically one does -- (a) scattering X and F<br>
>onto local vectors localX and localF (DMGlobalToLocal), (b) computing the<br>
>local residual, and (c) gathering the localF in the global F<br>
>(DMLocalToGlobal). This is what is done in the example.<br>
><br>
>ii) DMSNESSetFunctionLocal takes in a function pointer for the residual<br>
>evaluation routine that has the prototype<br>
>                 PetscErrorCode xyzlocalroutine(DM, Vec localX, localF,<br>
>void* ctx)<br>
><br>
>In this case, the localX and localF get passed to the routine. So, you<br>
>only have to do the local residual evaluation. PETSc does the<br>
>LocalToGlobal gather to form the global residual.<br>
><br>
>I chose to use SNESSetFunction in the example. You can use either of them.<br>
><br>
>Shri<br>
><br>
>From:  Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
>Date:  Fri, 26 Sep 2014 10:28:26 -0500<br>
>To:  Miguel Angel Salazar de Troya <<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>><br>
>Cc:  Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>>, Shri <<a href="mailto:abhyshr@mcs.anl.gov">abhyshr@mcs.anl.gov</a>>,<br>
>"<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>" <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
>Subject:  Re: [petsc-users] DMPlex with spring elements<br>
><br>
><br>
>>On Fri, Sep 26, 2014 at 10:26 AM, Miguel Angel Salazar de Troya<br>
>><<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>> wrote:<br>
>><br>
>>Yeah, but doesn't it only work with the local vectors localX and localF?<br>
>><br>
>><br>
>><br>
>>I am telling you what the interface for the functions is. You can do<br>
>>whatever you want inside.<br>
>><br>
>>  Matt<br>
>><br>
>><br>
>>Miguel<br>
>><br>
>>On Fri, Sep 26, 2014 at 10:10 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
>>wrote:<br>
>><br>
>>On Fri, Sep 26, 2014 at 10:06 AM, Miguel Angel Salazar de Troya<br>
>><<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>> wrote:<br>
>><br>
>>That means that if we call SNESSetFunction() we don't build the residual<br>
>>vector in parallel? In the pflow example<br>
>>(<a href="http://www.mcs.anl.gov/petsc/petsc-as/petsc-current/src/snes/examples/tu" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/petsc-current/src/snes/examples/tu</a><br>
>>t<br>
>>orials/network/pflow/pf.c.html) the function FormFunction() (Input for<br>
>>SNESSetFunction() works with the local vectors. I don't understand this.<br>
>><br>
>><br>
>><br>
>>FormFunction() in that link clearly takes in a global vector X and<br>
>>returns a global vector F. Inside, it<br>
>>converts them to local vectors. This is exactly what you would do for a<br>
>>function given to SNESSetFunction().<br>
>><br>
>>  Matt<br>
>><br>
>><br>
>><br>
>>Thanks<br>
>>Miguel<br>
>><br>
>><br>
>>On Fri, Sep 26, 2014 at 9:34 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
>>wrote:<br>
>><br>
>>On Fri, Sep 26, 2014 at 9:31 AM, Miguel Angel Salazar de Troya<br>
>><<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>> wrote:<br>
>><br>
>>Thanks. I had another question about the DM and SNES and TS. There are<br>
>>similar routines to assign the residual and jacobian evaluation to both<br>
>>objects. For the SNES case are:<br>
>>DMSNESSetFunctionLocal<br>
>>DMSNESSetJacobianLocal<br>
>><br>
>>What are the differences of these with:<br>
>><br>
>>SNESSetFunction<br>
>>SNESSetJacobian<br>
>><br>
>><br>
>><br>
>><br>
>>SNESSetFunction() expects the user to construct the entire parallel<br>
>>residual vector. DMSNESSetFunctionLocal()<br>
>>expects the user to construct the local pieces of the residual, and then<br>
>>it automatically calls DMLocalToGlobal()<br>
>>to assembly the full residual. It also converts the input from global<br>
>>vectors to local vectors, and in the case of<br>
>>DMDA multidimensional arrays.<br>
>><br>
>>  Thanks,<br>
>><br>
>>    Matt<br>
>><br>
>><br>
>>and when should we use each? With "Local", it is meant to evaluate the<br>
>>function/jacobian for the elements in the local processor? I could get<br>
>>the local edges in DMNetwork by calling DMNetworkGetEdgeRange?<br>
>><br>
>>Miguel<br>
>><br>
>><br>
>>On Thu, Sep 25, 2014 at 5:17 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
>>wrote:<br>
>><br>
>><br>
>><br>
>>On Thu, Sep 25, 2014 at 5:15 PM, Miguel Angel Salazar de Troya<br>
>><<a href="mailto:salazardetroya@gmail.com">salazardetroya@gmail.com</a>> wrote:<br>
>><br>
>>> If you need a symmetric Jacobian, you can use the BC facility in<br>
>>> PetscSection, which eliminates the<br>
>>> variables completely. This is how the FEM examples, like ex12, work.<br>
>>Would that be with PetscSectionSetConstraintDof ? For that I will need<br>
>>the PetscSection, DofSection, within DMNetwork, how can I obtain it? I<br>
>>could cast it to DM_Network from the dm, networkdm,  declared in the main<br>
>>program, maybe something like this:<br>
>>DM_Network     *network = (DM_Network*) networkdm->data;Then I would loop<br>
>>over the vertices and call PetscSectionSetConstraintDof if it's a<br>
>>boundary node (by checking the corresponding component)<br>
>><br>
>><br>
>><br>
>><br>
>>I admit to not completely understanding DMNetwork. However, it eventually<br>
>>builds a PetscSection for data layout, which<br>
>>you could get from DMGetDefaultSection(). The right thing to do is find<br>
>>where it builds the Section, and put in your BC<br>
>>there, but that sounds like it would entail coding.<br>
>><br>
>>  Thanks,<br>
>><br>
>>     Matt<br>
>><br>
>><br>
>><br>
>><br>
>>Thanks for your responses.Miguel<br>
>><br>
>><br>
>><br>
>><br>
>>On Thu, Sep 25, 2014 at 2:42 PM, Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br>
>><br>
>>Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> writes:<br>
>><br>
>>> On Thu, Sep 25, 2014 at 1:46 PM, Abhyankar, Shrirang G.<br>
>>><<a href="mailto:abhyshr@mcs.anl.gov">abhyshr@mcs.anl.gov</a><br>
>>>> wrote:<br>
>>><br>
>>>> You are right. The Jacobian for the power grid application is indeed<br>
>>>> non-symmetric. Is that a problem for your application?<br>
>>>><br>
>>><br>
>>> If you need a symmetric Jacobian, you can use the BC facility in<br>
>>> PetscSection, which eliminates the<br>
>>> variables completely. This is how the FEM examples, like ex12, work.<br>
>><br>
>>You can also use MatZeroRowsColumns() or do the equivalent<br>
>>transformation during assembly (my preference).<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>Miguel Angel Salazar de Troya<br>
>><br>
>><br>
>>Graduate Research Assistant<br>
>>Department of Mechanical Science and Engineering<br>
>>University of Illinois at Urbana-Champaign<br>
><br>
><br>
>>(217) 550-2360 <tel:%28217%29%20550-2360><br>
>><br>
>><br>
>><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>What most experimenters take for granted before they begin their<br>
>>experiments is infinitely more interesting than any results to which<br>
>>their experiments lead.<br>
>>-- Norbert Wiener<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>Miguel Angel Salazar de Troya<br>
>>Graduate Research Assistant<br>
>>Department of Mechanical Science and Engineering<br>
>>University of Illinois at Urbana-Champaign<br>
>>(217) 550-2360 <tel:%28217%29%20550-2360><br>
>><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>What most experimenters take for granted before they begin their<br>
>>experiments is infinitely more interesting than any results to which<br>
>>their experiments lead.<br>
>>-- Norbert Wiener<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>Miguel Angel Salazar de Troya<br>
>>Graduate Research Assistant<br>
>>Department of Mechanical Science and Engineering<br>
>>University of Illinois at Urbana-Champaign<br>
>>(217) 550-2360 <tel:%28217%29%20550-2360><br>
>><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>What most experimenters take for granted before they begin their<br>
>>experiments is infinitely more interesting than any results to which<br>
>>their experiments lead.<br>
>>-- Norbert Wiener<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>Miguel Angel Salazar de Troya<br>
>>Graduate Research Assistant<br>
>>Department of Mechanical Science and Engineering<br>
>>University of Illinois at Urbana-Champaign<br>
>>(217) 550-2360 <tel:%28217%29%20550-2360><br>
>><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>>--<br>
>>What most experimenters take for granted before they begin their<br>
>>experiments is infinitely more interesting than any results to which<br>
>>their experiments lead.<br>
>>-- Norbert Wiener<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
>--<br>
><br>
><br>
>Miguel Angel Salazar de Troya<br>
><br>
><br>
>Graduate Research Assistant<br>
>Department of Mechanical Science and Engineering<br>
>University of Illinois at Urbana-Champaign<br>
>(217) 550-2360<br>
><br>
><br>
><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
>--<br>
>Miguel Angel Salazar de Troya<br>
>Graduate Research Assistant<br>
>Department of Mechanical Science and Engineering<br>
>University of Illinois at Urbana-Champaign<br>
>(217) 550-2360<br>
><a href="mailto:salaza11@illinois.edu">salaza11@illinois.edu</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font face="verdana, sans-serif"><b>Miguel Angel Salazar de Troya</b></font><span><font color="#888888"><br><font face="arial,helvetica,sans-serif">Graduate Research Assistant<br>Department of Mechanical Science and Engineering<br></font>University of Illinois at Urbana-Champaign<br>(217) 550-2360<br>
<a href="mailto:salaza11@illinois.edu" target="_blank">salaza11@illinois.edu</a></font></span><div><br></div></div>
</div>