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" 100a835dfdSSatish Balay #include "petscsys.h" 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 */ 53552e946dSBarry Smith #define VEC_FILE_COOKIE 1211214 540c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_COOKIE; 550c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_SCATTER_COOKIE; 568ba1e511SMatthew Knepley 57e5bd5246SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(const char[]); 58fd487807SMatthew Knepley 590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm,Vec*); 60045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x)) 610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeq(MPI_Comm,PetscInt,Vec*); 62045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x)) 630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 64045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x)) 650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*); 66045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x)) 670c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 68045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x)) 690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetFromOptions(Vec); 71f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetUp(Vec); 720c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroy(Vec); 73f1e08e49SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecZeroEntries(Vec); 74f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOptionsPrefix(Vec,const char[]); 75f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAppendOptionsPrefix(Vec,const char[]); 76f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOptionsPrefix(Vec,const char*[]); 77f69a0ea3SMatthew Knepley 780c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec,PetscInt,PetscInt); 79fd487807SMatthew Knepley 803c5daeb9SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotNorm2(Vec,Vec,PetscScalar*,PetscScalar*); 810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDot(Vec,Vec,PetscScalar*); 82fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 830c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDot(Vec,Vec,PetscScalar*); 84fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 85*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]); 86*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]); 87cddf8d76SBarry Smith 8809321671SBarry Smith /*E 8909321671SBarry Smith NormType - determines what type of norm to compute 9009321671SBarry Smith 9109321671SBarry Smith Level: beginner 9209321671SBarry Smith 9309321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm() 9409321671SBarry Smith E*/ 959dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType; 969dcbbd2bSBarry Smith extern const char *NormTypes[]; 97cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY 9809321671SBarry Smith 999b250c83SBarry Smith /*MC 1009b250c83SBarry Smith NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum 1019b250c83SBarry Smith 1029b250c83SBarry Smith Level: beginner 1039b250c83SBarry Smith 1049b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS, 1059b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1069b250c83SBarry Smith 1079b250c83SBarry Smith M*/ 1089b250c83SBarry Smith 1099b250c83SBarry Smith /*MC 1109b250c83SBarry Smith NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only) 1119b250c83SBarry Smith 1129b250c83SBarry Smith Level: beginner 1139b250c83SBarry Smith 1149b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS, 1159b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1169b250c83SBarry Smith 1179b250c83SBarry Smith M*/ 1189b250c83SBarry Smith 1199b250c83SBarry Smith /*MC 1209b250c83SBarry Smith NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors 1219b250c83SBarry Smith 1229b250c83SBarry Smith Level: beginner 1239b250c83SBarry Smith 1249b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1259b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1269b250c83SBarry Smith 1279b250c83SBarry Smith M*/ 1289b250c83SBarry Smith 1299b250c83SBarry Smith /*MC 1309b250c83SBarry Smith NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum 1319b250c83SBarry Smith 1329b250c83SBarry Smith Level: beginner 1339b250c83SBarry Smith 1349b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1359b250c83SBarry Smith NORM_FROBINIUS, NORM_1_AND_2 1369b250c83SBarry Smith 1379b250c83SBarry Smith M*/ 1389b250c83SBarry Smith 1399b250c83SBarry Smith /*MC 1409b250c83SBarry Smith NORM_1_AND_2 - computes both the 1 and 2 norm of a vector 1419b250c83SBarry Smith 1429b250c83SBarry Smith Level: beginner 1439b250c83SBarry Smith 1449b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1459b250c83SBarry Smith NORM_FROBINIUS, NORM_INFINITY 1469b250c83SBarry Smith 1479b250c83SBarry Smith M*/ 1489b250c83SBarry Smith 1499b250c83SBarry Smith /*MC 1509b250c83SBarry Smith NORM_MAX - see NORM_INFINITY 1519b250c83SBarry Smith 152d41222bbSBarry Smith Level: beginner 153d41222bbSBarry Smith 1549b250c83SBarry Smith M*/ 1559b250c83SBarry Smith 1560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNorm(Vec,NormType,PetscReal *); 157045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) 158c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) 159c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r) 1600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormalize(Vec,PetscReal *); 1610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSum(Vec,PetscScalar*); 1620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMax(Vec,PetscInt*,PetscReal *); 163045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 1640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMin(Vec,PetscInt*,PetscReal *); 165045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 1669a05e725SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScale(Vec,PetscScalar); 1670c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCopy(Vec,Vec); 168abb0e124SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetRandom(Vec,PetscRandom); 1692dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSet(Vec,PetscScalar); 1700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSwap(Vec,Vec); 1712dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPY(Vec,PetscScalar,Vec); 1722dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBY(Vec,PetscScalar,PetscScalar,Vec); 173*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]); 1742dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAYPX(Vec,PetscScalar,Vec); 1752dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecWAXPY(Vec,PetscScalar,Vec,Vec); 17609192fe3SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); 1770c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMax(Vec,Vec,Vec); 1780190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y)) 1790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMaxAbs(Vec,Vec,Vec); 1800190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y)) 1810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMin(Vec,Vec,Vec); 1820190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y)) 1830c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMult(Vec,Vec,Vec); 184b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,x,y)) 1850c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseDivide(Vec,Vec,Vec); 186b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,x,y)) 1870c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 1882dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecShift(Vec,PetscScalar); 1890c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReciprocal(Vec); 1900c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPermute(Vec, IS, PetscTruth); 1910c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSqrt(Vec); 1920c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAbs(Vec); 1930c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicate(Vec,Vec*); 1940c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicateVecs(Vec,PetscInt,Vec*[]); 1950c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroyVecs(Vec[],PetscInt); 196*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNormAll(Vec,NormType,PetscReal[]); 197*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMaxAll(Vec,PetscInt [],PetscReal []); 198*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMinAll(Vec,PetscInt [],PetscReal []); 199*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScaleAll(Vec,PetscScalar[]); 2004a560884SBarry Smith 2010c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 202fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r) 203fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r) 2040c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 205fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 2060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 207fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 208f31393a2Sdalcinl EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScale(Vec,PetscInt,PetscScalar); 209954b3ec6SBarry Smith 210954b3ec6SBarry Smith 2110c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGather(Vec,PetscInt,Vec,InsertMode); 2120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 213*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGatherAll(Vec,Vec[],InsertMode); 214*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatterAll(Vec[],Vec,InsertMode); 215d2655a18SBarry Smith 2160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 2170c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 2180c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyBegin(Vec); 2190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyEnd(Vec); 2200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashSetInitialSize(Vec,PetscInt,PetscInt); 2210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashView(Vec,PetscViewer); 2220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 22362dc5420SSatish Balay 22430de9b25SBarry Smith /*MC 22530de9b25SBarry Smith VecSetValue - Set a single entry into a vector. 22630de9b25SBarry Smith 22730de9b25SBarry Smith Synopsis: 228d360dc6fSBarry Smith PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode); 22930de9b25SBarry Smith 23030de9b25SBarry Smith Not Collective 23130de9b25SBarry Smith 23230de9b25SBarry Smith Input Parameters: 23330de9b25SBarry Smith + v - the vector 23430de9b25SBarry Smith . row - the row location of the entry 23530de9b25SBarry Smith . value - the value to insert 23630de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 23730de9b25SBarry Smith 23830de9b25SBarry Smith Notes: 23930de9b25SBarry Smith For efficiency one should use VecSetValues() and set several or 24030de9b25SBarry Smith many values simultaneously if possible. 24130de9b25SBarry Smith 2421d73ed98SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 2431d73ed98SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 2441d73ed98SBarry Smith 2451d73ed98SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 2461d73ed98SBarry Smith 2471d73ed98SBarry Smith Level: beginner 2481d73ed98SBarry Smith 2491d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal() 2501d73ed98SBarry Smith M*/ 25150755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);} 2521d73ed98SBarry Smith 25330de9b25SBarry Smith 2540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetBlockSize(Vec,PetscInt); 2550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetBlockSize(Vec,PetscInt*); 256fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i) 2570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 2588ed539a5SBarry Smith 259fd487807SMatthew Knepley /* Dynamic creation and loading functions */ 260fd487807SMatthew Knepley extern PetscFList VecList; 261d772e1d7SMatthew Knepley extern PetscTruth VecRegisterAllCalled; 262a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, const VecType); 263a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, const VecType *); 2640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec)); 2650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []); 2660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void); 26730de9b25SBarry Smith 26830de9b25SBarry Smith /*MC 26930de9b25SBarry Smith VecRegisterDynamic - Adds a new vector component implementation 27030de9b25SBarry Smith 27130de9b25SBarry Smith Synopsis: 272d360dc6fSBarry Smith PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec)) 27330de9b25SBarry Smith 27430de9b25SBarry Smith Not Collective 27530de9b25SBarry Smith 27630de9b25SBarry Smith Input Parameters: 27730de9b25SBarry Smith + name - The name of a new user-defined creation routine 27830de9b25SBarry Smith . path - The path (either absolute or relative) of the library containing this routine 27930de9b25SBarry Smith . func_name - The name of routine to create method context 28030de9b25SBarry Smith - create_func - The creation routine itself 28130de9b25SBarry Smith 28230de9b25SBarry Smith Notes: 28330de9b25SBarry Smith VecRegisterDynamic() may be called multiple times to add several user-defined vectors 28430de9b25SBarry Smith 28530de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 28630de9b25SBarry Smith 28730de9b25SBarry Smith Sample usage: 28830de9b25SBarry Smith .vb 28930de9b25SBarry Smith VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate); 29030de9b25SBarry Smith .ve 29130de9b25SBarry Smith 29230de9b25SBarry Smith Then, your vector type can be chosen with the procedural interface via 29330de9b25SBarry Smith .vb 29430de9b25SBarry Smith VecCreate(MPI_Comm, Vec *); 29530de9b25SBarry Smith VecSetType(Vec,"my_vector_name"); 29630de9b25SBarry Smith .ve 29730de9b25SBarry Smith or at runtime via the option 29830de9b25SBarry Smith .vb 29930de9b25SBarry Smith -vec_type my_vector_name 30030de9b25SBarry Smith .ve 30130de9b25SBarry Smith 302ab901514SBarry Smith Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 30330de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 30430de9b25SBarry Smith 30530de9b25SBarry Smith Level: advanced 30630de9b25SBarry Smith 30730de9b25SBarry Smith .keywords: Vec, register 30830de9b25SBarry Smith .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister() 30930de9b25SBarry Smith M*/ 310aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 311f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0) 31288d459dfSBarry Smith #else 313f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d) 31488d459dfSBarry Smith #endif 31588d459dfSBarry Smith 31609321671SBarry Smith 3170c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreate(Vec,IS,Vec,IS,VecScatter *); 318fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s) 3190190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s)) 320fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s) 3210190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s)) 322fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s) 323450faa77SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateEmpty(MPI_Comm,VecScatter *); 324fbb399caSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt); 325ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode); 326ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode); 3270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterDestroy(VecScatter); 3280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCopy(VecScatter,VecScatter *); 3290c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterView(VecScatter,PetscViewer); 3300c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterRemap(VecScatter,PetscInt *,PetscInt*); 3310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterGetMerged(VecScatter,PetscTruth*); 3322195c698SBarry Smith 3330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray_Private(Vec,PetscScalar*[]); 3340c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray_Private(Vec,PetscScalar*[]); 3350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 3360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 3370c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 3380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 3390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 3400c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 3410c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 3420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 343ab360428SBarry Smith 3440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPlaceArray(Vec,const PetscScalar[]); 3450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecResetArray(Vec); 3460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReplaceArray(Vec,const PetscScalar[]); 3470c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 3480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 34984cb2905SBarry Smith 3500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecValid(Vec,PetscTruth*); 3510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecView(Vec,PetscViewer); 3524e2ffeddSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecViewFromOptions(Vec, const char *); 3530c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecEqual(Vec,Vec,PetscTruth*); 354fcd5dd21SSatish Balay PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s) 355a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoad(PetscViewer,const VecType,Vec*); 3560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoadIntoVector(PetscViewer,Vec); 3578ed539a5SBarry Smith 3580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetSize(Vec,PetscInt*); 359fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s) 3600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetLocalSize(Vec,PetscInt*); 361fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s) 3620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 36306709851SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRanges(Vec,const PetscInt *[]); 3648ed539a5SBarry Smith 3650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 3660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 36788b03592SBarry Smith 36888b03592SBarry Smith /*MC 36988b03592SBarry Smith VecSetValueLocal - Set a single entry into a vector using the local numbering 37088b03592SBarry Smith 37188b03592SBarry Smith Synopsis: 37288b03592SBarry Smith PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode); 37388b03592SBarry Smith 37488b03592SBarry Smith Not Collective 37588b03592SBarry Smith 37688b03592SBarry Smith Input Parameters: 37788b03592SBarry Smith + v - the vector 37888b03592SBarry Smith . row - the row location of the entry 37988b03592SBarry Smith . value - the value to insert 38088b03592SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 38188b03592SBarry Smith 38288b03592SBarry Smith Notes: 38388b03592SBarry Smith For efficiency one should use VecSetValues() and set several or 38488b03592SBarry Smith many values simultaneously if possible. 38588b03592SBarry Smith 38688b03592SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 38788b03592SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 38888b03592SBarry Smith 38988b03592SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 39088b03592SBarry Smith 39188b03592SBarry Smith Level: beginner 39288b03592SBarry Smith 39388b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue() 39488b03592SBarry Smith M*/ 39588b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);} 39688b03592SBarry Smith 3970c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping); 3980c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 39990f02eecSBarry Smith 4000c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotBegin(Vec,Vec,PetscScalar *); 401ba966639SSatish Balay PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4020c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotEnd(Vec,Vec,PetscScalar *); 403fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4040c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotBegin(Vec,Vec,PetscScalar *); 405ba966639SSatish Balay PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotEnd(Vec,Vec,PetscScalar *); 407fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormBegin(Vec,NormType,PetscReal *); 409ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL)) 410ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL)) 4110c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormEnd(Vec,NormType,PetscReal *); 412fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s) 413fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s) 414d3c178dbSBarry Smith 415*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 416*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 417*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 418*bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 419a751f32aSSatish Balay 420a751f32aSSatish Balay 4219533e83fSBarry Smith typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption; 4229533e83fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOption(Vec,VecOption,PetscTruth); 42390f02eecSBarry Smith 424ebe3b25bSBarry Smith /* 425ebe3b25bSBarry Smith Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function 426ebe3b25bSBarry Smith call overhead on any 'native' Vecs. 427ebe3b25bSBarry Smith */ 428e1fa1e0fSSatish Balay 4291d8d5f9aSSatish Balay #include "private/vecimpl.h" 430ebe3b25bSBarry Smith 4310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecContourScale(Vec,PetscReal,PetscReal); 432522c5e43SBarry Smith 43315091d37SBarry Smith /* 43415091d37SBarry Smith These numbers need to match the entries in 4353c94ec11SBarry Smith the function table in vecimpl.h 43615091d37SBarry Smith */ 43709192fe3SBarry Smith typedef enum { VECOP_VIEW = 33, VECOP_LOADINTOVECTOR = 41} VecOperation; 4380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOperation(Vec,VecOperation,void(*)(void)); 439b19c1e4cSBarry Smith 440e182c471SBarry Smith /* 441e182c471SBarry Smith Routines for dealing with ghosted vectors: 442e182c471SBarry Smith vectors with ghost elements at the end of the array. 443e182c471SBarry Smith */ 4440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 4450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 4460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 4470c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 4480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostGetLocalForm(Vec,Vec*); 449ba966639SSatish Balay PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s) 4500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostRestoreLocalForm(Vec,Vec*); 4510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 4520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 453e182c471SBarry Smith 4540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecConjugate(Vec); 45534233285SBarry Smith 4560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToAll(Vec,VecScatter*,Vec*); 4570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToZero(Vec,VecScatter*,Vec*); 458bba1ac68SSatish Balay 4590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaGetVector(PetscViewer, Vec); 4600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaPutVector(PetscViewer, Vec); 4617dbadf16SMatthew Knepley 462d59c15a7SBarry Smith /*S 463d59c15a7SBarry Smith Vecs - Collection of vectors where the data for the vectors is stored in 464759e7b9cSHong Zhang one contiguous memory 465d59c15a7SBarry Smith 466d59c15a7SBarry Smith Level: advanced 467d59c15a7SBarry Smith 468d59c15a7SBarry Smith Notes: 469d59c15a7SBarry Smith Temporary construct for handling multiply right hand side solves 470d59c15a7SBarry Smith 471d59c15a7SBarry Smith This is faked by storing a single vector that has enough array space for 472d59c15a7SBarry Smith n vectors 473d59c15a7SBarry Smith 474d59c15a7SBarry Smith Concepts: parallel decomposition 475d59c15a7SBarry Smith 476d59c15a7SBarry Smith S*/ 47795fbd943SSatish Balay struct _n_Vecs {PetscInt n; Vec v;}; 47895fbd943SSatish Balay typedef struct _n_Vecs* Vecs; 479d59c15a7SBarry Smith #define VecsDestroy(x) (VecDestroy((x)->v) || PetscFree(x)) 48095fbd943SSatish Balay #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 48195fbd943SSatish Balay #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 48295fbd943SSatish Balay #define VecsDuplicate(x,y) (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n))) 483e9fa29b7SSatish Balay 484e9fa29b7SSatish Balay 485e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 4862eac72dbSBarry Smith #endif 487