Actual source code: petscvec.h

  1: /*
  2:     Defines the vector component of PETSc. Vectors generally represent
  3:   degrees of freedom for finite element/finite difference functions
  4:   on a grid. They have more mathematical structure then simple arrays.
  5: */

  7: #if !defined(PETSCVEC_H)
  8: #define PETSCVEC_H
  9: #include <petscsys.h>
 10: #include <petscsftypes.h>
 11: #include <petscis.h>
 12: #include <petscdevicetypes.h>
 13: #include <petscviewer.h>

 15: /*S
 16:      Vec - Abstract PETSc vector object

 18:    Level: beginner

 20: .seealso:  VecCreate(), VecType, VecSetType()
 21: S*/
 22: typedef struct _p_Vec*         Vec;

 24: /*E
 25:   ScatterMode - Determines the direction of a scatter

 27:   Level: beginner

 29: .seealso: VecScatter, VecScatterBegin(), VecScatterEnd()
 30: E*/
 31: typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode;

 33: /*MC
 34:     SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call

 36:     Level: beginner

 38: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
 39:           SCATTER_REVERSE_LOCAL

 41: M*/

 43: /*MC
 44:     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
 45:          in the VecScatterCreate()

 47:     Level: beginner

 49: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 50:           SCATTER_REVERSE_LOCAL

 52: M*/

 54: /*MC
 55:     SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication
 56:        is done. Any variables that have be moved between processes are ignored

 58:     Level: developer

 60: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
 61:           SCATTER_REVERSE_LOCAL

 63: M*/

 65: /*MC
 66:     SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
 67:          in the VecScatterCreate()  except NO parallel communication
 68:        is done. Any variables that have be moved between processes are ignored

 70:     Level: developer

 72: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 73:           SCATTER_REVERSE

 75: M*/

 77: /*J
 78:     VecType - String with the name of a PETSc vector

 80:    Level: beginner

 82: .seealso: VecSetType(), Vec, VecCreate(), VecDestroy()
 83: J*/
 84: typedef const char* VecType;
 85: #define VECSEQ         "seq"
 86: #define VECMPI         "mpi"
 87: #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
 88: #define VECSHARED      "shared"
 89: #define VECSEQVIENNACL "seqviennacl"
 90: #define VECMPIVIENNACL "mpiviennacl"
 91: #define VECVIENNACL    "viennacl"   /* seqviennacl on one process and mpiviennacl on several */
 92: #define VECSEQCUDA     "seqcuda"
 93: #define VECMPICUDA     "mpicuda"
 94: #define VECCUDA        "cuda"       /* seqcuda on one process and mpicuda on several */
 95: #define VECSEQHIP      "seqhip"
 96: #define VECMPIHIP      "mpihip"
 97: #define VECHIP         "hip"       /* seqcuda on one process and mpicuda on several */
 98: #define VECNEST        "nest"
 99: #define VECSEQKOKKOS   "seqkokkos"
100: #define VECMPIKOKKOS   "mpikokkos"
101: #define VECKOKKOS      "kokkos"     /* seqkokkos on one process and mpikokkos on several */

103: /* Dynamic creation and loading functions */
104: PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType);
105: PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType*);
106: PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter);
107: PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[],PetscErrorCode (*)(VecScatter));
108: PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter*);

110: /* Logging support */
111: #define    REAL_FILE_CLASSID 1211213
112: #define    VEC_FILE_CLASSID 1211214
113: PETSC_EXTERN PetscClassId VEC_CLASSID;
114: PETSC_EXTERN PetscClassId PETSCSF_CLASSID;

116: PETSC_EXTERN PetscErrorCode VecInitializePackage(void);
117: PETSC_EXTERN PetscErrorCode VecFinalizePackage(void);

119: PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*);
120: PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
121: PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
122: PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
123: PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*);
124: PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
125: PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm,PetscInt,PetscInt,Vec*);

127: PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec);
128: PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec,PetscObject,const char[]);

130: PETSC_EXTERN PetscErrorCode VecSetUp(Vec);
131: PETSC_EXTERN PetscErrorCode VecDestroy(Vec*);
132: PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec);
133: PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]);
134: PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]);
135: PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]);

137: PETSC_EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt);

139: PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*);
140: PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
141: PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*);
142: PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
143: PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
144: PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
145: PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*);
146: PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*);
147: PETSC_EXTERN PetscErrorCode VecConcatenate(PetscInt,const Vec[],Vec*,IS*[]);

