[petsc-users] What are the differences between ex11.c and ex11_sa.c
Matthew Knepley
knepley at gmail.com
Fri Nov 25 10:03:30 CST 2016
On Fri, Nov 25, 2016 at 9:09 AM, leejearl <leejearl at 126.com> wrote:
> Hi, Matt:
> Thank you for your kind reply, and I can not make it.
> I replace the code in the routine SetInitialCondition in ex11.c as
>
> #undef __FUNCT__
> #define __FUNCT__ "SetInitialCondition"
> PetscErrorCode SetInitialCondition(DM dm, Vec X, User user)
> {
> DM dmCell;
> Model mod = user->model;
> Vec cellgeom;
> const PetscScalar *cgeom;
> PetscScalar *x;
> PetscInt cStart, cEnd, cEndInterior, c;
> PetscErrorCode ierr;
>
> PetscFunctionBeginUser;
> ierr = DMPlexGetHybridBounds(dm, &cEndInterior, NULL, NULL,
> NULL);CHKERRQ(ierr);
> ierr = DMPlexTSGetGeometryFVM(dm, NULL, &cellgeom, NULL);CHKERRQ(ierr);
> ierr = VecGetDM(cellgeom, &dmCell);CHKERRQ(ierr);
> ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr);
> ierr = VecGetArrayRead(cellgeom, &cgeom);CHKERRQ(ierr);
> ierr = VecGetArray(X, &x);CHKERRQ(ierr);
> for (c = cStart; c < cEndInterior; ++c) {
> const PetscFVCellGeom *cg;
> PetscScalar *xc;
>
> ierr = DMPlexPointLocalRead(dmCell,c,cgeom,&cg);CHKERRQ(ierr);
> ierr = DMPlexPointGlobalRef(dm,c,x,&xc);CHKERRQ(ierr);
> /*if (xc) {ierr = (*mod->solution)(mod,0.0,cg->
> centroid,xc,mod->solutionctx);CHKERRQ(ierr);}*/
> xc[0] = =1.0;
> xc[1] = =2.0;
> xc[2] = =3.0;
> xc[3] = =4.0;
> }
> ierr = VecRestoreArrayRead(cellgeom, &cgeom);CHKERRQ(ierr);
> ierr = VecRestoreArray(X, &x);CHKERRQ(ierr);
> PetscFunctionReturn(0);
> }
>
> I find it works in serial computation. Can you tell me whether I have a
> wrong use of the xc in the routine?
>
If you want to initialize 4 fields to the constants 1, 2, 3, 4 then this
should work.
Matt
> Thanks
>
> leejearl
>
> On 2016年11月25日 22:53, Matthew Knepley wrote:
>
> On Fri, Nov 25, 2016 at 8:43 AM, leejearl <leejearl at 126.com> wrote:
>
>> Hello, Petsc developer:
>>
>> I find two files ex11.c and ex11_sa.c in the directory of
>> "/petsc/src/ts/examples/tutorials".
>>
>> Can you tell me what are the differences between them? What is the
>> meaning of the “suffix”?
>>
>
> I think Jed wanted his original version, but I don'y know what _sa means.
>
> Thanks,
>
> Matt
>
>
>> Thanks!
>>
>> leejearl
>>
>>
>>
>>
>
>
> --
> 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
>
>
>
--
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/20161125/a83852e8/attachment.html>
More information about the petsc-users
mailing list