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