Actual source code: petscvec.h

petsc-master 2020-10-23
Report Typos and Errors
  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: #ifndef PETSCVEC_H
  8: #define PETSCVEC_H
  9: #include "petscsys.h"
 10: #include "petscsystypes.h"
 11: #include <petscis.h>
 12: #include <petscviewer.h>

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

 17:    Level: beginner

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

 23: /*S
 24:      VecScatter - Object used to manage communication of data
 25:        between vectors in parallel. Manages both scatters and gathers

 27:    Level: beginner

 29: .seealso:  VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
 30: S*/
 31: typedef struct _p_VecScatter*  VecScatter;

 33: /*E
 34:   ScatterMode - Determines the direction of a scatter

 36:   Level: beginner

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

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

 45:     Level: beginner

 47: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
 48:           SCATTER_REVERSE_LOCAL

 50: M*/

 52: /*MC
 53:     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
 54:          in the VecScatterCreate()

 56:     Level: beginner

 58: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 59:           SCATTER_REVERSE_LOCAL

 61: M*/

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

 67:     Level: developer

 69: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
 70:           SCATTER_REVERSE_LOCAL

 72: M*/

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

 79:     Level: developer

 81: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 82:           SCATTER_REVERSE

 84: M*/

 86: /*J
 87:     VecType - String with the name of a PETSc vector

 89:    Level: beginner

 91: .seealso: VecSetType(), Vec, VecCreate(), VecDestroy()
 92: J*/
 93: typedef const char* VecType;
 94: #define VECSEQ         "seq"
 95: #define VECMPI         "mpi"
 96: #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
 97: #define VECSHARED      "shared"
 98: #define VECSEQVIENNACL "seqviennacl"
 99: #define VECMPIVIENNACL "mpiviennacl"
100: #define VECVIENNACL    "viennacl"   /* seqviennacl on one process and mpiviennacl on several */
101: #define VECSEQCUDA     "seqcuda"
102: #define VECMPICUDA     "mpicuda"
103: #define VECCUDA        "cuda"       /* seqcuda on one process and mpicuda on several */
104: #define VECNEST        "nest"
105: #define VECNODE        "node"       /* use on-node shared memory */
106: #define VECSEQKOKKOS   "seqkokkos"
107: #define VECMPIKOKKOS   "mpikokkos"
108: #define VECKOKKOS      "kokkos"     /* seqkokkos on one process and mpikokkos on several */

110: /*J
111:     VecScatterType - String with the name of a PETSc vector scatter type

113:    Level: beginner

115: .seealso: VecScatterSetType(), VecScatter, VecScatterCreate(), VecScatterDestroy()
116: J*/
117: typedef const char* VecScatterType;
118: #define VECSCATTERSEQ       "seq"
119: #define VECSCATTERMPI1      "mpi1"
120: #define VECSCATTERMPI3      "mpi3"     /* use MPI3 on-node shared memory */
121: #define VECSCATTERMPI3NODE  "mpi3node" /* use MPI3 on-node shared memory for vector type VECNODE */
122: #define VECSCATTERSF        "sf"       /* use StarForest */

124: /* Dynamic creation and loading functions */
125: PETSC_EXTERN PetscFunctionList VecScatterList;
126: PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType);
127: PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType *);
128: PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter);
129: PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[],PetscErrorCode (*)(VecScatter));
130: PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter*);
131: PETSC_EXTERN PetscErrorCode VecScatterInitializePackage(void);
132: PETSC_EXTERN PetscErrorCode VecScatterFinalizePackage(void);

134: /* Logging support */
135: #define    REAL_FILE_CLASSID 1211213
136: #define    VEC_FILE_CLASSID 1211214
137: PETSC_EXTERN PetscClassId VEC_CLASSID;
138: PETSC_EXTERN PetscClassId VEC_SCATTER_CLASSID;


141: PETSC_EXTERN PetscErrorCode VecInitializePackage(void);
142: PETSC_EXTERN PetscErrorCode VecFinalizePackage(void);

144: PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*);
145: PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
146: PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
147: PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
148: PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*);
149: PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
150: PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm,PetscInt,PetscInt,Vec*);

152: PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec);
153: PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec,PetscObject,const char[]);

