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