[petsc-users] TS and SNES

Konstantinos Kontzialis ckontzialis at lycos.com
Tue Nov 8 04:14:44 CST 2011


Deall all,

I perform a simulation over a cylinder at M=0.14 using the Euler 
equations. The explicit part works.

But,  when I go for the implicit solution I code:

ierr = TSCreate(sys.comm, &sys.ts);
     CHKERRQ(ierr);

     ierr = TSSetProblemType(sys.ts, TS_NONLINEAR);
     CHKERRQ(ierr);

     ierr = TSSetSolution(sys.ts, sys.gsv);
     CHKERRQ(ierr);

     ierr = TSSetIFunction(sys.ts, PETSC_NULL, base_residual_implicit, 
&sys);
     CHKERRQ(ierr);

     ierr = TSGetSNES(sys.ts, &sys.snes);
     CHKERRQ(ierr);

     ierr = MatCreateSNESMF(sys.snes, &sys.J);
     CHKERRQ(ierr);

     ISColoring iscoloring;
     MatFDColoring matfdcoloring;

     ierr = jacobian_diff_numerical(sys, &sys.P);
     CHKERRQ(ierr);

     ierr = MatGetColoring(sys.P, MATCOLORINGSL, &iscoloring);
     CHKERRQ(ierr);

     ierr = MatFDColoringCreate(sys.P, iscoloring, &matfdcoloring);
     CHKERRQ(ierr);

     ierr = MatFDColoringSetFunction(matfdcoloring,
             (PetscErrorCode(*)(void)) SNESTSFormFunction, sys.ts);
     CHKERRQ(ierr);

     ierr = MatFDColoringSetFromOptions(matfdcoloring);
     CHKERRQ(ierr);

     ierr = ISColoringDestroy(&iscoloring);
     CHKERRQ(ierr);

     ierr = SNESSetJacobian(sys.snes, sys.J, sys.P,
             SNESDefaultComputeJacobianColor, matfdcoloring);
     CHKERRQ(ierr);

     ierr = TSSetInitialTimeStep(sys.ts, sys.con->tm, sys.con->dt);
     CHKERRQ(ierr);

     ierr = TSSetDuration(sys.ts, 100e+6, sys.con->etime);
     CHKERRQ(ierr);

     ierr = TSMonitorSet(sys.ts, monitor, &sys, PETSC_NULL);
     CHKERRQ(ierr);

     ierr = TSSetFromOptions(sys.ts);
     CHKERRQ(ierr);

     ierr = TSSolve(sys.ts, sys.gsv, &sys.con->etime);
     CHKERRQ(ierr);


I run with:

mpiexec -n 1 ./hoac cylinder -snes_mf_operator -llf_flux -n_out 10 
-end_time 5 -implicit -pc_type asm -sub_pc_type ilu 
-sub_pc_factor_mat_ordering_type rcm -gl -ksp_type gmres 
-sub_pc_factor_levels 0 -dt 1.0e-1 -snes_monitor -snes_converged_reason 
-ksp_converged_reason -ts_view -ts_type beuler

and I get:

Approximation order = 0
# DOF = 1520
# nodes in mesh = 400
# elements in mesh = 380
Euler solution
Using LLF flux


Linear solve converged due to CONVERGED_RTOL iterations 1
[0]PETSC ERROR: --------------------- Error Message 
------------------------------------
[0]PETSC ERROR: Object is in wrong state!
[0]PETSC ERROR: Must call SNESSetFunction() or SNESSetDM() first!
[0]PETSC ERROR: 
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29 
13:45:54 CDT 2011
[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: ./hoac on a linux-gnu named PlusSodaL by kontzialis Tue 
Nov  8 12:11:04 2011
[0]PETSC ERROR: Libraries linked from 
/home/kontzialis/petsc-3.2-p5/linux-gnu-c-debug/lib
[0]PETSC ERROR: Configure run at Sat Nov  5 20:58:12 2011
[0]PETSC ERROR: Configure options --with-debugging=1 
---with-mpi-dir=/usr/lib64/mpich2/bin --with-shared-libraries 
--with-shared-libraries --with-large-file-io=1 --with-precision=double 
--with-blacs=1 --download-blacs=yes --download-f-blas-lapack=yes 
--with-plapack=1 --download-plapack=yes --with-scalapack=1 
--download-scalapack=yes --with-superlu=1 --download-superlu=yes 
--with-superlu_dist=1 --download-superlu_dist=yes --with-ml=1 
--download-ml=yes --with-umfpack=1 --download-umfpack=yes --with-mpi=1 
--download-mpich=1 --with-sundials=1 --download-sundials=1 
--with-parmetis=1 --download-parmetis=1 --with-hypre=1 --download-hypre=1
[0]PETSC ERROR: 
------------------------------------------------------------------------
[0]PETSC ERROR: MatCreateSNESMF() line 142 in 
/home/kontzialis/petsc-3.2-p5/src/snes/mf/snesmfj.c
[0]PETSC ERROR: implicit_time() line 38 in 
"unknowndirectory/"../src/implicit_time.c
[0]PETSC ERROR: main() line 1176 in "unknowndirectory/"../src/hoac.c
application called MPI_Abort(MPI_COMM_WORLD, 73) - process 0
[cli_0]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 73) - process 0

What am I doing wrong?

Thank you,

Kostas


More information about the petsc-users mailing list