1af0996ceSBarry Smith #include <petsc/private/tsimpl.h> /*I "petscts.h" I*/
2bdad233fSMatthew Knepley
39371c9d4SSatish Balay const char *const TSConvergedReasons_Shifted[] = {"ADJOINT_DIVERGED_LINEAR_SOLVE", "FORWARD_DIVERGED_LINEAR_SOLVE", "DIVERGED_STEP_REJECTED", "DIVERGED_NONLINEAR_SOLVE", "CONVERGED_ITERATING", "CONVERGED_TIME", "CONVERGED_ITS", "CONVERGED_USER", "CONVERGED_EVENT", "CONVERGED_PSEUDO_FATOL", "CONVERGED_PSEUDO_FATOL", "TSConvergedReason", "TS_", NULL};
422b60d99SBarry Smith const char *const *TSConvergedReasons = TSConvergedReasons_Shifted + 4;
5193ac0bcSJed Brown
6cc4c1da9SBarry Smith /*@
7bcf0153eSBarry Smith TSCreate - This function creates an empty timestepper. The problem type can then be set with `TSSetProblemType()` and the
8bcf0153eSBarry Smith type of solver can then be set with `TSSetType()`.
9bdad233fSMatthew Knepley
10d083f849SBarry Smith Collective
11bdad233fSMatthew Knepley
12bdad233fSMatthew Knepley Input Parameter:
13bdad233fSMatthew Knepley . comm - The communicator
14bdad233fSMatthew Knepley
15bdad233fSMatthew Knepley Output Parameter:
16bcf0153eSBarry Smith . ts - The `TS`
17bdad233fSMatthew Knepley
18bdad233fSMatthew Knepley Level: beginner
19bdad233fSMatthew Knepley
2095452b02SPatrick Sanan Developer Notes:
21bcf0153eSBarry Smith `TS` essentially always creates a `SNES` object even though explicit methods do not use it. This is
22efd4aadfSBarry Smith unfortunate and should be fixed at some point. The flag snes->usessnes indicates if the
23bcf0153eSBarry Smith particular method does use SNES and regulates if the information about the `SNES` is printed
24bcf0153eSBarry Smith in `TSView()`. `TSSetFromOptions(`) does call `SNESSetFromOptions()` which can lead to users being confused
25bcf0153eSBarry Smith by help messages about meaningless `SNES` options.
26efd4aadfSBarry Smith
27*188af4bfSBarry Smith .seealso: [](ch_ts), `TS`, `SNES`, `TSSetType()`, `TSSetUp()`, `TSDestroy()`, `TSSetProblemType()`, `TSSetTimeStep()`
28bdad233fSMatthew Knepley @*/
TSCreate(MPI_Comm comm,TS * ts)29d71ae5a4SJacob Faibussowitsch PetscErrorCode TSCreate(MPI_Comm comm, TS *ts)
30d71ae5a4SJacob Faibussowitsch {
31bdad233fSMatthew Knepley TS t;
32bdad233fSMatthew Knepley
33bdad233fSMatthew Knepley PetscFunctionBegin;
344f572ea9SToby Isaac PetscAssertPointer(ts, 2);
359566063dSJacob Faibussowitsch PetscCall(TSInitializePackage());
36bdad233fSMatthew Knepley
379566063dSJacob Faibussowitsch PetscCall(PetscHeaderCreate(t, TS_CLASSID, "TS", "Time stepping", "TS", comm, TSDestroy, TSView));
38bdad233fSMatthew Knepley
39bdad233fSMatthew Knepley /* General TS description */
40089b2837SJed Brown t->problem_type = TS_NONLINEAR;
41ef85077eSLisandro Dalcin t->equation_type = TS_EQ_UNSPECIFIED;
42ef85077eSLisandro Dalcin
43cdbf8f93SLisandro Dalcin t->ptime = 0.0;
44cdbf8f93SLisandro Dalcin t->time_step = 0.1;
45*188af4bfSBarry Smith t->initial_time_step = t->time_step;
46ef85077eSLisandro Dalcin t->max_time = PETSC_MAX_REAL;
47ef85077eSLisandro Dalcin t->exact_final_time = TS_EXACTFINALTIME_UNSPECIFIED;
48bdad233fSMatthew Knepley t->steps = 0;
498e562f8dSJames Wright PetscObjectParameterSetDefault(t, max_steps, PETSC_INT_MAX);
508e562f8dSJames Wright PetscObjectParameterSetDefault(t, run_steps, PETSC_INT_MAX);
51ef85077eSLisandro Dalcin t->steprestart = PETSC_TRUE;
52ef85077eSLisandro Dalcin
53193ac0bcSJed Brown t->max_snes_failures = 1;
54193ac0bcSJed Brown t->max_reject = 10;
55193ac0bcSJed Brown t->errorifstepfailed = PETSC_TRUE;
56bdad233fSMatthew Knepley
57ef85077eSLisandro Dalcin t->rhsjacobian.time = PETSC_MIN_REAL;
58ef85077eSLisandro Dalcin t->rhsjacobian.scale = 1.0;
59ef85077eSLisandro Dalcin t->ijacobian.shift = 1.0;
6068bece0bSHong Zhang
61b92453a8SLisandro Dalcin /* All methods that do adaptivity should specify
62b92453a8SLisandro Dalcin * its preferred adapt type in their constructor */
63b92453a8SLisandro Dalcin t->default_adapt_type = TSADAPTNONE;
64ef85077eSLisandro Dalcin t->atol = 1e-4;
65ef85077eSLisandro Dalcin t->rtol = 1e-4;
66ef85077eSLisandro Dalcin t->cfltime = PETSC_MAX_REAL;
67ef85077eSLisandro Dalcin t->cfltime_local = PETSC_MAX_REAL;
68715f1b00SHong Zhang
6987f4e208SHong Zhang t->num_rhs_splits = 0;
7087f4e208SHong Zhang
71d60b7d5cSBarry Smith t->axpy_pattern = UNKNOWN_NONZERO_PATTERN;
72bdad233fSMatthew Knepley *ts = t;
733ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
74bdad233fSMatthew Knepley }
75