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 148a124369SBarry Smith PetscMap - Abstract PETSc object that defines the layout of vector and 15013c094aSBarry Smith matrices across processors 1609321671SBarry Smith 1709321671SBarry Smith Level: advanced 1809321671SBarry Smith 1909321671SBarry Smith Notes: 2009321671SBarry Smith Does not play a role in the PETSc design, can be ignored 2109321671SBarry Smith 2209321671SBarry Smith Concepts: parallel decomposition 2309321671SBarry Smith 248a124369SBarry Smith .seealso: PetscMapCreateMPI() 2509321671SBarry Smith S*/ 268a124369SBarry Smith typedef struct _p_PetscMap* PetscMap; 2709321671SBarry Smith 28d772e1d7SMatthew Knepley #define MAP_SEQ "seq" 29d772e1d7SMatthew Knepley #define MAP_MPI "mpi" 30f69a0ea3SMatthew Knepley #define PetscMapType const char* 31d772e1d7SMatthew Knepley 32d772e1d7SMatthew Knepley /* Logging support */ 336849ba73SBarry Smith extern PetscCookie MAP_COOKIE; 34d772e1d7SMatthew Knepley 350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapCreate(MPI_Comm,PetscMap*); 3665f510b9SBarry Smith PetscPolymorphicSubroutine(PetscMapCreate,(PetscMap*m),(m)) 3765f510b9SBarry Smith PetscPolymorphicFunction(PetscMapCreate,(void),(PETSC_COMM_SELF,&m),PetscMap,m) 380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapCreateMPI(MPI_Comm,PetscInt,PetscInt,PetscMap*); 3965f510b9SBarry Smith PetscPolymorphicFunction(PetscMapCreateMPI,(MPI_Comm comm,PetscInt l,PetscInt g),(comm,l,g,&m),PetscMap,m) 400c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetFromOptions(PetscMap); 410c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapPrintHelp(PetscMap); 420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapDestroy(PetscMap); 43d772e1d7SMatthew Knepley 44f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetUp(PetscMap); 45f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapView(PetscMap,PetscViewer); 46f69a0ea3SMatthew Knepley 47f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetOptionsPrefix(PetscMap,const char[]); 48f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapAppendOptionsPrefix(PetscMap,const char[]); 49f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetOptionsPrefix(PetscMap,const char*[]); 50f69a0ea3SMatthew Knepley 510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetLocalSize(PetscMap,PetscInt); 520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetLocalSize(PetscMap,PetscInt *); 539785fde0SSatish Balay PetscPolymorphicFunction(PetscMapGetLocalSize,(PetscMap m),(m,&s),PetscInt,s) 540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetSize(PetscMap,PetscInt); 550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetSize(PetscMap,PetscInt *); 569785fde0SSatish Balay PetscPolymorphicFunction(PetscMapGetSize,(PetscMap m),(m,&s),PetscInt,s) 570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetLocalRange(PetscMap,PetscInt *,PetscInt *); 580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetGlobalRange(PetscMap,PetscInt *[]); 59d772e1d7SMatthew Knepley 60d772e1d7SMatthew Knepley /* Dynamic creation and loading functions */ 61d772e1d7SMatthew Knepley extern PetscFList PetscMapList; 62d772e1d7SMatthew Knepley extern PetscTruth PetscMapRegisterAllCalled; 63f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetType(PetscMap, PetscMapType); 640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetType(PetscMap, PetscMapType *); 659785fde0SSatish Balay PetscPolymorphicFunction(PetscMapGetType,(PetscMap m),(m,&t),PetscMapType,t) 660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscMap)); 670c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapRegisterAll(const char []); 680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapRegisterDestroy(void); 69d772e1d7SMatthew Knepley #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 70d772e1d7SMatthew Knepley #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,0) 71d772e1d7SMatthew Knepley #else 72d772e1d7SMatthew Knepley #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,d) 73d772e1d7SMatthew Knepley #endif 74d772e1d7SMatthew Knepley 7509321671SBarry Smith /*S 7609321671SBarry Smith Vec - Abstract PETSc vector object 7709321671SBarry Smith 7809321671SBarry Smith Level: beginner 7909321671SBarry Smith 8009321671SBarry Smith Concepts: field variables, unknowns, arrays 8109321671SBarry Smith 8209321671SBarry Smith .seealso: VecCreate(), VecType, VecSetType() 8309321671SBarry Smith S*/ 84f09e8eb9SSatish Balay typedef struct _p_Vec* Vec; 8509321671SBarry Smith 8609321671SBarry Smith /*S 8709321671SBarry Smith VecScatter - Object used to manage communication of data 8809321671SBarry Smith between vectors in parallel. Manages both scatters and gathers 8909321671SBarry Smith 9009321671SBarry Smith Level: beginner 9109321671SBarry Smith 9209321671SBarry Smith Concepts: scatter 9309321671SBarry Smith 9409321671SBarry Smith .seealso: VecScatterCreate(), VecScatterBegin(), VecScatterEnd() 9509321671SBarry Smith S*/ 96f09e8eb9SSatish Balay typedef struct _p_VecScatter* VecScatter; 9709321671SBarry Smith 9809321671SBarry Smith /*E 9909321671SBarry Smith VecType - String with the name of a PETSc vector or the creation function 10009321671SBarry Smith with an optional dynamic library name, for example 10109321671SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 10209321671SBarry Smith 10309321671SBarry Smith Level: beginner 10409321671SBarry Smith 10509321671SBarry Smith .seealso: VecSetType(), Vec 10609321671SBarry Smith E*/ 1070676abe4SMatthew Knepley #define VECSEQ "seq" 1080676abe4SMatthew Knepley #define VECMPI "mpi" 1090676abe4SMatthew Knepley #define VECFETI "feti" 1100676abe4SMatthew Knepley #define VECSHARED "shared" 111f69a0ea3SMatthew Knepley #define VecType const char* 1122eac72dbSBarry Smith 113fd487807SMatthew Knepley /* Logging support */ 114552e946dSBarry Smith #define VEC_FILE_COOKIE 1211214 1150c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_COOKIE; 1160c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_SCATTER_COOKIE; 1176849ba73SBarry Smith extern PetscEvent VEC_View, VEC_Max, VEC_Min, VEC_DotBarrier, VEC_Dot, VEC_MDotBarrier, VEC_MDot, VEC_TDot, VEC_MTDot; 1186849ba73SBarry Smith extern PetscEvent VEC_Norm, VEC_Normalize, VEC_Scale, VEC_Copy, VEC_Set, VEC_AXPY, VEC_AYPX, VEC_WAXPY, VEC_MAXPY; 1196849ba73SBarry Smith extern PetscEvent VEC_AssemblyEnd, VEC_PointwiseMult, VEC_SetValues, VEC_Load, VEC_ScatterBarrier, VEC_ScatterBegin, VEC_ScatterEnd; 1206849ba73SBarry Smith extern PetscEvent VEC_SetRandom, VEC_ReduceArithmetic, VEC_ReduceBarrier, VEC_ReduceCommunication; 1216849ba73SBarry Smith extern PetscEvent VEC_Swap, VEC_AssemblyBegin, VEC_NormBarrier; 1228ba1e511SMatthew Knepley 1230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(char *); 124fd487807SMatthew Knepley 1250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm,Vec*); 126045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x)) 1270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeq(MPI_Comm,PetscInt,Vec*); 128045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x)) 1290c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 130045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x)) 1310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*); 132045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x)) 1330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 134045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x)) 1350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 1360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetFromOptions(Vec); 1370c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPrintHelp(Vec); 138f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetUp(Vec); 1390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroy(Vec); 140f1e08e49SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecZeroEntries(Vec); 141f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOptionsPrefix(Vec,const char[]); 142f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAppendOptionsPrefix(Vec,const char[]); 143f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOptionsPrefix(Vec,const char*[]); 144f69a0ea3SMatthew Knepley 1450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec,PetscInt,PetscInt); 146fd487807SMatthew Knepley 1470c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDot(Vec,Vec,PetscScalar*); 148fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 1490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDot(Vec,Vec,PetscScalar*); 150fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 1510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDot(PetscInt,Vec,const Vec[],PetscScalar*); 1520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDot(PetscInt,Vec,const Vec[],PetscScalar*); 153cddf8d76SBarry Smith 15409321671SBarry Smith /*E 15509321671SBarry Smith NormType - determines what type of norm to compute 15609321671SBarry Smith 15709321671SBarry Smith Level: beginner 15809321671SBarry Smith 15909321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm() 16009321671SBarry Smith E*/ 1619dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType; 1629dcbbd2bSBarry Smith extern const char *NormTypes[]; 163cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY 16409321671SBarry Smith 1659b250c83SBarry Smith /*MC 1669b250c83SBarry Smith NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum 1679b250c83SBarry Smith 1689b250c83SBarry Smith Level: beginner 1699b250c83SBarry Smith 1709b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS, 1719b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1729b250c83SBarry Smith 1739b250c83SBarry Smith M*/ 1749b250c83SBarry Smith 1759b250c83SBarry Smith /*MC 1769b250c83SBarry Smith NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only) 1779b250c83SBarry Smith 1789b250c83SBarry Smith Level: beginner 1799b250c83SBarry Smith 1809b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS, 1819b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1829b250c83SBarry Smith 1839b250c83SBarry Smith M*/ 1849b250c83SBarry Smith 1859b250c83SBarry Smith /*MC 1869b250c83SBarry Smith NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors 1879b250c83SBarry Smith 1889b250c83SBarry Smith Level: beginner 1899b250c83SBarry Smith 1909b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 1919b250c83SBarry Smith NORM_INFINITY, NORM_1_AND_2 1929b250c83SBarry Smith 1939b250c83SBarry Smith M*/ 1949b250c83SBarry Smith 1959b250c83SBarry Smith /*MC 1969b250c83SBarry Smith NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum 1979b250c83SBarry Smith 1989b250c83SBarry Smith Level: beginner 1999b250c83SBarry Smith 2009b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 2019b250c83SBarry Smith NORM_FROBINIUS, NORM_1_AND_2 2029b250c83SBarry Smith 2039b250c83SBarry Smith M*/ 2049b250c83SBarry Smith 2059b250c83SBarry Smith /*MC 2069b250c83SBarry Smith NORM_1_AND_2 - computes both the 1 and 2 norm of a vector 2079b250c83SBarry Smith 2089b250c83SBarry Smith Level: beginner 2099b250c83SBarry Smith 2109b250c83SBarry Smith .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 2119b250c83SBarry Smith NORM_FROBINIUS, NORM_INFINITY 2129b250c83SBarry Smith 2139b250c83SBarry Smith M*/ 2149b250c83SBarry Smith 2159b250c83SBarry Smith /*MC 2169b250c83SBarry Smith NORM_MAX - see NORM_INFINITY 2179b250c83SBarry Smith 218d41222bbSBarry Smith Level: beginner 219d41222bbSBarry Smith 2209b250c83SBarry Smith M*/ 2219b250c83SBarry Smith 2220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNorm(Vec,NormType,PetscReal *); 223045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r)) 224c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r) 225c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r) 2260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormalize(Vec,PetscReal *); 2270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSum(Vec,PetscScalar*); 2280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMax(Vec,PetscInt*,PetscReal *); 229045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 2300c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMin(Vec,PetscInt*,PetscReal *); 231045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r)) 2322dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScale(Vec v,PetscScalar a); 2330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCopy(Vec,Vec); 234abb0e124SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetRandom(Vec,PetscRandom); 2352dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSet(Vec,PetscScalar); 2360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSwap(Vec,Vec); 2372dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPY(Vec,PetscScalar,Vec); 2382dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBY(Vec,PetscScalar,PetscScalar,Vec); 2392dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec*); 2402dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAYPX(Vec,PetscScalar,Vec); 2412dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecWAXPY(Vec,PetscScalar,Vec,Vec); 2420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMax(Vec,Vec,Vec); 2430190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y)) 2440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMaxAbs(Vec,Vec,Vec); 2450190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y)) 2460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMin(Vec,Vec,Vec); 2470190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y)) 2480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMult(Vec,Vec,Vec); 2490190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,y,y)) 2500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseDivide(Vec,Vec,Vec); 2510190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,y,y)) 2520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 2532dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecShift(Vec,PetscScalar); 2540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReciprocal(Vec); 2550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPermute(Vec, IS, PetscTruth); 2560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSqrt(Vec); 2570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAbs(Vec); 2580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicate(Vec,Vec*); 2590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicateVecs(Vec,PetscInt,Vec*[]); 2600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroyVecs(Vec[],PetscInt); 2610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetPetscMap(Vec,PetscMap*); 262fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetPetscMap,(Vec x),(x,&y),PetscMap,y) 2630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNormAll(Vec,NormType,PetscReal*); 2640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMaxAll(Vec,PetscInt *,PetscReal *); 2650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMinAll(Vec,PetscInt *,PetscReal *); 2660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScaleAll(Vec,PetscScalar*); 2674a560884SBarry Smith 2680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 269fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r) 270fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r) 2710c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 272fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 2730c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 274fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r) 2750c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScale(Vec,PetscInt,PetscScalar*); 276ba966639SSatish Balay PetscPolymorphicScalar(VecStrideScale,(Vec x,PetscInt i,PetscScalar _t),(x,i,&_T)) 277954b3ec6SBarry Smith 278954b3ec6SBarry Smith 2790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGather(Vec,PetscInt,Vec,InsertMode); 2800c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 2810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGatherAll(Vec,Vec*,InsertMode); 2820c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatterAll(Vec*,Vec,InsertMode); 283d2655a18SBarry Smith 2840c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 2850c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 2860c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyBegin(Vec); 2870c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyEnd(Vec); 2880c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashSetInitialSize(Vec,PetscInt,PetscInt); 2890c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashView(Vec,PetscViewer); 2900c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 29162dc5420SSatish Balay 2920c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscInt VecSetValue_Row; 2930c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscScalar VecSetValue_Value; 29430de9b25SBarry Smith /*MC 29530de9b25SBarry Smith VecSetValue - Set a single entry into a vector. 29630de9b25SBarry Smith 29730de9b25SBarry Smith Synopsis: 298d360dc6fSBarry Smith PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode); 29930de9b25SBarry Smith 30030de9b25SBarry Smith Not Collective 30130de9b25SBarry Smith 30230de9b25SBarry Smith Input Parameters: 30330de9b25SBarry Smith + v - the vector 30430de9b25SBarry Smith . row - the row location of the entry 30530de9b25SBarry Smith . value - the value to insert 30630de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 30730de9b25SBarry Smith 30830de9b25SBarry Smith Notes: 30930de9b25SBarry Smith For efficiency one should use VecSetValues() and set several or 31030de9b25SBarry Smith many values simultaneously if possible. 31130de9b25SBarry Smith 3121d73ed98SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 3131d73ed98SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 3141d73ed98SBarry Smith 3151d73ed98SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 3161d73ed98SBarry Smith 3171d73ed98SBarry Smith Level: beginner 3181d73ed98SBarry Smith 3191d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal() 3201d73ed98SBarry Smith M*/ 321f1144a30SSatish Balay #define VecSetValue(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValues(v,1,&VecSetValue_Row,&VecSetValue_Value,mode)) 3221d73ed98SBarry Smith 3231d73ed98SBarry Smith /*MC 3241d73ed98SBarry Smith VecSetValueLocal - Set a single entry into a vector using the local numbering 3251d73ed98SBarry Smith 3261d73ed98SBarry Smith Synopsis: 327d360dc6fSBarry Smith PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode); 3281d73ed98SBarry Smith 3291d73ed98SBarry Smith Not Collective 3301d73ed98SBarry Smith 3311d73ed98SBarry Smith Input Parameters: 3321d73ed98SBarry Smith + v - the vector 3331d73ed98SBarry Smith . row - the row location of the entry 3341d73ed98SBarry Smith . value - the value to insert 3351d73ed98SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 3361d73ed98SBarry Smith 3371d73ed98SBarry Smith Notes: 3381d73ed98SBarry Smith For efficiency one should use VecSetValues() and set several or 3391d73ed98SBarry Smith many values simultaneously if possible. 34030de9b25SBarry Smith 34130de9b25SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 34230de9b25SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 34330de9b25SBarry Smith 34430de9b25SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 34530de9b25SBarry Smith 34630de9b25SBarry Smith Level: beginner 34730de9b25SBarry Smith 3481d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue() 34930de9b25SBarry Smith M*/ 350f1144a30SSatish Balay #define VecSetValueLocal(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValuesLocal(v,1,&VecSetValue_Row,&VecSetValue_Value,mode)) 35130de9b25SBarry Smith 3520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetBlockSize(Vec,PetscInt); 3530c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetBlockSize(Vec,PetscInt*); 354fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i) 3550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 3568ed539a5SBarry Smith 357fd487807SMatthew Knepley /* Dynamic creation and loading functions */ 358fd487807SMatthew Knepley extern PetscFList VecList; 359d772e1d7SMatthew Knepley extern PetscTruth VecRegisterAllCalled; 360f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, VecType); 3610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, VecType *); 3620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec)); 3630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []); 3640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void); 36530de9b25SBarry Smith 36630de9b25SBarry Smith /*MC 36730de9b25SBarry Smith VecRegisterDynamic - Adds a new vector component implementation 36830de9b25SBarry Smith 36930de9b25SBarry Smith Synopsis: 370d360dc6fSBarry Smith PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec)) 37130de9b25SBarry Smith 37230de9b25SBarry Smith Not Collective 37330de9b25SBarry Smith 37430de9b25SBarry Smith Input Parameters: 37530de9b25SBarry Smith + name - The name of a new user-defined creation routine 37630de9b25SBarry Smith . path - The path (either absolute or relative) of the library containing this routine 37730de9b25SBarry Smith . func_name - The name of routine to create method context 37830de9b25SBarry Smith - create_func - The creation routine itself 37930de9b25SBarry Smith 38030de9b25SBarry Smith Notes: 38130de9b25SBarry Smith VecRegisterDynamic() may be called multiple times to add several user-defined vectors 38230de9b25SBarry Smith 38330de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 38430de9b25SBarry Smith 38530de9b25SBarry Smith Sample usage: 38630de9b25SBarry Smith .vb 38730de9b25SBarry Smith VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate); 38830de9b25SBarry Smith .ve 38930de9b25SBarry Smith 39030de9b25SBarry Smith Then, your vector type can be chosen with the procedural interface via 39130de9b25SBarry Smith .vb 39230de9b25SBarry Smith VecCreate(MPI_Comm, Vec *); 39330de9b25SBarry Smith VecSetType(Vec,"my_vector_name"); 39430de9b25SBarry Smith .ve 39530de9b25SBarry Smith or at runtime via the option 39630de9b25SBarry Smith .vb 39730de9b25SBarry Smith -vec_type my_vector_name 39830de9b25SBarry Smith .ve 39930de9b25SBarry Smith 400ab901514SBarry Smith Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 40130de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 40230de9b25SBarry Smith 40330de9b25SBarry Smith Level: advanced 40430de9b25SBarry Smith 40530de9b25SBarry Smith .keywords: Vec, register 40630de9b25SBarry Smith .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister() 40730de9b25SBarry Smith M*/ 408aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 409f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0) 41088d459dfSBarry Smith #else 411f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d) 41288d459dfSBarry Smith #endif 41388d459dfSBarry Smith 41409321671SBarry Smith 4150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreate(Vec,IS,Vec,IS,VecScatter *); 416fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s) 4170190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s)) 418fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s) 4190190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s)) 420fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s) 4210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterPostRecvs(Vec,Vec,InsertMode,ScatterMode,VecScatter); 4220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatter); 4230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatter); 4240c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterDestroy(VecScatter); 4250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCopy(VecScatter,VecScatter *); 4260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterView(VecScatter,PetscViewer); 4270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterRemap(VecScatter,PetscInt *,PetscInt*); 4280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterGetMerged(VecScatter,PetscTruth*); 4292195c698SBarry Smith 4300c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray_Private(Vec,PetscScalar*[]); 4310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray_Private(Vec,PetscScalar*[]); 4320c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4340c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4370c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 4390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]); 440ab360428SBarry Smith 4410c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPlaceArray(Vec,const PetscScalar[]); 4420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecResetArray(Vec); 4430c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReplaceArray(Vec,const PetscScalar[]); 4440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 4450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 44684cb2905SBarry Smith 4470c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecValid(Vec,PetscTruth*); 4480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecView(Vec,PetscViewer); 4490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecViewFromOptions(Vec, char *); 4500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecEqual(Vec,Vec,PetscTruth*); 451fcd5dd21SSatish Balay PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s) 452f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoad(PetscViewer,VecType,Vec*); 4530c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoadIntoVector(PetscViewer,Vec); 4548ed539a5SBarry Smith 4550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetSize(Vec,PetscInt*); 456fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s) 4570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetLocalSize(Vec,PetscInt*); 458fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s) 4590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 4608ed539a5SBarry Smith 4610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 4620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 4630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping); 4640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 46590f02eecSBarry Smith 4660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotBegin(Vec,Vec,PetscScalar *); 467ba966639SSatish Balay PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotEnd(Vec,Vec,PetscScalar *); 469fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotBegin(Vec,Vec,PetscScalar *); 471ba966639SSatish Balay PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL)) 4720c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotEnd(Vec,Vec,PetscScalar *); 473fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s) 4740c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormBegin(Vec,NormType,PetscReal *); 475ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL)) 476ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL)) 4770c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormEnd(Vec,NormType,PetscReal *); 478fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s) 479fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s) 480d3c178dbSBarry Smith 481*a751f32aSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotBegin(PetscInt,Vec,const Vec[],PetscScalar *); 482*a751f32aSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotEnd(PetscInt,Vec,const Vec[],PetscScalar *); 483*a751f32aSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotBegin(PetscInt,Vec,const Vec[],PetscScalar *); 484*a751f32aSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotEnd(PetscInt,Vec,const Vec[],PetscScalar *); 485*a751f32aSSatish Balay 486*a751f32aSSatish Balay 487fdbc4c26SBarry Smith typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_TREAT_OFF_PROC_ENTRIES} VecOption; 4880c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOption(Vec,VecOption); 48990f02eecSBarry Smith 490ebe3b25bSBarry Smith /* 491ebe3b25bSBarry Smith Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function 492ebe3b25bSBarry Smith call overhead on any 'native' Vecs. 493ebe3b25bSBarry Smith */ 494e1fa1e0fSSatish Balay 495e1fa1e0fSSatish Balay PETSC_EXTERN_CXX_END 4961d8d5f9aSSatish Balay #include "private/vecimpl.h" 497e1fa1e0fSSatish Balay PETSC_EXTERN_CXX_BEGIN 498ebe3b25bSBarry Smith 4990c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecContourScale(Vec,PetscReal,PetscReal); 500522c5e43SBarry Smith 50115091d37SBarry Smith /* 50215091d37SBarry Smith These numbers need to match the entries in 5033c94ec11SBarry Smith the function table in vecimpl.h 50415091d37SBarry Smith */ 505954b3ec6SBarry Smith typedef enum { VECOP_VIEW = 32, VECOP_LOADINTOVECTOR = 38} VecOperation; 5060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOperation(Vec,VecOperation,void(*)(void)); 507b19c1e4cSBarry Smith 508e182c471SBarry Smith /* 509e182c471SBarry Smith Routines for dealing with ghosted vectors: 510e182c471SBarry Smith vectors with ghost elements at the end of the array. 511e182c471SBarry Smith */ 5120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 5130c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 5140c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 5150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 5160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostGetLocalForm(Vec,Vec*); 517ba966639SSatish Balay PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s) 5180c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostRestoreLocalForm(Vec,Vec*); 5190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 5200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 521e182c471SBarry Smith 5220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecConjugate(Vec); 52334233285SBarry Smith 5240c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToAll(Vec,VecScatter*,Vec*); 5250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToZero(Vec,VecScatter*,Vec*); 526bba1ac68SSatish Balay 5270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaGetVector(PetscViewer, Vec); 5280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaPutVector(PetscViewer, Vec); 5297dbadf16SMatthew Knepley 530d59c15a7SBarry Smith /*S 531d59c15a7SBarry Smith Vecs - Collection of vectors where the data for the vectors is stored in 532d59c15a7SBarry Smith one continquous memory 533d59c15a7SBarry Smith 534d59c15a7SBarry Smith Level: advanced 535d59c15a7SBarry Smith 536d59c15a7SBarry Smith Notes: 537d59c15a7SBarry Smith Temporary construct for handling multiply right hand side solves 538d59c15a7SBarry Smith 539d59c15a7SBarry Smith This is faked by storing a single vector that has enough array space for 540d59c15a7SBarry Smith n vectors 541d59c15a7SBarry Smith 542d59c15a7SBarry Smith Concepts: parallel decomposition 543d59c15a7SBarry Smith 544d59c15a7SBarry Smith S*/ 54595fbd943SSatish Balay struct _n_Vecs {PetscInt n; Vec v;}; 54695fbd943SSatish Balay typedef struct _n_Vecs* Vecs; 547d59c15a7SBarry Smith #define VecsDestroy(x) (VecDestroy((x)->v) || PetscFree(x)) 54895fbd943SSatish Balay #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 54995fbd943SSatish Balay #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m)))) 55095fbd943SSatish Balay #define VecsDuplicate(x,y) (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n))) 551e9fa29b7SSatish Balay 552e9fa29b7SSatish Balay 553e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 5542eac72dbSBarry Smith #endif 555