[petsc-users] sequential Vec question

Matthew Knepley knepley at gmail.com
Fri May 24 13:02:41 CDT 2013


On Fri, May 24, 2013 at 12:53 PM, Zou (Non-US), Ling <ling.zou at inl.gov>wrote:

> Hi All,
>
> For a 1-D problem with multiple variables (u, v, w), it is natural to put
> those unknowns in a Vec for SNES to solve, like,
>
> u0, v0, w0, u1, v1, w1, ... uN, vN, wN
>
> as it would reduce the band width of the Jacobian matrix.
>
> When passing this kind of structure to FormFunction, it is however not
> convenient to access values as you need to jump around to get u(i-1), u(i)
> and u(i+1). It is more convenient to have the structure in an order like
>
> u0, u1, ... uN, v0, v1, ... vN, w0, w1, ... wN
>

No, not at all. That will kill your cache coherence, and generally be very
bad. You can still index as you want, just
use DMDAVecGetArrayDOF(), so that you get

  f[i-1][j][0] --> f_u(i-1,j)
  f[i][j+1][2] --> f_w(i,j+1)

   Matt


> Thus I need some way to map b/w them. I looked at the manual, it seems
> that AO is probably the thing I am looking for. However, there are no
> specific examples for them. I also tried VecScatter, split the original Vec
> to three Vec(s), however, I am not quite sure if it is the right concept to
> use for this kind of scenario.
>
> Does anyone have experience on this topic (I bet it is quite common).
>
>
> Best,
>
> Ling
>



-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130524/2bff410e/attachment.html>


More information about the petsc-users mailing list