[petsc-users] Compute norm of a single component of DMDAVec struct

Peter Brune prbrune at gmail.com
Thu Mar 20 11:10:41 CDT 2014


You could use

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/DMCreateFieldDecomposition.html

to get DMDAs representing the layout of the individual components and
DMCreateGlobalVector() on those DMDAs to get properly laid-out individual
field vectors.  Then, you would use the ISes given by this function to
build VecScatters using

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreate.html

 from the monolithic vector to the component ones.  Then apply the scatter
and do whatever you want with those vectors (take norms, etc.)

Hope this helps.

- Peter


On Thu, Mar 20, 2014 at 10:38 AM, Mark Lohry <mlohry at gmail.com> wrote:

> I'm using a struct for a multi-component PDE as suggested in the manual,
> like so:
>
> typedef struct {
> PetscScalar u,v,omega,temperature;
> } Node;
> Node **f,**u;
> DMDAVecGetArray(DM da,Vec local,&u);
> DMDAVecGetArray(DM da,Vec global,&f);
>
>
> Calling VecNorm(...) on these vectors gives a norm for the entire vector.
> If one wants separate norms for each component of the struct, i.e. Norm(u)
> or Norm(v), what's the right approach? Would I need to manually compute
> norms locally and then call an MPI reduce function, or is this ability
> built-in to PETSc somewhere?
>
>
> -Mark Lohry
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140320/68ccaf15/attachment.html>


More information about the petsc-users mailing list