Actual source code: tscreate.c
petsc-3.10.5 2019-03-28
Report Typos and Errors

      1:  #include <petsc/private/tsimpl.h>

      3: const char *const TSConvergedReasons_Shifted[] = {
      4:   "DIVERGED_STEP_REJECTED",
      5:   "DIVERGED_NONLINEAR_SOLVE",
      6:   "CONVERGED_ITERATING",
      7:   "CONVERGED_TIME",
      8:   "CONVERGED_ITS",
      9:   "CONVERGED_USER",
     10:   "CONVERGED_EVENT",
     11:   "CONVERGED_PSEUDO_FATOL",
     12:   "CONVERGED_PSEUDO_FATOL",
     13:   "TSConvergedReason","TS_",0};
     14: const char *const*TSConvergedReasons = TSConvergedReasons_Shifted + 2;

     16: /*@C
     17:   TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the
     18:        type of solver can then be set with TSSetType().

     20:   Collective on MPI_Comm

     22:   Input Parameter:
     23: . comm - The communicator

     25:   Output Parameter:
     26: . ts   - The TS

     28:   Level: beginner

     30:   Developer Notes:
     31:     TS essentially always creates a SNES object even though explicit methods do not use it. This is
     32:                     unfortunate and should be fixed at some point. The flag snes->usessnes indicates if the
     33:                     particular method does use SNES and regulates if the information about the SNES is printed
     34:                     in TSView(). TSSetFromOptions() does call SNESSetFromOptions() which can lead to users being confused
     35:                     by help messages about meaningless SNES options.

     37: .keywords: TS, create
     38: .seealso: TSSetType(), TSSetUp(), TSDestroy(), TSSetProblemType()
     39: @*/
     40: PetscErrorCode  TSCreate(MPI_Comm comm, TS *ts)
     41: {
     42:   TS             t;

     47:   *ts = NULL;
     48:   TSInitializePackage();

     50:   PetscHeaderCreate(t, TS_CLASSID, "TS", "Time stepping", "TS", comm, TSDestroy, TSView);

     52:   /* General TS description */
     53:   t->problem_type      = TS_NONLINEAR;
     54:   t->equation_type     = TS_EQ_UNSPECIFIED;

     56:   t->ptime             = 0.0;
     57:   t->time_step         = 0.1;
     58:   t->max_time          = PETSC_MAX_REAL;
     59:   t->exact_final_time  = TS_EXACTFINALTIME_UNSPECIFIED;
     60:   t->steps             = 0;
     61:   t->max_steps         = PETSC_MAX_INT;
     62:   t->steprestart       = PETSC_TRUE;

     64:   t->max_snes_failures = 1;
     65:   t->max_reject        = 10;
     66:   t->errorifstepfailed = PETSC_TRUE;

     68:   t->rhsjacobian.time  = PETSC_MIN_REAL;
     69:   t->rhsjacobian.scale = 1.0;
     70:   t->ijacobian.shift   = 1.0;

     72:   /* All methods that do adaptivity should specify
     73:    * its preferred adapt type in their constructor */
     74:   t->default_adapt_type = TSADAPTNONE;
     75:   t->atol               = 1e-4;
     76:   t->rtol               = 1e-4;
     77:   t->cfltime            = PETSC_MAX_REAL;
     78:   t->cfltime_local      = PETSC_MAX_REAL;

     80:   t->num_rhs_splits     = 0;

     82:   *ts = t;
     83:   return(0);
     84: }