1bdad233fSMatthew Knepley 2af0996ceSBarry Smith #include <petsc/private/tsimpl.h> /*I "petscts.h" I*/ 3bdad233fSMatthew Knepley 4193ac0bcSJed Brown const char *const TSConvergedReasons_Shifted[] = { 5193ac0bcSJed Brown "DIVERGED_STEP_REJECTED", 6193ac0bcSJed Brown "DIVERGED_NONLINEAR_SOLVE", 7193ac0bcSJed Brown "CONVERGED_ITERATING", 8193ac0bcSJed Brown "CONVERGED_TIME", 9193ac0bcSJed Brown "CONVERGED_ITS", 103118ae5eSBarry Smith "CONVERGED_USER", 113118ae5eSBarry Smith "CONVERGED_EVENT", 123118ae5eSBarry Smith "CONVERGED_PSEUDO_FATOL", 133118ae5eSBarry Smith "CONVERGED_PSEUDO_FATOL", 14193ac0bcSJed Brown "TSConvergedReason","TS_",0}; 15193ac0bcSJed Brown const char *const*TSConvergedReasons = TSConvergedReasons_Shifted + 2; 16193ac0bcSJed Brown 1760893bc3SSatish Balay /*@C 18bd6a702fSBarry Smith TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the 19bd6a702fSBarry Smith type of solver can then be set with TSSetType(). 20bdad233fSMatthew Knepley 21bdad233fSMatthew Knepley Collective on MPI_Comm 22bdad233fSMatthew Knepley 23bdad233fSMatthew Knepley Input Parameter: 24bdad233fSMatthew Knepley . comm - The communicator 25bdad233fSMatthew Knepley 26bdad233fSMatthew Knepley Output Parameter: 27bdad233fSMatthew Knepley . ts - The TS 28bdad233fSMatthew Knepley 29bdad233fSMatthew Knepley Level: beginner 30bdad233fSMatthew Knepley 31*efd4aadfSBarry Smith Developer Notes: TS essentially always creates a SNES object even though explicit methods do not use it. This is 32*efd4aadfSBarry Smith unfortunate and should be fixed at some point. The flag snes->usessnes indicates if the 33*efd4aadfSBarry Smith particular method does use SNES and regulates if the information about the SNES is printed 34*efd4aadfSBarry Smith in TSView(). TSSetFromOptions() does call SNESSetFromOptions() which can lead to users being confused 35*efd4aadfSBarry Smith by help messages about meaningless SNES options. 36*efd4aadfSBarry Smith 37bdad233fSMatthew Knepley .keywords: TS, create 3804ceabe5SMatthew G. Knepley .seealso: TSSetType(), TSSetUp(), TSDestroy(), TSSetProblemType() 39bdad233fSMatthew Knepley @*/ 400adebc6cSBarry Smith PetscErrorCode TSCreate(MPI_Comm comm, TS *ts) 410adebc6cSBarry Smith { 42bdad233fSMatthew Knepley TS t; 43dfbe8321SBarry Smith PetscErrorCode ierr; 44bdad233fSMatthew Knepley 45bdad233fSMatthew Knepley PetscFunctionBegin; 464482741eSBarry Smith PetscValidPointer(ts,1); 470298fd71SBarry Smith *ts = NULL; 48607a6623SBarry Smith ierr = TSInitializePackage();CHKERRQ(ierr); 49bdad233fSMatthew Knepley 5073107ff1SLisandro Dalcin ierr = PetscHeaderCreate(t, TS_CLASSID, "TS", "Time stepping", "TS", comm, TSDestroy, TSView);CHKERRQ(ierr); 51bdad233fSMatthew Knepley 52bdad233fSMatthew Knepley /* General TS description */ 53089b2837SJed Brown t->problem_type = TS_NONLINEAR; 540298fd71SBarry Smith t->vec_sol = NULL; 55bdad233fSMatthew Knepley t->numbermonitors = 0; 560298fd71SBarry Smith t->snes = NULL; 57bdad233fSMatthew Knepley t->setupcalled = 0; 580298fd71SBarry Smith t->data = NULL; 590298fd71SBarry Smith t->user = NULL; 60cdbf8f93SLisandro Dalcin t->ptime = 0.0; 61cdbf8f93SLisandro Dalcin t->time_step = 0.1; 62bdad233fSMatthew Knepley t->max_time = 5.0; 638392e04aSShri Abhyankar t->steprollback = PETSC_FALSE; 64e7069c78SShri t->steprestart = PETSC_FALSE; 65bdad233fSMatthew Knepley t->steps = 0; 66cdbf8f93SLisandro Dalcin t->max_steps = 5000; 675ef26d82SJed Brown t->ksp_its = 0; 685ef26d82SJed Brown t->snes_its = 0; 690298fd71SBarry Smith t->work = NULL; 70bdad233fSMatthew Knepley t->nwork = 0; 71193ac0bcSJed Brown t->max_snes_failures = 1; 72193ac0bcSJed Brown t->max_reject = 10; 73193ac0bcSJed Brown t->errorifstepfailed = PETSC_TRUE; 740e4ef248SJed Brown t->rhsjacobian.time = -1e20; 75e1244c69SJed Brown t->rhsjacobian.scale = 1.; 76b41af12eSJed Brown t->ijacobian.shift = 1.; 77e817cc15SEmil Constantinescu t->equation_type = TS_EQ_UNSPECIFIED; 78bdad233fSMatthew Knepley 791c3436cfSJed Brown t->atol = 1e-4; 801c3436cfSJed Brown t->rtol = 1e-4; 818d59e960SJed Brown t->cfltime = PETSC_MAX_REAL; 828d59e960SJed Brown t->cfltime_local = PETSC_MAX_REAL; 83feed9e9dSBarry Smith t->exact_final_time = TS_EXACTFINALTIME_UNSPECIFIED; 84814b06c0SHong Zhang t->vec_costintegral = NULL; 8568bece0bSHong Zhang t->trajectory = NULL; 8668bece0bSHong Zhang 87b92453a8SLisandro Dalcin /* All methods that do adaptivity should specify 88b92453a8SLisandro Dalcin * its preferred adapt type in their constructor */ 89b92453a8SLisandro Dalcin t->default_adapt_type = TSADAPTNONE; 90b92453a8SLisandro Dalcin 91bdad233fSMatthew Knepley *ts = t; 92bdad233fSMatthew Knepley PetscFunctionReturn(0); 93bdad233fSMatthew Knepley } 94