155: PETSC_EXTERN PetscErrorCode VecSetUp(Vec);
156: PETSC_EXTERN PetscErrorCode VecDestroy(Vec*);
157: PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec);
158: PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]);
159: PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]);
160: PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]);

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

164: PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*);
165: PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
166: PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*);
167: PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
168: PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
169: PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
170: PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*);
171: PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*);

173: /*E
174:     NormType - determines what type of norm to compute

176:     Level: beginner

178: .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
179: E*/
180: typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
181: PETSC_EXTERN const char *const NormTypes[];
182: #define NORM_MAX NORM_INFINITY

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

187:    Level: beginner

189: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
190:            NORM_INFINITY, NORM_1_AND_2

192: M*/

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

197:    Level: beginner

199: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
200:            NORM_INFINITY, NORM_1_AND_2

202: M*/

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

207:    Level: beginner

209: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
210:            NORM_INFINITY, NORM_1_AND_2

212: M*/

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

217:    Level: beginner

219: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
220:            NORM_FROBINIUS, NORM_1_AND_2

222: M*/

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

227:    Level: beginner

229: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
230:            NORM_FROBINIUS, NORM_INFINITY

232: M*/

234: /*MC
235:      NORM_MAX - see NORM_INFINITY

237:    Level: beginner

239: M*/

241: PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
242: PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *);
243: PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
244: PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
245: PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
246: PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
247: PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
248: PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec);
249: PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
250: PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
251: PETSC_EXTERN PetscErrorCode VecSetInf(Vec);
252: PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec);
253: PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
254: PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
255: PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
256: PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
257: PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
258: PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
259: PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
260: PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
261: PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
262: PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
263: PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
264: PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
265: PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
266: PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
267: PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool);
268: PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
269: PETSC_EXTERN PetscErrorCode VecLog(Vec);
270: PETSC_EXTERN PetscErrorCode VecExp(Vec);
271: PETSC_EXTERN PetscErrorCode VecAbs(Vec);
272: PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
273: PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
274: PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]);
275: PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
276: PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
277: PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
278: PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]);
279: PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**);

281: PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
282: PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
283: PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
284: PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
285: PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar);


288: PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
289: PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
290: PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
291: PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);

293: PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
294: PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);

296: PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
297: PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
298: PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
299: PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
300: PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
301: PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
302: PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]);
303: PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

305: /*MC
306:    VecSetValue - Set a single entry into a vector.

308:    Synopsis:
309: #include <petscvec.h>
310:    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

312:    Not Collective

314:    Input Parameters:
315: +  v - the vector
316: .  row - the row location of the entry
317: .  value - the value to insert
318: -  mode - either INSERT_VALUES or ADD_VALUES

320:    Notes:
321:    For efficiency one should use VecSetValues() and set several or
322:    many values simultaneously if possible.

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

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

329:    Level: beginner

331: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
332: M*/
333: PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}


336: PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
337: PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
338: PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

340: /* Dynamic creation and loading functions */
341: PETSC_EXTERN PetscFunctionList VecList;
342: PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType);
343: PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*);
344: PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec));

346: PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
347: PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
348: PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*);
349: PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter);
350: PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
351: PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
352: PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]);
353: PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]);
354: PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*);

356: PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
357: PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
358: PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
359: PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
360: PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
361: PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
362: PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);
363: PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);

365: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
366: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
367: PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
368: PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
369: PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
370: PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
371: PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
372: PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);
373: PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);

375: PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
376: PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
377: PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
378: PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
379: PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
380: PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
381: PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);
382: PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);

384: PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
385: PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
386: PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);

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

391: PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer);
392: PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*);
393: PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer);

395: PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
396: PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
397: PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
398: PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]);

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

403: PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**);
404: PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**);

406: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**);
407: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**);

409: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**);
410: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**);

412: PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]);
413: PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]);
414: PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec);

416: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*);
417: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*);
418: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*);
419: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*);
420: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec);
421: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*);
422: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec);

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

427:    Synopsis:
428: #include <petscvec.h>
429:    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

431:    Not Collective

433:    Input Parameters:
434: +  v - the vector
435: .  row - the row location of the entry
436: .  value - the value to insert
437: -  mode - either INSERT_VALUES or ADD_VALUES

