12eac72dbSBarry Smith /* 237f753daSBarry Smith Defines the vector component of PETSc. Vectors generally represent 337f753daSBarry Smith degrees of freedom for finite element/finite difference functions 484cb2905SBarry Smith on a grid. They have more mathematical structure then simple arrays. 52eac72dbSBarry Smith */ 62eac72dbSBarry Smith 70a835dfdSSatish Balay #ifndef __PETSCVEC_H 80a835dfdSSatish Balay #define __PETSCVEC_H 90a835dfdSSatish Balay #include "petscis.h" 105f5f199fSBarry Smith 11e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 122eac72dbSBarry Smith 1309321671SBarry Smith /*S 1409321671SBarry Smith Vec - Abstract PETSc vector object 1509321671SBarry Smith 1609321671SBarry Smith Level: beginner 1709321671SBarry Smith 1809321671SBarry Smith Concepts: field variables, unknowns, arrays 1909321671SBarry Smith 2009321671SBarry Smith .seealso: VecCreate(), VecType, VecSetType() 2109321671SBarry Smith S*/ 22f09e8eb9SSatish Balay typedef struct _p_Vec* Vec; 2309321671SBarry Smith 2409321671SBarry Smith /*S 2509321671SBarry Smith VecScatter - Object used to manage communication of data 2609321671SBarry Smith between vectors in parallel. Manages both scatters and gathers 2709321671SBarry Smith 2809321671SBarry Smith Level: beginner 2909321671SBarry Smith 3009321671SBarry Smith Concepts: scatter 3109321671SBarry Smith 3209321671SBarry Smith .seealso: VecScatterCreate(), VecScatterBegin(), VecScatterEnd() 3309321671SBarry Smith S*/ 34f09e8eb9SSatish Balay typedef struct _p_VecScatter* VecScatter; 3509321671SBarry Smith 3609321671SBarry Smith /*E 3709321671SBarry Smith VecType - String with the name of a PETSc vector or the creation function 3809321671SBarry Smith with an optional dynamic library name, for example 3909321671SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 4009321671SBarry Smith 4109321671SBarry Smith Level: beginner 4209321671SBarry Smith 4309321671SBarry Smith .seealso: VecSetType(), Vec 4409321671SBarry Smith E*/ 45a313700dSBarry Smith #define VecType char* 460676abe4SMatthew Knepley #define VECSEQ "seq" 470676abe4SMatthew Knepley #define VECMPI "mpi" 480676abe4SMatthew Knepley #define VECFETI "feti" 490676abe4SMatthew Knepley #define VECSHARED "shared" 50765467adSMatthew Knepley #define VECSIEVE "sieve" 512eac72dbSBarry Smith 52fd487807SMatthew Knepley /* Logging support */ 53*0700a824SBarry Smith #define VEC_FILE_CLASSID 1211214 54*0700a824SBarry Smith extern PETSCVEC_DLLEXPORT PetscClassId VEC_CLASSID; 55*0700a824SBarry Smith extern PETSCVEC_DLLEXPORT PetscClassId VEC_SCATTER_CLASSID; 568ba1e511SMatthew Knepley 57e5bd5246SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(const char[]); 588a9890e4SLisandro Dalcin EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecFinalizePackage(void); 59fd487807SMatthew Knepley 600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm,Vec*); 61045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x)) 620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeq(MPI_Comm,PetscInt,Vec*); 63045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x)) 640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 65045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x)) 660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*); 67045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x)) 680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 69045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x)) 700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 710c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetFromOptions(Vec); 72f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetUp(Vec); 730c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroy(Vec); 74f1e08e49SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecZeroEntries(Vec); 75f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOptionsPrefix(Vec,const char[]); 76f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAppendOptionsPrefix(Vec,const char[]); 77f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOptionsPrefix(Vec,const char*[]); 78f69a0ea3SMatthew Knepley 790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec,PetscInt,PetscInt); 80fd487807SMatthew Knepley 813c5daeb9SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotNorm2(Vec,Vec,PetscScalar*,PetscScalar*); 820c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDot(Vec,Vec,PetscScalar*); 83fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 840c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDot(Vec,Vec,PetscScalar*); 85fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 86bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]); 87bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]); 88cddf8d76SBarry Smith 8909321671SBarry Smith /*E 9009321671SBarry Smith NormType - determines what type of norm to compute 9109321671SBarry Smith 9209321671SBarry Smith Level: beginner 9309321671SBarry Smith 9409321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm() 9509321671SBarry Smith E*/ 969dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType; 979dcbbd2bSBarry Smith extern const char *NormTypes[]; 98cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY 9909321671SBarry Smith 1009b250c83SBarry Smith /*MC 1019b250c83SBarry Smith NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum 1029b250c83SBarry Smith 1039b250c83SBarry Smith Level: beginner 1049b250c83SBarry Smith 1059b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS, 1069b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1079b250c83SBarry Smith 1089b250c83SBarry Smith M*/ 1099b250c83SBarry Smith 1109b250c83SBarry Smith /*MC 1119b250c83SBarry Smith NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only) 1129b250c83SBarry Smith 1139b250c83SBarry Smith Level: beginner 1149b250c83SBarry Smith 1159b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS, 1169b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1179b250c83SBarry Smith 1189b250c83SBarry Smith M*/ 1199b250c83SBarry Smith 1209b250c83SBarry Smith /*MC 1219b250c83SBarry Smith NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors 1229b250c83SBarry Smith 1239b250c83SBarry Smith Level: beginner 1249b250c83SBarry Smith 1259b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1269b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1279b250c83SBarry Smith 1289b250c83SBarry Smith M*/ 1299b250c83SBarry Smith 1309b250c83SBarry Smith /*MC 1319b250c83SBarry Smith NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum 1329b250c83SBarry Smith 1339b250c83SBarry Smith Level: beginner 1349b250c83SBarry Smith 1359b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1369b250c83SBarry Smith NORM_FROBINIUS, NORM_1_AND_2 1379b250c83SBarry Smith 1389b250c83SBarry Smith M*/ 1399b250c83SBarry Smith 1409b250c83SBarry Smith /*MC 1419b250c83SBarry Smith NORM_1_AND_2 - computes both the 1 and 2 norm of a vector 1429b250c83SBarry Smith 1439b250c83SBarry Smith Level: beginner 1449b250c83SBarry Smith 1459b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1469b250c83SBarry Smith NORM_FROBINIUS, NORM_INFINITY 1479b250c83SBarry Smith 1489b250c83SBarry Smith M*/ 1499b250c83SBarry Smith 1509b250c83SBarry Smith /*MC 1519b250c83SBarry Smith NORM_MAX - see NORM_INFINITY 1529b250c83SBarry Smith 153d41222bbSBarry Smith Level: beginner 154d41222bbSBarry Smith 1559b250c83SBarry Smith M*/ 1569b250c83SBarry Smith 1570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNorm(Vec,NormType,PetscReal *); 1587319c654SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormAvailable(Vec,NormType,PetscTruth*,PetscReal *); 159045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) 160c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) 161c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r) 1620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormalize(Vec,PetscReal *); 1630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSum(Vec,PetscScalar*); 1640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMax(Vec,PetscInt*,PetscReal *); 165045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 1660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMin(Vec,PetscInt*,PetscReal *); 167045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 1689a05e725SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScale(Vec,PetscScalar); 1690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCopy(Vec,Vec); 170abb0e124SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetRandom(Vec,PetscRandom); 1712dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSet(Vec,PetscScalar); 1720c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSwap(Vec,Vec); 1732dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPY(Vec,PetscScalar,Vec); 1742dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBY(Vec,PetscScalar,PetscScalar,Vec); 175bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]); 1762dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAYPX(Vec,PetscScalar,Vec); 1772dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecWAXPY(Vec,PetscScalar,Vec,Vec); 17809192fe3SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); 1790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMax(Vec,Vec,Vec); 1800190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y)) 1810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMaxAbs(Vec,Vec,Vec); 1820190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y)) 1830c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMin(Vec,Vec,Vec); 1840190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y)) 1850c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMult(Vec,Vec,Vec); 186b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,x,y)) 1870c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseDivide(Vec,Vec,Vec); 188b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,x,y)) 1890c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 1902dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecShift(Vec,PetscScalar); 1910c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReciprocal(Vec); 1920c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPermute(Vec, IS, PetscTruth); 1930c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSqrt(Vec); 19406c1185fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLog(Vec); 19506c1185fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecExp(Vec); 1960c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAbs(Vec); 1970c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicate(Vec,Vec*); 1980c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicateVecs(Vec,PetscInt,Vec*[]); 1990c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroyVecs(Vec[],PetscInt); 200bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNormAll(Vec,NormType,PetscReal[]); 201bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMaxAll(Vec,PetscInt [],PetscReal []); 202bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMinAll(Vec,PetscInt [],PetscReal []); 203bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScaleAll(Vec,PetscScalar[]); 2044a560884SBarry Smith 2050c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 206fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r) 207fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r) 2080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 209fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 2100c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 211fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 212f31393a2Sdalcinl EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScale(Vec,PetscInt,PetscScalar); 213954b3ec6SBarry Smith 214954b3ec6SBarry Smith 2150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGather(Vec,PetscInt,Vec,InsertMode); 2160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 217bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGatherAll(Vec,Vec[],InsertMode); 218bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatterAll(Vec[],Vec,InsertMode); 219d2655a18SBarry Smith 2200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 2210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 2220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyBegin(Vec); 2230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyEnd(Vec); 2240c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashSetInitialSize(Vec,PetscInt,PetscInt); 2250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashView(Vec,PetscViewer); 2260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 22762dc5420SSatish Balay 22830de9b25SBarry Smith /*MC 22930de9b25SBarry Smith VecSetValue - Set a single entry into a vector. 23030de9b25SBarry Smith 23130de9b25SBarry Smith Synopsis: 232d360dc6fSBarry Smith PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode); 23330de9b25SBarry Smith 23430de9b25SBarry Smith Not Collective 23530de9b25SBarry Smith 23630de9b25SBarry Smith Input Parameters: 23730de9b25SBarry Smith + v - the vector 23830de9b25SBarry Smith . row - the row location of the entry 23930de9b25SBarry Smith . value - the value to insert 24030de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 24130de9b25SBarry Smith 24230de9b25SBarry Smith Notes: 24330de9b25SBarry Smith For efficiency one should use VecSetValues() and set several or 24430de9b25SBarry Smith many values simultaneously if possible. 24530de9b25SBarry Smith 2461d73ed98SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 2471d73ed98SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 2481d73ed98SBarry Smith 2491d73ed98SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 2501d73ed98SBarry Smith 2511d73ed98SBarry Smith Level: beginner 2521d73ed98SBarry Smith 2531d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal() 2541d73ed98SBarry Smith M*/ 25550755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);} 2561d73ed98SBarry Smith 25730de9b25SBarry Smith 2580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetBlockSize(Vec,PetscInt); 2590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetBlockSize(Vec,PetscInt*); 260fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i) 2610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 2628ed539a5SBarry Smith 263fd487807SMatthew Knepley /* Dynamic creation and loading functions */ 264fd487807SMatthew Knepley extern PetscFList VecList; 265d772e1d7SMatthew Knepley extern PetscTruth VecRegisterAllCalled; 266a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, const VecType); 267a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, const VecType *); 2680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec)); 2690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []); 2700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void); 27130de9b25SBarry Smith 27230de9b25SBarry Smith /*MC 27330de9b25SBarry Smith VecRegisterDynamic - Adds a new vector component implementation 27430de9b25SBarry Smith 27530de9b25SBarry Smith Synopsis: 276d360dc6fSBarry Smith PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec)) 27730de9b25SBarry Smith 27830de9b25SBarry Smith Not Collective 27930de9b25SBarry Smith 28030de9b25SBarry Smith Input Parameters: 28130de9b25SBarry Smith + name - The name of a new user-defined creation routine 28230de9b25SBarry Smith . path - The path (either absolute or relative) of the library containing this routine 28330de9b25SBarry Smith . func_name - The name of routine to create method context 28430de9b25SBarry Smith - create_func - The creation routine itself 28530de9b25SBarry Smith 28630de9b25SBarry Smith Notes: 28730de9b25SBarry Smith VecRegisterDynamic() may be called multiple times to add several user-defined vectors 28830de9b25SBarry Smith 28930de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 29030de9b25SBarry Smith 29130de9b25SBarry Smith Sample usage: 29230de9b25SBarry Smith .vb 29330de9b25SBarry Smith VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate); 29430de9b25SBarry Smith .ve 29530de9b25SBarry Smith 29630de9b25SBarry Smith Then, your vector type can be chosen with the procedural interface via 29730de9b25SBarry Smith .vb 29830de9b25SBarry Smith VecCreate(MPI_Comm, Vec *); 29930de9b25SBarry Smith VecSetType(Vec,"my_vector_name"); 30030de9b25SBarry Smith .ve 30130de9b25SBarry Smith or at runtime via the option 30230de9b25SBarry Smith .vb 30330de9b25SBarry Smith -vec_type my_vector_name 30430de9b25SBarry Smith .ve 30530de9b25SBarry Smith 306ab901514SBarry Smith Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 30730de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 30830de9b25SBarry Smith 30930de9b25SBarry Smith Level: advanced 31030de9b25SBarry Smith 31130de9b25SBarry Smith .keywords: Vec, register 31230de9b25SBarry Smith .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister() 31330de9b25SBarry Smith M*/ 314aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 315f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0) 31688d459dfSBarry Smith #else 317f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d) 31888d459dfSBarry Smith #endif 31988d459dfSBarry Smith 32009321671SBarry Smith 3210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreate(Vec,IS,Vec,IS,VecScatter *); 322fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s) 3230190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s)) 324fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s) 3250190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s)) 326fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s) 327450faa77SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateEmpty(MPI_Comm,VecScatter *); 328fbb399caSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt); 329ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode); 330ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode); 3310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterDestroy(VecScatter); 3320c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCopy(VecScatter,VecScatter *); 3330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterView(VecScatter,PetscViewer); 3340c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterRemap(VecScatter,PetscInt *,PetscInt*); 3350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterGetMerged(VecScatter,PetscTruth*); 3362195c698SBarry Smith 3370c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray_Private(Vec,PetscScalar*[]); 3380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray_Private(Vec,PetscScalar*[]); 3390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 3400c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 3410c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 3420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 3430c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 3440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 3450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 3460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 347ab360428SBarry Smith 3480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPlaceArray(Vec,const PetscScalar[]); 3490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecResetArray(Vec); 3500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReplaceArray(Vec,const PetscScalar[]); 3510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 3520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 35384cb2905SBarry Smith 3540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecValid(Vec,PetscTruth*); 3550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecView(Vec,PetscViewer); 3564e2ffeddSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecViewFromOptions(Vec, const char *); 3570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecEqual(Vec,Vec,PetscTruth*); 358fcd5dd21SSatish Balay PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s) 359a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoad(PetscViewer,const VecType,Vec*); 3600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoadIntoVector(PetscViewer,Vec); 3618ed539a5SBarry Smith 3620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetSize(Vec,PetscInt*); 363fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s) 3640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetLocalSize(Vec,PetscInt*); 365fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s) 3660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 36706709851SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRanges(Vec,const PetscInt *[]); 3688ed539a5SBarry Smith 3690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 3700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 37188b03592SBarry Smith 37288b03592SBarry Smith /*MC 37388b03592SBarry Smith VecSetValueLocal - Set a single entry into a vector using the local numbering 37488b03592SBarry Smith 37588b03592SBarry Smith Synopsis: 37688b03592SBarry Smith PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode); 37788b03592SBarry Smith 37888b03592SBarry Smith Not Collective 37988b03592SBarry Smith 38088b03592SBarry Smith Input Parameters: 38188b03592SBarry Smith + v - the vector 38288b03592SBarry Smith . row - the row location of the entry 38388b03592SBarry Smith . value - the value to insert 38488b03592SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 38588b03592SBarry Smith 38688b03592SBarry Smith Notes: 38788b03592SBarry Smith For efficiency one should use VecSetValues() and set several or 38888b03592SBarry Smith many values simultaneously if possible. 38988b03592SBarry Smith 39088b03592SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 39188b03592SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 39288b03592SBarry Smith 39388b03592SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 39488b03592SBarry Smith 39588b03592SBarry Smith Level: beginner 39688b03592SBarry Smith 39788b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue() 39888b03592SBarry Smith M*/ 39988b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);} 40088b03592SBarry Smith 4010c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping); 4020c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 40390f02eecSBarry Smith 4040c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotBegin(Vec,Vec,PetscScalar *); 405ba966639SSatish Balay PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotEnd(Vec,Vec,PetscScalar *); 407fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotBegin(Vec,Vec,PetscScalar *); 409ba966639SSatish Balay PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4100c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotEnd(Vec,Vec,PetscScalar *); 411fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormBegin(Vec,NormType,PetscReal *); 413ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL)) 414ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL)) 4150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormEnd(Vec,NormType,PetscReal *); 416fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s) 417fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s) 418d3c178dbSBarry Smith 419bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 420bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 421bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 422bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 423a751f32aSSatish Balay 424a751f32aSSatish Balay 4259533e83fSBarry Smith typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption; 4269533e83fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOption(Vec,VecOption,PetscTruth); 42790f02eecSBarry Smith 428ebe3b25bSBarry Smith /* 429ebe3b25bSBarry Smith Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function 430ebe3b25bSBarry Smith call overhead on any 'native' Vecs. 431ebe3b25bSBarry Smith */ 432e1fa1e0fSSatish Balay 4331d8d5f9aSSatish Balay #include "private/vecimpl.h" 434ebe3b25bSBarry Smith 4350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecContourScale(Vec,PetscReal,PetscReal); 436522c5e43SBarry Smith 43715091d37SBarry Smith /* 43815091d37SBarry Smith These numbers need to match the entries in 4393c94ec11SBarry Smith the function table in vecimpl.h 44015091d37SBarry Smith */ 44109192fe3SBarry Smith typedef enum { VECOP_VIEW = 33, VECOP_LOADINTOVECTOR = 41} VecOperation; 4420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOperation(Vec,VecOperation,void(*)(void)); 443b19c1e4cSBarry Smith 444e182c471SBarry Smith /* 445e182c471SBarry Smith Routines for dealing with ghosted vectors: 446e182c471SBarry Smith vectors with ghost elements at the end of the array. 447e182c471SBarry Smith */ 4480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 4490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 4500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 4510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 4520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostGetLocalForm(Vec,Vec*); 453ba966639SSatish Balay PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s) 4540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostRestoreLocalForm(Vec,Vec*); 4550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 4560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 457e182c471SBarry Smith 4580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecConjugate(Vec); 45934233285SBarry Smith 4600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToAll(Vec,VecScatter*,Vec*); 4610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToZero(Vec,VecScatter*,Vec*); 462bba1ac68SSatish Balay 4630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaGetVector(PetscViewer, Vec); 4640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaPutVector(PetscViewer, Vec); 4657dbadf16SMatthew Knepley 466d59c15a7SBarry Smith /*S 467d59c15a7SBarry Smith Vecs - Collection of vectors where the data for the vectors is stored in 468759e7b9cSHong Zhang one contiguous memory 469d59c15a7SBarry Smith 470d59c15a7SBarry Smith Level: advanced 471d59c15a7SBarry Smith 472d59c15a7SBarry Smith Notes: 473d59c15a7SBarry Smith Temporary construct for handling multiply right hand side solves 474d59c15a7SBarry Smith 475d59c15a7SBarry Smith This is faked by storing a single vector that has enough array space for 476d59c15a7SBarry Smith n vectors 477d59c15a7SBarry Smith 478d59c15a7SBarry Smith Concepts: parallel decomposition 479d59c15a7SBarry Smith 480d59c15a7SBarry Smith S*/ 48195fbd943SSatish Balay struct _n_Vecs {PetscInt n; Vec v;}; 48295fbd943SSatish Balay typedef struct _n_Vecs* Vecs; 483d59c15a7SBarry Smith #define VecsDestroy(x) (VecDestroy((x)->v) || PetscFree(x)) 48495fbd943SSatish Balay #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 48595fbd943SSatish Balay #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 48695fbd943SSatish Balay #define VecsDuplicate(x,y) (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n))) 487e9fa29b7SSatish Balay 488e9fa29b7SSatish Balay 489e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 4902eac72dbSBarry Smith #endif 491