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 */ 697929ea7SJunchao Zhang #if !defined(PETSCVEC_H) 726bd1501SBarry Smith #define PETSCVEC_H 8ac09b921SBarry Smith 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 15ac09b921SBarry Smith /* SUBMANSEC = Vec */ 16ac09b921SBarry Smith 1709321671SBarry Smith /*S 1809321671SBarry Smith Vec - Abstract PETSc vector object 1909321671SBarry Smith 2009321671SBarry Smith Level: beginner 2109321671SBarry Smith 22db781477SPatrick Sanan .seealso: `VecCreate()`, `VecType`, `VecSetType()` 2309321671SBarry Smith S*/ 24f09e8eb9SSatish Balay typedef struct _p_Vec* Vec; 2509321671SBarry Smith 2609321671SBarry Smith /*E 27398c84b2SBarry Smith ScatterMode - Determines the direction of a scatter 28398c84b2SBarry Smith 29398c84b2SBarry Smith Level: beginner 30398c84b2SBarry Smith 31db781477SPatrick Sanan .seealso: `VecScatter`, `VecScatterBegin()`, `VecScatterEnd()` 32398c84b2SBarry Smith E*/ 33398c84b2SBarry Smith typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode; 34398c84b2SBarry Smith 35398c84b2SBarry Smith /*MC 36*87497f52SBarry Smith SCATTER_FORWARD - Scatters the values as dictated by the `VecScatterCreate()` call 37398c84b2SBarry Smith 38398c84b2SBarry Smith Level: beginner 39398c84b2SBarry Smith 40db781477SPatrick Sanan .seealso: `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_REVERSE`, `SCATTER_FORWARD_LOCAL`, 41db781477SPatrick Sanan `SCATTER_REVERSE_LOCAL` 42398c84b2SBarry Smith 43398c84b2SBarry Smith M*/ 44398c84b2SBarry Smith 45398c84b2SBarry Smith /*MC 46398c84b2SBarry Smith SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in 47*87497f52SBarry Smith in the `VecScatterCreate()` 48398c84b2SBarry Smith 49398c84b2SBarry Smith Level: beginner 50398c84b2SBarry Smith 51db781477SPatrick Sanan .seealso: `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_FORWARD`, `SCATTER_FORWARD_LOCAL`, 52db781477SPatrick Sanan `SCATTER_REVERSE_LOCAL` 53398c84b2SBarry Smith 54398c84b2SBarry Smith M*/ 55398c84b2SBarry Smith 56398c84b2SBarry Smith /*MC 57*87497f52SBarry Smith SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the `VecScatterCreate()` call except NO parallel communication 58398c84b2SBarry Smith is done. Any variables that have be moved between processes are ignored 59398c84b2SBarry Smith 60398c84b2SBarry Smith Level: developer 61398c84b2SBarry Smith 62db781477SPatrick Sanan .seealso: `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_REVERSE`, `SCATTER_FORWARD`, 63db781477SPatrick Sanan `SCATTER_REVERSE_LOCAL` 64398c84b2SBarry Smith 65398c84b2SBarry Smith M*/ 66398c84b2SBarry Smith 67398c84b2SBarry Smith /*MC 68398c84b2SBarry Smith SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in 69*87497f52SBarry Smith in the `VecScatterCreate()` except NO parallel communication 70398c84b2SBarry Smith is done. Any variables that have be moved between processes are ignored 71398c84b2SBarry Smith 72398c84b2SBarry Smith Level: developer 73398c84b2SBarry Smith 74db781477SPatrick Sanan .seealso: `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_FORWARD`, `SCATTER_FORWARD_LOCAL`, 75db781477SPatrick Sanan `SCATTER_REVERSE` 76398c84b2SBarry Smith 77398c84b2SBarry Smith M*/ 78398c84b2SBarry Smith 7976bdecfbSBarry Smith /*J 808f6c3df8SBarry Smith VecType - String with the name of a PETSc vector 8109321671SBarry Smith 8209321671SBarry Smith Level: beginner 8309321671SBarry Smith 84db781477SPatrick Sanan .seealso: `VecSetType()`, `Vec`, `VecCreate()`, `VecDestroy()` 8576bdecfbSBarry Smith J*/ 8619fd82e9SBarry Smith typedef const char* VecType; 870676abe4SMatthew Knepley #define VECSEQ "seq" 880676abe4SMatthew Knepley #define VECMPI "mpi" 89f48c50deSBarry Smith #define VECSTANDARD "standard" /* seq on one process and mpi on several */ 900676abe4SMatthew Knepley #define VECSHARED "shared" 91b17c682bSKarl Rupp #define VECSEQVIENNACL "seqviennacl" 92b17c682bSKarl Rupp #define VECMPIVIENNACL "mpiviennacl" 93b17c682bSKarl Rupp #define VECVIENNACL "viennacl" /* seqviennacl on one process and mpiviennacl on several */ 9482f73ecaSAlejandro Lamas Daviña #define VECSEQCUDA "seqcuda" 9582f73ecaSAlejandro Lamas Daviña #define VECMPICUDA "mpicuda" 9682f73ecaSAlejandro Lamas Daviña #define VECCUDA "cuda" /* seqcuda on one process and mpicuda on several */ 9759af0bd3SScott Kruger #define VECSEQHIP "seqhip" 9859af0bd3SScott Kruger #define VECMPIHIP "mpihip" 9959af0bd3SScott Kruger #define VECHIP "hip" /* seqcuda on one process and mpicuda on several */ 1001aae2881SJed Brown #define VECNEST "nest" 10110171e34SJunchao Zhang #define VECSEQKOKKOS "seqkokkos" 10210171e34SJunchao Zhang #define VECMPIKOKKOS "mpikokkos" 10310171e34SJunchao Zhang #define VECKOKKOS "kokkos" /* seqkokkos on one process and mpikokkos on several */ 1042eac72dbSBarry Smith 105803a1b88SHong Zhang /* Dynamic creation and loading functions */ 106803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType); 107803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType*); 108803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter); 109803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[],PetscErrorCode (*)(VecScatter)); 110130e142eSJunchao Zhang PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter*); 1114b71561bSShri Abhyankar 112fd487807SMatthew Knepley /* Logging support */ 113450a797fSBarry Smith #define REAL_FILE_CLASSID 1211213 1140700a824SBarry Smith #define VEC_FILE_CLASSID 1211214 115014dd563SJed Brown PETSC_EXTERN PetscClassId VEC_CLASSID; 11697929ea7SJunchao Zhang PETSC_EXTERN PetscClassId PETSCSF_CLASSID; 11745b63f25SDmitry Karpeev 118607a6623SBarry Smith PETSC_EXTERN PetscErrorCode VecInitializePackage(void); 119014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecFinalizePackage(void); 120fd487807SMatthew Knepley 121014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*); 122014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*); 123014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*); 124014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*); 125014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*); 126014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*); 127803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm,PetscInt,PetscInt,Vec*); 128803a1b88SHong Zhang 129014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec); 130fe2efc57SMark PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec,PetscObject,const char[]); 1310d2bece7SBarry Smith 132014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetUp(Vec); 133014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroy(Vec*); 134014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec); 135014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]); 136014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]); 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]); 138f69a0ea3SMatthew Knepley 139014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt); 140fd487807SMatthew Knepley 14152b6e47cSBarry Smith PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*); 142014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*); 14367392de3SBarry Smith PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*); 144014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*); 145014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]); 146014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]); 147014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*); 148014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*); 149598f99faSAlp Dener PETSC_EXTERN PetscErrorCode VecConcatenate(PetscInt,const Vec[],Vec*,IS*[]); 150cddf8d76SBarry Smith 15109321671SBarry Smith /*E 15209321671SBarry Smith NormType - determines what type of norm to compute 15309321671SBarry Smith 15409321671SBarry Smith Level: beginner 15509321671SBarry Smith 156db781477SPatrick Sanan .seealso: `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `MatNorm()` 15709321671SBarry Smith E*/ 158a873a8cdSSam Reynolds typedef enum {NORM_1=0, 159a873a8cdSSam Reynolds NORM_2=1, 160a873a8cdSSam Reynolds NORM_FROBENIUS=2, 161a873a8cdSSam Reynolds NORM_INFINITY=3, 162a873a8cdSSam Reynolds NORM_1_AND_2=4 163a873a8cdSSam Reynolds } NormType; 1646a6fc655SJed Brown PETSC_EXTERN const char *const NormTypes[]; 165cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY 16609321671SBarry Smith 1679b250c83SBarry Smith /*MC 1689b250c83SBarry Smith NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum 1699b250c83SBarry Smith 1709b250c83SBarry Smith Level: beginner 1719b250c83SBarry Smith 172db781477SPatrick Sanan .seealso: `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_2`, `NORM_FROBENIUS`, 173db781477SPatrick Sanan `NORM_INFINITY`, `NORM_1_AND_2` 1749b250c83SBarry Smith 1759b250c83SBarry Smith M*/ 1769b250c83SBarry Smith 1779b250c83SBarry Smith /*MC 178df54d55cSMatthias Liertzer NORM_2 - the two norm, ||v|| = sqrt(sum_i |v_i|^2) (vectors only) 1799b250c83SBarry Smith 1809b250c83SBarry Smith Level: beginner 1819b250c83SBarry Smith 182db781477SPatrick Sanan .seealso: `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_FROBENIUS`, 183db781477SPatrick Sanan `NORM_INFINITY`, `NORM_1_AND_2` 1849b250c83SBarry Smith 1859b250c83SBarry Smith M*/ 1869b250c83SBarry Smith 1879b250c83SBarry Smith /*MC 188*87497f52SBarry Smith NORM_FROBENIUS - ||A|| = sqrt(sum_ij |A_ij|^2), same as `NORM_2` for vectors 1899b250c83SBarry Smith 1909b250c83SBarry Smith Level: beginner 1919b250c83SBarry Smith 192db781477SPatrick Sanan .seealso: `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`, 193db781477SPatrick Sanan `NORM_INFINITY`, `NORM_1_AND_2` 1949b250c83SBarry Smith 1959b250c83SBarry Smith M*/ 1969b250c83SBarry Smith 1979b250c83SBarry Smith /*MC 1989b250c83SBarry Smith NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum 1999b250c83SBarry Smith 2009b250c83SBarry Smith Level: beginner 2019b250c83SBarry Smith 202db781477SPatrick Sanan .seealso: `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`, 203db781477SPatrick Sanan `NORM_FROBENIUS`, `NORM_1_AND_2` 2049b250c83SBarry Smith 2059b250c83SBarry Smith M*/ 2069b250c83SBarry Smith 2079b250c83SBarry Smith /*MC 2089b250c83SBarry Smith NORM_1_AND_2 - computes both the 1 and 2 norm of a vector 2099b250c83SBarry Smith 2109b250c83SBarry Smith Level: beginner 2119b250c83SBarry Smith 212db781477SPatrick Sanan .seealso: `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`, 213db781477SPatrick Sanan `NORM_FROBENIUS`, `NORM_INFINITY` 2149b250c83SBarry Smith 2159b250c83SBarry Smith M*/ 2169b250c83SBarry Smith 2179b250c83SBarry Smith /*MC 218*87497f52SBarry Smith NORM_MAX - see `NORM_INFINITY` 2199b250c83SBarry Smith 220d41222bbSBarry Smith Level: beginner 221d41222bbSBarry Smith 2229b250c83SBarry Smith M*/ 2239b250c83SBarry Smith 224a873a8cdSSam Reynolds /*E 225*87497f52SBarry Smith ReductionType - determines what type of column reduction (one that is not a type of norm defined in `NormType`) to compute 226a873a8cdSSam Reynolds 227a873a8cdSSam Reynolds Level: beginner 228a873a8cdSSam Reynolds 229db781477SPatrick Sanan .seealso: `MatGetColumnReductions()`, `MatGetColumnNorms()`, `NormType` 230a873a8cdSSam Reynolds E*/ 231857cbf51SRichard Tran Mills /* NOTE: The integer constants defined in ReductionType MUST BE DISTINCT from those defined in NormType. 232857cbf51SRichard Tran Mills * This is because MatGetColumnReductions() is used to compute both norms and other types of reductions, 233857cbf51SRichard Tran Mills * and the constants defined in both NormType and ReductionType are used to designate the desired operation. */ 234857cbf51SRichard Tran Mills typedef enum {REDUCTION_SUM_REALPART=10, 235857cbf51SRichard Tran Mills REDUCTION_MEAN_REALPART=11, 236857cbf51SRichard Tran Mills REDUCTION_SUM_IMAGINARYPART=12, 237857cbf51SRichard Tran Mills REDUCTION_MEAN_IMAGINARYPART=13 238a873a8cdSSam Reynolds } ReductionType; 239a873a8cdSSam Reynolds 240a873a8cdSSam Reynolds /*MC 241857cbf51SRichard Tran Mills REDUCTION_SUM_REALPART - sum of real part of matrix column 242a873a8cdSSam Reynolds 243a873a8cdSSam Reynolds Level: beginner 244a873a8cdSSam Reynolds 245db781477SPatrick Sanan .seealso: `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_SUM_IMAGINARYPART`, `REDUCTION_MEAN_REALPART`, `REDUCTION_NORM_1`, 246db781477SPatrick Sanan `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY` 247a873a8cdSSam Reynolds 248a873a8cdSSam Reynolds M*/ 249a873a8cdSSam Reynolds 250a873a8cdSSam Reynolds /*MC 251857cbf51SRichard Tran Mills REDUCTION_SUM_IMAGINARYPART - sum of imaginary part of matrix column 252a873a8cdSSam Reynolds 253a873a8cdSSam Reynolds Level: beginner 254a873a8cdSSam Reynolds 255db781477SPatrick Sanan .seealso: `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_SUM_REALPART`, `REDUCTION_MEAN_IMAGINARYPART`, `REDUCTION_NORM_1`, 256db781477SPatrick Sanan `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY` 257857cbf51SRichard Tran Mills 258857cbf51SRichard Tran Mills M*/ 259857cbf51SRichard Tran Mills 260857cbf51SRichard Tran Mills /*MC 261857cbf51SRichard Tran Mills REDUCTION_MEAN_REALPART - arithmetic mean of real part of matrix column 262857cbf51SRichard Tran Mills 263857cbf51SRichard Tran Mills Level: beginner 264857cbf51SRichard Tran Mills 265db781477SPatrick Sanan .seealso: `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_MEAN_IMAGINARYPART`, `REDUCTION_SUM_REALPART`, `REDUCTION_NORM_1`, 266db781477SPatrick Sanan `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY` 267857cbf51SRichard Tran Mills 268857cbf51SRichard Tran Mills M*/ 269857cbf51SRichard Tran Mills 270857cbf51SRichard Tran Mills /*MC 271857cbf51SRichard Tran Mills REDUCTION_MEAN_IMAGINARYPART - arithmetic mean of imaginary part of matrix column 272857cbf51SRichard Tran Mills 273857cbf51SRichard Tran Mills Level: beginner 274857cbf51SRichard Tran Mills 275db781477SPatrick Sanan .seealso: `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_MEAN_REALPART`, `REDUCTION_SUM_IMAGINARYPART`, `REDUCTION_NORM_1`, 276db781477SPatrick Sanan `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY` 277a873a8cdSSam Reynolds 278a873a8cdSSam Reynolds M*/ 279a873a8cdSSam Reynolds 280014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *); 281014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *); 282014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *); 283014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*); 284f7c17b9fSRichard Tran Mills PETSC_EXTERN PetscErrorCode VecMean(Vec,PetscScalar*); 285014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *); 286014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *); 287014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar); 288014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec); 289014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom); 290014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar); 291422a814eSBarry Smith PETSC_EXTERN PetscErrorCode VecSetInf(Vec); 292014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec); 293014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec); 294014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec); 295014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]); 296014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec); 297014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec); 298014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); 299014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec); 300014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec); 301014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec); 302014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec); 303014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec); 304014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*); 305014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar); 306014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReciprocal(Vec); 307014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool); 308014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec); 309014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLog(Vec); 310014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecExp(Vec); 311014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAbs(Vec); 312014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*); 313014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]); 314014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]); 315014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]); 316014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []); 317014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []); 318014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]); 319408c233dSJeremy L Thompson PETSC_EXTERN PetscErrorCode VecStrideSumAll(Vec,PetscScalar*); 320849b11cfSMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**); 3214a560884SBarry Smith 322014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*); 323014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *); 324014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *); 325014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar); 326408c233dSJeremy L Thompson PETSC_EXTERN PetscErrorCode VecStrideSum(Vec,PetscInt,PetscScalar*); 327014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar); 328954b3ec6SBarry Smith 329014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode); 330014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode); 331014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode); 332014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode); 333d2655a18SBarry Smith 334bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode); 335bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode); 336bdeb6c88SBarry Smith 337014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 338014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]); 339014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec); 340014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec); 341014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt); 342014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer); 343685405a1SBarry Smith PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]); 344014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 34562dc5420SSatish Balay 346158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetPreallocationCOO(Vec,PetscCount,const PetscInt[]); 347158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetPreallocationCOOLocal(Vec,PetscCount,PetscInt[]); 348158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetValuesCOO(Vec,const PetscScalar[],InsertMode); 349158e8e18SJunchao Zhang 35030de9b25SBarry Smith /*MC 35130de9b25SBarry Smith VecSetValue - Set a single entry into a vector. 35230de9b25SBarry Smith 35330de9b25SBarry Smith Synopsis: 354aaa7dc30SBarry Smith #include <petscvec.h> 3558122439eSJed Brown PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode); 35630de9b25SBarry Smith 35730de9b25SBarry Smith Not Collective 35830de9b25SBarry Smith 35930de9b25SBarry Smith Input Parameters: 36030de9b25SBarry Smith + v - the vector 36130de9b25SBarry Smith . row - the row location of the entry 36230de9b25SBarry Smith . value - the value to insert 363*87497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 36430de9b25SBarry Smith 36530de9b25SBarry Smith Notes: 366*87497f52SBarry Smith For efficiency one should use `VecSetValues()` and set several or 36730de9b25SBarry Smith many values simultaneously if possible. 36830de9b25SBarry Smith 369*87497f52SBarry Smith These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()` 370*87497f52SBarry Smith MUST be called after all calls to `VecSetValue()` have been completed. 3711d73ed98SBarry Smith 372*87497f52SBarry Smith `VecSetValue()` uses 0-based indices in Fortran as well as in C. 3731d73ed98SBarry Smith 3741d73ed98SBarry Smith Level: beginner 3751d73ed98SBarry Smith 376db781477SPatrick Sanan .seealso: `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValuesBlockedLocal()`, `VecSetValueLocal()` 3771d73ed98SBarry Smith M*/ 3789fbee547SJacob Faibussowitsch static inline PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);} 3791d73ed98SBarry Smith 380014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt); 381014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*); 382014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 3838ed539a5SBarry Smith 384fd487807SMatthew Knepley /* Dynamic creation and loading functions */ 385140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList VecList; 38619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType); 38719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*); 388bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec)); 38930de9b25SBarry Smith 390014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode); 391014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode); 392014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*); 393246626dcSBarry Smith PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter); 394014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *); 395014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer); 396fe2efc57SMark PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]); 397d27e6124SSatish Balay PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]); 398014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*); 3992195c698SBarry Smith 400014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 401014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 402014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 403014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 404014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 405014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 406014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]); 407014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]); 408ab360428SBarry Smith 409fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 410fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 411fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 412fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 413fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 414fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 415fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 416fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]); 417fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]); 418fdc842d1SBarry Smith 4195edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4205edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]); 4215edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4225edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]); 4235edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4245edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]); 4255edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]); 4265edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]); 4275edff71fSBarry Smith 428014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]); 429014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecResetArray(Vec); 430014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]); 431de0d48c1SKarl Rupp 432014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]); 433014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]); 43484cb2905SBarry Smith 435014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer); 436f9558f5cSBarry Smith PETSC_EXTERN PetscErrorCode VecViewNative(Vec,PetscViewer); 437014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*); 438014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer); 4398ed539a5SBarry Smith 440014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*); 441014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*); 442014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*); 443014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]); 4448ed539a5SBarry Smith 445014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping); 446014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 44788b03592SBarry Smith 4489a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**); 4499a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**); 450de0d48c1SKarl Rupp 4519a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**); 4529a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**); 453de0d48c1SKarl Rupp 4549a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**); 4559a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**); 456de0d48c1SKarl Rupp 457cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]); 458cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]); 459de0d48c1SKarl Rupp PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec); 460de0d48c1SKarl Rupp 46159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArray(Vec,PetscScalar**); 46259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArray(Vec,PetscScalar**); 46359af0bd3SScott Kruger 46459af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArrayRead(Vec,const PetscScalar**); 46559af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayRead(Vec,const PetscScalar**); 46659af0bd3SScott Kruger 46759af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPGetArrayWrite(Vec,PetscScalar**); 46859af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayWrite(Vec,PetscScalar**); 46959af0bd3SScott Kruger 47059af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPPlaceArray(Vec,const PetscScalar[]); 47159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPReplaceArray(Vec,const PetscScalar[]); 47259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecHIPResetArray(Vec); 47359af0bd3SScott Kruger 47476ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*); 47576ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*); 47676ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*); 47776ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*); 47876ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec); 47976ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*); 48076ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec); 48176ec7f3eSKaushik Kulkarni 48288b03592SBarry Smith /*MC 48388b03592SBarry Smith VecSetValueLocal - Set a single entry into a vector using the local numbering 48488b03592SBarry Smith 48588b03592SBarry Smith Synopsis: 486aaa7dc30SBarry Smith #include <petscvec.h> 4878122439eSJed Brown PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode); 48888b03592SBarry Smith 48988b03592SBarry Smith Not Collective 49088b03592SBarry Smith 49188b03592SBarry Smith Input Parameters: 49288b03592SBarry Smith + v - the vector 49388b03592SBarry Smith . row - the row location of the entry 49488b03592SBarry Smith . value - the value to insert 495*87497f52SBarry Smith - mode - either `INSERT_VALUES` or `ADD_VALUES` 49688b03592SBarry Smith 49788b03592SBarry Smith Notes: 498*87497f52SBarry Smith For efficiency one should use `VecSetValues()` and set several or 49988b03592SBarry Smith many values simultaneously if possible. 50088b03592SBarry Smith 501*87497f52SBarry Smith These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()` 502*87497f52SBarry Smith MUST be called after all calls to `VecSetValues()` have been completed. 50388b03592SBarry Smith 504*87497f52SBarry Smith `VecSetValues()` uses 0-based indices in Fortran as well as in C. 50588b03592SBarry Smith 50688b03592SBarry Smith Level: beginner 50788b03592SBarry Smith 508db781477SPatrick Sanan .seealso: `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValuesBlockedLocal()`, `VecSetValue()` 50988b03592SBarry Smith M*/ 5109fbee547SJacob Faibussowitsch static inline PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);} 51188b03592SBarry Smith 512014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 513014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping*); 51490f02eecSBarry Smith 515014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *); 516014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *); 517014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *); 518014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *); 519014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *); 520014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *); 521d3c178dbSBarry Smith 522014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 523014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 524014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]); 525014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]); 526014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm); 527a751f32aSSatish Balay 528b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool); 5299fbee547SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") static inline PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);} 5302216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode VecBoundToCPU(Vec,PetscBool*); 53165a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetBindingPropagates(Vec,PetscBool); 532e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetBindingPropagates(Vec,PetscBool *); 533387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t); 534387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *); 535a751f32aSSatish Balay 5366fe358cdSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec,PetscOffloadMask *); 53748d97fd2SKaushik Kulkarni 538bda0d2a0SJed Brown typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES,VEC_SUBSET_OFF_PROC_ENTRIES} VecOption; 539014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscBool); 54090f02eecSBarry Smith 5415c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**); 542fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**); 5435c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**); 5445c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**); 545fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**); 5465c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**); 547046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec); 548046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec); 549046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec); 550046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec); 551a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec,PetscScalar**,PetscMemType*); 552a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec,PetscScalar**); 553a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec,const PetscScalar**,PetscMemType*); 554a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec,const PetscScalar**); 555b5f78e91SJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayWriteAndMemType(Vec,PetscScalar**,PetscMemType*); 556b5f78e91SJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayWriteAndMemType(Vec,PetscScalar**); 55710171e34SJunchao Zhang 5589521ec69SBarry Smith /*@C 5599521ec69SBarry Smith VecGetArrayPair - Accesses a pair of pointers for two vectors that may be common. When not common the first is read only 5609521ec69SBarry Smith 561d083f849SBarry Smith Logically Collective on x 5629521ec69SBarry Smith 563f5f57ec0SBarry Smith Input Parameters: 5649521ec69SBarry Smith + x - the vector 5659521ec69SBarry Smith - y - the second vector 5669521ec69SBarry Smith 567f5f57ec0SBarry Smith Output Parameters: 5689521ec69SBarry Smith + xv - location to put pointer to the first array 5699521ec69SBarry Smith - yv - location to put pointer to the second array 5709521ec69SBarry Smith 5719521ec69SBarry Smith Level: developer 5729521ec69SBarry Smith 573f5f57ec0SBarry Smith Not available from Fortran 574f5f57ec0SBarry Smith 575db781477SPatrick Sanan .seealso: `VecGetArray()`, `VecGetArrayRead()`, `VecRestoreArrayPair()` 5769521ec69SBarry Smith 5779521ec69SBarry Smith @*/ 5789fbee547SJacob Faibussowitsch static inline PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv) 579d9ca1df4SBarry Smith { 580d9ca1df4SBarry Smith PetscFunctionBegin; 5819566063dSJacob Faibussowitsch PetscCall(VecGetArray(y,yv)); 5825f80ce2aSJacob Faibussowitsch if (x == y) *xv = *yv; 5839566063dSJacob Faibussowitsch else PetscCall(VecGetArrayRead(x,(const PetscScalar**)xv)); 584d9ca1df4SBarry Smith PetscFunctionReturn(0); 585d9ca1df4SBarry Smith } 5869521ec69SBarry Smith 5879521ec69SBarry Smith /*@C 5889521ec69SBarry Smith VecRestoreArrayPair - Returns a pair of pointers for two vectors that may be common. When not common the first is read only 5899521ec69SBarry Smith 590d083f849SBarry Smith Logically Collective on x 5919521ec69SBarry Smith 592f5f57ec0SBarry Smith Input Parameters: 5939521ec69SBarry Smith + x - the vector 5949521ec69SBarry Smith - y - the second vector 5959521ec69SBarry Smith 596f5f57ec0SBarry Smith Output Parameters: 5979521ec69SBarry Smith + xv - location to put pointer to the first array 5989521ec69SBarry Smith - yv - location to put pointer to the second array 5999521ec69SBarry Smith 6009521ec69SBarry Smith Level: developer 6019521ec69SBarry Smith 602f5f57ec0SBarry Smith Not available from Fortran 603f5f57ec0SBarry Smith 604db781477SPatrick Sanan .seealso: `VecGetArray()`, `VecGetArrayRead()`, `VecGetArrayPair()` 6059521ec69SBarry Smith 6069521ec69SBarry Smith @*/ 6079fbee547SJacob Faibussowitsch static inline PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv) 608d9ca1df4SBarry Smith { 609d9ca1df4SBarry Smith PetscFunctionBegin; 6109566063dSJacob Faibussowitsch PetscCall(VecRestoreArray(y,yv)); 6119566063dSJacob Faibussowitsch if (x != y) PetscCall(VecRestoreArrayRead(x,(const PetscScalar**)xv)); 612d9ca1df4SBarry Smith PetscFunctionReturn(0); 613d9ca1df4SBarry Smith } 614d9ca1df4SBarry Smith 615d9ca1df4SBarry Smith #if defined(PETSC_USE_DEBUG) 61638fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec); 61738fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec); 618805b4a0dSBarry Smith PETSC_EXTERN PetscErrorCode VecLockWriteSet(Vec,PetscBool); 619d9ca1df4SBarry Smith PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*); 6205a96b57dSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode VecLockGetLocation(Vec,const char*[],const char*[],int*); 6219fbee547SJacob Faibussowitsch static inline PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg) 622da1c2f70SJunchao Zhang { 623da1c2f70SJunchao Zhang PetscInt state; 62438fecf7cSJunchao Zhang 625da1c2f70SJunchao Zhang PetscFunctionBegin; 6269566063dSJacob Faibussowitsch PetscCall(VecLockGet(x,&state)); 6275a96b57dSJacob Faibussowitsch if (PetscUnlikely(state != 0)) { 6285a96b57dSJacob Faibussowitsch const char *file,*func,*name; 6295a96b57dSJacob Faibussowitsch int line; 6305a96b57dSJacob Faibussowitsch 6315a96b57dSJacob Faibussowitsch PetscCall(VecLockGetLocation(x,&file,&func,&line)); 6325a96b57dSJacob Faibussowitsch PetscCall(PetscObjectGetName((PetscObject)x,&name)); 6335a96b57dSJacob Faibussowitsch SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Vector '%s' (argument #%" PetscInt_FMT ") was locked for %s access in %s() at %s:%d (line numbers only accurate to function begin)",name,arg,state > 0 ? "read-only" : "write-only",func ? func : "unknown_function",file ? file : "unknown file",line ? line : 0); 6345a96b57dSJacob Faibussowitsch } 635da1c2f70SJunchao Zhang PetscFunctionReturn(0); 636da1c2f70SJunchao Zhang } 63738fecf7cSJunchao Zhang /* The three are deprecated */ 6385f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec); 6395f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)") PetscErrorCode VecLockPop(Vec); 640ed274036SLisandro Dalcin #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"") 641d9ca1df4SBarry Smith #else 64245fccdb2SJunchao Zhang #define VecLockReadPush(x) 0 64345fccdb2SJunchao Zhang #define VecLockReadPop(x) 0 64438fecf7cSJunchao Zhang #define VecLockGet(x,s) *(s) = 0 64545fccdb2SJunchao Zhang #define VecSetErrorIfLocked(x,arg) 0 646805b4a0dSBarry Smith #define VecLockWriteSet(x,flg) 0 64738fecf7cSJunchao Zhang /* The three are deprecated */ 64845fccdb2SJunchao Zhang #define VecLockPush(x) 0 64945fccdb2SJunchao Zhang #define VecLockPop(x) 0 65045fccdb2SJunchao Zhang #define VecLocked(x,arg) 0 651d9ca1df4SBarry Smith #endif 652e1fa1e0fSSatish Balay 65362796dfbSBarry Smith PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool); 654f7ecc322SBarry Smith 65515091d37SBarry Smith /* 65615091d37SBarry Smith These numbers need to match the entries in 6573c94ec11SBarry Smith the function table in vecimpl.h 65815091d37SBarry Smith */ 65992d03f5aSMatthew G. Knepley typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation; 660014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void)); 661b19c1e4cSBarry Smith 662e182c471SBarry Smith /* 663e182c471SBarry Smith Routines for dealing with ghosted vectors: 664e182c471SBarry Smith vectors with ghost elements at the end of the array. 665e182c471SBarry Smith */ 666014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]); 667014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 668014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 669014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*); 670014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*); 671014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*); 672014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*); 6733efe6655SBarry Smith PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*); 674014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode); 675014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode); 676e182c471SBarry Smith 677014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecConjugate(Vec); 678c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec); 679c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecRealPart(Vec); 68034233285SBarry Smith 681014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*); 682014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*); 683bba1ac68SSatish Balay 6844473680cSBarry Smith PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*); 6854473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar); 6864473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec); 687ce902467SBarry Smith PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *); 6884473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *); 6894473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *); 6904473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *); 6914473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *); 6924473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *); 6934473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec); 6948883cd90SMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec); 6954473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar); 6964473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec); 6974473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*); 6984473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *); 6994473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*); 7004473680cSBarry Smith 701014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec); 702014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec); 7037dbadf16SMatthew Knepley 704d59c15a7SBarry Smith /*S 705d59c15a7SBarry Smith Vecs - Collection of vectors where the data for the vectors is stored in 706759e7b9cSHong Zhang one contiguous memory 707d59c15a7SBarry Smith 708d59c15a7SBarry Smith Level: advanced 709d59c15a7SBarry Smith 710d59c15a7SBarry Smith Notes: 711d59c15a7SBarry Smith Temporary construct for handling multiply right hand side solves 712d59c15a7SBarry Smith 713d59c15a7SBarry Smith This is faked by storing a single vector that has enough array space for 714d59c15a7SBarry Smith n vectors 715d59c15a7SBarry Smith 716d59c15a7SBarry Smith S*/ 71795fbd943SSatish Balay struct _n_Vecs {PetscInt n; Vec v;}; 71895fbd943SSatish Balay typedef struct _n_Vecs* Vecs; 719e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs); 720e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*); 721e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*); 722e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*); 723e9fa29b7SSatish Balay 724e9e886b6SKarl Rupp #if defined(PETSC_HAVE_VIENNACL) 725b17c682bSKarl Rupp typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices; 726b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*); 727b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*); 728b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices); 729b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices); 730b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*); 731b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*); 732b8ced49eSKarl Rupp #endif 73359af0bd3SScott Kruger #if defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_HIP) 73459af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec); 73559af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter); 73659af0bd3SScott Kruger #endif 737fd314934SBarry Smith #if defined(PETSC_HAVE_CUDA) 73882f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*); 73976d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 740f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 74182f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*); 74276d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 743f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 744b17c682bSKarl Rupp #endif 74559af0bd3SScott Kruger #if defined(PETSC_HAVE_HIP) 74659af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIP(MPI_Comm,PetscInt,Vec*); 74759af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 74859af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 74959af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIP(MPI_Comm,PetscInt,PetscInt,Vec*); 75059af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 75159af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*); 75259af0bd3SScott Kruger #endif 7531e8b6502SStefano Zampini #if defined(PETSC_HAVE_KOKKOS_KERNELS) 7541e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkos(MPI_Comm,PetscInt,Vec*); 7551e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkosWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*); 7561e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkos(MPI_Comm,PetscInt,PetscInt,Vec*); 7571e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkosWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*); 7581e8b6502SStefano Zampini #endif 759b17c682bSKarl Rupp 760014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**); 761014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*); 762014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*); 763014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec); 764014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*); 765014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*); 76645b63f25SDmitry Karpeev 767c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetVec(PetscOptions,const char[],const char[],Vec,PetscBool*); 7684325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecChop(Vec,PetscReal); 769ab352700SBarry Smith 770077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*); 771077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout); 7729a6d0b0bSJed Brown 7739a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer); 7749a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **); 7759a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode); 77622d96a0cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []); 7779a6d0b0bSJed Brown 7785543aaa0SToby Isaac /*S 7795543aaa0SToby Isaac VecTagger - Object used to manage the tagging of a subset of indices based on the values of a vector. The 7805543aaa0SToby Isaac motivating application is the selection of cells for refinement or coarsening based on vector containing 7815543aaa0SToby Isaac the values in an error indicator metric. 7825543aaa0SToby Isaac 7835543aaa0SToby Isaac Level: advanced 784*87497f52SBarry Smith 785*87497f52SBarry Smith Developer Note: 786*87497f52SBarry Smith Why not use a `DMLabel` or similar object 787*87497f52SBarry Smith 7885543aaa0SToby Isaac S*/ 78961bbf837SToby Isaac typedef struct _p_VecTagger *VecTagger; 7905543aaa0SToby Isaac 7915543aaa0SToby Isaac /*J 792*87497f52SBarry Smith VecTaggerType - String with the name of a `VecTagger` type 7935543aaa0SToby Isaac 7945543aaa0SToby Isaac Level: advanced 7955543aaa0SToby Isaac J*/ 7965543aaa0SToby Isaac typedef const char* VecTaggerType; 7974178c1b7SToby Isaac /* tag where the vector values are in a box of explicitly defined values */ 798cab77d58SToby Isaac #define VECTAGGERABSOLUTE "absolute" 7994178c1b7SToby Isaac /* tag where the vector values are in a box of values relative to the set of all values in the vector */ 8005543aaa0SToby Isaac #define VECTAGGERRELATIVE "relative" 8015543aaa0SToby Isaac /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */ 8021d1d0dd8SToby Isaac #define VECTAGGERCDF "cdf" 8035543aaa0SToby Isaac /* tag a vector as the union of other tags */ 8045543aaa0SToby Isaac #define VECTAGGEROR "or" 8055543aaa0SToby Isaac /* tag a vector as the intersection of other tags */ 8065543aaa0SToby Isaac #define VECTAGGERAND "and" 8075543aaa0SToby Isaac 8085543aaa0SToby Isaac PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID; 80961bbf837SToby Isaac PETSC_EXTERN PetscFunctionList VecTaggerList; 81061bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger)); 8115543aaa0SToby Isaac 8125543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *); 813cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt); 814cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*); 8155543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType); 8165543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *); 8175543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool); 8185543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*); 8195543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger); 8205543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger); 8215543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer); 8221cee10b1SBarry Smith PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *,PetscBool*); 8235543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *); 8245543aaa0SToby Isaac 8254178c1b7SToby Isaac /*S 8264178c1b7SToby 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 8274178c1b7SToby Isaac such that real(min) <= real(z) <= real(max) and imag(min) <= imag(z) <= imag(max). INF is an acceptable endpoint. 82861bbf837SToby Isaac 8294178c1b7SToby Isaac Level: beginner 83061bbf837SToby Isaac 831db781477SPatrick Sanan .seealso: `VecTaggerComputeIntervals()` 8324178c1b7SToby Isaac S*/ 8334178c1b7SToby Isaac typedef struct { 8344178c1b7SToby Isaac PetscScalar min; 8354178c1b7SToby Isaac PetscScalar max; 8364178c1b7SToby Isaac } VecTaggerBox; 8371cee10b1SBarry Smith PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **,PetscBool*); 8384178c1b7SToby Isaac 8394178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *); 8404178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **); 8414178c1b7SToby Isaac 8424178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *); 8434178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **); 8444178c1b7SToby Isaac 8454178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *); 8464178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **); 8471d1d0dd8SToby Isaac 8481d1d0dd8SToby Isaac /*E 849*87497f52SBarry Smith 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). 850*87497f52SBarry Smith Relevant only in parallel: in serial it is directly computed. 8511d1d0dd8SToby Isaac 8521d1d0dd8SToby Isaac Level: advanced 853*87497f52SBarry Smith 854db781477SPatrick Sanan .seealso: `VecTaggerCDFSetMethod()`, `VecTaggerCDFMethods` 8551d1d0dd8SToby Isaac E*/ 8561d1d0dd8SToby Isaac typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod; 8571d1d0dd8SToby Isaac PETSC_EXTERN const char *const VecTaggerCDFMethods[]; 8581d1d0dd8SToby Isaac 8591d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod); 8601d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*); 8611d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal); 8621d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*); 86361bbf837SToby Isaac 864497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode); 865497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**); 86661bbf837SToby Isaac 867497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode); 868497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**); 86961bbf837SToby Isaac 87061bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void); 87161bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void); 87261bbf837SToby Isaac 8732eac72dbSBarry Smith #endif 874