xref: /petsc/src/ts/interface/tscreate.c (revision ef85077e430a7477173c3b1902f00a822867af81)
1af0996ceSBarry Smith #include <petsc/private/tsimpl.h>      /*I "petscts.h"  I*/
2bdad233fSMatthew Knepley 
3193ac0bcSJed Brown const char *const TSConvergedReasons_Shifted[] = {
4193ac0bcSJed Brown   "DIVERGED_STEP_REJECTED",
5193ac0bcSJed Brown   "DIVERGED_NONLINEAR_SOLVE",
6193ac0bcSJed Brown   "CONVERGED_ITERATING",
7193ac0bcSJed Brown   "CONVERGED_TIME",
8193ac0bcSJed Brown   "CONVERGED_ITS",
93118ae5eSBarry Smith   "CONVERGED_USER",
103118ae5eSBarry Smith   "CONVERGED_EVENT",
113118ae5eSBarry Smith   "CONVERGED_PSEUDO_FATOL",
123118ae5eSBarry Smith   "CONVERGED_PSEUDO_FATOL",
13193ac0bcSJed Brown   "TSConvergedReason","TS_",0};
14193ac0bcSJed Brown const char *const*TSConvergedReasons = TSConvergedReasons_Shifted + 2;
15193ac0bcSJed Brown 
1660893bc3SSatish Balay /*@C
17bd6a702fSBarry Smith   TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the
18bd6a702fSBarry Smith        type of solver can then be set with TSSetType().
19bdad233fSMatthew Knepley 
20bdad233fSMatthew Knepley   Collective on MPI_Comm
21bdad233fSMatthew Knepley 
22bdad233fSMatthew Knepley   Input Parameter:
23bdad233fSMatthew Knepley . comm - The communicator
24bdad233fSMatthew Knepley 
25bdad233fSMatthew Knepley   Output Parameter:
26bdad233fSMatthew Knepley . ts   - The TS
27bdad233fSMatthew Knepley 
28bdad233fSMatthew Knepley   Level: beginner
29bdad233fSMatthew Knepley 
30efd4aadfSBarry Smith   Developer Notes:  TS essentially always creates a SNES object even though explicit methods do not use it. This is
31efd4aadfSBarry Smith                     unfortunate and should be fixed at some point. The flag snes->usessnes indicates if the
32efd4aadfSBarry Smith                     particular method does use SNES and regulates if the information about the SNES is printed
33efd4aadfSBarry Smith                     in TSView(). TSSetFromOptions() does call SNESSetFromOptions() which can lead to users being confused
34efd4aadfSBarry Smith                     by help messages about meaningless SNES options.
35efd4aadfSBarry Smith 
36bdad233fSMatthew Knepley .keywords: TS, create
3704ceabe5SMatthew G. Knepley .seealso: TSSetType(), TSSetUp(), TSDestroy(), TSSetProblemType()
38bdad233fSMatthew Knepley @*/
390adebc6cSBarry Smith PetscErrorCode  TSCreate(MPI_Comm comm, TS *ts)
400adebc6cSBarry Smith {
41bdad233fSMatthew Knepley   TS             t;
42dfbe8321SBarry Smith   PetscErrorCode ierr;
43bdad233fSMatthew Knepley 
44bdad233fSMatthew Knepley   PetscFunctionBegin;
454482741eSBarry Smith   PetscValidPointer(ts,1);
460298fd71SBarry Smith   *ts = NULL;
47607a6623SBarry Smith   ierr = TSInitializePackage();CHKERRQ(ierr);
48bdad233fSMatthew Knepley 
4973107ff1SLisandro Dalcin   ierr = PetscHeaderCreate(t, TS_CLASSID, "TS", "Time stepping", "TS", comm, TSDestroy, TSView);CHKERRQ(ierr);
50bdad233fSMatthew Knepley 
51bdad233fSMatthew Knepley   /* General TS description */
52089b2837SJed Brown   t->problem_type      = TS_NONLINEAR;
53*ef85077eSLisandro Dalcin   t->equation_type     = TS_EQ_UNSPECIFIED;
54*ef85077eSLisandro Dalcin 
55cdbf8f93SLisandro Dalcin   t->ptime             = 0.0;
56cdbf8f93SLisandro Dalcin   t->time_step         = 0.1;
57*ef85077eSLisandro Dalcin   t->max_time          = PETSC_MAX_REAL;
58*ef85077eSLisandro Dalcin   t->exact_final_time  = TS_EXACTFINALTIME_UNSPECIFIED;
59bdad233fSMatthew Knepley   t->steps             = 0;
60*ef85077eSLisandro Dalcin   t->max_steps         = PETSC_MAX_INT;
61*ef85077eSLisandro Dalcin   t->steprestart       = PETSC_TRUE;
62*ef85077eSLisandro Dalcin 
63193ac0bcSJed Brown   t->max_snes_failures = 1;
64193ac0bcSJed Brown   t->max_reject        = 10;
65193ac0bcSJed Brown   t->errorifstepfailed = PETSC_TRUE;
66bdad233fSMatthew Knepley 
67*ef85077eSLisandro Dalcin   t->rhsjacobian.time  = PETSC_MIN_REAL;
68*ef85077eSLisandro Dalcin   t->rhsjacobian.scale = 1.0;
69*ef85077eSLisandro Dalcin   t->ijacobian.shift   = 1.0;
7068bece0bSHong Zhang 
71b92453a8SLisandro Dalcin   /* All methods that do adaptivity should specify
72b92453a8SLisandro Dalcin    * its preferred adapt type in their constructor */
73b92453a8SLisandro Dalcin   t->default_adapt_type = TSADAPTNONE;
74*ef85077eSLisandro Dalcin   t->atol               = 1e-4;
75*ef85077eSLisandro Dalcin   t->rtol               = 1e-4;
76*ef85077eSLisandro Dalcin   t->cfltime            = PETSC_MAX_REAL;
77*ef85077eSLisandro Dalcin   t->cfltime_local      = PETSC_MAX_REAL;
78715f1b00SHong Zhang 
79bdad233fSMatthew Knepley   *ts = t;
80bdad233fSMatthew Knepley   PetscFunctionReturn(0);
81bdad233fSMatthew Knepley }
82