/* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the TS methods that are in the basic PETSc libpetscts library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); /*prototype*/ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = TSInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode DMTSCreate(MPI_Comm comm,DMTS *kdm) { PetscErrorCode ierr; PetscFunctionBegin; ierr = TSInitializePackage();CHKERRQ(ierr); ierr = PetscHeaderCreate(*kdm, DMTS_CLASSID, "DMTS", "DMTS", "DMTS", comm, DMTSDestroy, DMTSView);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode DMTSCreate(MPI_Comm comm,DMTS *kdm) { PetscErrorCode ierr; PetscFunctionBegin; ierr = TSInitializePackage();CHKERRQ(ierr); ierr = PetscHeaderCreate(*kdm, _p_DMTS, struct _DMTSOps, DMTS_CLASSID, "DMTS", "DMTS", "DMTS", comm, DMTSDestroy, DMTSView);CHKERRQ(ierr); ierr = PetscMemzero((*kdm)->ops, sizeof(struct _DMTSOps));CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C TSCreate - This function creates an empty timestepper. The problem type can then be set with TSSetProblemType() and the type of solver can then be set with TSSetType(). Collective on MPI_Comm Input Parameter: . comm - The communicator Output Parameter: . ts - The TS Level: beginner .keywords: TS, create .seealso: TSSetType(), TSSetUp(), TSDestroy(), MeshCreate(), TSSetProblemType() @*/ PetscErrorCode TSCreate(MPI_Comm comm, TS *ts) { TS t; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(ts,1); *ts = PETSC_NULL; #ifndef PETSC_USE_DYNAMIC_LIBRARIES ierr = TSInitializePackage(PETSC_NULL);CHKERRQ(ierr); #endif ierr = PetscHeaderCreate(t, _p_TS, struct _TSOps, TS_CLASSID, -1, "TS", "Time stepping", "TS", comm, TSDestroy, TSView);CHKERRQ(ierr); ierr = PetscMemzero(t->ops, sizeof(struct _TSOps));CHKERRQ(ierr); ierr = PetscMalloc(sizeof(struct _TSUserOps), &t->userops); t->userops->rhsfunction = 0; t->userops->ifunction = 0; t->userops->rhsjacobian = 0; t->userops->rhsjacobian = 0; t->userops->ijacobian = 0; /* General TS description */ t->problem_type = TS_NONLINEAR; t->vec_sol = PETSC_NULL; t->numbermonitors = 0; t->snes = PETSC_NULL; t->funP = PETSC_NULL; t->jacP = PETSC_NULL; t->setupcalled = 0; t->data = PETSC_NULL; t->user = PETSC_NULL; t->ptime = 0.0; t->time_step = 0.1; t->max_time = 5.0; t->steps = 0; t->max_steps = 5000; t->ksp_its = 0; t->snes_its = 0; t->work = PETSC_NULL; t->nwork = 0; t->max_snes_failures = 1; t->max_reject = 10; t->errorifstepfailed = PETSC_TRUE; t->rhsjacobian.time = -1e20; t->ijacobian.time = -1e20; t->atol = 1e-4; t->rtol = 1e-4; t->cfltime = PETSC_MAX_REAL; t->cfltime_local = PETSC_MAX_REAL; t->exact_final_time = PETSC_DECIDE; *ts = t; PetscFunctionReturn(0); }
/*@C TSTrajectoryCreate - This function creates an empty trajectory object used to store the time dependent solution of an ODE/DAE Collective on MPI_Comm Input Parameter: . comm - the communicator Output Parameter: . tj - the trajectory object Level: advanced Notes: Usually one does not call this routine, it is called automatically when one calls TSSetSaveTrajectory(). .keywords: TS, trajectory, create .seealso: TSTrajectorySetUp(), TSTrajectoryDestroy(), TSTrajectorySetType() @*/ PetscErrorCode TSTrajectoryCreate(MPI_Comm comm,TSTrajectory *tj) { TSTrajectory t; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(tj,2); *tj = NULL; ierr = TSInitializePackage();CHKERRQ(ierr); ierr = PetscHeaderCreate(t,TSTRAJECTORY_CLASSID,"TSTrajectory","Time stepping","TS",comm,TSTrajectoryDestroy,TSTrajectoryView);CHKERRQ(ierr); t->setupcalled = PETSC_FALSE; *tj = t; PetscFunctionReturn(0); }
/* PetscInitialize_DynamicLibraries - Adds the default dynamic link libraries to the search path. */ PETSC_INTERN PetscErrorCode PetscInitialize_DynamicLibraries(void) { char *libname[32]; PetscErrorCode ierr; PetscInt nmax,i; #if defined(PETSC_USE_DYNAMIC_LIBRARIES) && defined(PETSC_USE_SHARED_LIBRARIES) PetscBool preload; #endif PetscFunctionBegin; nmax = 32; ierr = PetscOptionsGetStringArray(NULL,NULL,"-dll_prepend",libname,&nmax,NULL);CHKERRQ(ierr); for (i=0; i<nmax; i++) { ierr = PetscDLLibraryPrepend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,libname[i]);CHKERRQ(ierr); ierr = PetscFree(libname[i]);CHKERRQ(ierr); } #if !defined(PETSC_USE_DYNAMIC_LIBRARIES) || !defined(PETSC_USE_SHARED_LIBRARIES) /* This just initializes the most basic PETSc stuff. The classes, from PetscDraw to PetscTS, are initialized the first time an XXCreate() is called. */ ierr = PetscSysInitializePackage();CHKERRQ(ierr); #else preload = PETSC_FALSE; ierr = PetscOptionsGetBool(NULL,NULL,"-dynamic_library_preload",&preload,NULL);CHKERRQ(ierr); if (preload) { PetscBool found; #if defined(PETSC_USE_SINGLE_LIBRARY) ierr = PetscLoadDynamicLibrary("",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc dynamic library \n You cannot move the dynamic libraries!"); #else ierr = PetscLoadDynamicLibrary("sys",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("vec",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc Vec dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("mat",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc Mat dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("dm",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc DM dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("ksp",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc KSP dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("snes",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc SNES dynamic library \n You cannot move the dynamic libraries!"); ierr = PetscLoadDynamicLibrary("ts",&found);CHKERRQ(ierr); if (!found) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to locate PETSc TS dynamic library \n You cannot move the dynamic libraries!"); #endif } #endif nmax = 32; ierr = PetscOptionsGetStringArray(NULL,NULL,"-dll_append",libname,&nmax,NULL);CHKERRQ(ierr); for (i=0; i<nmax; i++) { ierr = PetscDLLibraryAppend(PETSC_COMM_WORLD,&PetscDLLibrariesLoaded,libname[i]);CHKERRQ(ierr); ierr = PetscFree(libname[i]);CHKERRQ(ierr); } #if defined(PETSC_HAVE_THREADSAFETY) /* These must be done here because it is not safe for individual threads to call these initialize routines */ ierr = AOInitializePackage();CHKERRQ(ierr); ierr = PetscSFInitializePackage();CHKERRQ(ierr); #if !defined(PETSC_USE_COMPLEX) ierr = CharacteristicInitializePackage();CHKERRQ(ierr); #endif ierr = ISInitializePackage();CHKERRQ(ierr); ierr = VecInitializePackage();CHKERRQ(ierr); ierr = MatInitializePackage();CHKERRQ(ierr); ierr = DMInitializePackage();CHKERRQ(ierr); ierr = PCInitializePackage();CHKERRQ(ierr); ierr = KSPInitializePackage();CHKERRQ(ierr); ierr = SNESInitializePackage();CHKERRQ(ierr); ierr = TSInitializePackage();CHKERRQ(ierr); ierr = PetscCommDuplicate(PETSC_COMM_SELF,&PETSC_COMM_SELF_INNER,NULL);CHKERRQ(ierr); ierr = PetscCommDuplicate(PETSC_COMM_WORLD,&PETSC_COMM_WORLD_INNER,NULL);CHKERRQ(ierr); #endif PetscFunctionReturn(0); }