149: /*E
150:     NormType - determines what type of norm to compute

152:     Level: beginner

154: .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
155: E*/
156: typedef enum {NORM_1=0,
157:               NORM_2=1,
158:               NORM_FROBENIUS=2,
159:               NORM_INFINITY=3,
160:               NORM_1_AND_2=4
161:               } NormType;
162: PETSC_EXTERN const char *const NormTypes[];
163: #define NORM_MAX NORM_INFINITY

165: /*MC
166:      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum

168:    Level: beginner

170: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
171:            NORM_INFINITY, NORM_1_AND_2

173: M*/

175: /*MC
176:      NORM_2 - the two norm, ||v|| = sqrt(sum_i |v_i|^2) (vectors only)

178:    Level: beginner

180: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
181:            NORM_INFINITY, NORM_1_AND_2

183: M*/

185: /*MC
186:      NORM_FROBENIUS - ||A|| = sqrt(sum_ij |A_ij|^2), same as NORM_2 for vectors

188:    Level: beginner

190: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
191:            NORM_INFINITY, NORM_1_AND_2

193: M*/

195: /*MC
196:      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum

198:    Level: beginner

200: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
201:            NORM_FROBENIUS, NORM_1_AND_2

203: M*/

205: /*MC
206:      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector

208:    Level: beginner

210: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
211:            NORM_FROBENIUS, NORM_INFINITY

213: M*/

215: /*MC
216:      NORM_MAX - see NORM_INFINITY

218:    Level: beginner

220: M*/

222: /*E
223:     ReductionType - determines what type of column reduction (one that is not a type of norm defined in NormType) to compute

225:     Level: beginner

227: .seealso: MatGetColumnReductions(), MatGetColumnNorms(), NormType
228: E*/
229: /* NOTE: The integer constants defined in ReductionType MUST BE DISTINCT from those defined in NormType.
230:  * This is because MatGetColumnReductions() is used to compute both norms and other types of reductions,
231:  * and the constants defined in both NormType and ReductionType are used to designate the desired operation. */
232: typedef enum {REDUCTION_SUM_REALPART=10,
233:               REDUCTION_MEAN_REALPART=11,
234:               REDUCTION_SUM_IMAGINARYPART=12,
235:               REDUCTION_MEAN_IMAGINARYPART=13
236:               } ReductionType;

238: /*MC
239:      REDUCTION_SUM_REALPART - sum of real part of matrix column

241:    Level: beginner

243: .seealso:  ReductionType, MatGetColumnReductions(), REDUCTION_SUM_IMAGINARYPART, REDUCTION_MEAN_REALPART, REDUCTION_NORM_1,
244:            REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY

246: M*/

248: /*MC
249:      REDUCTION_SUM_IMAGINARYPART - sum of imaginary part of matrix column

251:    Level: beginner

253: .seealso:  ReductionType, MatGetColumnReductions(), REDUCTION_SUM_REALPART, REDUCTION_MEAN_IMAGINARYPART, REDUCTION_NORM_1,
254:            REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY

256: M*/

258: /*MC
259:      REDUCTION_MEAN_REALPART - arithmetic mean of real part of matrix column

261:    Level: beginner

263: .seealso:  ReductionType, MatGetColumnReductions(), REDUCTION_MEAN_IMAGINARYPART, REDUCTION_SUM_REALPART, REDUCTION_NORM_1,
264:            REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY

266: M*/

268: /*MC
269:      REDUCTION_MEAN_IMAGINARYPART - arithmetic mean of imaginary part of matrix column

271:    Level: beginner

273: .seealso:  ReductionType, MatGetColumnReductions(), REDUCTION_MEAN_REALPART, REDUCTION_SUM_IMAGINARYPART, REDUCTION_NORM_1,
274:            REDUCTION_NORM_2, REDUCTION_NORM_FROBENIUS, REDUCTION_NORM_INFINITY

276: M*/

278: PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
279: PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *);
280: PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
281: PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
282: PETSC_EXTERN PetscErrorCode VecMean(Vec,PetscScalar*);
283: PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
284: PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
285: PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
286: PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec);
287: PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
288: PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
289: PETSC_EXTERN PetscErrorCode VecSetInf(Vec);
290: PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec);
291: PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
292: PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
293: PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
294: PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
295: PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
296: PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
297: PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
298: PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
299: PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
300: PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
301: PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
302: PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
303: PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
304: PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
305: PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool);
306: PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
307: PETSC_EXTERN PetscErrorCode VecLog(Vec);
308: PETSC_EXTERN PetscErrorCode VecExp(Vec);
309: PETSC_EXTERN PetscErrorCode VecAbs(Vec);
310: PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
311: PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
312: PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]);
313: PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
314: PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
315: PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
316: PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]);
317: PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**);

