1c6db04a5SJed Brown #include <private/tsimpl.h> /*I "petscts.h" I*/ 23f3760d9SBarry Smith 3bdad233fSMatthew Knepley PetscFList TSList = PETSC_NULL; 4ace3abfcSBarry Smith PetscBool TSRegisterAllCalled = PETSC_FALSE; 53f3760d9SBarry Smith 64a2ae208SSatish Balay #undef __FUNCT__ 74a2ae208SSatish Balay #define __FUNCT__ "TSSetType" 882bf6240SBarry Smith /*@C 9ae12b187SLois Curfman McInnes TSSetType - Sets the method for the timestepping solver. 103f3760d9SBarry Smith 11fee21e36SBarry Smith Collective on TS 12fee21e36SBarry Smith 13bef22f13SLois Curfman McInnes Input Parameters: 14bdad233fSMatthew Knepley + ts - The TS context 15bdad233fSMatthew Knepley - type - A known method 16bef22f13SLois Curfman McInnes 17ae12b187SLois Curfman McInnes Options Database Command: 18bdad233fSMatthew Knepley . -ts_type <type> - Sets the method; use -help for a list of available methods (for instance, euler) 19ae12b187SLois Curfman McInnes 203f3760d9SBarry Smith Notes: 21e090d566SSatish Balay See "petsc/include/petscts.h" for available methods (for instance) 229596e0b4SJed Brown + TSEULER - Euler 239596e0b4SJed Brown . TSSUNDIALS - SUNDIALS interface 249596e0b4SJed Brown . TSBEULER - Backward Euler 259596e0b4SJed Brown - TSPSEUDO - Pseudo-timestepping 263f3760d9SBarry Smith 27ae12b187SLois Curfman McInnes Normally, it is best to use the TSSetFromOptions() command and 28ae12b187SLois Curfman McInnes then set the TS type from the options database rather than by using 29ae12b187SLois Curfman McInnes this routine. Using the options database provides the user with 30ae12b187SLois Curfman McInnes maximum flexibility in evaluating the many different solvers. 31ae12b187SLois Curfman McInnes The TSSetType() routine is provided for those situations where it 32ae12b187SLois Curfman McInnes is necessary to set the timestepping solver independently of the 33ae12b187SLois Curfman McInnes command line or options database. This might be the case, for example, 34ae12b187SLois Curfman McInnes when the choice of solver changes during the execution of the 35ae12b187SLois Curfman McInnes program, and the user's application is taking responsibility for 36ae12b187SLois Curfman McInnes choosing the appropriate method. In other words, this routine is 37d5d37b61SLois Curfman McInnes not for beginners. 38d5d37b61SLois Curfman McInnes 39d5d37b61SLois Curfman McInnes Level: intermediate 403f3760d9SBarry Smith 41ae12b187SLois Curfman McInnes .keywords: TS, set, type 42437fc6d7SBarry Smith 433f3760d9SBarry Smith @*/ 447087cfbeSBarry Smith PetscErrorCode TSSetType(TS ts,const TSType type) 453f3760d9SBarry Smith { 466849ba73SBarry Smith PetscErrorCode (*r)(TS); 47ace3abfcSBarry Smith PetscBool match; 48dfbe8321SBarry Smith PetscErrorCode ierr; 49df8cb225SBarry Smith 503a40ed3dSBarry Smith PetscFunctionBegin; 510700a824SBarry Smith PetscValidHeaderSpecific(ts, TS_CLASSID,1); 52bdad233fSMatthew Knepley ierr = PetscTypeCompare((PetscObject) ts, type, &match);CHKERRQ(ierr); 53958c9bccSBarry Smith if (match) PetscFunctionReturn(0); 54bdad233fSMatthew Knepley 554b91b6eaSBarry Smith ierr = PetscFListFind( TSList,((PetscObject)ts)->comm, type,PETSC_TRUE, (void (**)(void)) &r);CHKERRQ(ierr); 56e32f2f54SBarry Smith if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown TS type: %s", type); 57958c9bccSBarry Smith if (ts->ops->destroy) { 58bdad233fSMatthew Knepley ierr = (*(ts)->ops->destroy)(ts);CHKERRQ(ierr); 59bdad233fSMatthew Knepley } 60*79531b15SSean Farley ierr = PetscMemzero(ts->ops,sizeof(*ts->ops));CHKERRQ(ierr); 61277b19d0SLisandro Dalcin ts->setupcalled = PETSC_FALSE; 62bdad233fSMatthew Knepley ierr = PetscObjectChangeTypeName((PetscObject)ts, type);CHKERRQ(ierr); 63d372ba47SLisandro Dalcin ierr = (*r)(ts);CHKERRQ(ierr); 649fb22e1aSBarry Smith #if defined(PETSC_HAVE_AMS) 659fb22e1aSBarry Smith if (PetscAMSPublishAll) { 669fb22e1aSBarry Smith ierr = PetscObjectAMSPublish((PetscObject)ts);CHKERRQ(ierr); 679fb22e1aSBarry Smith } 689fb22e1aSBarry Smith #endif 693a40ed3dSBarry Smith PetscFunctionReturn(0); 703f3760d9SBarry Smith } 713f3760d9SBarry Smith 724a2ae208SSatish Balay #undef __FUNCT__ 734a2ae208SSatish Balay #define __FUNCT__ "TSGetType" 743f3760d9SBarry Smith /*@C 75fee21e36SBarry Smith TSGetType - Gets the TS method type (as a string). 763f3760d9SBarry Smith 77bef22f13SLois Curfman McInnes Not Collective 78bef22f13SLois Curfman McInnes 793f3760d9SBarry Smith Input Parameter: 80bdad233fSMatthew Knepley . ts - The TS 813f3760d9SBarry Smith 823f3760d9SBarry Smith Output Parameter: 83bdad233fSMatthew Knepley . type - The name of TS method 843f3760d9SBarry Smith 85d5d37b61SLois Curfman McInnes Level: intermediate 86d5d37b61SLois Curfman McInnes 87df8cb225SBarry Smith .keywords: TS, timestepper, get, type, name 88bdad233fSMatthew Knepley .seealso TSSetType() 893f3760d9SBarry Smith @*/ 907087cfbeSBarry Smith PetscErrorCode TSGetType(TS ts, const TSType *type) 913f3760d9SBarry Smith { 923a40ed3dSBarry Smith PetscFunctionBegin; 930700a824SBarry Smith PetscValidHeaderSpecific(ts,TS_CLASSID,1); 944482741eSBarry Smith PetscValidPointer(type,2); 957adad957SLisandro Dalcin *type = ((PetscObject)ts)->type_name; 963a40ed3dSBarry Smith PetscFunctionReturn(0); 973f3760d9SBarry Smith } 983f3760d9SBarry Smith 99bdad233fSMatthew Knepley /*--------------------------------------------------------------------------------------------------------------------*/ 1003cea93caSBarry Smith 101bdad233fSMatthew Knepley #undef __FUNCT__ 102bdad233fSMatthew Knepley #define __FUNCT__ "TSRegister" 1033cea93caSBarry Smith /*@C 1043cea93caSBarry Smith TSRegister - See TSRegisterDynamic() 1053cea93caSBarry Smith 1067f6c08e0SMatthew Knepley Level: advanced 1073cea93caSBarry Smith @*/ 1087087cfbeSBarry Smith PetscErrorCode TSRegister(const char sname[], const char path[], const char name[], PetscErrorCode (*function)(TS)) 109bdad233fSMatthew Knepley { 110e2d1d2b7SBarry Smith char fullname[PETSC_MAX_PATH_LEN]; 111dfbe8321SBarry Smith PetscErrorCode ierr; 112bdad233fSMatthew Knepley 113bdad233fSMatthew Knepley PetscFunctionBegin; 114bdad233fSMatthew Knepley ierr = PetscStrcpy(fullname, path);CHKERRQ(ierr); 115bdad233fSMatthew Knepley ierr = PetscStrcat(fullname, ":");CHKERRQ(ierr); 116bdad233fSMatthew Knepley ierr = PetscStrcat(fullname, name);CHKERRQ(ierr); 117bdad233fSMatthew Knepley ierr = PetscFListAdd(&TSList, sname, fullname, (void (*)(void)) function);CHKERRQ(ierr); 118bdad233fSMatthew Knepley PetscFunctionReturn(0); 119bdad233fSMatthew Knepley } 120bdad233fSMatthew Knepley 121bdad233fSMatthew Knepley /*-------------------------------------------------------------------------------------------------------------------*/ 122bdad233fSMatthew Knepley #undef __FUNCT__ 123bdad233fSMatthew Knepley #define __FUNCT__ "TSRegisterDestroy" 124bdad233fSMatthew Knepley /*@C 1253cea93caSBarry Smith TSRegisterDestroy - Frees the list of timestepping routines that were registered by TSRegister()/TSRegisterDynamic(). 126bdad233fSMatthew Knepley 127bdad233fSMatthew Knepley Not Collective 128bdad233fSMatthew Knepley 129bdad233fSMatthew Knepley Level: advanced 130bdad233fSMatthew Knepley 131bdad233fSMatthew Knepley .keywords: TS, timestepper, register, destroy 132437fc6d7SBarry Smith .seealso: TSRegister(), TSRegisterAll(), TSRegisterDynamic() 133bdad233fSMatthew Knepley @*/ 1347087cfbeSBarry Smith PetscErrorCode TSRegisterDestroy(void) 135bdad233fSMatthew Knepley { 136dfbe8321SBarry Smith PetscErrorCode ierr; 137bdad233fSMatthew Knepley 138bdad233fSMatthew Knepley PetscFunctionBegin; 1391441b1d3SBarry Smith ierr = PetscFListDestroy(&TSList);CHKERRQ(ierr); 140bdad233fSMatthew Knepley TSRegisterAllCalled = PETSC_FALSE; 141bdad233fSMatthew Knepley PetscFunctionReturn(0); 142bdad233fSMatthew Knepley } 143