[petsc-users] help about my ts program
Barry Smith
bsmith at mcs.anl.gov
Fri Jul 2 13:12:41 CDT 2010
You still need to tell it what TS method you want, such as -ts_type beuler
It just defaults to euler if you don't tell it anything.
Barry
On Jul 2, 2010, at 1:08 PM, Xuan YU wrote:
>
> On Jun 23, 2010, at 10:44 AM, Jed Brown wrote:
>
>> On Wed, 23 Jun 2010 10:22:19 -0400, Xuan YU <xxy113 at psu.edu> wrote:
>>> I got the correct results! Thanks!
>>>
>>> Could you please tell me whether I can use TS to solve ODE without
>>> providing Jacobian matrix?
>>
>> Sure, use -snes_mf to solve it without assembling any matrix (linear
>> systems are solved with an unpreconditioned Krylov method). Note that
>> this usually will not converge for larger problems. To assemble a dense
>> matrix by finite differencing, you can use -snes_fd.
>
> If I don't provide Jacobian, it will be: type: euler
> total number of nonlinear solver iterations=0
> total number of linear solver iterations=0
>
>
>
>
>
>>
>> To use coloring to compute a sparse matrix efficiently, you have to know
>> the sparsity pattern of the Jacobian, try something like (this is
>> somewhat different in petsc-dev than release).
>>
>> ISColoring iscoloring;
>> ierr = DAGetColoring(rd->da,IS_COLORING_GLOBAL,MATAIJ,&iscoloring);CHKERRQ(ierr);
>> ierr = MatFDColoringCreate(B,iscoloring,&matfdcoloring);CHKERRQ(ierr);
>> ierr = ISColoringDestroy(iscoloring);CHKERRQ(ierr);
>> ierr = MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode(*)(void))SNESTSFormFunction,ts);CHKERRQ(ierr);
>> ierr = MatFDColoringSetFromOptions(matfdcoloring);CHKERRQ(ierr);
>> ierr = SNESSetJacobian(snes,A,B,SNESDefaultComputeJacobianColor,matfdcoloring);CHKERRQ(ierr);
>>
>> Jed
>>
>
>
> Now I added coloring
>
> ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
> ierr = TSSetProblemType(ts,TS_NONLINEAR);CHKERRQ(ierr);
> ierr = TSMonitorSet(ts,Monitor,&appctx,PETSC_NULL);CHKERRQ(ierr);
> ierr = TSSetSolution(ts,CV_Y);CHKERRQ(ierr);
> ierr = TSSetRHSFunction(ts,f,&appctx);CHKERRQ(ierr);
> ierr=DACreate2d(PETSC_COMM_WORLD,DA_NONPERIODIC,DA_STENCIL_STAR,1,1,PETSC_DECIDE,PETSC_DECIDE,
> 1,1,PETSC_NULL,PETSC_NULL,&da);CHKERRQ(ierr);
> DACreateGlobalVector(da,&CV_Y);
> ierr = DAGetColoring(da,IS_COLORING_GLOBAL,MATAIJ,&iscoloring);CHKERRQ(ierr);
> DAGetMatrix(da,MATAIJ,&J);
> MatFDColoringCreate(J,iscoloring,&matfdcoloring);
> ISColoringDestroy(iscoloring);
> ierr = MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode (*)(void))f,da);CHKERRQ(ierr);
> MatFDColoringSetFromOptions(matfdcoloring);
> TSSetRHSJacobian(ts,J,J,TSDefaultComputeJacobianColor,matfdcoloring);
> ierr = TSSetType(ts,TSPSEUDO);CHKERRQ(ierr);
> ierr = TSSetInitialTimeStep(ts,0,1.0);CHKERRQ(ierr);
> ierr = TSSetDuration(ts,cData.EndTime,cData.EndTime);CHKERRQ(ierr);
> ierr = TSSetFromOptions(ts);CHKERRQ(ierr);
> ierr = TSSetUp(ts);CHKERRQ(ierr);
> ierr = TSStep(ts,&its,&ftime);CHKERRQ(ierr);
>
>
> When I run the code, I got the following:
>
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Floating point exception!
> [0]PETSC ERROR: User provided compute function generated a Not-a-Number!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 2, Fri Apr 30 20:23:44 CDT 2010
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: ./pihm on a linux-gnu named lionxi.rcc.psu.edu by xxy113 Fri Jul 2 13:53:44 2010
> [0]PETSC ERROR: Libraries linked from /gpfs/home/xxy113/soft/petsc-3.1-p2/linux-gnu-c-debug/lib
> [0]PETSC ERROR: Configure run at Tue May 11 13:53:58 2010
> [0]PETSC ERROR: Configure options --with-cc=gcc --download-f-blas-lapack=1 --download-mpich=1
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: SNESSolve_LS() line 168 in src/snes/impls/ls/ls.c
> [0]PETSC ERROR: SNESSolve() line 2255 in src/snes/interface/snes.c
> [0]PETSC ERROR: TSStep_Pseudo() line 163 in src/ts/impls/pseudo/posindep.c
> [0]PETSC ERROR: TSStep() line 1693 in src/ts/interface/ts.c
> [0]PETSC ERROR: User provided function() line 216 in /work/petsc/pihm.c(which is ierr = TSStep(ts,&its,&ftime);CHKERRQ(ierr);)
>
> Could you please tell me how to check where is my problem?
>
>
> Xuan YU
> xxy113 at psu.edu
>
>
>
>
More information about the petsc-users
mailing list