439:    Notes:
440:    For efficiency one should use VecSetValues() and set several or
441:    many values simultaneously if possible.

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

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

448:    Level: beginner

450: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
451: M*/
452: PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}

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

457: PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
458: PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
459: PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
460: PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
461: PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
462: PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);

464: PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
465: PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
466: PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
467: PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
468: PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);

470: PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool);
471: PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") PETSC_STATIC_INLINE PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);}
472: PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t);
473: PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *);


476: /*E
477:     PetscOffloadMask - indicates which memory (CPU, GPU, or none) contains valid data

479:    PETSC_OFFLOAD_UNALLOCATED  - no memory contains valid matrix entries; NEVER used for vectors
480:    PETSC_OFFLOAD_GPU - GPU has valid vector/matrix entries
481:    PETSC_OFFLOAD_CPU - CPU has valid vector/matrix entries
482:    PETSC_OFFLOAD_BOTH - Both GPU and CPU have valid vector/matrix entries and they match
483:    PETSC_OFFLOAD_VECKOKKOS - Reserved for Vec_Kokkos. The offload is managed by Kokkos, thus this flag is not used in Vec_Kokkos.

485:    Level: developer
486: E*/
487: typedef enum {PETSC_OFFLOAD_UNALLOCATED=0x0,PETSC_OFFLOAD_CPU=0x1,PETSC_OFFLOAD_GPU=0x2,PETSC_OFFLOAD_BOTH=0x3,PETSC_OFFLOAD_VECKOKKOS=0x100} PetscOffloadMask;
488: PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec,PetscOffloadMask *);

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

493: PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**);
494: PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**);
495: PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**);
496: PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**);
497: PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**);
498: PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**);
499: PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec);
500: PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec);
501: PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec);
502: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec);
503: PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec,PetscScalar**,PetscMemType*);
504: PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec,PetscScalar**);
505: PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec,const PetscScalar**,PetscMemType*);
506: PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec,const PetscScalar**);

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

511:    Logically Collective on x

513:    Input Parameters:
514: +  x - the vector
515: -  y - the second vector

517:    Output Parameters:
518: +  xv - location to put pointer to the first array
519: -  yv - location to put pointer to the second array

521:    Level: developer

523:    Not available from Fortran

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

527: @*/
528: PETSC_STATIC_INLINE PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
529: {

533:   VecGetArray(y,yv);
534:   if (x != y) {
535:     VecGetArrayRead(x,(const PetscScalar **)xv);
536:   } else {
537:     *xv = *yv;
538:   }
539:   return(0);
540: }

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

545:    Logically Collective on x

547:    Input Parameters:
548: +  x - the vector
549: -  y - the second vector

551:    Output Parameters:
552: +  xv - location to put pointer to the first array
553: -  yv - location to put pointer to the second array

555:    Level: developer

557:    Not available from Fortran

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

561: @*/
562: PETSC_STATIC_INLINE PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
563: {

567:   VecRestoreArray(y,yv);
568:   if (x != y) {
569:     VecRestoreArrayRead(x,(const PetscScalar **)xv);
570:   }
571:   return(0);
572: }

574: #if defined(PETSC_USE_DEBUG)
575: PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec);
576: PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec);
577: /* We also have a non-public VecLockWriteSet_Private() in vecimpl.h */
578: PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*);
579: PETSC_STATIC_INLINE PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg)
580: {
581:   PetscInt       state;

585:   VecLockGet(x,&state);
586:   if (state != 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE," Vec is already locked for read-only or read/write access, argument # %d",arg);
587:   return(0);
588: }
589: /* The three are deprecated */
590: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec);
591: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)")  PetscErrorCode VecLockPop(Vec);
592: #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"")
593: #else
594: #define VecLockReadPush(x)           0
595: #define VecLockReadPop(x)            0
596: #define VecLockGet(x,s)              *(s) = 0
597: #define VecSetErrorIfLocked(x,arg)   0
598: /* The three are deprecated */
599: #define VecLockPush(x)               0
600: #define VecLockPop(x)                0
601: #define VecLocked(x,arg)             0
602: #endif

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

606: /*
607:     These numbers need to match the entries in
608:   the function table in vecimpl.h
609: */
610: typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation;
611: PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));

