xref: /petsc/src/ts/interface/tscreate.c (revision 8370ee3b0cabe4fc747f6e7e660d1b382033c84c)
1 
2 #include <private/tsimpl.h>      /*I "petscts.h"  I*/
3 
4 const char *const TSConvergedReasons_Shifted[] = {
5   "DIVERGED_STEP_REJECTED",
6   "DIVERGED_NONLINEAR_SOLVE",
7   "CONVERGED_ITERATING",
8   "CONVERGED_TIME",
9   "CONVERGED_ITS",
10   "TSConvergedReason","TS_",0};
11 const char *const*TSConvergedReasons = TSConvergedReasons_Shifted + 2;
12 
13 #if 0
14 #undef __FUNCT__
15 #define __FUNCT__ "TSPublish_Petsc"
16 static PetscErrorCode TSPublish_Petsc(PetscObject obj)
17 {
18   PetscFunctionBegin;
19   PetscFunctionReturn(0);
20 }
21 #endif
22 
23 #undef  __FUNCT__
24 #define __FUNCT__ "TSCreate"
25 /*@C
26   TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the
27        type of solver can then be set with TSSetType().
28 
29   Collective on MPI_Comm
30 
31   Input Parameter:
32 . comm - The communicator
33 
34   Output Parameter:
35 . ts   - The TS
36 
37   Level: beginner
38 
39 .keywords: TS, create
40 .seealso: TSSetType(), TSSetUp(), TSDestroy(), MeshCreate(), TSSetProblemType()
41 @*/
42 PetscErrorCode  TSCreate(MPI_Comm comm, TS *ts) {
43   TS             t;
44   PetscErrorCode ierr;
45 
46   PetscFunctionBegin;
47   PetscValidPointer(ts,1);
48   *ts = PETSC_NULL;
49 #ifndef PETSC_USE_DYNAMIC_LIBRARIES
50   ierr = TSInitializePackage(PETSC_NULL);CHKERRQ(ierr);
51 #endif
52 
53   ierr = PetscHeaderCreate(t, _p_TS, struct _TSOps, TS_CLASSID, -1, "TS", comm, TSDestroy, TSView);CHKERRQ(ierr);
54   ierr = PetscMemzero(t->ops, sizeof(struct _TSOps));CHKERRQ(ierr);
55 
56   ierr = PetscMalloc(sizeof(struct _TSUserOps), &t->userops);
57   t->userops->rhsfunction = 0;
58   t->userops->ifunction   = 0;
59   t->userops->rhsjacobian = 0;
60   t->userops->rhsjacobian = 0;
61   t->userops->ijacobian   = 0;
62 
63   /* General TS description */
64   t->problem_type       = TS_NONLINEAR;
65   t->vec_sol            = PETSC_NULL;
66   t->numbermonitors     = 0;
67   t->snes               = PETSC_NULL;
68   t->funP               = PETSC_NULL;
69   t->jacP               = PETSC_NULL;
70   t->setupcalled        = 0;
71   t->data               = PETSC_NULL;
72   t->user               = PETSC_NULL;
73   t->max_steps          = 5000;
74   t->max_time           = 5.0;
75   t->steps              = 0;
76   t->linear_its         = 0;
77   t->nonlinear_its      = 0;
78   t->work               = PETSC_NULL;
79   t->nwork              = 0;
80   t->max_snes_failures  = 1;
81   t->max_reject         = 10;
82   t->errorifstepfailed  = PETSC_TRUE;
83   t->rhsjacobian.time   = -1e20;
84   t->ijacobian.time     = -1e20;
85 
86   ierr = TSSetInitialTimeStep(t,0.,0.1);CHKERRQ(ierr);
87 
88   *ts = t;
89   PetscFunctionReturn(0);
90 }
91