/* PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. This one registers all the methods that are in the basic PETSc Vec library. */ PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscSFInitializePackage();CHKERRQ(ierr); ierr = ISInitializePackage();CHKERRQ(ierr); ierr = AOInitializePackage();CHKERRQ(ierr); ierr = VecInitializePackage();CHKERRQ(ierr); ierr = PFInitializePackage();CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@ VecCreate - Creates an empty vector object. The type can then be set with VecSetType(), or VecSetFromOptions(). If you never call VecSetType() or VecSetFromOptions() it will generate an error when you try to use the vector. Collective on MPI_Comm Input Parameter: . comm - The communicator for the vector object Output Parameter: . vec - The vector object Level: beginner .keywords: vector, create .seealso: VecSetType(), VecSetSizes(), VecCreateMPIWithArray(), VecCreateMPI(), VecDuplicate(), VecDuplicateVecs(), VecCreateGhost(), VecCreateSeq(), VecPlaceArray() @*/ PetscErrorCode VecCreate(MPI_Comm comm, Vec *vec) { Vec v; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(vec,2); *vec = NULL; ierr = VecInitializePackage();CHKERRQ(ierr); ierr = PetscHeaderCreate(v, VEC_CLASSID, "Vec", "Vector", "Vec", comm, VecDestroy, VecView);CHKERRQ(ierr); ierr = PetscLayoutCreate(comm,&v->map);CHKERRQ(ierr); v->array_gotten = PETSC_FALSE; v->petscnative = PETSC_FALSE; *vec = v; PetscFunctionReturn(0); }
/*@ VecCreate - Creates an empty vector object. The type can then be set with VecSetType(), or VecSetFromOptions(). If you never call VecSetType() or VecSetFromOptions() it will generate an error when you try to use the vector. Collective on MPI_Comm Input Parameter: . comm - The communicator for the vector object Output Parameter: . vec - The vector object Level: beginner .keywords: vector, create .seealso: VecSetType(), VecSetSizes(), VecCreateMPIWithArray(), VecCreateMPI(), VecDuplicate(), VecDuplicateVecs(), VecCreateGhost(), VecCreateSeq(), VecPlaceArray() @*/ PetscErrorCode VecCreate(MPI_Comm comm, Vec *vec) { Vec v; PetscErrorCode ierr; PetscFunctionBegin; PetscValidPointer(vec,2); *vec = PETSC_NULL; #ifndef PETSC_USE_DYNAMIC_LIBRARIES ierr = VecInitializePackage(PETSC_NULL);CHKERRQ(ierr); #endif ierr = PetscHeaderCreate(v, _p_Vec, struct _VecOps, VEC_CLASSID, -1, "Vec", "Vector", "Vec", comm, VecDestroy, VecView);CHKERRQ(ierr); ierr = PetscMemzero(v->ops, sizeof(struct _VecOps));CHKERRQ(ierr); ierr = PetscLayoutCreate(comm,&v->map);CHKERRQ(ierr); v->array_gotten = PETSC_FALSE; v->petscnative = PETSC_FALSE; *vec = v; 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); }