[petsc-users] dof>1 vector tools

Edward Bueler elbueler at alaska.edu
Sun Nov 14 13:46:04 CST 2010


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.

Same question for VecNorm: norm just an identified component?

Ed


-- 
**********************************
Ed Bueler
474-7693     (fax 474-5394)
Dept of Mathematics and Statistics
301C Chapman Hall, Univ of Alaska
Fairbanks, AK 99775-6660
www.dms.uaf.edu/~bueler
**********************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101114/564734d3/attachment.htm>


More information about the petsc-users mailing list