Actual source code: vecimpl.h
petsc-3.9.4 2018-09-11
2: /*
3: This private file should not be included in users' code.
4: Defines the fields shared by all vector implementations.
6: */
8: #ifndef __VECIMPL_H
11: #include <petscvec.h>
12: #include <petsc/private/petscimpl.h>
13: #include <petscviewer.h>
15: PETSC_EXTERN PetscBool VecRegisterAllCalled;
16: PETSC_EXTERN PetscErrorCode VecRegisterAll(void);
18: PETSC_EXTERN PetscBool VecScatterRegisterAllCalled;
19: PETSC_EXTERN PetscErrorCode VecScatterRegisterAll(void);
21: /* ----------------------------------------------------------------------------*/
23: typedef struct _VecOps *VecOps;
24: struct _VecOps {
25: PetscErrorCode (*duplicate)(Vec,Vec*); /* get single vector */
26: PetscErrorCode (*duplicatevecs)(Vec,PetscInt,Vec**); /* get array of vectors */
27: PetscErrorCode (*destroyvecs)(PetscInt,Vec[]); /* free array of vectors */
28: PetscErrorCode (*dot)(Vec,Vec,PetscScalar*); /* z = x^H * y */
29: PetscErrorCode (*mdot)(Vec,PetscInt,const Vec[],PetscScalar*); /* z[j] = x dot y[j] */
30: PetscErrorCode (*norm)(Vec,NormType,PetscReal*); /* z = sqrt(x^H * x) */
31: PetscErrorCode (*tdot)(Vec,Vec,PetscScalar*); /* x'*y */
32: PetscErrorCode (*mtdot)(Vec,PetscInt,const Vec[],PetscScalar*);/* z[j] = x dot y[j] */
33: PetscErrorCode (*scale)(Vec,PetscScalar); /* x = alpha * x */
34: PetscErrorCode (*copy)(Vec,Vec); /* y = x */
35: PetscErrorCode (*set)(Vec,PetscScalar); /* y = alpha */
36: PetscErrorCode (*swap)(Vec,Vec); /* exchange x and y */
37: PetscErrorCode (*axpy)(Vec,PetscScalar,Vec); /* y = y + alpha * x */
38: PetscErrorCode (*axpby)(Vec,PetscScalar,PetscScalar,Vec); /* y = alpha * x + beta * y*/
39: PetscErrorCode (*maxpy)(Vec,PetscInt,const PetscScalar*,Vec*); /* y = y + alpha[j] x[j] */
40: PetscErrorCode (*aypx)(Vec,PetscScalar,Vec); /* y = x + alpha * y */
41: PetscErrorCode (*waxpy)(Vec,PetscScalar,Vec,Vec); /* w = y + alpha * x */
42: PetscErrorCode (*axpbypcz)(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec); /* z = alpha * x + beta *y + gamma *z*/
43: PetscErrorCode (*pointwisemult)(Vec,Vec,Vec); /* w = x .* y */
44: PetscErrorCode (*pointwisedivide)(Vec,Vec,Vec); /* w = x ./ y */
45: PetscErrorCode (*setvalues)(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
46: PetscErrorCode (*assemblybegin)(Vec); /* start global assembly */
47: PetscErrorCode (*assemblyend)(Vec); /* end global assembly */
48: PetscErrorCode (*getarray)(Vec,PetscScalar**); /* get data array */
49: PetscErrorCode (*getsize)(Vec,PetscInt*);
50: PetscErrorCode (*getlocalsize)(Vec,PetscInt*);
51: PetscErrorCode (*restorearray)(Vec,PetscScalar**); /* restore data array */
52: PetscErrorCode (*max)(Vec,PetscInt*,PetscReal*); /* z = max(x); idx=index of max(x) */
53: PetscErrorCode (*min)(Vec,PetscInt*,PetscReal*); /* z = min(x); idx=index of min(x) */
54: PetscErrorCode (*setrandom)(Vec,PetscRandom); /* set y[j] = random numbers */
55: PetscErrorCode (*setoption)(Vec,VecOption,PetscBool );
56: PetscErrorCode (*setvaluesblocked)(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
57: PetscErrorCode (*destroy)(Vec);
58: PetscErrorCode (*view)(Vec,PetscViewer);
59: PetscErrorCode (*placearray)(Vec,const PetscScalar*); /* place data array */
60: PetscErrorCode (*replacearray)(Vec,const PetscScalar*); /* replace data array */
61: PetscErrorCode (*dot_local)(Vec,Vec,PetscScalar*);
62: PetscErrorCode (*tdot_local)(Vec,Vec,PetscScalar*);
63: PetscErrorCode (*norm_local)(Vec,NormType,PetscReal*);
64: PetscErrorCode (*mdot_local)(Vec,PetscInt,const Vec[],PetscScalar*);
65: PetscErrorCode (*mtdot_local)(Vec,PetscInt,const Vec[],PetscScalar*);
66: PetscErrorCode (*load)(Vec,PetscViewer);
67: PetscErrorCode (*reciprocal)(Vec);
68: PetscErrorCode (*conjugate)(Vec);
69: PetscErrorCode (*setlocaltoglobalmapping)(Vec,ISLocalToGlobalMapping);
70: PetscErrorCode (*setvalueslocal)(Vec,PetscInt,const PetscInt *,const PetscScalar *,InsertMode);
71: PetscErrorCode (*resetarray)(Vec); /* vector points to its original array, i.e. undoes any VecPlaceArray() */
72: PetscErrorCode (*setfromoptions)(PetscOptionItems*,Vec);
73: PetscErrorCode (*maxpointwisedivide)(Vec,Vec,PetscReal*); /* m = max abs(x ./ y) */
74: PetscErrorCode (*pointwisemax)(Vec,Vec,Vec);
75: PetscErrorCode (*pointwisemaxabs)(Vec,Vec,Vec);
76: PetscErrorCode (*pointwisemin)(Vec,Vec,Vec);
77: PetscErrorCode (*getvalues)(Vec,PetscInt,const PetscInt[],PetscScalar[]);
78: PetscErrorCode (*sqrt)(Vec);
79: PetscErrorCode (*abs)(Vec);
80: PetscErrorCode (*exp)(Vec);
81: PetscErrorCode (*log)(Vec);
82: PetscErrorCode (*shift)(Vec,PetscScalar);
83: PetscErrorCode (*create)(Vec);
84: PetscErrorCode (*stridegather)(Vec,PetscInt,Vec,InsertMode);
85: PetscErrorCode (*stridescatter)(Vec,PetscInt,Vec,InsertMode);
86: PetscErrorCode (*dotnorm2)(Vec,Vec,PetscScalar*,PetscScalar*);
87: PetscErrorCode (*getsubvector)(Vec,IS,Vec*);
88: PetscErrorCode (*restoresubvector)(Vec,IS,Vec*);
89: PetscErrorCode (*getarrayread)(Vec,const PetscScalar**);
90: PetscErrorCode (*restorearrayread)(Vec,const PetscScalar**);
91: PetscErrorCode (*stridesubsetgather)(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
92: PetscErrorCode (*stridesubsetscatter)(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
93: PetscErrorCode (*viewnative)(Vec,PetscViewer);
94: PetscErrorCode (*loadnative)(Vec,PetscViewer);
95: PetscErrorCode (*getlocalvector)(Vec,Vec);
96: PetscErrorCode (*restorelocalvector)(Vec,Vec);
97: PetscErrorCode (*getlocalvectorread)(Vec,Vec);
98: PetscErrorCode (*restorelocalvectorread)(Vec,Vec);
99: };
101: /*
102: The stash is used to temporarily store inserted vec values that
103: belong to another processor. During the assembly phase the stashed
104: values are moved to the correct processor and
105: */
107: typedef struct {
108: PetscInt nmax; /* maximum stash size */
109: PetscInt umax; /* max stash size user wants */
110: PetscInt oldnmax; /* the nmax value used previously */
111: PetscInt n; /* stash size */
112: PetscInt bs; /* block size of the stash */
113: PetscInt reallocs; /* preserve the no of mallocs invoked */
114: PetscInt *idx; /* global row numbers in stash */
115: PetscScalar *array; /* array to hold stashed values */
116: /* The following variables are used for communication */
117: MPI_Comm comm;
118: PetscMPIInt size,rank;
119: PetscMPIInt tag1,tag2;
120: MPI_Request *send_waits; /* array of send requests */
121: MPI_Request *recv_waits; /* array of receive requests */
122: MPI_Status *send_status; /* array of send status */
123: PetscInt nsends,nrecvs; /* numbers of sends and receives */
124: PetscScalar *svalues,*rvalues; /* sending and receiving data */
125: PetscInt *sindices,*rindices;
126: PetscInt rmax; /* maximum message length */
127: PetscInt *nprocs; /* tmp data used both during scatterbegin and end */
128: PetscInt nprocessed; /* number of messages already processed */
129: PetscBool donotstash;
130: PetscBool ignorenegidx; /* ignore negative indices passed into VecSetValues/VetGetValues */
131: InsertMode insertmode;
132: PetscInt *bowners;
133: } VecStash;
135: struct _p_Vec {
136: PETSCHEADER(struct _VecOps);
137: PetscLayout map;
138: void *data; /* implementation-specific data */
139: PetscBool array_gotten;
140: VecStash stash,bstash; /* used for storing off-proc values during assembly */
141: PetscBool petscnative; /* means the ->data starts with VECHEADER and can use VecGetArrayFast()*/
142: PetscInt lock; /* vector is locked to read only */
143: #if defined(PETSC_HAVE_VIENNACL) || defined(PETSC_HAVE_VECCUDA)
144: PetscOffloadFlag valid_GPU_array; /* indicates where the most recently modified vector data is (GPU or CPU) */
145: void *spptr; /* this is the special pointer to the array on the GPU */
146: #endif
147: };
149: PETSC_EXTERN PetscLogEvent VEC_SetRandom;
150: PETSC_EXTERN PetscLogEvent VEC_View;
151: PETSC_EXTERN PetscLogEvent VEC_Max;
152: PETSC_EXTERN PetscLogEvent VEC_Min;
153: PETSC_EXTERN PetscLogEvent VEC_DotBarrier;
154: PETSC_EXTERN PetscLogEvent VEC_Dot;
155: PETSC_EXTERN PetscLogEvent VEC_MDotBarrier;
156: PETSC_EXTERN PetscLogEvent VEC_MDot;
157: PETSC_EXTERN PetscLogEvent VEC_TDot;
158: PETSC_EXTERN PetscLogEvent VEC_MTDot;
159: PETSC_EXTERN PetscLogEvent VEC_Norm;
160: PETSC_EXTERN PetscLogEvent VEC_Normalize;
161: PETSC_EXTERN PetscLogEvent VEC_Scale;
162: PETSC_EXTERN PetscLogEvent VEC_Copy;
163: PETSC_EXTERN PetscLogEvent VEC_Set;
164: PETSC_EXTERN PetscLogEvent VEC_AXPY;
165: PETSC_EXTERN PetscLogEvent VEC_AYPX;
166: PETSC_EXTERN PetscLogEvent VEC_WAXPY;
167: PETSC_EXTERN PetscLogEvent VEC_MAXPY;
168: PETSC_EXTERN PetscLogEvent VEC_AssemblyEnd;
169: PETSC_EXTERN PetscLogEvent VEC_PointwiseMult;
170: PETSC_EXTERN PetscLogEvent VEC_SetValues;
171: PETSC_EXTERN PetscLogEvent VEC_Load;
172: PETSC_EXTERN PetscLogEvent VEC_ScatterBarrier;
173: PETSC_EXTERN PetscLogEvent VEC_ScatterBegin;
174: PETSC_EXTERN PetscLogEvent VEC_ScatterEnd;
175: PETSC_EXTERN PetscLogEvent VEC_ReduceArithmetic;
176: PETSC_EXTERN PetscLogEvent VEC_ReduceBarrier;
177: PETSC_EXTERN PetscLogEvent VEC_ReduceCommunication;
178: PETSC_EXTERN PetscLogEvent VEC_ReduceBegin;
179: PETSC_EXTERN PetscLogEvent VEC_ReduceEnd;
180: PETSC_EXTERN PetscLogEvent VEC_Swap;
181: PETSC_EXTERN PetscLogEvent VEC_AssemblyBegin;
182: PETSC_EXTERN PetscLogEvent VEC_NormBarrier;
183: PETSC_EXTERN PetscLogEvent VEC_DotNormBarrier;
184: PETSC_EXTERN PetscLogEvent VEC_DotNorm;
185: PETSC_EXTERN PetscLogEvent VEC_AXPBYPCZ;
186: PETSC_EXTERN PetscLogEvent VEC_Ops;
187: PETSC_EXTERN PetscLogEvent VEC_ViennaCLCopyToGPU;
188: PETSC_EXTERN PetscLogEvent VEC_ViennaCLCopyFromGPU;
189: PETSC_EXTERN PetscLogEvent VEC_CUDACopyToGPU;
190: PETSC_EXTERN PetscLogEvent VEC_CUDACopyFromGPU;
191: PETSC_EXTERN PetscLogEvent VEC_CUDACopyToGPUSome;
192: PETSC_EXTERN PetscLogEvent VEC_CUDACopyFromGPUSome;
194: PETSC_EXTERN PetscErrorCode VecView_Seq(Vec,PetscViewer);
195: #if defined(PETSC_HAVE_VIENNACL)
196: PETSC_EXTERN PetscErrorCode VecViennaCLAllocateCheckHost(Vec v);
197: PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPU(Vec v);
198: #endif
199: #if defined(PETSC_HAVE_VECCUDA)
200: PETSC_EXTERN PetscErrorCode VecCUDAAllocateCheckHost(Vec v);
201: PETSC_EXTERN PetscErrorCode VecCUDACopyFromGPU(Vec v);
202: #endif
205: /*
206: Common header shared by array based vectors,
207: currently Vec_Seq and Vec_MPI
208: */
209: #define VECHEADER \
210: PetscScalar *array; \
211: PetscScalar *array_allocated; /* if the array was allocated by PETSc this is its pointer */ \
212: PetscScalar *unplacedarray; /* if one called VecPlaceArray(), this is where it stashed the original */
214: /* Default obtain and release vectors; can be used by any implementation */
215: PETSC_EXTERN PetscErrorCode VecDuplicateVecs_Default(Vec,PetscInt,Vec *[]);
216: PETSC_EXTERN PetscErrorCode VecDestroyVecs_Default(PetscInt,Vec []);
217: PETSC_INTERN PetscErrorCode VecLoad_Binary(Vec, PetscViewer);
218: PETSC_EXTERN PetscErrorCode VecLoad_Default(Vec, PetscViewer);
220: PETSC_EXTERN PetscInt NormIds[7]; /* map from NormType to IDs used to cache/retreive values of norms */
222: /* --------------------------------------------------------------------*/
223: /* */
224: /* Defines the data structures used in the Vec Scatter operations */
226: typedef enum { VEC_SCATTER_SEQ_GENERAL,VEC_SCATTER_SEQ_STRIDE,
227: VEC_SCATTER_MPI_GENERAL,VEC_SCATTER_MPI_TOALL,
228: VEC_SCATTER_MPI_TOONE} VecScatterFormat;
230: #define VECSCATTER_IMPL_HEADER \
231: VecScatterFormat format;
233: typedef struct {
234: VECSCATTER_IMPL_HEADER
235: } VecScatter_Common;
237: /*
238: These scatters are for the purely local case.
239: */
240: typedef struct {
241: VECSCATTER_IMPL_HEADER
242: PetscInt n; /* number of components to scatter */
243: PetscInt *vslots; /* locations of components */
244: /*
245: The next three fields are used in parallel scatters, they contain
246: optimization in the special case that the "to" vector and the "from"
247: vector are the same, so one only needs copy components that truly
248: copies instead of just y[idx[i]] = y[jdx[i]] where idx[i] == jdx[i].
249: */
250: PetscBool nonmatching_computed;
251: PetscInt n_nonmatching; /* number of "from"s != "to"s */
252: PetscInt *slots_nonmatching; /* locations of "from"s != "to"s */
253: PetscBool is_copy;
254: PetscInt copy_start; /* local scatter is a copy starting at copy_start */
255: PetscInt copy_length;
256: } VecScatter_Seq_General;
258: typedef struct {
259: VECSCATTER_IMPL_HEADER
260: PetscInt n;
261: PetscInt first;
262: PetscInt step;
263: } VecScatter_Seq_Stride;
265: /*
266: This scatter is for a global vector copied (completely) to each processor (or all to one)
267: */
268: typedef struct {
269: VECSCATTER_IMPL_HEADER
270: PetscMPIInt *count; /* elements of vector on each processor */
271: PetscMPIInt *displx;
272: PetscScalar *work1;
273: PetscScalar *work2;
274: } VecScatter_MPI_ToAll;
276: /*
277: This is the general parallel scatter
278: */
279: typedef struct {
280: VECSCATTER_IMPL_HEADER
281: PetscInt n; /* number of processors to send/receive */
282: PetscInt *starts; /* starting point in indices and values for each proc*/
283: PetscInt *indices; /* list of all components sent or received */
284: PetscMPIInt *procs; /* processors we are communicating with in scatter */
285: MPI_Request *requests,*rev_requests;
286: PetscScalar *values; /* buffer for all sends or receives */
287: VecScatter_Seq_General local; /* any part that happens to be local */
288: MPI_Status *sstatus,*rstatus;
289: PetscBool use_readyreceiver;
290: PetscInt bs;
291: PetscBool sendfirst;
292: PetscBool contiq;
293: /* for MPI_Alltoallv() approach */
294: PetscBool use_alltoallv;
295: PetscMPIInt *counts,*displs;
296: /* for MPI_Alltoallw() approach */
297: PetscBool use_alltoallw;
298: #if defined(PETSC_HAVE_MPI_ALLTOALLW)
299: PetscMPIInt *wcounts,*wdispls;
300: MPI_Datatype *types;
301: #endif
302: PetscBool use_window; /* these uses windows for communication across all MPI processes */
303: #if defined(PETSC_HAVE_MPI_WIN_CREATE_FEATURE)
304: MPI_Win window;
305: PetscInt *winstarts; /* displacements in the processes I am putting to */
306: #endif
307: #if defined(PETSC_HAVE_MPI_WIN_CREATE_FEATURE) /* these uses windows for communication only within each node */
308: PetscMPIInt msize,sharedcnt; /* total to entries that are going to processes with the same shared memory space */
309: PetscScalar *sharedspace; /* space each process puts data to be read from other processes; allocated by MPI */
310: PetscScalar **sharedspaces; /* [msize] space other processes put data to be read from this processes. */
311: PetscInt *sharedspacesoffset; /* [msize] offset into sharedspaces, that I will read from */
312: PetscInt *sharedspacestarts; /* [msize+1] for each shared memory partner this maps to the part of sharedspaceindices of that partner */
313: PetscInt *sharedspaceindices; /* [] for each shared memory partner contains indices where values are to be copied to */
314: MPI_Win sharedwin; /* Window that owns sharedspace */
315: PetscInt notdone; /* used by VecScatterEndMPI3Node() */
316: #endif
317: } VecScatter_MPI_General;
320: PETSC_INTERN PetscErrorCode VecScatterGetTypes_Private(VecScatter,VecScatterFormat*,VecScatterFormat*);
321: PETSC_INTERN PetscErrorCode VecScatterIsSequential_Private(VecScatter_Common*,PetscBool*);
323: typedef struct _VecScatterOps *VecScatterOps;
324: struct _VecScatterOps {
325: PetscErrorCode (*begin)(VecScatter,Vec,Vec,InsertMode,ScatterMode);
326: PetscErrorCode (*end)(VecScatter,Vec,Vec,InsertMode,ScatterMode);
327: PetscErrorCode (*copy)(VecScatter,VecScatter);
328: PetscErrorCode (*destroy)(VecScatter);
329: PetscErrorCode (*view)(VecScatter,PetscViewer);
330: PetscErrorCode (*viewfromoptions)(VecScatter,const char prefix[],const char name[]);
331: PetscErrorCode (*remap)(VecScatter,PetscInt *,PetscInt*);
332: PetscErrorCode (*getmerged)(VecScatter,PetscBool *);
333: };
335: struct _p_VecScatter {
336: PETSCHEADER(struct _VecScatterOps);
337: PetscInt to_n,from_n;
338: PetscBool inuse; /* prevents corruption from mixing two scatters */
339: PetscBool beginandendtogether; /* indicates that the scatter begin and end function are called together, VecScatterEnd()
340: is then treated as a nop */
341: PetscBool packtogether; /* packs all the messages before sending, same with receive */
342: PetscBool reproduce; /* always receive the ghost points in the same order of processes */
343: void *fromdata,*todata;
344: void *spptr;
345: PetscBool is_duplicate; /* IS has duplicate indices, would cause writing error in the case StoP of VecScatterEndMPI3Node */
346: Vec to_v,from_v; /* used in VecScatterCreate() */
347: IS to_is,from_is; /* used in VecScatterCreate() */
348: };
350: PETSC_INTERN PetscErrorCode VecScatterCreate_Seq(VecScatter);
351: PETSC_INTERN PetscErrorCode VecScatterCreate_MPI1(VecScatter);
352: PETSC_INTERN PetscErrorCode VecScatterCreate_MPI3(VecScatter);
353: PETSC_INTERN PetscErrorCode VecScatterCreate_MPI3Node(VecScatter);
355: PETSC_INTERN PetscErrorCode VecStashCreate_Private(MPI_Comm,PetscInt,VecStash*);
356: PETSC_INTERN PetscErrorCode VecStashDestroy_Private(VecStash*);
357: PETSC_EXTERN PetscErrorCode VecStashExpand_Private(VecStash*,PetscInt);
358: PETSC_INTERN PetscErrorCode VecStashScatterEnd_Private(VecStash*);
359: PETSC_INTERN PetscErrorCode VecStashSetInitialSize_Private(VecStash*,PetscInt);
360: PETSC_INTERN PetscErrorCode VecStashGetInfo_Private(VecStash*,PetscInt*,PetscInt*);
361: PETSC_INTERN PetscErrorCode VecStashScatterBegin_Private(VecStash*,PetscInt*);
362: PETSC_INTERN PetscErrorCode VecStashScatterGetMesg_Private(VecStash*,PetscMPIInt*,PetscInt**,PetscScalar**,PetscInt*);
363: PETSC_INTERN PetscErrorCode VecStashSortCompress_Private(VecStash*);
364: PETSC_INTERN PetscErrorCode VecStashGetOwnerList_Private(VecStash*,PetscLayout,PetscMPIInt*,PetscMPIInt**);
366: /*
367: VecStashValue_Private - inserts a single value into the stash.
369: Input Parameters:
370: stash - the stash
371: idx - the global of the inserted value
372: values - the value inserted
373: */
374: PETSC_STATIC_INLINE PetscErrorCode VecStashValue_Private(VecStash *stash,PetscInt row,PetscScalar value)
375: {
377: /* Check and see if we have sufficient memory */
378: if (((stash)->n + 1) > (stash)->nmax) {
379: VecStashExpand_Private(stash,1);
380: }
381: (stash)->idx[(stash)->n] = row;
382: (stash)->array[(stash)->n] = value;
383: (stash)->n++;
384: return 0;
385: }
387: /*
388: VecStashValuesBlocked_Private - inserts 1 block of values into the stash.
390: Input Parameters:
391: stash - the stash
392: idx - the global block index
393: values - the values inserted
394: */
395: PETSC_STATIC_INLINE PetscErrorCode VecStashValuesBlocked_Private(VecStash *stash,PetscInt row,PetscScalar *values)
396: {
397: PetscInt jj,stash_bs=(stash)->bs;
398: PetscScalar *array;
400: if (((stash)->n+1) > (stash)->nmax) {
401: VecStashExpand_Private(stash,1);
402: }
403: array = (stash)->array + stash_bs*(stash)->n;
404: (stash)->idx[(stash)->n] = row;
405: for (jj=0; jj<stash_bs; jj++) { array[jj] = values[jj];}
406: (stash)->n++;
407: return 0;
408: }
410: PETSC_INTERN PetscErrorCode VecStrideGather_Default(Vec,PetscInt,Vec,InsertMode);
411: PETSC_INTERN PetscErrorCode VecStrideScatter_Default(Vec,PetscInt,Vec,InsertMode);
412: PETSC_INTERN PetscErrorCode VecReciprocal_Default(Vec);
413: PETSC_INTERN PetscErrorCode VecStrideSubSetGather_Default(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
414: PETSC_INTERN PetscErrorCode VecStrideSubSetScatter_Default(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
416: #if defined(PETSC_HAVE_MATLAB_ENGINE)
417: PETSC_EXTERN PetscErrorCode VecMatlabEnginePut_Default(PetscObject,void*);
418: PETSC_EXTERN PetscErrorCode VecMatlabEngineGet_Default(PetscObject,void*);
419: #endif
421: PETSC_EXTERN PetscErrorCode PetscSectionGetField_Internal(PetscSection, PetscSection, Vec, PetscInt, PetscInt, PetscInt, IS *, Vec *);
422: PETSC_EXTERN PetscErrorCode PetscSectionRestoreField_Internal(PetscSection, PetscSection, Vec, PetscInt, PetscInt, PetscInt, IS *, Vec *);
424: #define VecCheckSameLocalSize(x,ar1,y,ar2) \
425: if ((x)->map->n != (y)->map->n) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incompatible vector local lengths parameter # %d local size %D != parameter # %d local size %D", ar1,(x)->map->n, ar2,(y)->map->n);
427: #define VecCheckSameSize(x,ar1,y,ar2) \
428: if ((x)->map->N != (y)->map->N) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incompatible vector global lengths parameter # %d %D != paramter # %d %D", ar1,(x)->map->N, ar2,(y)->map->N); \
429: if ((x)->map->n != (y)->map->n) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Incompatible vector local lengths parameter # %d %D != parameter # %d %D", ar1,(x)->map->n, ar2,(y)->map->n);
431: typedef struct _VecTaggerOps *VecTaggerOps;
432: struct _VecTaggerOps {
433: PetscErrorCode (*create) (VecTagger);
434: PetscErrorCode (*destroy) (VecTagger);
435: PetscErrorCode (*setfromoptions) (PetscOptionItems*,VecTagger);
436: PetscErrorCode (*setup) (VecTagger);
437: PetscErrorCode (*view) (VecTagger,PetscViewer);
438: PetscErrorCode (*computeboxes) (VecTagger,Vec,PetscInt *,VecTaggerBox **);
439: PetscErrorCode (*computeis) (VecTagger,Vec,IS *);
440: };
441: struct _p_VecTagger {
442: PETSCHEADER(struct _VecTaggerOps);
443: void *data;
444: PetscInt blocksize;
445: PetscBool invert;
446: PetscBool setupcalled;
447: };
449: PETSC_EXTERN PetscBool VecTaggerRegisterAllCalled;
450: PETSC_EXTERN PetscErrorCode VecTaggerRegisterAll(void);
451: PETSC_EXTERN PetscErrorCode VecTaggerComputeIS_FromBoxes(VecTagger,Vec,IS*);
452: PETSC_EXTERN PetscMPIInt Petsc_Reduction_keyval;
454: #endif