1af0996ceSBarry Smith #include <petsc/private/tsimpl.h> /*I "petscts.h" I*/ 2bdad233fSMatthew Knepley 3193ac0bcSJed Brown const char *const TSConvergedReasons_Shifted[] = { 422b60d99SBarry Smith "ADJOINT_DIVERGED_LINEAR_SOLVE", 52f17b9e8SHong Zhang "FORWARD_DIVERGED_LINEAR_SOLVE", 6193ac0bcSJed Brown "DIVERGED_STEP_REJECTED", 7193ac0bcSJed Brown "DIVERGED_NONLINEAR_SOLVE", 8193ac0bcSJed Brown "CONVERGED_ITERATING", 9193ac0bcSJed Brown "CONVERGED_TIME", 10193ac0bcSJed Brown "CONVERGED_ITS", 113118ae5eSBarry Smith "CONVERGED_USER", 123118ae5eSBarry Smith "CONVERGED_EVENT", 133118ae5eSBarry Smith "CONVERGED_PSEUDO_FATOL", 143118ae5eSBarry Smith "CONVERGED_PSEUDO_FATOL", 15c793f718SLisandro Dalcin "TSConvergedReason","TS_",NULL}; 1622b60d99SBarry Smith const char *const*TSConvergedReasons = TSConvergedReasons_Shifted + 4; 17193ac0bcSJed Brown 1860893bc3SSatish Balay /*@C 19bd6a702fSBarry Smith TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the 20bd6a702fSBarry Smith type of solver can then be set with TSSetType(). 21bdad233fSMatthew Knepley 22d083f849SBarry Smith Collective 23bdad233fSMatthew Knepley 24bdad233fSMatthew Knepley Input Parameter: 25bdad233fSMatthew Knepley . comm - The communicator 26bdad233fSMatthew Knepley 27bdad233fSMatthew Knepley Output Parameter: 28bdad233fSMatthew Knepley . ts - The TS 29bdad233fSMatthew Knepley 30bdad233fSMatthew Knepley Level: beginner 31bdad233fSMatthew Knepley 3295452b02SPatrick Sanan Developer Notes: 3395452b02SPatrick Sanan TS essentially always creates a SNES object even though explicit methods do not use it. This is 34efd4aadfSBarry Smith unfortunate and should be fixed at some point. The flag snes->usessnes indicates if the 35efd4aadfSBarry Smith particular method does use SNES and regulates if the information about the SNES is printed 36efd4aadfSBarry Smith in TSView(). TSSetFromOptions() does call SNESSetFromOptions() which can lead to users being confused 37efd4aadfSBarry Smith by help messages about meaningless SNES options. 38efd4aadfSBarry Smith 3904ceabe5SMatthew G. Knepley .seealso: TSSetType(), TSSetUp(), TSDestroy(), TSSetProblemType() 40bdad233fSMatthew Knepley @*/ 410adebc6cSBarry Smith PetscErrorCode TSCreate(MPI_Comm comm, TS *ts) 420adebc6cSBarry Smith { 43bdad233fSMatthew Knepley TS t; 44dfbe8321SBarry Smith PetscErrorCode ierr; 45bdad233fSMatthew Knepley 46bdad233fSMatthew Knepley PetscFunctionBegin; 474482741eSBarry Smith PetscValidPointer(ts,1); 480298fd71SBarry Smith *ts = NULL; 49607a6623SBarry Smith ierr = TSInitializePackage();CHKERRQ(ierr); 50bdad233fSMatthew Knepley 5173107ff1SLisandro Dalcin ierr = PetscHeaderCreate(t, TS_CLASSID, "TS", "Time stepping", "TS", comm, TSDestroy, TSView);CHKERRQ(ierr); 52bdad233fSMatthew Knepley 53bdad233fSMatthew Knepley /* General TS description */ 54089b2837SJed Brown t->problem_type = TS_NONLINEAR; 55ef85077eSLisandro Dalcin t->equation_type = TS_EQ_UNSPECIFIED; 56ef85077eSLisandro Dalcin 57cdbf8f93SLisandro Dalcin t->ptime = 0.0; 58cdbf8f93SLisandro Dalcin t->time_step = 0.1; 59ef85077eSLisandro Dalcin t->max_time = PETSC_MAX_REAL; 60ef85077eSLisandro Dalcin t->exact_final_time = TS_EXACTFINALTIME_UNSPECIFIED; 61bdad233fSMatthew Knepley t->steps = 0; 62ef85077eSLisandro Dalcin t->max_steps = PETSC_MAX_INT; 63ef85077eSLisandro Dalcin t->steprestart = PETSC_TRUE; 64ef85077eSLisandro Dalcin 65193ac0bcSJed Brown t->max_snes_failures = 1; 66193ac0bcSJed Brown t->max_reject = 10; 67193ac0bcSJed Brown t->errorifstepfailed = PETSC_TRUE; 68bdad233fSMatthew Knepley 69ef85077eSLisandro Dalcin t->rhsjacobian.time = PETSC_MIN_REAL; 70ef85077eSLisandro Dalcin t->rhsjacobian.scale = 1.0; 71ef85077eSLisandro Dalcin t->ijacobian.shift = 1.0; 7268bece0bSHong Zhang 73b92453a8SLisandro Dalcin /* All methods that do adaptivity should specify 74b92453a8SLisandro Dalcin * its preferred adapt type in their constructor */ 75b92453a8SLisandro Dalcin t->default_adapt_type = TSADAPTNONE; 76ef85077eSLisandro Dalcin t->atol = 1e-4; 77ef85077eSLisandro Dalcin t->rtol = 1e-4; 78ef85077eSLisandro Dalcin t->cfltime = PETSC_MAX_REAL; 79ef85077eSLisandro Dalcin t->cfltime_local = PETSC_MAX_REAL; 80715f1b00SHong Zhang 8187f4e208SHong Zhang t->num_rhs_splits = 0; 8287f4e208SHong Zhang 83*d60b7d5cSBarry Smith t->axpy_pattern = UNKNOWN_NONZERO_PATTERN; 84bdad233fSMatthew Knepley *ts = t; 85bdad233fSMatthew Knepley PetscFunctionReturn(0); 86bdad233fSMatthew Knepley } 87