xref: /petsc/src/ts/interface/tscreate.c (revision 72ce74bd30d5d09d1371a3eb387704f4af395d1a)
1 
2 #include "src/ts/tsimpl.h"      /*I "petscts.h"  I*/
3 
4 #undef __FUNCT__
5 #define __FUNCT__ "TSPublish_Petsc"
6 static int TSPublish_Petsc(PetscObject obj)
7 {
8 #if defined(PETSC_HAVE_AMS)
9   TS   v = (TS) obj;
10   PetscErrorCode ierr;
11 #endif
12 
13   PetscFunctionBegin;
14 
15 #if defined(PETSC_HAVE_AMS)
16   /* if it is already published then return */
17   if (v->amem >=0) PetscFunctionReturn(0);
18 
19   ierr = PetscObjectPublishBaseBegin(obj);CHKERRQ(ierr);
20   ierr = AMS_Memory_add_field((AMS_Memory)v->amem,"Step",&v->steps,1,AMS_INT,AMS_READ,
21                                 AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRQ(ierr);
22   ierr = AMS_Memory_add_field((AMS_Memory)v->amem,"Time",&v->ptime,1,AMS_DOUBLE,AMS_READ,
23                                 AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRQ(ierr);
24   ierr = AMS_Memory_add_field((AMS_Memory)v->amem,"CurrentTimeStep",&v->time_step,1,
25                                AMS_DOUBLE,AMS_READ,AMS_COMMON,AMS_REDUCT_UNDEF);CHKERRQ(ierr);
26   ierr = PetscObjectPublishBaseEnd(obj);CHKERRQ(ierr);
27 #endif
28   PetscFunctionReturn(0);
29 }
30 
31 #undef  __FUNCT__
32 #define __FUNCT__ "TSCreate"
33 /*@C
34   TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the
35        type of solver can then be set with TSSetType().
36 
37   Collective on MPI_Comm
38 
39   Input Parameter:
40 . comm - The communicator
41 
42   Output Parameter:
43 . ts   - The TS
44 
45   Level: beginner
46 
47 .keywords: TS, create
48 .seealso: TSSetType(), TSSetUp(), TSDestroy(), MeshCreate(), TSSetProblemType()
49 @*/
50 PetscErrorCode TSCreate(MPI_Comm comm, TS *ts) {
51   TS  t;
52   PetscErrorCode ierr;
53 
54   PetscFunctionBegin;
55   PetscValidPointer(ts,1);
56   *ts = PETSC_NULL;
57 #ifndef PETSC_USE_DYNAMIC_LIBRARIES
58   ierr = TSInitializePackage(PETSC_NULL);CHKERRQ(ierr);
59 #endif
60 
61   PetscHeaderCreate(t, _p_TS, struct _TSOps, TS_COOKIE, -1, "TS", comm, TSDestroy, TSView);
62   PetscLogObjectCreate(t);
63   PetscLogObjectMemory(t, sizeof(struct _p_TS));
64   ierr = PetscMemzero(t->ops, sizeof(struct _TSOps));CHKERRQ(ierr);
65   t->bops->publish    = TSPublish_Petsc;
66   t->type_name        = PETSC_NULL;
67 
68   t->ops->applymatrixbc = TSDefaultSystemMatrixBC;
69   t->ops->applyrhsbc    = TSDefaultRhsBC;
70   t->ops->applysolbc    = TSDefaultSolutionBC;
71   t->ops->prestep       = TSDefaultPreStep;
72   t->ops->update        = TSDefaultUpdate;
73   t->ops->poststep      = TSDefaultPostStep;
74 
75   /* General TS description */
76   t->problem_type       = TS_LINEAR;
77   t->vec_sol            = PETSC_NULL;
78   t->vec_sol_always     = PETSC_NULL;
79   t->numbermonitors     = 0;
80   t->isGTS              = PETSC_FALSE;
81   t->isExplicit         = PETSC_NULL;
82   t->Iindex             = PETSC_NULL;
83   t->ksp               = PETSC_NULL;
84   t->A                  = PETSC_NULL;
85   t->B                  = PETSC_NULL;
86   t->snes               = PETSC_NULL;
87   t->funP               = PETSC_NULL;
88   t->jacP               = PETSC_NULL;
89   t->setupcalled        = 0;
90   t->data               = PETSC_NULL;
91   t->user               = PETSC_NULL;
92   t->max_steps          = 5000;
93   t->max_time           = 5.0;
94   t->time_step          = .1;
95   t->time_step_old      = t->time_step;
96   t->initial_time_step  = t->time_step;
97   t->steps              = 0;
98   t->ptime              = 0.0;
99   t->linear_its         = 0;
100   t->nonlinear_its      = 0;
101   t->work               = PETSC_NULL;
102   t->nwork              = 0;
103 
104   *ts = t;
105   PetscFunctionReturn(0);
106 }
107 
108