613: /*
614:      Routines for dealing with ghosted vectors:
615:   vectors with ghost elements at the end of the array.
616: */
617: PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]);
618: PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
619: PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
620: PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
621: PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
622: PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
623: PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
624: PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*);
625: PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
626: PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);

628: PETSC_EXTERN PetscErrorCode VecConjugate(Vec);
629: PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec);
630: PETSC_EXTERN PetscErrorCode VecRealPart(Vec);

632: PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
633: PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);

635: PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*);
636: PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
637: PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
638: PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *);
639: PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
640: PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
641: PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *);
642: PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
643: PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
644: PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec);
645: PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec);
646: PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar);
647: PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
648: PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*);
649: PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
650: PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*);

652: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
653: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);

655: /*S
656:      Vecs - Collection of vectors where the data for the vectors is stored in
657:             one contiguous memory

659:    Level: advanced

661:    Notes:
662:     Temporary construct for handling multiply right hand side solves

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

667: S*/
668:         struct _n_Vecs  {PetscInt n; Vec v;};
669: typedef struct _n_Vecs* Vecs;
670: PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
671: PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*);
672: PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*);
673: PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*);

675: #if defined(PETSC_HAVE_VIENNACL)
676: typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices;
677: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*);
678: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*);
679: PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices);
680: PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices);
681: PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*);
682: PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*);
683: #endif
684: #if defined(PETSC_HAVE_CUDA)
685: typedef struct _p_PetscCUDAIndices* PetscCUDAIndices;
686: typedef struct _p_VecScatterCUDAIndices_StoS* VecScatterCUDAIndices_StoS;
687: typedef struct _p_VecScatterCUDAIndices_PtoP* VecScatterCUDAIndices_PtoP;
688: PETSC_EXTERN PetscErrorCode VecCUDACopyToGPUSome_Public(Vec,PetscCUDAIndices,ScatterMode);
689: PETSC_EXTERN PetscErrorCode VecCUDACopyFromGPUSome_Public(Vec,PetscCUDAIndices,ScatterMode);
690: PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec);
691: PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
692: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*);
693: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
694: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
695: PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*);
696: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
697: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
698: #endif

700: PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**);
701: PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*);
702: PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*);
703: PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec);
704: PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*);
705: PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*);

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

710: PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*);
711: PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout);

713: PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
714: PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
715: PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode);
716: PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []);

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

723:   Level: advanced
724: S*/
725: typedef struct _p_VecTagger *VecTagger;

727: /*J
728:   VecTaggerType - String with the name of a VecTagger type

730:   Level: advanced
731: J*/
732: typedef const char* VecTaggerType;
733: /* tag where the vector values are in a box of explicitly defined values */
734: #define VECTAGGERABSOLUTE   "absolute"
735: /* tag where the vector values are in a box of values relative to the set of all values in the vector */
736: #define VECTAGGERRELATIVE   "relative"
737: /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */
738: #define VECTAGGERCDF        "cdf"
739: /* tag a vector as the union of other tags */
740: #define VECTAGGEROR         "or"
741: /* tag a vector as the intersection of other tags */
742: #define VECTAGGERAND        "and"

744: PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID;
745: PETSC_EXTERN PetscFunctionList VecTaggerList;
746: PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger));

748: PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *);
749: PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt);
750: PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*);
751: PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType);
752: PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *);
753: PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool);
754: PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*);
755: PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger);
756: PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger);
757: PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer);
758: PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *);
759: PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *);

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

765:    Level: beginner

767: .seealso: VecTaggerComputeIntervals()
768: S*/
769: typedef struct {
770:   PetscScalar min;
771:   PetscScalar max;
772: } VecTaggerBox;
773: PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **);


776: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *);
777: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **);

779: PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *);
780: PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **);

782: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *);
783: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **);

785: /*E
786:   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.

788:   Level: advanced
789: .seealso: VecTaggerCDFSetMethod(), VecTaggerCDFMethods
790: E*/
791: typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod;
792: PETSC_EXTERN const char *const VecTaggerCDFMethods[];

794: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod);
795: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*);
796: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal);
797: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*);

799: PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
800: PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**);

802: PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
803: PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**);

805: PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void);
806: PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void);

808: #endif