Actual source code: petscvec.h
petsc-3.15.0 2021-03-30
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: #if !defined(PETSCVEC_H)
      8: #define PETSCVEC_H
      9: #include <petscsys.h>
     10: #include <petscsftypes.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: /*E
     24:   ScatterMode - Determines the direction of a scatter

     26:   Level: beginner

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

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

     35:     Level: beginner

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

     40: M*/

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

     46:     Level: beginner

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

     51: M*/

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

     57:     Level: developer

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

     62: M*/

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

     69:     Level: developer

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

     74: M*/

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

     79:    Level: beginner

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

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

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

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

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

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

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

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

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

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

    151:     Level: beginner

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

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

    162:    Level: beginner

    164: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
    165:            NORM_INFINITY, NORM_1_AND_2

    167: M*/

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

    172:    Level: beginner

    174: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
    175:            NORM_INFINITY, NORM_1_AND_2

    177: M*/

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

    182:    Level: beginner

    184: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
    185:            NORM_INFINITY, NORM_1_AND_2

    187: M*/

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

    192:    Level: beginner

    194: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
    195:            NORM_FROBENIUS, NORM_1_AND_2

    197: M*/

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

    202:    Level: beginner

    204: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
    205:            NORM_FROBENIUS, NORM_INFINITY

    207: M*/

    209: /*MC
    210:      NORM_MAX - see NORM_INFINITY

    212:    Level: beginner

    214: M*/

    216: PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
    217: PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *);
    218: PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
    219: PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
    220: PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
    221: PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
    222: PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
    223: PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec);
    224: PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
    225: PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
    226: PETSC_EXTERN PetscErrorCode VecSetInf(Vec);
    227: PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec);
    228: PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
    229: PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
    230: PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
    231: PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
    232: PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
    233: PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
    234: PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
    235: PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
    236: PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
    237: PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
    238: PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
    239: PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
    240: PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
    241: PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
    242: PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool);
    243: PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
    244: PETSC_EXTERN PetscErrorCode VecLog(Vec);
    245: PETSC_EXTERN PetscErrorCode VecExp(Vec);
    246: PETSC_EXTERN PetscErrorCode VecAbs(Vec);
    247: PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
    248: PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
    249: PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]);
    250: PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
    251: PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
    252: PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
    253: PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]);
    254: PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**);

    256: PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
    257: PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
    258: PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
    259: PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
    260: PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar);

    263: PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
    264: PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
    265: PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
    266: PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);

    268: PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
    269: PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);

    271: PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
    272: PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
    273: PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
    274: PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
    275: PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
    276: PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
    277: PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]);
    278: PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

    280: /*MC
    281:    VecSetValue - Set a single entry into a vector.

    283:    Synopsis:
    284: #include <petscvec.h>
    285:    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

    287:    Not Collective

    289:    Input Parameters:
    290: +  v - the vector
    291: .  row - the row location of the entry
    292: .  value - the value to insert
    293: -  mode - either INSERT_VALUES or ADD_VALUES

    295:    Notes:
    296:    For efficiency one should use VecSetValues() and set several or
    297:    many values simultaneously if possible.

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

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

    304:    Level: beginner

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

    311: PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
    312: PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
    313: PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

    315: /* Dynamic creation and loading functions */
    316: PETSC_EXTERN PetscFunctionList VecList;
    317: PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType);
    318: PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*);
    319: PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec));

    321: PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
    322: PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
    323: PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*);
    324: PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter);
    325: PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
    326: PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
    327: PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]);
    328: PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]);
    329: PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*);

    331: PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    332: PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    333: PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    334: PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    335: PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    336: PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    337: PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);
    338: PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);

    340: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    341: PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    342: PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    343: PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    344: PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    345: PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    346: PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    347: PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);
    348: PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);

    350: PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    351: PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
    352: PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    353: PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
    354: PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    355: PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
    356: PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);
    357: PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);

    359: PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
    360: PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
    361: PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);

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

    366: PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer);
    367: PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*);
    368: PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer);

    370: PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
    371: PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
    372: PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
    373: PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]);

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

    378: PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**);
    379: PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**);

    381: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**);
    382: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**);

    384: PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**);
    385: PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**);

    387: PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]);
    388: PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]);
    389: PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec);

    391: PETSC_EXTERN PetscErrorCode VecHIPGetArray(Vec,PetscScalar**);
    392: PETSC_EXTERN PetscErrorCode VecHIPRestoreArray(Vec,PetscScalar**);

    394: PETSC_EXTERN PetscErrorCode VecHIPGetArrayRead(Vec,const PetscScalar**);
    395: PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayRead(Vec,const PetscScalar**);

    397: PETSC_EXTERN PetscErrorCode VecHIPGetArrayWrite(Vec,PetscScalar**);
    398: PETSC_EXTERN PetscErrorCode VecHIPRestoreArrayWrite(Vec,PetscScalar**);

    400: PETSC_EXTERN PetscErrorCode VecHIPPlaceArray(Vec,const PetscScalar[]);
    401: PETSC_EXTERN PetscErrorCode VecHIPReplaceArray(Vec,const PetscScalar[]);
    402: PETSC_EXTERN PetscErrorCode VecHIPResetArray(Vec);

    404: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*);
    405: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*);
    406: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*);
    407: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*);
    408: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec);
    409: PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*);
    410: PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec);

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

    415:    Synopsis:
    416: #include <petscvec.h>
    417:    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

    419:    Not Collective

    421:    Input Parameters:
    422: +  v - the vector
    423: .  row - the row location of the entry
    424: .  value - the value to insert
    425: -  mode - either INSERT_VALUES or ADD_VALUES

    427:    Notes:
    428:    For efficiency one should use VecSetValues() and set several or
    429:    many values simultaneously if possible.

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

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

    436:    Level: beginner

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

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

    445: PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
    446: PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
    447: PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
    448: PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
    449: PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
    450: PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);

    452: PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
    453: PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
    454: PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
    455: PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
    456: PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);

    458: PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool);
    459: PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") PETSC_STATIC_INLINE PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);}
    460: PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t);
    461: PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *);

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

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

    473:    Level: developer
    474: E*/
    475: typedef enum {PETSC_OFFLOAD_UNALLOCATED=0x0,PETSC_OFFLOAD_CPU=0x1,PETSC_OFFLOAD_GPU=0x2,PETSC_OFFLOAD_BOTH=0x3,PETSC_OFFLOAD_VECKOKKOS=0x100} PetscOffloadMask;
    476: PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec,PetscOffloadMask *);

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

    481: PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**);
    482: PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**);
    483: PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**);
    484: PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**);
    485: PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**);
    486: PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**);
    487: PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec);
    488: PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec);
    489: PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec);
    490: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec);
    491: PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec,PetscScalar**,PetscMemType*);
    492: PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec,PetscScalar**);
    493: PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec,const PetscScalar**,PetscMemType*);
    494: PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec,const PetscScalar**);

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

    499:    Logically Collective on x

    501:    Input Parameters:
    502: +  x - the vector
    503: -  y - the second vector

    505:    Output Parameters:
    506: +  xv - location to put pointer to the first array
    507: -  yv - location to put pointer to the second array

    509:    Level: developer

    511:    Not available from Fortran

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

    515: @*/
    516: PETSC_STATIC_INLINE PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
    517: {

    521:   VecGetArray(y,yv);
    522:   if (x != y) {
    523:     VecGetArrayRead(x,(const PetscScalar **)xv);
    524:   } else {
    525:     *xv = *yv;
    526:   }
    527:   return(0);
    528: }

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

    533:    Logically Collective on x

    535:    Input Parameters:
    536: +  x - the vector
    537: -  y - the second vector

    539:    Output Parameters:
    540: +  xv - location to put pointer to the first array
    541: -  yv - location to put pointer to the second array

    543:    Level: developer

    545:    Not available from Fortran

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

    549: @*/
    550: PETSC_STATIC_INLINE PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
    551: {

    555:   VecRestoreArray(y,yv);
    556:   if (x != y) {
    557:     VecRestoreArrayRead(x,(const PetscScalar **)xv);
    558:   }
    559:   return(0);
    560: }

    562: #if defined(PETSC_USE_DEBUG)
    563: PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec);
    564: PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec);
    565: /* We also have a non-public VecLockWriteSet_Private() in vecimpl.h */
    566: PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*);
    567: PETSC_STATIC_INLINE PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg)
    568: {
    569:   PetscInt       state;

    573:   VecLockGet(x,&state);
    574:   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);
    575:   return(0);
    576: }
    577: /* The three are deprecated */
    578: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec);
    579: PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)")  PetscErrorCode VecLockPop(Vec);
    580: #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"")
    581: #else
    582: #define VecLockReadPush(x)           0
    583: #define VecLockReadPop(x)            0
    584: #define VecLockGet(x,s)              *(s) = 0
    585: #define VecSetErrorIfLocked(x,arg)   0
    586: /* The three are deprecated */
    587: #define VecLockPush(x)               0
    588: #define VecLockPop(x)                0
    589: #define VecLocked(x,arg)             0
    590: #endif

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

    594: /*
    595:     These numbers need to match the entries in
    596:   the function table in vecimpl.h
    597: */
    598: typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation;
    599: PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));

    601: /*
    602:      Routines for dealing with ghosted vectors:
    603:   vectors with ghost elements at the end of the array.
    604: */
    605: PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]);
    606: PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
    607: PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
    608: PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
    609: PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
    610: PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
    611: PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
    612: PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*);
    613: PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
    614: PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);

    616: PETSC_EXTERN PetscErrorCode VecConjugate(Vec);
    617: PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec);
    618: PETSC_EXTERN PetscErrorCode VecRealPart(Vec);

    620: PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
    621: PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);

    623: PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*);
    624: PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
    625: PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
    626: PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *);
    627: PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
    628: PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
    629: PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *);
    630: PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
    631: PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
    632: PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec);
    633: PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec);
    634: PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar);
    635: PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
    636: PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*);
    637: PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
    638: PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*);

    640: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
    641: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);

    643: /*S
    644:      Vecs - Collection of vectors where the data for the vectors is stored in
    645:             one contiguous memory

    647:    Level: advanced

    649:    Notes:
    650:     Temporary construct for handling multiply right hand side solves

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

    655: S*/
    656:         struct _n_Vecs  {PetscInt n; Vec v;};
    657: typedef struct _n_Vecs* Vecs;
    658: PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
    659: PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*);
    660: PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*);
    661: PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*);

    663: #if defined(PETSC_HAVE_VIENNACL)
    664: typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices;
    665: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*);
    666: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*);
    667: PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices);
    668: PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices);
    669: PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*);
    670: PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*);
    671: #endif
    672: #if defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_HIP)
    673: PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec);
    674: PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
    675: #endif
    676: #if defined(PETSC_HAVE_CUDA)
    677: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*);
    678: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
    679: PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
    680: PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*);
    681: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
    682: PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
    683: #endif
    684: #if defined(PETSC_HAVE_HIP)
    685: PETSC_EXTERN PetscErrorCode VecCreateSeqHIP(MPI_Comm,PetscInt,Vec*);
    686: PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
    687: PETSC_EXTERN PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
    688: PETSC_EXTERN PetscErrorCode VecCreateMPIHIP(MPI_Comm,PetscInt,PetscInt,Vec*);
    689: PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
    690: PETSC_EXTERN PetscErrorCode VecCreateMPIHIPWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
    691: #endif

    693: PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**);
    694: PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*);
    695: PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*);
    696: PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec);
    697: PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*);
    698: PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*);

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

    703: PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*);
    704: PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout);

    706: PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
    707: PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
    708: PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode);
    709: PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []);

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

    716:   Level: advanced
    717: S*/
    718: typedef struct _p_VecTagger *VecTagger;

    720: /*J
    721:   VecTaggerType - String with the name of a VecTagger type

    723:   Level: advanced
    724: J*/
    725: typedef const char* VecTaggerType;
    726: /* tag where the vector values are in a box of explicitly defined values */
    727: #define VECTAGGERABSOLUTE   "absolute"
    728: /* tag where the vector values are in a box of values relative to the set of all values in the vector */
    729: #define VECTAGGERRELATIVE   "relative"
    730: /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */
    731: #define VECTAGGERCDF        "cdf"
    732: /* tag a vector as the union of other tags */
    733: #define VECTAGGEROR         "or"
    734: /* tag a vector as the intersection of other tags */
    735: #define VECTAGGERAND        "and"

    737: PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID;
    738: PETSC_EXTERN PetscFunctionList VecTaggerList;
    739: PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger));

    741: PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *);
    742: PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt);
    743: PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*);
    744: PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType);
    745: PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *);
    746: PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool);
    747: PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*);
    748: PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger);
    749: PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger);
    750: PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer);
    751: PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *);
    752: PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *);

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

    758:    Level: beginner

    760: .seealso: VecTaggerComputeIntervals()
    761: S*/
    762: typedef struct {
    763:   PetscScalar min;
    764:   PetscScalar max;
    765: } VecTaggerBox;
    766: PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **);

    769: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *);
    770: PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **);

    772: PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *);
    773: PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **);

    775: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *);
    776: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **);

    778: /*E
    779:   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.

    781:   Level: advanced
    782: .seealso: VecTaggerCDFSetMethod(), VecTaggerCDFMethods
    783: E*/
    784: typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod;
    785: PETSC_EXTERN const char *const VecTaggerCDFMethods[];

    787: PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod);
    788: PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*);
    789: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal);
    790: PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*);

    792: PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
    793: PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**);

    795: PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
    796: PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**);

    798: PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void);
    799: PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void);

    801: #endif