[petsc-users] dof>1 vector tools

Jed Brown jed at 59A2.org
Sun Nov 14 14:15:41 CST 2010


On Sun, Nov 14, 2010 at 20:46, Edward Bueler <elbueler at alaska.edu> wrote:

> Dear PETSc--
>
> This is an actual user request.  I am working on a typical PETSc task
> involving two nonlinear PDEs coupled together.  I notice that there are
> several tools for Vecs which don't help much when I have a dof>1 Vec from my
> DA, for which the components have different scaling.  Thus VecNorm and
> VecScale are not really what I want.  Is there a plan for component-wise
> versions of those?
>
> For example, is there a better/quicker way to scale one component of a
> dof>1 DA-derived Vec than writing my own, something like this:
>
>   typedef struct {
>      PetscReal H, u;
>   } Node;
>   ierr =
> DACreate1d(PETSC_COMM_WORLD,DA_NONPERIODIC,-M,2,1,PETSC_NULL,&da);CHKERRQ(ierr);
>   ierr = DACreateGlobalVector(da,&v);CHKERRQ(ierr);
>   ...
>   Node           *n;
>   ierr = DAVecGetArray(da,v,&n);CHKERRQ(ierr);
>   for (i = xs; i < xs + xm; i++) {
>     n[i].u *= alpha;
>   }
>   ierr = DAVecRestoreArray(da,v,&n);CHKERRQ(ierr);
>
> I guess I would want the loop to be replaced by
> "DAVecScaleDOF(da,v,k,alpha)" for k=0,...,dof-1.
>

It's spelled VecStrideScale().

Same question for VecNorm: norm just an identified component?
>

You guessed it, VecStrideNorm()


But, I actually recommend nondimensionalizing (in the sense of ex48, not in
terms on nondimensional numbers which tend to have imprecise definitions for
complex geometry or multi-physics) so that these component norms are not
needed by the solvers, as the nondimensional system will generally produce a
better conditioned algebraic system.

Jed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101114/10a40053/attachment.htm>


More information about the petsc-users mailing list