1 /* 2 Defines the vector component of PETSc. Vectors generally represent 3 degrees of freedom for finite element/finite difference functions 4 on a grid. They have more mathematical structure then simple arrays. 5 */ 6 7 #ifndef __PETSCVEC_H 8 #define __PETSCVEC_H 9 #include "petscis.h" 10 #include "petscsys.h" 11 PETSC_EXTERN_CXX_BEGIN 12 13 /*S 14 PetscMap - Abstract PETSc object that defines the layout of vector and 15 matrices across processors 16 17 Level: advanced 18 19 Notes: 20 Does not play a role in the PETSc design, can be ignored 21 22 Concepts: parallel decomposition 23 24 .seealso: PetscMapCreateMPI() 25 S*/ 26 typedef struct _p_PetscMap* PetscMap; 27 28 #define MAP_SEQ "seq" 29 #define MAP_MPI "mpi" 30 #define PetscMapType char* 31 32 /* Logging support */ 33 extern PetscCookie MAP_COOKIE; 34 35 EXTERN PetscErrorCode PetscMapCreate(MPI_Comm,PetscMap*); 36 EXTERN PetscErrorCode PetscMapCreateMPI(MPI_Comm,PetscInt,PetscInt,PetscMap*); 37 EXTERN PetscErrorCode PetscMapSetFromOptions(PetscMap); 38 EXTERN PetscErrorCode PetscMapPrintHelp(PetscMap); 39 EXTERN PetscErrorCode PetscMapDestroy(PetscMap); 40 41 EXTERN PetscErrorCode PetscMapSetLocalSize(PetscMap,PetscInt); 42 EXTERN PetscErrorCode PetscMapGetLocalSize(PetscMap,PetscInt *); 43 EXTERN PetscErrorCode PetscMapSetSize(PetscMap,PetscInt); 44 EXTERN PetscErrorCode PetscMapGetSize(PetscMap,PetscInt *); 45 EXTERN PetscErrorCode PetscMapGetLocalRange(PetscMap,PetscInt *,PetscInt *); 46 EXTERN PetscErrorCode PetscMapGetGlobalRange(PetscMap,PetscInt *[]); 47 48 /* Dynamic creation and loading functions */ 49 extern PetscFList PetscMapList; 50 extern PetscTruth PetscMapRegisterAllCalled; 51 EXTERN PetscErrorCode PetscMapSetType(PetscMap, const PetscMapType); 52 EXTERN PetscErrorCode PetscMapGetType(PetscMap, PetscMapType *); 53 EXTERN PetscErrorCode PetscMapRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscMap)); 54 EXTERN PetscErrorCode PetscMapRegisterAll(const char []); 55 EXTERN PetscErrorCode PetscMapRegisterDestroy(void); 56 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 57 #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,0) 58 #else 59 #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,d) 60 #endif 61 62 /*S 63 Vec - Abstract PETSc vector object 64 65 Level: beginner 66 67 Concepts: field variables, unknowns, arrays 68 69 .seealso: VecCreate(), VecType, VecSetType() 70 S*/ 71 typedef struct _p_Vec* Vec; 72 73 /*S 74 VecScatter - Object used to manage communication of data 75 between vectors in parallel. Manages both scatters and gathers 76 77 Level: beginner 78 79 Concepts: scatter 80 81 .seealso: VecScatterCreate(), VecScatterBegin(), VecScatterEnd() 82 S*/ 83 typedef struct _p_VecScatter* VecScatter; 84 85 /*E 86 VecType - String with the name of a PETSc vector or the creation function 87 with an optional dynamic library name, for example 88 http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 89 90 Level: beginner 91 92 .seealso: VecSetType(), Vec 93 E*/ 94 #define VECSEQ "seq" 95 #define VECMPI "mpi" 96 #define VECFETI "feti" 97 #define VECSHARED "shared" 98 #define VecType char* 99 100 /* Logging support */ 101 #define VEC_FILE_COOKIE 1211214 102 extern PetscCookie VEC_COOKIE, VEC_SCATTER_COOKIE; 103 extern PetscEvent VEC_View, VEC_Max, VEC_Min, VEC_DotBarrier, VEC_Dot, VEC_MDotBarrier, VEC_MDot, VEC_TDot, VEC_MTDot; 104 extern PetscEvent VEC_Norm, VEC_Normalize, VEC_Scale, VEC_Copy, VEC_Set, VEC_AXPY, VEC_AYPX, VEC_WAXPY, VEC_MAXPY; 105 extern PetscEvent VEC_AssemblyEnd, VEC_PointwiseMult, VEC_SetValues, VEC_Load, VEC_ScatterBarrier, VEC_ScatterBegin, VEC_ScatterEnd; 106 extern PetscEvent VEC_SetRandom, VEC_ReduceArithmetic, VEC_ReduceBarrier, VEC_ReduceCommunication; 107 extern PetscEvent VEC_Swap, VEC_AssemblyBegin, VEC_NormBarrier; 108 109 EXTERN PetscErrorCode VecInitializePackage(char *); 110 111 EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec *); 112 PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x)) 113 EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*); 114 PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x)) 115 EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 116 PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x)) 117 EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*); 118 PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x)) 119 EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 120 PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x)) 121 EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 122 EXTERN PetscErrorCode VecSetFromOptions(Vec); 123 EXTERN PetscErrorCode VecPrintHelp(Vec); 124 EXTERN PetscErrorCode VecDestroy(Vec); 125 126 EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt); 127 128 EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*); 129 EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*); 130 EXTERN PetscErrorCode VecMDot(PetscInt,Vec,const Vec[],PetscScalar*); 131 EXTERN PetscErrorCode VecMTDot(PetscInt,Vec,const Vec[],PetscScalar*); 132 133 /*E 134 NormType - determines what type of norm to compute 135 136 Level: beginner 137 138 .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm() 139 E*/ 140 typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4,NORM_1_AND_2=5} NormType; 141 #define NORM_MAX NORM_INFINITY 142 143 /*MC 144 NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum 145 146 Level: beginner 147 148 .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS, 149 NORM_INFINITY, NORM_1_AND_2 150 151 M*/ 152 153 /*MC 154 NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only) 155 156 Level: beginner 157 158 .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS, 159 NORM_INFINITY, NORM_1_AND_2 160 161 M*/ 162 163 /*MC 164 NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors 165 166 Level: beginner 167 168 .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 169 NORM_INFINITY, NORM_1_AND_2 170 171 M*/ 172 173 /*MC 174 NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum 175 176 Level: beginner 177 178 .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 179 NORM_FROBINIUS, NORM_1_AND_2 180 181 M*/ 182 183 /*MC 184 NORM_1_AND_2 - computes both the 1 and 2 norm of a vector 185 186 Level: beginner 187 188 .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 189 NORM_FROBINIUS, NORM_INFINITY 190 191 M*/ 192 193 /*MC 194 NORM_MAX - see NORM_INFINITY 195 196 Level: beginner 197 198 M*/ 199 200 EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *); 201 PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) 202 PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) 203 PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r) 204 EXTERN PetscErrorCode VecNormComposedDataID(NormType,PetscInt*); 205 EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *); 206 EXTERN PetscErrorCode VecSum(Vec,PetscScalar*); 207 EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *); 208 PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 209 EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *); 210 PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 211 EXTERN PetscErrorCode VecScale(const PetscScalar *a,Vec v); 212 EXTERN PetscErrorCode VecCopy(Vec,Vec); 213 EXTERN PetscErrorCode VecSetRandom(PetscRandom,Vec); 214 EXTERN PetscErrorCode VecSet(const PetscScalar*,Vec); 215 EXTERN PetscErrorCode VecSwap(Vec,Vec); 216 EXTERN PetscErrorCode VecAXPY(const PetscScalar*,Vec,Vec); 217 EXTERN PetscErrorCode VecAXPBY(const PetscScalar*,const PetscScalar *,Vec,Vec); 218 EXTERN PetscErrorCode VecMAXPY(PetscInt,const PetscScalar*,Vec,Vec*); 219 EXTERN PetscErrorCode VecAYPX(const PetscScalar*,Vec,Vec); 220 EXTERN PetscErrorCode VecWAXPY(const PetscScalar*,Vec,Vec,Vec); 221 EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec); 222 EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec); 223 EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec); 224 EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec); 225 EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec); 226 EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 227 EXTERN PetscErrorCode VecShift(const PetscScalar*,Vec); 228 EXTERN PetscErrorCode VecReciprocal(Vec); 229 EXTERN PetscErrorCode VecPermute(Vec, IS, PetscTruth); 230 EXTERN PetscErrorCode VecSqrt(Vec); 231 EXTERN PetscErrorCode VecAbs(Vec); 232 EXTERN PetscErrorCode VecDuplicate(Vec,Vec*); 233 EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]); 234 EXTERN PetscErrorCode VecDestroyVecs(Vec[],PetscInt); 235 EXTERN PetscErrorCode VecGetPetscMap(Vec,PetscMap*); 236 237 EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal*); 238 EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt *,PetscReal *); 239 EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt *,PetscReal *); 240 EXTERN PetscErrorCode VecStrideScaleAll(Vec,PetscScalar*); 241 242 EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 243 EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 244 EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 245 EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar*); 246 EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode); 247 EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 248 EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec*,InsertMode); 249 EXTERN PetscErrorCode VecStrideScatterAll(Vec*,Vec,InsertMode); 250 251 EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 252 EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 253 EXTERN PetscErrorCode VecAssemblyBegin(Vec); 254 EXTERN PetscErrorCode VecAssemblyEnd(Vec); 255 EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt); 256 EXTERN PetscErrorCode VecStashView(Vec,PetscViewer); 257 EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 258 259 extern PetscInt VecSetValue_Row; 260 extern PetscScalar VecSetValue_Value; 261 /*MC 262 VecSetValue - Set a single entry into a vector. 263 264 Synopsis: 265 PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode); 266 267 Not Collective 268 269 Input Parameters: 270 + v - the vector 271 . row - the row location of the entry 272 . value - the value to insert 273 - mode - either INSERT_VALUES or ADD_VALUES 274 275 Notes: 276 For efficiency one should use VecSetValues() and set several or 277 many values simultaneously if possible. 278 279 These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 280 MUST be called after all calls to VecSetValues() have been completed. 281 282 VecSetValues() uses 0-based indices in Fortran as well as in C. 283 284 Level: beginner 285 286 .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal() 287 M*/ 288 #define VecSetValue(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValues(v,1,&VecSetValue_Row,&VecSetValue_Value,mode)) 289 290 /*MC 291 VecSetValueLocal - Set a single entry into a vector using the local numbering 292 293 Synopsis: 294 PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode); 295 296 Not Collective 297 298 Input Parameters: 299 + v - the vector 300 . row - the row location of the entry 301 . value - the value to insert 302 - mode - either INSERT_VALUES or ADD_VALUES 303 304 Notes: 305 For efficiency one should use VecSetValues() and set several or 306 many values simultaneously if possible. 307 308 These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 309 MUST be called after all calls to VecSetValues() have been completed. 310 311 VecSetValues() uses 0-based indices in Fortran as well as in C. 312 313 Level: beginner 314 315 .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue() 316 M*/ 317 #define VecSetValueLocal(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValuesLocal(v,1,&VecSetValue_Row,&VecSetValue_Value,mode)) 318 319 EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt); 320 EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*); 321 EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 322 323 /* Dynamic creation and loading functions */ 324 extern PetscFList VecList; 325 extern PetscTruth VecRegisterAllCalled; 326 EXTERN PetscErrorCode VecSetType(Vec, const VecType); 327 EXTERN PetscErrorCode VecGetType(Vec, VecType *); 328 EXTERN PetscErrorCode VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec)); 329 EXTERN PetscErrorCode VecRegisterAll(const char []); 330 EXTERN PetscErrorCode VecRegisterDestroy(void); 331 332 /*MC 333 VecRegisterDynamic - Adds a new vector component implementation 334 335 Synopsis: 336 PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec)) 337 338 Not Collective 339 340 Input Parameters: 341 + name - The name of a new user-defined creation routine 342 . path - The path (either absolute or relative) of the library containing this routine 343 . func_name - The name of routine to create method context 344 - create_func - The creation routine itself 345 346 Notes: 347 VecRegisterDynamic() may be called multiple times to add several user-defined vectors 348 349 If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 350 351 Sample usage: 352 .vb 353 VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate); 354 .ve 355 356 Then, your vector type can be chosen with the procedural interface via 357 .vb 358 VecCreate(MPI_Comm, Vec *); 359 VecSetType(Vec,"my_vector_name"); 360 .ve 361 or at runtime via the option 362 .vb 363 -vec_type my_vector_name 364 .ve 365 366 Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 367 If your function is not being put into a shared library then use VecRegister() instead 368 369 Level: advanced 370 371 .keywords: Vec, register 372 .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister() 373 M*/ 374 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 375 #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0) 376 #else 377 #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d) 378 #endif 379 380 381 EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter *); 382 EXTERN PetscErrorCode VecScatterPostRecvs(Vec,Vec,InsertMode,ScatterMode,VecScatter); 383 EXTERN PetscErrorCode VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatter); 384 EXTERN PetscErrorCode VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatter); 385 EXTERN PetscErrorCode VecScatterDestroy(VecScatter); 386 EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *); 387 EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer); 388 EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt *,PetscInt*); 389 EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscTruth*); 390 391 EXTERN PetscErrorCode VecGetArray_Private(Vec,PetscScalar*[]); 392 EXTERN PetscErrorCode VecRestoreArray_Private(Vec,PetscScalar*[]); 393 EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 394 EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 395 EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 396 EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 397 EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 398 EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 399 EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 400 EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 401 402 EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]); 403 EXTERN PetscErrorCode VecResetArray(Vec); 404 EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]); 405 EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 406 EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 407 408 EXTERN PetscErrorCode VecValid(Vec,PetscTruth*); 409 EXTERN PetscErrorCode VecView(Vec,PetscViewer); 410 EXTERN PetscErrorCode VecViewFromOptions(Vec, char *); 411 EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscTruth*); 412 EXTERN PetscErrorCode VecLoad(PetscViewer,const VecType,Vec*); 413 EXTERN PetscErrorCode VecLoadIntoVector(PetscViewer,Vec); 414 415 EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*); 416 EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*); 417 EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 418 419 EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 420 EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 421 EXTERN PetscErrorCode VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping); 422 EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 423 424 EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *); 425 EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *); 426 EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *); 427 EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *); 428 EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *); 429 EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *); 430 431 typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_TREAT_OFF_PROC_ENTRIES} VecOption; 432 EXTERN PetscErrorCode VecSetOption(Vec,VecOption); 433 434 /* 435 Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function 436 call overhead on any 'native' Vecs. 437 */ 438 #include "vecimpl.h" 439 440 EXTERN PetscErrorCode VecContourScale(Vec,PetscReal,PetscReal); 441 442 /* 443 These numbers need to match the entries in 444 the function table in vecimpl.h 445 */ 446 typedef enum { VECOP_VIEW = 32, 447 VECOP_LOADINTOVECTOR = 38 448 } VecOperation; 449 EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void)); 450 451 /* 452 Routines for dealing with ghosted vectors: 453 vectors with ghost elements at the end of the array. 454 */ 455 EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 456 EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 457 EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 458 EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 459 EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*); 460 EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*); 461 EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 462 EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 463 464 EXTERN PetscErrorCode VecConjugate(Vec); 465 466 EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*); 467 EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*); 468 469 EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec); 470 EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec); 471 472 /*S 473 Vecs - Collection of vectors where the data for the vectors is stored in 474 one continquous memory 475 476 Level: advanced 477 478 Notes: 479 Temporary construct for handling multiply right hand side solves 480 481 This is faked by storing a single vector that has enough array space for 482 n vectors 483 484 Concepts: parallel decomposition 485 486 S*/ 487 struct _p_Vecs {PetscInt n; Vec v;}; 488 typedef struct _p_Vecs* Vecs; 489 #define VecsDestroy(x) (VecDestroy((x)->v) || PetscFree(x)) 490 #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _p_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 491 #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _p_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 492 #define VecsDuplicate(x,y) (PetscNew(struct _p_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n))) 493 494 495 PETSC_EXTERN_CXX_END 496 #endif 497