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 797929ea7SJunchao Zhang #if !defined(PETSCVEC_H) 826bd1501SBarry Smith #define PETSCVEC_H 997929ea7SJunchao Zhang #include <petscsys.h> 1097929ea7SJunchao Zhang #include <petscsftypes.h> /* for VecScatter, VecScatterType */ 112c8e378dSBarry Smith #include <petscis.h> 12030f984aSJacob Faibussowitsch #include <petscdevicetypes.h> 13665c2dedSJed Brown #include <petscviewer.h> 142eac72dbSBarry Smith 1509321671SBarry Smith /*S 1609321671SBarry Smith Vec - Abstract PETSc vector object 1709321671SBarry Smith 1809321671SBarry Smith Level: beginner 1909321671SBarry Smith 2009321671SBarry Smith .seealso: VecCreate(), VecType, VecSetType() 2109321671SBarry Smith S*/ 22f09e8eb9SSatish Balay typedef struct _p_Vec* Vec; 2309321671SBarry Smith 2409321671SBarry Smith /*E 25398c84b2SBarry Smith ScatterMode - Determines the direction of a scatter 26398c84b2SBarry Smith 27398c84b2SBarry Smith Level: beginner 28398c84b2SBarry Smith 29398c84b2SBarry Smith .seealso: VecScatter, VecScatterBegin(), VecScatterEnd() 30398c84b2SBarry Smith E*/ 31398c84b2SBarry Smith typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode; 32398c84b2SBarry Smith 33398c84b2SBarry Smith /*MC 34130e142eSJunchao Zhang SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call 35398c84b2SBarry Smith 36398c84b2SBarry Smith Level: beginner 37398c84b2SBarry Smith 38130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL, 39398c84b2SBarry Smith SCATTER_REVERSE_LOCAL 40398c84b2SBarry Smith 41398c84b2SBarry Smith M*/ 42398c84b2SBarry Smith 43398c84b2SBarry Smith /*MC 44398c84b2SBarry Smith SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in 45130e142eSJunchao Zhang in the VecScatterCreate() 46398c84b2SBarry Smith 47398c84b2SBarry Smith Level: beginner 48398c84b2SBarry Smith 49130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 50398c84b2SBarry Smith SCATTER_REVERSE_LOCAL 51398c84b2SBarry Smith 52398c84b2SBarry Smith M*/ 53398c84b2SBarry Smith 54398c84b2SBarry Smith /*MC 55130e142eSJunchao Zhang SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication 56398c84b2SBarry Smith is done. Any variables that have be moved between processes are ignored 57398c84b2SBarry Smith 58398c84b2SBarry Smith Level: developer 59398c84b2SBarry Smith 60130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD, 61398c84b2SBarry Smith SCATTER_REVERSE_LOCAL 62398c84b2SBarry Smith 63398c84b2SBarry Smith M*/ 64398c84b2SBarry Smith 65398c84b2SBarry Smith /*MC 66398c84b2SBarry Smith SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in 67130e142eSJunchao Zhang in the VecScatterCreate() 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 72130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL, 73398c84b2SBarry Smith SCATTER_REVERSE 74398c84b2SBarry Smith 75398c84b2SBarry Smith M*/ 76398c84b2SBarry Smith 7776bdecfbSBarry Smith /*J 788f6c3df8SBarry Smith VecType - String with the name of a PETSc vector 7909321671SBarry Smith 8009321671SBarry Smith Level: beginner 8109321671SBarry Smith 828f6c3df8SBarry Smith .seealso: VecSetType(), Vec, VecCreate(), VecDestroy() 8376bdecfbSBarry Smith J*/ 8419fd82e9SBarry Smith typedef const char* VecType; 850676abe4SMatthew Knepley #define VECSEQ "seq" 860676abe4SMatthew Knepley #define VECMPI "mpi" 87f48c50deSBarry Smith #define VECSTANDARD "standard" /* seq on one process and mpi on several */ 880676abe4SMatthew Knepley #define VECSHARED "shared" 89b17c682bSKarl Rupp #define VECSEQVIENNACL "seqviennacl" 90b17c682bSKarl Rupp #define VECMPIVIENNACL "mpiviennacl" 91b17c682bSKarl Rupp #define VECVIENNACL "viennacl" /* seqviennacl on one process and mpiviennacl on several */ 9282f73ecaSAlejandro Lamas Daviña #define VECSEQCUDA "seqcuda" 9382f73ecaSAlejandro Lamas Daviña #define VECMPICUDA "mpicuda" 9482f73ecaSAlejandro Lamas Daviña #define VECCUDA "cuda" /* seqcuda on one process and mpicuda on several */ 9559af0bd3SScott Kruger #define VECSEQHIP "seqhip" 9659af0bd3SScott Kruger #define VECMPIHIP "mpihip" 9759af0bd3SScott Kruger #define VECHIP "hip" /* seqcuda on one process and mpicuda on several */ 981aae2881SJed Brown #define VECNEST "nest" 9910171e34SJunchao Zhang #define VECSEQKOKKOS "seqkokkos" 10010171e34SJunchao Zhang #define VECMPIKOKKOS "mpikokkos" 10110171e34SJunchao Zhang #define VECKOKKOS "kokkos" /* seqkokkos on one process and mpikokkos on several */ 1022eac72dbSBarry Smith 103803a1b88SHong Zhang /* Dynamic creation and loading functions */ 104803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType); 105803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType*); 106803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter); 107803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[],PetscErrorCode (*)(VecScatter)); 108130e142eSJunchao Zhang PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter*); 1094b71561bSShri Abhyankar 110fd487807SMatthew Knepley /* Logging support */ 111450a797fSBarry Smith #define REAL_FILE_CLASSID 1211213 1120700a824SBarry Smith #define VEC_FILE_CLASSID 1211214 113014dd563SJed Brown PETSC_EXTERN PetscClassId VEC_CLASSID; 11497929ea7SJunchao Zhang PETSC_EXTERN PetscClassId PETSCSF_CLASSID; 11545b63f25SDmitry Karpeev 116607a6623SBarry Smith PETSC_EXTERN PetscErrorCode VecInitializePackage(void); 117014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecFinalizePackage(void); 118fd487807SMatthew Knepley 119014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*); 120014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*); 121014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 122014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 123014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*); 124014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 125803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm,PetscInt,PetscInt,Vec*); 126803a1b88SHong Zhang 127014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec); 128fe2efc57SMark PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec,PetscObject,const char[]); 1290d2bece7SBarry Smith 130014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetUp(Vec); 131014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroy(Vec*); 132014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec); 133014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]); 134014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]); 135014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]); 136f69a0ea3SMatthew Knepley 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt); 138fd487807SMatthew Knepley 13952b6e47cSBarry Smith PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*); 140014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*); 14167392de3SBarry Smith PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*); 142014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*); 143014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]); 144014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]); 145014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*); 146014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*); 147598f99faSAlp Dener PETSC_EXTERN PetscErrorCode VecConcatenate(PetscInt,const Vec[],Vec*,IS*[]); 148cddf8d76SBarry Smith 14909321671SBarry Smith /*E 15009321671SBarry Smith NormType - determines what type of norm to compute 15109321671SBarry Smith 15209321671SBarry Smith Level: beginner 15309321671SBarry Smith 15409321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm() 15509321671SBarry Smith E*/ 156a873a8cdSSam Reynolds typedef enum {NORM_1=0, 157a873a8cdSSam Reynolds NORM_2=1, 158a873a8cdSSam Reynolds NORM_FROBENIUS=2, 159a873a8cdSSam Reynolds NORM_INFINITY=3, 160a873a8cdSSam Reynolds NORM_1_AND_2=4 161a873a8cdSSam Reynolds } NormType; 1626a6fc655SJed Brown PETSC_EXTERN const char *const 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 176df54d55cSMatthias Liertzer 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 186df54d55cSMatthias Liertzer 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, 20152e318dbSPierre Jolivet NORM_FROBENIUS, 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, 21152e318dbSPierre Jolivet NORM_FROBENIUS, 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 222a873a8cdSSam Reynolds /*E 223*857cbf51SRichard Tran Mills ReductionType - determines what type of column reduction (one that is not a type of norm defined in NormType) to compute 224a873a8cdSSam Reynolds 225a873a8cdSSam Reynolds Level: beginner 226a873a8cdSSam Reynolds 227a873a8cdSSam Reynolds .seealso: MatGetColumnReductions(), MatGetColumnNorms(), NormType 228a873a8cdSSam Reynolds E*/ 229*857cbf51SRichard Tran Mills /* NOTE: The integer constants defined in ReductionType MUST BE DISTINCT from those defined in NormType. 230*857cbf51SRichard Tran Mills * This is because MatGetColumnReductions() is used to compute both norms and other types of reductions, 231*857cbf51SRichard Tran Mills * and the constants defined in both NormType and ReductionType are used to designate the desired operation. */ 232*857cbf51SRichard Tran Mills typedef enum {REDUCTION_SUM_REALPART=10, 233*857cbf51SRichard Tran Mills REDUCTION_MEAN_REALPART=11, 234*857cbf51SRichard Tran Mills REDUCTION_SUM_IMAGINARYPART=12, 235*857cbf51SRichard Tran Mills REDUCTION_MEAN_IMAGINARYPART=13 236a873a8cdSSam Reynolds } ReductionType; 237a873a8cdSSam Reynolds 238a873a8cdSSam Reynolds /*MC 239*857cbf51SRichard Tran Mills REDUCTION_SUM_REALPART - sum of real part of matrix column 240a873a8cdSSam Reynolds 241a873a8cdSSam Reynolds Level: beginner 242a873a8cdSSam Reynolds 243*857cbf51SRichard Tran Mills .seealso: ReductionType, MatGetColumnReductions(), REDUCTION_SUM_IMAGINARYPART, REDUCTION_MEAN_REALPART, REDUCTION_NORM_1, 244a873a8cdSSam Reynolds REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY 245a873a8cdSSam Reynolds 246a873a8cdSSam Reynolds M*/ 247a873a8cdSSam Reynolds 248a873a8cdSSam Reynolds /*MC 249*857cbf51SRichard Tran Mills REDUCTION_SUM_IMAGINARYPART - sum of imaginary part of matrix column 250a873a8cdSSam Reynolds 251a873a8cdSSam Reynolds Level: beginner 252a873a8cdSSam Reynolds 253*857cbf51SRichard Tran Mills .seealso: ReductionType, MatGetColumnReductions(), REDUCTION_SUM_REALPART, REDUCTION_MEAN_IMAGINARYPART, REDUCTION_NORM_1, 254*857cbf51SRichard Tran Mills REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY 255*857cbf51SRichard Tran Mills 256*857cbf51SRichard Tran Mills M*/ 257*857cbf51SRichard Tran Mills 258*857cbf51SRichard Tran Mills /*MC 259*857cbf51SRichard Tran Mills REDUCTION_MEAN_REALPART - arithmetic mean of real part of matrix column 260*857cbf51SRichard Tran Mills 261*857cbf51SRichard Tran Mills Level: beginner 262*857cbf51SRichard Tran Mills 263*857cbf51SRichard Tran Mills .seealso: ReductionType, MatGetColumnReductions(), REDUCTION_MEAN_IMAGINARYPART, REDUCTION_SUM_REALPART, REDUCTION_NORM_1, 264*857cbf51SRichard Tran Mills REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY 265*857cbf51SRichard Tran Mills 266*857cbf51SRichard Tran Mills M*/ 267*857cbf51SRichard Tran Mills 268*857cbf51SRichard Tran Mills /*MC 269*857cbf51SRichard Tran Mills REDUCTION_MEAN_IMAGINARYPART - arithmetic mean of imaginary part of matrix column 270*857cbf51SRichard Tran Mills 271*857cbf51SRichard Tran Mills Level: beginner 272*857cbf51SRichard Tran Mills 273*857cbf51SRichard Tran Mills .seealso: ReductionType, MatGetColumnReductions(), REDUCTION_MEAN_REALPART, REDUCTION_SUM_IMAGINARYPART, REDUCTION_NORM_1, 274a873a8cdSSam Reynolds REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY 275a873a8cdSSam Reynolds 276a873a8cdSSam Reynolds M*/ 277a873a8cdSSam Reynolds 278014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *); 279014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *); 280014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *); 281014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*); 282014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *); 283014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *); 284014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar); 285014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec); 286014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom); 287014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar); 288422a814eSBarry Smith PETSC_EXTERN PetscErrorCode VecSetInf(Vec); 289014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec); 290014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec); 291014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec); 292014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]); 293014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec); 294014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec); 295014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); 296014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec); 297014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec); 298014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec); 299014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec); 300014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec); 301014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 302014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar); 303014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReciprocal(Vec); 304014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool); 305014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec); 306014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLog(Vec); 307014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecExp(Vec); 308014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAbs(Vec); 309014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*); 310014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]); 311014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]); 312014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]); 313014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []); 314014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []); 315014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]); 316849b11cfSMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**); 3174a560884SBarry Smith 318014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 319014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 320014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 321014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar); 322014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar); 323954b3ec6SBarry Smith 324014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode); 325014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 326014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode); 327014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode); 328d2655a18SBarry Smith 329bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode); 330bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode); 331bdeb6c88SBarry Smith 332014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 333014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 334014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec); 335014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec); 336014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt); 337014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer); 338685405a1SBarry Smith PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]); 339014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 34062dc5420SSatish Balay 34130de9b25SBarry Smith /*MC 34230de9b25SBarry Smith VecSetValue - Set a single entry into a vector. 34330de9b25SBarry Smith 34430de9b25SBarry Smith Synopsis: 345aaa7dc30SBarry Smith #include <petscvec.h> 3468122439eSJed Brown PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode); 34730de9b25SBarry Smith 34830de9b25SBarry Smith Not Collective 34930de9b25SBarry Smith 35030de9b25SBarry Smith Input Parameters: 35130de9b25SBarry Smith + v - the vector 35230de9b25SBarry Smith . row - the row location of the entry 35330de9b25SBarry Smith . value - the value to insert 35430de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 35530de9b25SBarry Smith 35630de9b25SBarry Smith Notes: 35730de9b25SBarry Smith For efficiency one should use VecSetValues() and set several or 35830de9b25SBarry Smith many values simultaneously if possible. 35930de9b25SBarry Smith 3601d73ed98SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 361879a43d7SBarry Smith MUST be called after all calls to VecSetValue() have been completed. 3621d73ed98SBarry Smith 363879a43d7SBarry Smith VecSetValue() uses 0-based indices in Fortran as well as in C. 3641d73ed98SBarry Smith 3651d73ed98SBarry Smith Level: beginner 3661d73ed98SBarry Smith 3671d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal() 3681d73ed98SBarry Smith M*/ 36950755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);} 3701d73ed98SBarry Smith 371014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt); 372014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*); 373014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 3748ed539a5SBarry Smith 375fd487807SMatthew Knepley /* Dynamic creation and loading functions */ 376140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList VecList; 37719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType); 37819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*); 379bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec)); 38030de9b25SBarry Smith 381014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode); 382014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode); 383014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*); 384246626dcSBarry Smith PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter); 385014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *); 386014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer); 387fe2efc57SMark PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]); 388d27e6124SSatish Balay PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]); 389014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*); 3902195c698SBarry Smith 391014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 392014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 393014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 394014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 395014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 396014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 397014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]); 398014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]); 399ab360428SBarry Smith 400fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 401fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 402fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 403fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 404fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 405fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 406fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 407fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]); 408fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]); 409fdc842d1SBarry Smith 4105edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4115edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4125edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4135edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4145edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4155edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4165edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]); 4175edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]); 4185edff71fSBarry Smith 419014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]); 420014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecResetArray(Vec); 421014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]); 422de0d48c1SKarl Rupp 423014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 424014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 42584cb2905SBarry Smith 426014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer); 427014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*); 428014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer); 4298ed539a5SBarry Smith 430014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*); 431014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*); 432014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 433014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]); 4348ed539a5SBarry Smith 435014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 436014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 43788b03592SBarry Smith 4389a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**); 4399a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**); 440de0d48c1SKarl Rupp 4419a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**); 4429a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**); 443de0d48c1SKarl Rupp 4449a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**); 4459a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**); 446de0d48c1SKarl Rupp 447cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]); 448cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]); 449de0d48c1SKarl Rupp PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec); 450de0d48c1SKarl Rupp 45159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArray(Vec,PetscScalar**); 45259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArray(Vec,PetscScalar**); 45359af0bd3SScott Kruger 45459af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArrayRead(Vec,const PetscScalar**); 45559af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayRead(Vec,const PetscScalar**); 45659af0bd3SScott Kruger 45759af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArrayWrite(Vec,PetscScalar**); 45859af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayWrite(Vec,PetscScalar**); 45959af0bd3SScott Kruger 46059af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPPlaceArray(Vec,const PetscScalar[]); 46159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPReplaceArray(Vec,const PetscScalar[]); 46259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPResetArray(Vec); 46359af0bd3SScott Kruger 46476ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*); 46576ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*); 46676ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*); 46776ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*); 46876ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec); 46976ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*); 47076ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec); 47176ec7f3eSKaushik Kulkarni 47288b03592SBarry Smith /*MC 47388b03592SBarry Smith VecSetValueLocal - Set a single entry into a vector using the local numbering 47488b03592SBarry Smith 47588b03592SBarry Smith Synopsis: 476aaa7dc30SBarry Smith #include <petscvec.h> 4778122439eSJed Brown PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode); 47888b03592SBarry Smith 47988b03592SBarry Smith Not Collective 48088b03592SBarry Smith 48188b03592SBarry Smith Input Parameters: 48288b03592SBarry Smith + v - the vector 48388b03592SBarry Smith . row - the row location of the entry 48488b03592SBarry Smith . value - the value to insert 48588b03592SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 48688b03592SBarry Smith 48788b03592SBarry Smith Notes: 48888b03592SBarry Smith For efficiency one should use VecSetValues() and set several or 48988b03592SBarry Smith many values simultaneously if possible. 49088b03592SBarry Smith 49188b03592SBarry Smith These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 49288b03592SBarry Smith MUST be called after all calls to VecSetValues() have been completed. 49388b03592SBarry Smith 49488b03592SBarry Smith VecSetValues() uses 0-based indices in Fortran as well as in C. 49588b03592SBarry Smith 49688b03592SBarry Smith Level: beginner 49788b03592SBarry Smith 49888b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue() 49988b03592SBarry Smith M*/ 50088b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);} 50188b03592SBarry Smith 502014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 503014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping*); 50490f02eecSBarry Smith 505014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *); 506014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *); 507014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *); 508014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *); 509014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *); 510014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *); 511d3c178dbSBarry Smith 512014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 513014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 514014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 515014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 516014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm); 517a751f32aSSatish Balay 518b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool); 519b470e4b4SRichard Tran Mills PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") PETSC_STATIC_INLINE PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);} 520387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t); 521387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *); 522a751f32aSSatish Balay 5236fe358cdSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec,PetscOffloadMask *); 52448d97fd2SKaushik Kulkarni 525bda0d2a0SJed Brown typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES,VEC_SUBSET_OFF_PROC_ENTRIES} VecOption; 526014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscBool); 52790f02eecSBarry Smith 5285c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**); 529fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**); 5305c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**); 5315c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**); 532fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**); 5335c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**); 534046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec); 535046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec); 536046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec); 537046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec); 538a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec,PetscScalar**,PetscMemType*); 539a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec,PetscScalar**); 540a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec,const PetscScalar**,PetscMemType*); 541a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec,const PetscScalar**); 54210171e34SJunchao Zhang 5439521ec69SBarry Smith /*@C 5449521ec69SBarry Smith VecGetArrayPair - Accesses a pair of pointers for two vectors that may be common. When not common the first is read only 5459521ec69SBarry Smith 546d083f849SBarry Smith Logically Collective on x 5479521ec69SBarry Smith 548f5f57ec0SBarry Smith Input Parameters: 5499521ec69SBarry Smith + x - the vector 5509521ec69SBarry Smith - y - the second vector 5519521ec69SBarry Smith 552f5f57ec0SBarry Smith Output Parameters: 5539521ec69SBarry Smith + xv - location to put pointer to the first array 5549521ec69SBarry Smith - yv - location to put pointer to the second array 5559521ec69SBarry Smith 5569521ec69SBarry Smith Level: developer 5579521ec69SBarry Smith 558f5f57ec0SBarry Smith Not available from Fortran 559f5f57ec0SBarry Smith 5609521ec69SBarry Smith .seealso: VecGetArray(), VecGetArrayRead(), VecRestoreArrayPair() 5619521ec69SBarry Smith 5629521ec69SBarry Smith @*/ 563d9ca1df4SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv) 564d9ca1df4SBarry Smith { 565d9ca1df4SBarry Smith PetscErrorCode ierr; 566d9ca1df4SBarry Smith 567d9ca1df4SBarry Smith PetscFunctionBegin; 568d9ca1df4SBarry Smith ierr = VecGetArray(y,yv);CHKERRQ(ierr); 569d9ca1df4SBarry Smith if (x != y) { 570d9ca1df4SBarry Smith ierr = VecGetArrayRead(x,(const PetscScalar **)xv);CHKERRQ(ierr); 571d9ca1df4SBarry Smith } else { 572d9ca1df4SBarry Smith *xv = *yv; 573d9ca1df4SBarry Smith } 574d9ca1df4SBarry Smith PetscFunctionReturn(0); 575d9ca1df4SBarry Smith } 5769521ec69SBarry Smith 5779521ec69SBarry Smith /*@C 5789521ec69SBarry Smith VecRestoreArrayPair - Returns a pair of pointers for two vectors that may be common. When not common the first is read only 5799521ec69SBarry Smith 580d083f849SBarry Smith Logically Collective on x 5819521ec69SBarry Smith 582f5f57ec0SBarry Smith Input Parameters: 5839521ec69SBarry Smith + x - the vector 5849521ec69SBarry Smith - y - the second vector 5859521ec69SBarry Smith 586f5f57ec0SBarry Smith Output Parameters: 5879521ec69SBarry Smith + xv - location to put pointer to the first array 5889521ec69SBarry Smith - yv - location to put pointer to the second array 5899521ec69SBarry Smith 5909521ec69SBarry Smith Level: developer 5919521ec69SBarry Smith 592f5f57ec0SBarry Smith Not available from Fortran 593f5f57ec0SBarry Smith 5949521ec69SBarry Smith .seealso: VecGetArray(), VecGetArrayRead(), VecGetArrayPair() 5959521ec69SBarry Smith 5969521ec69SBarry Smith @*/ 597d9ca1df4SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv) 598d9ca1df4SBarry Smith { 599d9ca1df4SBarry Smith PetscErrorCode ierr; 600d9ca1df4SBarry Smith 601d9ca1df4SBarry Smith PetscFunctionBegin; 602d9ca1df4SBarry Smith ierr = VecRestoreArray(y,yv);CHKERRQ(ierr); 603d9ca1df4SBarry Smith if (x != y) { 604d9ca1df4SBarry Smith ierr = VecRestoreArrayRead(x,(const PetscScalar **)xv);CHKERRQ(ierr); 605d9ca1df4SBarry Smith } 606d9ca1df4SBarry Smith PetscFunctionReturn(0); 607d9ca1df4SBarry Smith } 608d9ca1df4SBarry Smith 609d9ca1df4SBarry Smith #if defined(PETSC_USE_DEBUG) 61038fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec); 61138fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec); 61238fecf7cSJunchao Zhang /* We also have a non-public VecLockWriteSet_Private() in vecimpl.h */ 613d9ca1df4SBarry Smith PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*); 614da1c2f70SJunchao Zhang PETSC_STATIC_INLINE PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg) 615da1c2f70SJunchao Zhang { 616da1c2f70SJunchao Zhang PetscInt state; 617da1c2f70SJunchao Zhang PetscErrorCode ierr; 61838fecf7cSJunchao Zhang 619da1c2f70SJunchao Zhang PetscFunctionBegin; 620da1c2f70SJunchao Zhang ierr = VecLockGet(x,&state);CHKERRQ(ierr); 621da1c2f70SJunchao Zhang if (state != 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE," Vec is already locked for read-only or read/write access, argument # %d",arg); 622da1c2f70SJunchao Zhang PetscFunctionReturn(0); 623da1c2f70SJunchao Zhang } 62438fecf7cSJunchao Zhang /* The three are deprecated */ 6255f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec); 6265f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)") PetscErrorCode VecLockPop(Vec); 627ed274036SLisandro Dalcin #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"") 628d9ca1df4SBarry Smith #else 62945fccdb2SJunchao Zhang #define VecLockReadPush(x) 0 63045fccdb2SJunchao Zhang #define VecLockReadPop(x) 0 63138fecf7cSJunchao Zhang #define VecLockGet(x,s) *(s) = 0 63245fccdb2SJunchao Zhang #define VecSetErrorIfLocked(x,arg) 0 63338fecf7cSJunchao Zhang /* The three are deprecated */ 63445fccdb2SJunchao Zhang #define VecLockPush(x) 0 63545fccdb2SJunchao Zhang #define VecLockPop(x) 0 63645fccdb2SJunchao Zhang #define VecLocked(x,arg) 0 637d9ca1df4SBarry Smith #endif 638e1fa1e0fSSatish Balay 63962796dfbSBarry Smith PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool); 640f7ecc322SBarry Smith 64115091d37SBarry Smith /* 64215091d37SBarry Smith These numbers need to match the entries in 6433c94ec11SBarry Smith the function table in vecimpl.h 64415091d37SBarry Smith */ 64592d03f5aSMatthew G. Knepley typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation; 646014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void)); 647b19c1e4cSBarry Smith 648e182c471SBarry Smith /* 649e182c471SBarry Smith Routines for dealing with ghosted vectors: 650e182c471SBarry Smith vectors with ghost elements at the end of the array. 651e182c471SBarry Smith */ 652014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]); 653014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 654014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 655014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 656014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 657014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*); 658014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*); 6593efe6655SBarry Smith PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*); 660014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 661014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 662e182c471SBarry Smith 663014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecConjugate(Vec); 664c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec); 665c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecRealPart(Vec); 66634233285SBarry Smith 667014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*); 668014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*); 669bba1ac68SSatish Balay 6704473680cSBarry Smith PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*); 6714473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar); 6724473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec); 673ce902467SBarry Smith PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *); 6744473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *); 6754473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *); 6764473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *); 6774473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *); 6784473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *); 6794473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec); 6808883cd90SMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec); 6814473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar); 6824473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec); 6834473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*); 6844473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *); 6854473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*); 6864473680cSBarry Smith 687014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec); 688014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec); 6897dbadf16SMatthew Knepley 690d59c15a7SBarry Smith /*S 691d59c15a7SBarry Smith Vecs - Collection of vectors where the data for the vectors is stored in 692759e7b9cSHong Zhang one contiguous memory 693d59c15a7SBarry Smith 694d59c15a7SBarry Smith Level: advanced 695d59c15a7SBarry Smith 696d59c15a7SBarry Smith Notes: 697d59c15a7SBarry Smith Temporary construct for handling multiply right hand side solves 698d59c15a7SBarry Smith 699d59c15a7SBarry Smith This is faked by storing a single vector that has enough array space for 700d59c15a7SBarry Smith n vectors 701d59c15a7SBarry Smith 702d59c15a7SBarry Smith S*/ 70395fbd943SSatish Balay struct _n_Vecs {PetscInt n; Vec v;}; 70495fbd943SSatish Balay typedef struct _n_Vecs* Vecs; 705e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs); 706e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*); 707e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*); 708e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*); 709e9fa29b7SSatish Balay 710e9e886b6SKarl Rupp #if defined(PETSC_HAVE_VIENNACL) 711b17c682bSKarl Rupp typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices; 712b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*); 713b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*); 714b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices); 715b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices); 716b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*); 717b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*); 718b8ced49eSKarl Rupp #endif 71959af0bd3SScott Kruger #if defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_HIP) 72059af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec); 72159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter); 72259af0bd3SScott Kruger #endif 723fd314934SBarry Smith #if defined(PETSC_HAVE_CUDA) 72482f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*); 72576d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 726f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 72782f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*); 72876d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 729f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 730b17c682bSKarl Rupp #endif 73159af0bd3SScott Kruger #if defined(PETSC_HAVE_HIP) 73259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIP(MPI_Comm,PetscInt,Vec*); 73359af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 73459af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 73559af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIP(MPI_Comm,PetscInt,PetscInt,Vec*); 73659af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 73759af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 73859af0bd3SScott Kruger #endif 7391e8b6502SStefano Zampini #if defined(PETSC_HAVE_KOKKOS_KERNELS) 7401e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkos(MPI_Comm,PetscInt,Vec*); 7411e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkosWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 7421e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkos(MPI_Comm,PetscInt,PetscInt,Vec*); 7431e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkosWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 7441e8b6502SStefano Zampini #endif 745b17c682bSKarl Rupp 746014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**); 747014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*); 748014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*); 749014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec); 750014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*); 751014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*); 75245b63f25SDmitry Karpeev 753c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetVec(PetscOptions,const char[],const char[],Vec,PetscBool*); 7544325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecChop(Vec,PetscReal); 755ab352700SBarry Smith 756077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*); 757077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout); 7589a6d0b0bSJed Brown 7599a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer); 7609a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **); 7619a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode); 76222d96a0cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []); 7639a6d0b0bSJed Brown 7645543aaa0SToby Isaac /*S 7655543aaa0SToby Isaac VecTagger - Object used to manage the tagging of a subset of indices based on the values of a vector. The 7665543aaa0SToby Isaac motivating application is the selection of cells for refinement or coarsening based on vector containing 7675543aaa0SToby Isaac the values in an error indicator metric. 7685543aaa0SToby Isaac 7695543aaa0SToby Isaac Level: advanced 7705543aaa0SToby Isaac S*/ 77161bbf837SToby Isaac typedef struct _p_VecTagger *VecTagger; 7725543aaa0SToby Isaac 7735543aaa0SToby Isaac /*J 7745543aaa0SToby Isaac VecTaggerType - String with the name of a VecTagger type 7755543aaa0SToby Isaac 7765543aaa0SToby Isaac Level: advanced 7775543aaa0SToby Isaac J*/ 7785543aaa0SToby Isaac typedef const char* VecTaggerType; 7794178c1b7SToby Isaac /* tag where the vector values are in a box of explicitly defined values */ 780cab77d58SToby Isaac #define VECTAGGERABSOLUTE "absolute" 7814178c1b7SToby Isaac /* tag where the vector values are in a box of values relative to the set of all values in the vector */ 7825543aaa0SToby Isaac #define VECTAGGERRELATIVE "relative" 7835543aaa0SToby Isaac /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */ 7841d1d0dd8SToby Isaac #define VECTAGGERCDF "cdf" 7855543aaa0SToby Isaac /* tag a vector as the union of other tags */ 7865543aaa0SToby Isaac #define VECTAGGEROR "or" 7875543aaa0SToby Isaac /* tag a vector as the intersection of other tags */ 7885543aaa0SToby Isaac #define VECTAGGERAND "and" 7895543aaa0SToby Isaac 7905543aaa0SToby Isaac PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID; 79161bbf837SToby Isaac PETSC_EXTERN PetscFunctionList VecTaggerList; 79261bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger)); 7935543aaa0SToby Isaac 7945543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *); 795cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt); 796cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*); 7975543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType); 7985543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *); 7995543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool); 8005543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*); 8015543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger); 8025543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger); 8035543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer); 8045543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *); 8055543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *); 8065543aaa0SToby Isaac 8074178c1b7SToby Isaac /*S 8084178c1b7SToby Isaac VecTaggerBox - A box range used to tag values. For real scalars, this is just a closed interval; for complex scalars, the box is the closed region in the complex plane 8094178c1b7SToby Isaac such that real(min) <= real(z) <= real(max) and imag(min) <= imag(z) <= imag(max). INF is an acceptable endpoint. 81061bbf837SToby Isaac 8114178c1b7SToby Isaac Level: beginner 81261bbf837SToby Isaac 8134178c1b7SToby Isaac .seealso: VecTaggerComputeIntervals() 8144178c1b7SToby Isaac S*/ 8154178c1b7SToby Isaac typedef struct { 8164178c1b7SToby Isaac PetscScalar min; 8174178c1b7SToby Isaac PetscScalar max; 8184178c1b7SToby Isaac } VecTaggerBox; 8194178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **); 8204178c1b7SToby Isaac 8214178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *); 8224178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **); 8234178c1b7SToby Isaac 8244178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *); 8254178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **); 8264178c1b7SToby Isaac 8274178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *); 8284178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **); 8291d1d0dd8SToby Isaac 8301d1d0dd8SToby Isaac /*E 8311d1d0dd8SToby Isaac VecTaggerCDFMethod - Determines what method is used to compute absolute values from cumulative distribution values (e.g., what value is the preimage of .95 in the cdf). Relevant only in parallel: in serial it is directly computed. 8321d1d0dd8SToby Isaac 8331d1d0dd8SToby Isaac Level: advanced 8341d1d0dd8SToby Isaac .seealso: VecTaggerCDFSetMethod(), VecTaggerCDFMethods 8351d1d0dd8SToby Isaac E*/ 8361d1d0dd8SToby Isaac typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod; 8371d1d0dd8SToby Isaac PETSC_EXTERN const char *const VecTaggerCDFMethods[]; 8381d1d0dd8SToby Isaac 8391d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod); 8401d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*); 8411d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal); 8421d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*); 84361bbf837SToby Isaac 844497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode); 845497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**); 84661bbf837SToby Isaac 847497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode); 848497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**); 84961bbf837SToby Isaac 85061bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void); 85161bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void); 85261bbf837SToby Isaac 8532eac72dbSBarry Smith #endif 854