319: PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
320: PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
321: PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
322: PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
323: PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar);

325: PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
326: PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
327: PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
328: PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);

330: PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
331: PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);

333: PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
334: PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
335: PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
336: PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
337: PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
338: PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
339: PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]);
340: PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

342: /*MC
343:    VecSetValue - Set a single entry into a vector.

345:    Synopsis:
346: #include <petscvec.h>
347:    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

349:    Not Collective

351:    Input Parameters:
352: +  v - the vector
353: .  row - the row location of the entry
354: .  value - the value to insert
355: -  mode - either INSERT_VALUES or ADD_VALUES

357:    Notes:
358:    For efficiency one should use VecSetValues() and set several or
359:    many values simultaneously if possible.

361:    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
362:    MUST be called after all calls to VecSetValue() have been completed.

364:    VecSetValue() uses 0-based indices in Fortran as well as in C.

366:    Level: beginner

368: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
369: M*/
370: static inline PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}

372: PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
373: PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
374: PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

376: /* Dynamic creation and loading functions */
377: PETSC_EXTERN PetscFunctionList VecList;
378: PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType);
379: PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*);
380: PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec));

382: PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
383: PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
384: PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*);
385: PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter);
386: PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
387: PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
388: PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]);
389: PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]);
390: PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*);

392: PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
393: PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
394: PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
395: PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
396: PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
397: PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
398: PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);
399: PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);

401: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
402: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
403: PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
404: PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
405: PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
406: PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
407: PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
408: PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);
409: PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);

411: PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
412: PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
413: PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
414: PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
415: PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
416: PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
417: PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);
418: PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);

420: PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
421: PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
422: PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);

424: PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
425: PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);

427: PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer);
428: PETSC_EXTERN PetscErrorCode VecViewNative(Vec,PetscViewer);
429: PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*);
430: PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer);

432: PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
433: PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
434: PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
435: PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]);

437: PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
438: PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

440: PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**);
441: PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**);

443: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**);
444: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**);

446: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**);
447: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**);

449: PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]);
450: PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]);
451: PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec);

453: PETSC_EXTERN PetscErrorCode VecHIPGetArray(Vec,PetscScalar**);
454: PETSC_EXTERN PetscErrorCode VecHIPRestoreArray(Vec,PetscScalar**);

456: PETSC_EXTERN PetscErrorCode VecHIPGetArrayRead(Vec,const PetscScalar**);
457: PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayRead(Vec,const PetscScalar**);

459: PETSC_EXTERN PetscErrorCode VecHIPGetArrayWrite(Vec,PetscScalar**);
460: PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayWrite(Vec,PetscScalar**);

462: PETSC_EXTERN PetscErrorCode VecHIPPlaceArray(Vec,const PetscScalar[]);
463: PETSC_EXTERN PetscErrorCode VecHIPReplaceArray(Vec,const PetscScalar[]);
464: PETSC_EXTERN PetscErrorCode VecHIPResetArray(Vec);

466: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*);
467: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*);
468: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*);
469: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*);
470: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec);
471: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*);
472: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec);

474: /*MC
475:    VecSetValueLocal - Set a single entry into a vector using the local numbering

477:    Synopsis:
478: #include <petscvec.h>
479:    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

481:    Not Collective

483:    Input Parameters:
484: +  v - the vector
485: .  row - the row location of the entry
486: .  value - the value to insert
487: -  mode - either INSERT_VALUES or ADD_VALUES

489:    Notes:
490:    For efficiency one should use VecSetValues() and set several or
491:    many values simultaneously if possible.

493:    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
494:    MUST be called after all calls to VecSetValues() have been completed.

496:    VecSetValues() uses 0-based indices in Fortran as well as in C.

498:    Level: beginner

500: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
501: M*/
502: static inline PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}

504: PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
505: PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping*);

507: PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
508: PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
509: PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
510: PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
511: PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
512: PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);

514: PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
515: PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
516: PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
517: PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
518: PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);

