xref: /petsc/include/petscvec.h (revision f48c50de2bf060e2c0c8a41c86317b6b47a547c6)
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
37398c84b2SBarry Smith   ScatterMode - Determines the direction of a scatter
38398c84b2SBarry Smith 
39398c84b2SBarry Smith   Level: beginner
40398c84b2SBarry Smith 
41398c84b2SBarry Smith .seealso: VecScatter, VecScatterBegin(), VecScatterEnd()
42398c84b2SBarry Smith E*/
43398c84b2SBarry Smith typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode;
44398c84b2SBarry Smith 
45398c84b2SBarry Smith /*MC
46398c84b2SBarry Smith     SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call
47398c84b2SBarry Smith 
48398c84b2SBarry Smith     Level: beginner
49398c84b2SBarry Smith 
50398c84b2SBarry Smith .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
51398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
52398c84b2SBarry Smith 
53398c84b2SBarry Smith M*/
54398c84b2SBarry Smith 
55398c84b2SBarry Smith /*MC
56398c84b2SBarry Smith     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
57398c84b2SBarry Smith          in the VecScatterCreate()
58398c84b2SBarry Smith 
59398c84b2SBarry Smith     Level: beginner
60398c84b2SBarry Smith 
61398c84b2SBarry Smith .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
62398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
63398c84b2SBarry Smith 
64398c84b2SBarry Smith M*/
65398c84b2SBarry Smith 
66398c84b2SBarry Smith /*MC
67398c84b2SBarry Smith     SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication
68398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
69398c84b2SBarry Smith 
70398c84b2SBarry Smith     Level: developer
71398c84b2SBarry Smith 
72398c84b2SBarry Smith .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
73398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
74398c84b2SBarry Smith 
75398c84b2SBarry Smith M*/
76398c84b2SBarry Smith 
77398c84b2SBarry Smith /*MC
78398c84b2SBarry Smith     SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
79398c84b2SBarry Smith          in the VecScatterCreate()  except NO parallel communication
80398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
81398c84b2SBarry Smith 
82398c84b2SBarry Smith     Level: developer
83398c84b2SBarry Smith 
84398c84b2SBarry Smith .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
85398c84b2SBarry Smith           SCATTER_REVERSE
86398c84b2SBarry Smith 
87398c84b2SBarry Smith M*/
88398c84b2SBarry Smith 
89398c84b2SBarry Smith /*E
9009321671SBarry Smith     VecType - String with the name of a PETSc vector or the creation function
9109321671SBarry Smith        with an optional dynamic library name, for example
9209321671SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
9309321671SBarry Smith 
9409321671SBarry Smith    Level: beginner
9509321671SBarry Smith 
9609321671SBarry Smith .seealso: VecSetType(), Vec
9709321671SBarry Smith E*/
98a313700dSBarry Smith #define VecType char*
990676abe4SMatthew Knepley #define VECSEQ         "seq"
1000676abe4SMatthew Knepley #define VECMPI         "mpi"
101*f48c50deSBarry Smith #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
1020676abe4SMatthew Knepley #define VECFETI        "feti"
1030676abe4SMatthew Knepley #define VECSHARED      "shared"
104765467adSMatthew Knepley #define VECSIEVE       "sieve"
10588b60a73SVictor Minden #define VECSEQCUDA     "seqcuda"
1062c1af831SVictor Minden #define VECMPICUDA     "mpicuda"
107*f48c50deSBarry Smith #define VECCUDA        "cuda"       /* seqcuda on one process and mpicuda on several */
1082eac72dbSBarry Smith 
109fd487807SMatthew Knepley /* Logging support */
1100700a824SBarry Smith #define    VEC_FILE_CLASSID 1211214
1110700a824SBarry Smith extern PETSCVEC_DLLEXPORT PetscClassId VEC_CLASSID;
1120700a824SBarry Smith extern PETSCVEC_DLLEXPORT PetscClassId VEC_SCATTER_CLASSID;
1138ba1e511SMatthew Knepley 
114e5bd5246SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(const char[]);
1158a9890e4SLisandro Dalcin EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecFinalizePackage(void);
116fd487807SMatthew Knepley 
1170c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm,Vec*);
118045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x))
1190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeq(MPI_Comm,PetscInt,Vec*);
120045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x))
1210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
122045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x))
1230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*);
124045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x))
1250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
126045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x))
1270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
1280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetFromOptions(Vec);
129f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetUp(Vec);
1300c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroy(Vec);
131f1e08e49SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecZeroEntries(Vec);
132f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOptionsPrefix(Vec,const char[]);
133f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAppendOptionsPrefix(Vec,const char[]);
134f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOptionsPrefix(Vec,const char*[]);
135f69a0ea3SMatthew Knepley 
1360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec,PetscInt,PetscInt);
137fd487807SMatthew Knepley 
1383c5daeb9SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotNorm2(Vec,Vec,PetscScalar*,PetscScalar*);
1390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDot(Vec,Vec,PetscScalar*);
140fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
1410c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDot(Vec,Vec,PetscScalar*);
142fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
143bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
144bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
145cddf8d76SBarry Smith 
14609321671SBarry Smith /*E
14709321671SBarry Smith     NormType - determines what type of norm to compute
14809321671SBarry Smith 
14909321671SBarry Smith     Level: beginner
15009321671SBarry Smith 
15109321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
15209321671SBarry Smith E*/
1539dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
1549dcbbd2bSBarry Smith extern const char *NormTypes[];
155cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY
15609321671SBarry Smith 
1579b250c83SBarry Smith /*MC
1589b250c83SBarry Smith      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
1599b250c83SBarry Smith 
1609b250c83SBarry Smith    Level: beginner
1619b250c83SBarry Smith 
1629b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
1639b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1649b250c83SBarry Smith 
1659b250c83SBarry Smith M*/
1669b250c83SBarry Smith 
1679b250c83SBarry Smith /*MC
1689b250c83SBarry Smith      NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only)
1699b250c83SBarry Smith 
1709b250c83SBarry Smith    Level: beginner
1719b250c83SBarry Smith 
1729b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
1739b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1749b250c83SBarry Smith 
1759b250c83SBarry Smith M*/
1769b250c83SBarry Smith 
1779b250c83SBarry Smith /*MC
1789b250c83SBarry Smith      NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors
1799b250c83SBarry Smith 
1809b250c83SBarry Smith    Level: beginner
1819b250c83SBarry Smith 
1829b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
1839b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1849b250c83SBarry Smith 
1859b250c83SBarry Smith M*/
1869b250c83SBarry Smith 
1879b250c83SBarry Smith /*MC
1889b250c83SBarry Smith      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
1899b250c83SBarry Smith 
1909b250c83SBarry Smith    Level: beginner
1919b250c83SBarry Smith 
1929b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
1939b250c83SBarry Smith            NORM_FROBINIUS, NORM_1_AND_2
1949b250c83SBarry Smith 
1959b250c83SBarry Smith M*/
1969b250c83SBarry Smith 
1979b250c83SBarry Smith /*MC
1989b250c83SBarry Smith      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector
1999b250c83SBarry Smith 
2009b250c83SBarry Smith    Level: beginner
2019b250c83SBarry Smith 
2029b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
2039b250c83SBarry Smith            NORM_FROBINIUS, NORM_INFINITY
2049b250c83SBarry Smith 
2059b250c83SBarry Smith M*/
2069b250c83SBarry Smith 
2079b250c83SBarry Smith /*MC
2089b250c83SBarry Smith      NORM_MAX - see NORM_INFINITY
2099b250c83SBarry Smith 
210d41222bbSBarry Smith    Level: beginner
211d41222bbSBarry Smith 
2129b250c83SBarry Smith M*/
2139b250c83SBarry Smith 
2140c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNorm(Vec,NormType,PetscReal *);
2157319c654SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormAvailable(Vec,NormType,PetscTruth*,PetscReal *);
216045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r))
217c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r)
218c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r)
2190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormalize(Vec,PetscReal *);
2200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSum(Vec,PetscScalar*);
2210c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMax(Vec,PetscInt*,PetscReal *);
222045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
2230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMin(Vec,PetscInt*,PetscReal *);
224045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
2259a05e725SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScale(Vec,PetscScalar);
2260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCopy(Vec,Vec);
227abb0e124SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetRandom(Vec,PetscRandom);
2282dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSet(Vec,PetscScalar);
2290c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSwap(Vec,Vec);
2302dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPY(Vec,PetscScalar,Vec);
2312dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
232bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
2332dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAYPX(Vec,PetscScalar,Vec);
2342dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecWAXPY(Vec,PetscScalar,Vec,Vec);
23509192fe3SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
2360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMax(Vec,Vec,Vec);
2370190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y))
2380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMaxAbs(Vec,Vec,Vec);
2390190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y))
2400c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMin(Vec,Vec,Vec);
2410190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y))
2420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMult(Vec,Vec,Vec);
243b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,x,y))
2440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseDivide(Vec,Vec,Vec);
245b2587007SBarry Smith PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,x,y))
2460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
2472dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecShift(Vec,PetscScalar);
2480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReciprocal(Vec);
2490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPermute(Vec, IS, PetscTruth);
2500e1b073aSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSqrtAbs(Vec);
25106c1185fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLog(Vec);
25206c1185fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecExp(Vec);
2530c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAbs(Vec);
2540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicate(Vec,Vec*);
2550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicateVecs(Vec,PetscInt,Vec*[]);
2560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroyVecs(Vec[],PetscInt);
257bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNormAll(Vec,NormType,PetscReal[]);
258bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
259bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMinAll(Vec,PetscInt [],PetscReal []);
260bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScaleAll(Vec,PetscScalar[]);
2614a560884SBarry Smith 
2620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
263fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r)
264fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r)
2650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
266fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
2670c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
268fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
269f31393a2Sdalcinl EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScale(Vec,PetscInt,PetscScalar);
270954b3ec6SBarry Smith 
271954b3ec6SBarry Smith 
2720c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGather(Vec,PetscInt,Vec,InsertMode);
2730c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
274bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGatherAll(Vec,Vec[],InsertMode);
275bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatterAll(Vec[],Vec,InsertMode);
276d2655a18SBarry Smith 
2770c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
2780c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
2790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyBegin(Vec);
2800c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyEnd(Vec);
2810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashSetInitialSize(Vec,PetscInt,PetscInt);
2820c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashView(Vec,PetscViewer);
2830c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
28462dc5420SSatish Balay 
28530de9b25SBarry Smith /*MC
28630de9b25SBarry Smith    VecSetValue - Set a single entry into a vector.
28730de9b25SBarry Smith 
28830de9b25SBarry Smith    Synopsis:
289d360dc6fSBarry Smith    PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode);
29030de9b25SBarry Smith 
29130de9b25SBarry Smith    Not Collective
29230de9b25SBarry Smith 
29330de9b25SBarry Smith    Input Parameters:
29430de9b25SBarry Smith +  v - the vector
29530de9b25SBarry Smith .  row - the row location of the entry
29630de9b25SBarry Smith .  value - the value to insert
29730de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
29830de9b25SBarry Smith 
29930de9b25SBarry Smith    Notes:
30030de9b25SBarry Smith    For efficiency one should use VecSetValues() and set several or
30130de9b25SBarry Smith    many values simultaneously if possible.
30230de9b25SBarry Smith 
3031d73ed98SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
3041d73ed98SBarry Smith    MUST be called after all calls to VecSetValues() have been completed.
3051d73ed98SBarry Smith 
3061d73ed98SBarry Smith    VecSetValues() uses 0-based indices in Fortran as well as in C.
3071d73ed98SBarry Smith 
3081d73ed98SBarry Smith    Level: beginner
3091d73ed98SBarry Smith 
3101d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
3111d73ed98SBarry Smith M*/
31250755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}
3131d73ed98SBarry Smith 
31430de9b25SBarry Smith 
3150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetBlockSize(Vec,PetscInt);
3160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetBlockSize(Vec,PetscInt*);
317fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i)
3180c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
3198ed539a5SBarry Smith 
320fd487807SMatthew Knepley /* Dynamic creation and loading functions */
321fd487807SMatthew Knepley extern PetscFList VecList;
322d772e1d7SMatthew Knepley extern PetscTruth VecRegisterAllCalled;
323a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, const VecType);
324a313700dSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, const VecType *);
3250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
3260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []);
3270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void);
32830de9b25SBarry Smith 
32930de9b25SBarry Smith /*MC
33030de9b25SBarry Smith   VecRegisterDynamic - Adds a new vector component implementation
33130de9b25SBarry Smith 
33230de9b25SBarry Smith   Synopsis:
3331890ba74SBarry Smith   PetscErrorCode VecRegisterDynamic(const char *name, const char *path, const char *func_name, PetscErrorCode (*create_func)(Vec))
33430de9b25SBarry Smith 
33530de9b25SBarry Smith   Not Collective
33630de9b25SBarry Smith 
33730de9b25SBarry Smith   Input Parameters:
33830de9b25SBarry Smith + name        - The name of a new user-defined creation routine
33930de9b25SBarry Smith . path        - The path (either absolute or relative) of the library containing this routine
34030de9b25SBarry Smith . func_name   - The name of routine to create method context
34130de9b25SBarry Smith - create_func - The creation routine itself
34230de9b25SBarry Smith 
34330de9b25SBarry Smith   Notes:
34430de9b25SBarry Smith   VecRegisterDynamic() may be called multiple times to add several user-defined vectors
34530de9b25SBarry Smith 
34630de9b25SBarry Smith   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
34730de9b25SBarry Smith 
34830de9b25SBarry Smith   Sample usage:
34930de9b25SBarry Smith .vb
35030de9b25SBarry Smith     VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate);
35130de9b25SBarry Smith .ve
35230de9b25SBarry Smith 
35330de9b25SBarry Smith   Then, your vector type can be chosen with the procedural interface via
35430de9b25SBarry Smith .vb
35530de9b25SBarry Smith     VecCreate(MPI_Comm, Vec *);
35630de9b25SBarry Smith     VecSetType(Vec,"my_vector_name");
35730de9b25SBarry Smith .ve
35830de9b25SBarry Smith    or at runtime via the option
35930de9b25SBarry Smith .vb
36030de9b25SBarry Smith     -vec_type my_vector_name
36130de9b25SBarry Smith .ve
36230de9b25SBarry Smith 
363ab901514SBarry Smith   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
36430de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
36530de9b25SBarry Smith 
36630de9b25SBarry Smith   Level: advanced
36730de9b25SBarry Smith 
36830de9b25SBarry Smith .keywords: Vec, register
36930de9b25SBarry Smith .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister()
37030de9b25SBarry Smith M*/
371aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
372f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0)
37388d459dfSBarry Smith #else
374f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d)
37588d459dfSBarry Smith #endif
37688d459dfSBarry Smith 
37709321671SBarry Smith 
3780c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
379fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s)
3800190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s))
381fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s)
3820190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s))
383fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s)
384450faa77SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateEmpty(MPI_Comm,VecScatter *);
385fbb399caSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt);
386ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
387ca9f406cSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
3880c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterDestroy(VecScatter);
3890c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCopy(VecScatter,VecScatter *);
3900c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterView(VecScatter,PetscViewer);
3910c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
3920c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterGetMerged(VecScatter,PetscTruth*);
3932195c698SBarry Smith 
3940c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray_Private(Vec,PetscScalar*[]);
3950c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray_Private(Vec,PetscScalar*[]);
3960c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3970c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3980c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
3990c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
4000c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
4010c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
4020c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
4030c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
404ab360428SBarry Smith 
4050c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPlaceArray(Vec,const PetscScalar[]);
4060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecResetArray(Vec);
4070c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReplaceArray(Vec,const PetscScalar[]);
4080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
4090c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);
41084cb2905SBarry Smith 
4110c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecValid(Vec,PetscTruth*);
4120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecView(Vec,PetscViewer);
4134e2ffeddSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecViewFromOptions(Vec, const char *);
4140c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecEqual(Vec,Vec,PetscTruth*);
415fcd5dd21SSatish Balay PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s)
416d3a0dce1SShri Abhyankar EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoad(PetscViewer,Vec);
4178ed539a5SBarry Smith 
4180c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetSize(Vec,PetscInt*);
419fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s)
4200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetLocalSize(Vec,PetscInt*);
421fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s)
4220c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
42306709851SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRanges(Vec,const PetscInt *[]);
4248ed539a5SBarry Smith 
4250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
4260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
42788b03592SBarry Smith 
42888b03592SBarry Smith /*MC
42988b03592SBarry Smith    VecSetValueLocal - Set a single entry into a vector using the local numbering
43088b03592SBarry Smith 
43188b03592SBarry Smith    Synopsis:
43288b03592SBarry Smith    PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode);
43388b03592SBarry Smith 
43488b03592SBarry Smith    Not Collective
43588b03592SBarry Smith 
43688b03592SBarry Smith    Input Parameters:
43788b03592SBarry Smith +  v - the vector
43888b03592SBarry Smith .  row - the row location of the entry
43988b03592SBarry Smith .  value - the value to insert
44088b03592SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
44188b03592SBarry Smith 
44288b03592SBarry Smith    Notes:
44388b03592SBarry Smith    For efficiency one should use VecSetValues() and set several or
44488b03592SBarry Smith    many values simultaneously if possible.
44588b03592SBarry Smith 
44688b03592SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
44788b03592SBarry Smith    MUST be called after all calls to VecSetValues() have been completed.
44888b03592SBarry Smith 
44988b03592SBarry Smith    VecSetValues() uses 0-based indices in Fortran as well as in C.
45088b03592SBarry Smith 
45188b03592SBarry Smith    Level: beginner
45288b03592SBarry Smith 
45388b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
45488b03592SBarry Smith M*/
45588b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}
45688b03592SBarry Smith 
4570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping);
4580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
45990f02eecSBarry Smith 
4600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotBegin(Vec,Vec,PetscScalar *);
461ba966639SSatish Balay PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
4620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotEnd(Vec,Vec,PetscScalar *);
463fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
4640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotBegin(Vec,Vec,PetscScalar *);
465ba966639SSatish Balay PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
4660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotEnd(Vec,Vec,PetscScalar *);
467fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
4680c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormBegin(Vec,NormType,PetscReal *);
469ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL))
470ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL))
4710c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormEnd(Vec,NormType,PetscReal *);
472fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s)
473fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s)
474d3c178dbSBarry Smith 
475bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
476bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
477bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
478bb9195b6SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
479a751f32aSSatish Balay 
480a751f32aSSatish Balay 
4819533e83fSBarry Smith typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption;
4829533e83fSBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOption(Vec,VecOption,PetscTruth);
48390f02eecSBarry Smith 
484ebe3b25bSBarry Smith /*
485ebe3b25bSBarry Smith    Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function
486ebe3b25bSBarry Smith    call overhead on any 'native' Vecs.
487ebe3b25bSBarry Smith */
488e1fa1e0fSSatish Balay 
4891d8d5f9aSSatish Balay #include "private/vecimpl.h"
490ebe3b25bSBarry Smith 
4910c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecContourScale(Vec,PetscReal,PetscReal);
492522c5e43SBarry Smith 
49315091d37SBarry Smith /*
49415091d37SBarry Smith     These numbers need to match the entries in
4953c94ec11SBarry Smith   the function table in vecimpl.h
49615091d37SBarry Smith */
497b4a4a85eSShri Abhyankar typedef enum { VECOP_VIEW = 33, VECOP_LOAD = 41} VecOperation;
4980c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOperation(Vec,VecOperation,void(*)(void));
499b19c1e4cSBarry Smith 
500e182c471SBarry Smith /*
501e182c471SBarry Smith      Routines for dealing with ghosted vectors:
502e182c471SBarry Smith   vectors with ghost elements at the end of the array.
503e182c471SBarry Smith */
5040c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
5050c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
5060c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
5070c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
5080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostGetLocalForm(Vec,Vec*);
509ba966639SSatish Balay PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s)
5100c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostRestoreLocalForm(Vec,Vec*);
5110c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
5120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);
513e182c471SBarry Smith 
5140c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecConjugate(Vec);
51534233285SBarry Smith 
5160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToAll(Vec,VecScatter*,Vec*);
5170c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToZero(Vec,VecScatter*,Vec*);
518bba1ac68SSatish Balay 
5190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaGetVector(PetscViewer, Vec);
5200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaPutVector(PetscViewer, Vec);
5217dbadf16SMatthew Knepley 
522d59c15a7SBarry Smith /*S
523d59c15a7SBarry Smith      Vecs - Collection of vectors where the data for the vectors is stored in
524759e7b9cSHong Zhang             one contiguous memory
525d59c15a7SBarry Smith 
526d59c15a7SBarry Smith    Level: advanced
527d59c15a7SBarry Smith 
528d59c15a7SBarry Smith    Notes:
529d59c15a7SBarry Smith     Temporary construct for handling multiply right hand side solves
530d59c15a7SBarry Smith 
531d59c15a7SBarry Smith     This is faked by storing a single vector that has enough array space for
532d59c15a7SBarry Smith     n vectors
533d59c15a7SBarry Smith 
534d59c15a7SBarry Smith   Concepts: parallel decomposition
535d59c15a7SBarry Smith 
536d59c15a7SBarry Smith S*/
53795fbd943SSatish Balay         struct _n_Vecs  {PetscInt n; Vec v;};
53895fbd943SSatish Balay typedef struct _n_Vecs* Vecs;
539d59c15a7SBarry Smith #define VecsDestroy(x)            (VecDestroy((x)->v)         || PetscFree(x))
54095fbd943SSatish Balay #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
54195fbd943SSatish Balay #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
54295fbd943SSatish Balay #define VecsDuplicate(x,y)        (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n)))
543e9fa29b7SSatish Balay 
544e9fa29b7SSatish Balay 
545e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
5462eac72dbSBarry Smith #endif
547