520: PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool);
521: PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") static inline PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);}
522: PETSC_EXTERN PetscErrorCode VecBoundToCPU(Vec,PetscBool*);
523: PETSC_EXTERN PetscErrorCode VecSetBindingPropagates(Vec,PetscBool);
524: PETSC_EXTERN PetscErrorCode VecGetBindingPropagates(Vec,PetscBool *);
525: PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t);
526: PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *);

528: PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec,PetscOffloadMask *);

530: typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES,VEC_SUBSET_OFF_PROC_ENTRIES} VecOption;
531: PETSC_EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscBool);

533: PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**);
534: PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**);
535: PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**);
536: PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**);
537: PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**);
538: PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**);
539: PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec);
540: PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec);
541: PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec);
542: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec);
543: PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec,PetscScalar**,PetscMemType*);
544: PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec,PetscScalar**);
545: PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec,const PetscScalar**,PetscMemType*);
546: PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec,const PetscScalar**);
547: PETSC_EXTERN PetscErrorCode VecGetArrayWriteAndMemType(Vec,PetscScalar**,PetscMemType*);
548: PETSC_EXTERN PetscErrorCode VecRestoreArrayWriteAndMemType(Vec,PetscScalar**);

550: /*@C
551:    VecGetArrayPair - Accesses a pair of pointers for two vectors that may be common. When not common the first is read only

553:    Logically Collective on x

555:    Input Parameters:
556: +  x - the vector
557: -  y - the second vector

559:    Output Parameters:
560: +  xv - location to put pointer to the first array
561: -  yv - location to put pointer to the second array

563:    Level: developer

565:    Not available from Fortran

567: .seealso: VecGetArray(), VecGetArrayRead(), VecRestoreArrayPair()

569: @*/
570: static inline PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
571: {
572:   VecGetArray(y,yv);
573:   if (x == y) *xv = *yv;
574:   else VecGetArrayRead(x,(const PetscScalar**)xv);
575:   return 0;
576: }

578: /*@C
579:    VecRestoreArrayPair - Returns a pair of pointers for two vectors that may be common. When not common the first is read only

581:    Logically Collective on x

583:    Input Parameters:
584: +  x - the vector
585: -  y - the second vector

587:    Output Parameters:
588: +  xv - location to put pointer to the first array
589: -  yv - location to put pointer to the second array

591:    Level: developer

593:    Not available from Fortran

595: .seealso: VecGetArray(), VecGetArrayRead(), VecGetArrayPair()

597: @*/
598: static inline PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
599: {
600:   VecRestoreArray(y,yv);
601:   if (x != y) VecRestoreArrayRead(x,(const PetscScalar**)xv);
602:   return 0;
603: }

605: #if defined(PETSC_USE_DEBUG)
606: PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec);
607: PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec);
608: /* We also have a non-public VecLockWriteSet_Private() in vecimpl.h */
609: PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*);
610: static inline PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg)
611: {
612:   PetscInt state;

614:   VecLockGet(x,&state);
616:   return 0;
617: }
618: /* The three are deprecated */
619: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec);
620: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)")  PetscErrorCode VecLockPop(Vec);
621: #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"")
622: #else
623: #define VecLockReadPush(x)           0
624: #define VecLockReadPop(x)            0
625: #define VecLockGet(x,s)              *(s) = 0
626: #define VecSetErrorIfLocked(x,arg)   0
627: /* The three are deprecated */
628: #define VecLockPush(x)               0
629: #define VecLockPop(x)                0
630: #define VecLocked(x,arg)             0
631: #endif

633: PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool);

635: /*
636:     These numbers need to match the entries in
637:   the function table in vecimpl.h
638: */
639: typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation;
640: PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));

642: /*
643:      Routines for dealing with ghosted vectors:
644:   vectors with ghost elements at the end of the array.
645: */
646: PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]);
647: PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
648: PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
649: PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
650: PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
651: PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
652: PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
653: PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*);
654: PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
655: PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);

657: PETSC_EXTERN PetscErrorCode VecConjugate(Vec);
658: PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec);
659: PETSC_EXTERN PetscErrorCode VecRealPart(Vec);

661: PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
662: PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);

664: PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*);
665: PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
666: PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
667: PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *);
668: PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
669: PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
670: PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *);
671: PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
672: PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
673: PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec);
674: PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec);
675: PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar);
676: PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
677: PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*);
678: PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
679: PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*);

681: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
682: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);

684: /*S
685:      Vecs - Collection of vectors where the data for the vectors is stored in
686:             one contiguous memory

688:    Level: advanced

690:    Notes:
691:     Temporary construct for handling multiply right hand side solves

693:     This is faked by storing a single vector that has enough array space for
694:     n vectors

696: S*/
697:         struct _n_Vecs  {PetscInt n; Vec v;};
698: typedef struct _n_Vecs* Vecs;
699: PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
700: PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*);
701: PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*);
702: PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*);

704: #if defined(PETSC_HAVE_VIENNACL)
705: typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices;
706: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*);
707: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*);
708: PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices);
709: PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices);
710: PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*);
711: PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*);
712: #endif
713: #if defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_HIP)
714: PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec);
715: PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
716: #endif
717: #if defined(PETSC_HAVE_CUDA)
718: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*);
719: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
720: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
721: PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*);
722: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
723: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
724: #endif
725: #if defined(PETSC_HAVE_HIP)
726: PETSC_EXTERN PetscErrorCode VecCreateSeqHIP(MPI_Comm,PetscInt,Vec*);
727: PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
728: PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
729: PETSC_EXTERN PetscErrorCode VecCreateMPIHIP(MPI_Comm,PetscInt,PetscInt,Vec*);
730: PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
731: PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
732: #endif
733: #if defined(PETSC_HAVE_KOKKOS_KERNELS)
734: PETSC_EXTERN PetscErrorCode VecCreateSeqKokkos(MPI_Comm,PetscInt,Vec*);
735: PETSC_EXTERN PetscErrorCode VecCreateSeqKokkosWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
736: PETSC_EXTERN PetscErrorCode VecCreateMPIKokkos(MPI_Comm,PetscInt,PetscInt,Vec*);
737: PETSC_EXTERN PetscErrorCode VecCreateMPIKokkosWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
738: #endif

740: PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**);
741: PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*);
742: PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*);
743: PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec);
744: PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*);
745: PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*);

747: PETSC_EXTERN PetscErrorCode PetscOptionsGetVec(PetscOptions,const char[],const char[],Vec,PetscBool*);
748: PETSC_EXTERN PetscErrorCode VecChop(Vec,PetscReal);

750: PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*);
751: PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout);

753: PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
754: PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
755: PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode);
756: PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []);

758: /*S
759:   VecTagger - Object used to manage the tagging of a subset of indices based on the values of a vector.  The
760:               motivating application is the selection of cells for refinement or coarsening based on vector containing
761:               the values in an error indicator metric.

763:   Level: advanced
764: S*/
765: typedef struct _p_VecTagger *VecTagger;

767: /*J
768:   VecTaggerType - String with the name of a VecTagger type

770:   Level: advanced
771: J*/
772: typedef const char* VecTaggerType;
773: /* tag where the vector values are in a box of explicitly defined values */
774: #define VECTAGGERABSOLUTE   "absolute"
775: /* tag where the vector values are in a box of values relative to the set of all values in the vector */
776: #define VECTAGGERRELATIVE   "relative"
777: /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */
778: #define VECTAGGERCDF        "cdf"
779: /* tag a vector as the union of other tags */
780: #define VECTAGGEROR         "or"
781: /* tag a vector as the intersection of other tags */
782: #define VECTAGGERAND        "and"

784: PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID;
785: PETSC_EXTERN PetscFunctionList VecTaggerList;
786: PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger));

788: PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *);
789: PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt);
790: PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*);
791: PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType);
792: PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *);
793: PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool);
794: PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*);
795: PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger);
796: PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger);
797: PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer);
798: PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *,PetscBool*);
799: PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *);

801: /*S
802:    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
803:    such that real(min) <= real(z) <= real(max) and imag(min) <= imag(z) <= imag(max).  INF is an acceptable endpoint.

805:    Level: beginner

807: .seealso: VecTaggerComputeIntervals()
808: S*/
809: typedef struct {
810:   PetscScalar min;
811:   PetscScalar max;
812: } VecTaggerBox;
813: PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **,PetscBool*);

815: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *);
816: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **);

818: PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *);
819: PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **);

821: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *);
822: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **);

824: /*E
825:   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.

827:   Level: advanced
828: .seealso: VecTaggerCDFSetMethod(), VecTaggerCDFMethods
829: E*/
830: typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod;
831: PETSC_EXTERN const char *const VecTaggerCDFMethods[];

833: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod);
834: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*);
835: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal);
836: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*);

838: PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
839: PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**);

841: PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
842: PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**);

844: PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void);
845: PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void);

847: #endif