1af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
233879625SMatthew G. Knepley
3552f7358SJed Brown /*@
4a1cb98faSBarry Smith DMPlexGetPointLocal - get location of point data in local `Vec`
5552f7358SJed Brown
6552f7358SJed Brown Not Collective
7552f7358SJed Brown
84165533cSJose E. Roman Input Parameters:
9a1cb98faSBarry Smith + dm - `DM` defining the topological space
10552f7358SJed Brown - point - topological point
11552f7358SJed Brown
124165533cSJose E. Roman Output Parameters:
13552f7358SJed Brown + start - start of point data
14552f7358SJed Brown - end - end of point data
15552f7358SJed Brown
16552f7358SJed Brown Level: intermediate
17552f7358SJed Brown
18a1cb98faSBarry Smith Note:
19a1cb98faSBarry Smith This is a half open interval [start, end)
20a1cb98faSBarry Smith
2160225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointLocalField()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointLocalRead()`, `DMPlexPointLocalRef()`
22552f7358SJed Brown @*/
DMPlexGetPointLocal(DM dm,PetscInt point,PetscInt * start,PetscInt * end)23d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointLocal(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
24d71ae5a4SJacob Faibussowitsch {
25a89cf0ddSMatthew G. Knepley PetscInt s, e;
26552f7358SJed Brown
27552f7358SJed Brown PetscFunctionBegin;
28552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
294f572ea9SToby Isaac if (start) PetscAssertPointer(start, 3);
304f572ea9SToby Isaac if (end) PetscAssertPointer(end, 4);
319566063dSJacob Faibussowitsch PetscCall(DMGetLocalOffset_Private(dm, point, &s, &e));
32a89cf0ddSMatthew G. Knepley if (start) *start = s;
33a89cf0ddSMatthew G. Knepley if (end) *end = e;
343ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
35552f7358SJed Brown }
36552f7358SJed Brown
37552f7358SJed Brown /*@
38552f7358SJed Brown DMPlexPointLocalRead - return read access to a point in local array
39552f7358SJed Brown
40552f7358SJed Brown Not Collective
41552f7358SJed Brown
424165533cSJose E. Roman Input Parameters:
43a1cb98faSBarry Smith + dm - `DM` defining topological space
44552f7358SJed Brown . point - topological point
45552f7358SJed Brown - array - array to index into
46552f7358SJed Brown
474165533cSJose E. Roman Output Parameter:
48552f7358SJed Brown . ptr - address of read reference to point data, type generic so user can place in structure
49552f7358SJed Brown
50552f7358SJed Brown Level: intermediate
51552f7358SJed Brown
52552f7358SJed Brown Note:
53*a4e35b19SJacob Faibussowitsch A common usage when data sizes are known statically\:
54a1cb98faSBarry Smith .vb
55a1cb98faSBarry Smith const struct { PetscScalar foo,bar,baz; } *ptr;
56a1cb98faSBarry Smith DMPlexPointLocalRead(dm,point,array,&ptr);
57a1cb98faSBarry Smith x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz;
58a1cb98faSBarry Smith .ve
59552f7358SJed Brown
601cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRead()`
61552f7358SJed Brown @*/
DMPlexPointLocalRead(DM dm,PetscInt point,const PetscScalar * array,void * ptr)62d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalRead(DM dm, PetscInt point, const PetscScalar *array, void *ptr)
63d71ae5a4SJacob Faibussowitsch {
64a89cf0ddSMatthew G. Knepley PetscInt start, end;
65552f7358SJed Brown
66552f7358SJed Brown PetscFunctionBegin;
67552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
684f572ea9SToby Isaac PetscAssertPointer(array, 3);
694f572ea9SToby Isaac PetscAssertPointer(ptr, 4);
709566063dSJacob Faibussowitsch PetscCall(DMGetLocalOffset_Private(dm, point, &start, &end));
71a89cf0ddSMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start : NULL;
723ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
73552f7358SJed Brown }
74552f7358SJed Brown
75552f7358SJed Brown /*@
76552f7358SJed Brown DMPlexPointLocalRef - return read/write access to a point in local array
77552f7358SJed Brown
78552f7358SJed Brown Not Collective
79552f7358SJed Brown
804165533cSJose E. Roman Input Parameters:
81a1cb98faSBarry Smith + dm - `DM` defining topological space
82552f7358SJed Brown . point - topological point
83552f7358SJed Brown - array - array to index into
84552f7358SJed Brown
854165533cSJose E. Roman Output Parameter:
86552f7358SJed Brown . ptr - address of reference to point data, type generic so user can place in structure
87552f7358SJed Brown
88552f7358SJed Brown Level: intermediate
89552f7358SJed Brown
90552f7358SJed Brown Note:
91*a4e35b19SJacob Faibussowitsch A common usage when data sizes are known statically\:
92a1cb98faSBarry Smith .vb
93a1cb98faSBarry Smith struct { PetscScalar foo,bar,baz; } *ptr;
94a1cb98faSBarry Smith DMPlexPointLocalRef(dm,point,array,&ptr);
95a1cb98faSBarry Smith ptr->foo = 2; ptr->bar = 3; ptr->baz = 5;
96a1cb98faSBarry Smith .ve
97552f7358SJed Brown
981cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()`
99552f7358SJed Brown @*/
DMPlexPointLocalRef(DM dm,PetscInt point,PetscScalar * array,void * ptr)100d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalRef(DM dm, PetscInt point, PetscScalar *array, void *ptr)
101d71ae5a4SJacob Faibussowitsch {
102a89cf0ddSMatthew G. Knepley PetscInt start, end;
103552f7358SJed Brown
104552f7358SJed Brown PetscFunctionBegin;
105552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1064f572ea9SToby Isaac PetscAssertPointer(array, 3);
1074f572ea9SToby Isaac PetscAssertPointer(ptr, 4);
1089566063dSJacob Faibussowitsch PetscCall(DMGetLocalOffset_Private(dm, point, &start, &end));
109a89cf0ddSMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start : NULL;
1103ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
111a89cf0ddSMatthew G. Knepley }
112a89cf0ddSMatthew G. Knepley
113a89cf0ddSMatthew G. Knepley /*@
114a89cf0ddSMatthew G. Knepley DMPlexGetPointLocalField - get location of point field data in local Vec
115a89cf0ddSMatthew G. Knepley
116a89cf0ddSMatthew G. Knepley Not Collective
117a89cf0ddSMatthew G. Knepley
1184165533cSJose E. Roman Input Parameters:
119a1cb98faSBarry Smith + dm - `DM` defining the topological space
120a89cf0ddSMatthew G. Knepley . point - topological point
121a89cf0ddSMatthew G. Knepley - field - the field number
122a89cf0ddSMatthew G. Knepley
1234165533cSJose E. Roman Output Parameters:
124a89cf0ddSMatthew G. Knepley + start - start of point data
125a89cf0ddSMatthew G. Knepley - end - end of point data
126a89cf0ddSMatthew G. Knepley
127a89cf0ddSMatthew G. Knepley Level: intermediate
128a89cf0ddSMatthew G. Knepley
129a1cb98faSBarry Smith Note:
130a1cb98faSBarry Smith This is a half open interval [start, end)
131a1cb98faSBarry Smith
13260225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointLocal()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointLocalRead()`, `DMPlexPointLocalRef()`
133a89cf0ddSMatthew G. Knepley @*/
DMPlexGetPointLocalField(DM dm,PetscInt point,PetscInt field,PetscInt * start,PetscInt * end)134d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointLocalField(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
135d71ae5a4SJacob Faibussowitsch {
136a89cf0ddSMatthew G. Knepley PetscInt s, e;
137a89cf0ddSMatthew G. Knepley
138a89cf0ddSMatthew G. Knepley PetscFunctionBegin;
139a89cf0ddSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1404f572ea9SToby Isaac if (start) PetscAssertPointer(start, 4);
1414f572ea9SToby Isaac if (end) PetscAssertPointer(end, 5);
1429566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &s, &e));
143a89cf0ddSMatthew G. Knepley if (start) *start = s;
144a89cf0ddSMatthew G. Knepley if (end) *end = e;
1453ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
146552f7358SJed Brown }
147552f7358SJed Brown
1481ce3176fSMatthew G. Knepley /*@
1491ce3176fSMatthew G. Knepley DMPlexPointLocalFieldRead - return read access to a field on a point in local array
1501ce3176fSMatthew G. Knepley
1511ce3176fSMatthew G. Knepley Not Collective
1521ce3176fSMatthew G. Knepley
1534165533cSJose E. Roman Input Parameters:
154a1cb98faSBarry Smith + dm - `DM` defining topological space
1551ce3176fSMatthew G. Knepley . point - topological point
1561ce3176fSMatthew G. Knepley . field - field number
1571ce3176fSMatthew G. Knepley - array - array to index into
1581ce3176fSMatthew G. Knepley
1594165533cSJose E. Roman Output Parameter:
1601ce3176fSMatthew G. Knepley . ptr - address of read reference to point data, type generic so user can place in structure
1611ce3176fSMatthew G. Knepley
1621ce3176fSMatthew G. Knepley Level: intermediate
1631ce3176fSMatthew G. Knepley
1641cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()`
1651ce3176fSMatthew G. Knepley @*/
DMPlexPointLocalFieldRead(DM dm,PetscInt point,PetscInt field,const PetscScalar * array,void * ptr)166d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalFieldRead(DM dm, PetscInt point, PetscInt field, const PetscScalar *array, void *ptr)
167d71ae5a4SJacob Faibussowitsch {
168a89cf0ddSMatthew G. Knepley PetscInt start, end;
1691ce3176fSMatthew G. Knepley
1701ce3176fSMatthew G. Knepley PetscFunctionBegin;
1711ce3176fSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1724f572ea9SToby Isaac PetscAssertPointer(array, 4);
1734f572ea9SToby Isaac PetscAssertPointer(ptr, 5);
1749566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &start, &end));
1751ce3176fSMatthew G. Knepley *(const PetscScalar **)ptr = array + start;
1763ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
1771ce3176fSMatthew G. Knepley }
1781ce3176fSMatthew G. Knepley
1794824f456SMatthew G. Knepley /*@
1804824f456SMatthew G. Knepley DMPlexPointLocalFieldRef - return read/write access to a field on a point in local array
1814824f456SMatthew G. Knepley
1824824f456SMatthew G. Knepley Not Collective
1834824f456SMatthew G. Knepley
1844165533cSJose E. Roman Input Parameters:
185a1cb98faSBarry Smith + dm - `DM` defining topological space
1864824f456SMatthew G. Knepley . point - topological point
1874824f456SMatthew G. Knepley . field - field number
1884824f456SMatthew G. Knepley - array - array to index into
1894824f456SMatthew G. Knepley
1904165533cSJose E. Roman Output Parameter:
1914824f456SMatthew G. Knepley . ptr - address of reference to point data, type generic so user can place in structure
1924824f456SMatthew G. Knepley
1934824f456SMatthew G. Knepley Level: intermediate
1944824f456SMatthew G. Knepley
1951cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()`
1964824f456SMatthew G. Knepley @*/
DMPlexPointLocalFieldRef(DM dm,PetscInt point,PetscInt field,PetscScalar * array,void * ptr)197d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalFieldRef(DM dm, PetscInt point, PetscInt field, PetscScalar *array, void *ptr)
198d71ae5a4SJacob Faibussowitsch {
199a89cf0ddSMatthew G. Knepley PetscInt start, end;
2004824f456SMatthew G. Knepley
2014824f456SMatthew G. Knepley PetscFunctionBegin;
2024824f456SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
2034f572ea9SToby Isaac PetscAssertPointer(array, 4);
2044f572ea9SToby Isaac PetscAssertPointer(ptr, 5);
2059566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &start, &end));
2064824f456SMatthew G. Knepley *(PetscScalar **)ptr = array + start;
2073ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
2084824f456SMatthew G. Knepley }
2094824f456SMatthew G. Knepley
210552f7358SJed Brown /*@
211552f7358SJed Brown DMPlexGetPointGlobal - get location of point data in global Vec
212552f7358SJed Brown
213552f7358SJed Brown Not Collective
214552f7358SJed Brown
2154165533cSJose E. Roman Input Parameters:
216a1cb98faSBarry Smith + dm - `DM` defining the topological space
217552f7358SJed Brown - point - topological point
218552f7358SJed Brown
2194165533cSJose E. Roman Output Parameters:
220a89cf0ddSMatthew G. Knepley + start - start of point data; returns -(globalStart+1) if point is not owned
221a89cf0ddSMatthew G. Knepley - end - end of point data; returns -(globalEnd+1) if point is not owned
222a89cf0ddSMatthew G. Knepley
223552f7358SJed Brown Level: intermediate
224552f7358SJed Brown
225a1cb98faSBarry Smith Note:
226a1cb98faSBarry Smith This is a half open interval [start, end)
227a1cb98faSBarry Smith
22860225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointGlobalField()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointGlobalRead()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()`
229552f7358SJed Brown @*/
DMPlexGetPointGlobal(DM dm,PetscInt point,PetscInt * start,PetscInt * end)230d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointGlobal(DM dm, PetscInt point, PetscInt *start, PetscInt *end)
231d71ae5a4SJacob Faibussowitsch {
232a89cf0ddSMatthew G. Knepley PetscInt s, e;
233552f7358SJed Brown
234552f7358SJed Brown PetscFunctionBegin;
235552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
2364f572ea9SToby Isaac if (start) PetscAssertPointer(start, 3);
2374f572ea9SToby Isaac if (end) PetscAssertPointer(end, 4);
2389566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &s, &e));
239a89cf0ddSMatthew G. Knepley if (start) *start = s;
240a89cf0ddSMatthew G. Knepley if (end) *end = e;
2413ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
242552f7358SJed Brown }
243552f7358SJed Brown
244552f7358SJed Brown /*@
245552f7358SJed Brown DMPlexPointGlobalRead - return read access to a point in global array
246552f7358SJed Brown
247552f7358SJed Brown Not Collective
248552f7358SJed Brown
2494165533cSJose E. Roman Input Parameters:
250a1cb98faSBarry Smith + dm - `DM` defining topological space
251552f7358SJed Brown . point - topological point
252552f7358SJed Brown - array - array to index into
253552f7358SJed Brown
2544165533cSJose E. Roman Output Parameter:
2550298fd71SBarry Smith . ptr - address of read reference to point data, type generic so user can place in structure; returns NULL if global point is not owned
256552f7358SJed Brown
257552f7358SJed Brown Level: intermediate
258552f7358SJed Brown
259552f7358SJed Brown Note:
260*a4e35b19SJacob Faibussowitsch A common usage when data sizes are known statically\:
261a1cb98faSBarry Smith .vb
262a1cb98faSBarry Smith const struct { PetscScalar foo,bar,baz; } *ptr;
263a1cb98faSBarry Smith DMPlexPointGlobalRead(dm,point,array,&ptr);
264a1cb98faSBarry Smith x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz;
265a1cb98faSBarry Smith .ve
266552f7358SJed Brown
2671cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRead()`, `DMPlexPointGlobalRef()`
268552f7358SJed Brown @*/
DMPlexPointGlobalRead(DM dm,PetscInt point,const PetscScalar * array,const void * ptr)269d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalRead(DM dm, PetscInt point, const PetscScalar *array, const void *ptr)
270d71ae5a4SJacob Faibussowitsch {
27179532bb4SMatthew G. Knepley PetscInt start, end;
272552f7358SJed Brown
273552f7358SJed Brown PetscFunctionBegin;
274552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
2754f572ea9SToby Isaac PetscAssertPointer(array, 3);
2764f572ea9SToby Isaac PetscAssertPointer(ptr, 4);
2779566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &start, &end));
27879532bb4SMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL;
2793ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
280552f7358SJed Brown }
281552f7358SJed Brown
282552f7358SJed Brown /*@
283552f7358SJed Brown DMPlexPointGlobalRef - return read/write access to a point in global array
284552f7358SJed Brown
285552f7358SJed Brown Not Collective
286552f7358SJed Brown
2874165533cSJose E. Roman Input Parameters:
288a1cb98faSBarry Smith + dm - `DM` defining topological space
289552f7358SJed Brown . point - topological point
290552f7358SJed Brown - array - array to index into
291552f7358SJed Brown
2924165533cSJose E. Roman Output Parameter:
2930298fd71SBarry Smith . ptr - address of reference to point data, type generic so user can place in structure; returns NULL if global point is not owned
294552f7358SJed Brown
295552f7358SJed Brown Level: intermediate
296552f7358SJed Brown
297552f7358SJed Brown Note:
298*a4e35b19SJacob Faibussowitsch A common usage when data sizes are known statically\:
299a1cb98faSBarry Smith .vb
300a1cb98faSBarry Smith struct { PetscScalar foo,bar,baz; } *ptr;
301a1cb98faSBarry Smith DMPlexPointGlobalRef(dm,point,array,&ptr);
302a1cb98faSBarry Smith ptr->foo = 2; ptr->bar = 3; ptr->baz = 5;
303a1cb98faSBarry Smith .ve
304552f7358SJed Brown
3051cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRef()`, `DMPlexPointGlobalRead()`
306552f7358SJed Brown @*/
DMPlexPointGlobalRef(DM dm,PetscInt point,PetscScalar * array,void * ptr)307d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalRef(DM dm, PetscInt point, PetscScalar *array, void *ptr)
308d71ae5a4SJacob Faibussowitsch {
30979532bb4SMatthew G. Knepley PetscInt start, end;
310552f7358SJed Brown
311552f7358SJed Brown PetscFunctionBegin;
312552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
3134f572ea9SToby Isaac PetscAssertPointer(array, 3);
3144f572ea9SToby Isaac PetscAssertPointer(ptr, 4);
3159566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &start, &end));
31679532bb4SMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL;
3173ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
318552f7358SJed Brown }
31933879625SMatthew G. Knepley
320a89cf0ddSMatthew G. Knepley /*@
321a1cb98faSBarry Smith DMPlexGetPointGlobalField - get location of point field data in global `Vec`
322a89cf0ddSMatthew G. Knepley
323a89cf0ddSMatthew G. Knepley Not Collective
324a89cf0ddSMatthew G. Knepley
3254165533cSJose E. Roman Input Parameters:
326a1cb98faSBarry Smith + dm - `DM` defining the topological space
327a89cf0ddSMatthew G. Knepley . point - topological point
328a89cf0ddSMatthew G. Knepley - field - the field number
329a89cf0ddSMatthew G. Knepley
3304165533cSJose E. Roman Output Parameters:
331a89cf0ddSMatthew G. Knepley + start - start of point data; returns -(globalStart+1) if point is not owned
332a89cf0ddSMatthew G. Knepley - end - end of point data; returns -(globalEnd+1) if point is not owned
333a89cf0ddSMatthew G. Knepley
334a89cf0ddSMatthew G. Knepley Level: intermediate
335a89cf0ddSMatthew G. Knepley
336a1cb98faSBarry Smith Note:
337a1cb98faSBarry Smith This is a half open interval [start, end)
338a1cb98faSBarry Smith
33960225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointGlobal()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointGlobalRead()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()`
340a89cf0ddSMatthew G. Knepley @*/
DMPlexGetPointGlobalField(DM dm,PetscInt point,PetscInt field,PetscInt * start,PetscInt * end)341d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointGlobalField(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end)
342d71ae5a4SJacob Faibussowitsch {
343a89cf0ddSMatthew G. Knepley PetscInt s, e;
344a89cf0ddSMatthew G. Knepley
345a89cf0ddSMatthew G. Knepley PetscFunctionBegin;
346a89cf0ddSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
3474f572ea9SToby Isaac if (start) PetscAssertPointer(start, 4);
3484f572ea9SToby Isaac if (end) PetscAssertPointer(end, 5);
3499566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &s, &e));
350a89cf0ddSMatthew G. Knepley if (start) *start = s;
351a89cf0ddSMatthew G. Knepley if (end) *end = e;
3523ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
353a89cf0ddSMatthew G. Knepley }
354a89cf0ddSMatthew G. Knepley
35533879625SMatthew G. Knepley /*@
35633879625SMatthew G. Knepley DMPlexPointGlobalFieldRead - return read access to a field on a point in global array
35733879625SMatthew G. Knepley
35833879625SMatthew G. Knepley Not Collective
35933879625SMatthew G. Knepley
3604165533cSJose E. Roman Input Parameters:
361a1cb98faSBarry Smith + dm - `DM` defining topological space
36233879625SMatthew G. Knepley . point - topological point
36333879625SMatthew G. Knepley . field - field number
36433879625SMatthew G. Knepley - array - array to index into
36533879625SMatthew G. Knepley
3664165533cSJose E. Roman Output Parameter:
36733879625SMatthew G. Knepley . ptr - address of read reference to point data, type generic so user can place in structure; returns NULL if global point is not owned
36833879625SMatthew G. Knepley
36933879625SMatthew G. Knepley Level: intermediate
37033879625SMatthew G. Knepley
3711cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRead()`, `DMPlexPointGlobalRef()`
37233879625SMatthew G. Knepley @*/
DMPlexPointGlobalFieldRead(DM dm,PetscInt point,PetscInt field,const PetscScalar * array,void * ptr)373d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalFieldRead(DM dm, PetscInt point, PetscInt field, const PetscScalar *array, void *ptr)
374d71ae5a4SJacob Faibussowitsch {
37579532bb4SMatthew G. Knepley PetscInt start, end;
37633879625SMatthew G. Knepley
37733879625SMatthew G. Knepley PetscFunctionBegin;
37833879625SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
3794f572ea9SToby Isaac PetscAssertPointer(array, 4);
3804f572ea9SToby Isaac PetscAssertPointer(ptr, 5);
3819566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &start, &end));
38279532bb4SMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL;
3833ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
38433879625SMatthew G. Knepley }
38533879625SMatthew G. Knepley
38633879625SMatthew G. Knepley /*@
38733879625SMatthew G. Knepley DMPlexPointGlobalFieldRef - return read/write access to a field on a point in global array
38833879625SMatthew G. Knepley
38933879625SMatthew G. Knepley Not Collective
39033879625SMatthew G. Knepley
3914165533cSJose E. Roman Input Parameters:
392a1cb98faSBarry Smith + dm - `DM` defining topological space
39333879625SMatthew G. Knepley . point - topological point
39433879625SMatthew G. Knepley . field - field number
39533879625SMatthew G. Knepley - array - array to index into
39633879625SMatthew G. Knepley
3974165533cSJose E. Roman Output Parameter:
39833879625SMatthew G. Knepley . ptr - address of reference to point data, type generic so user can place in structure; returns NULL if global point is not owned
39933879625SMatthew G. Knepley
40033879625SMatthew G. Knepley Level: intermediate
40133879625SMatthew G. Knepley
4021cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRef()`, `DMPlexPointGlobalRead()`
40333879625SMatthew G. Knepley @*/
DMPlexPointGlobalFieldRef(DM dm,PetscInt point,PetscInt field,PetscScalar * array,void * ptr)404d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalFieldRef(DM dm, PetscInt point, PetscInt field, PetscScalar *array, void *ptr)
405d71ae5a4SJacob Faibussowitsch {
40679532bb4SMatthew G. Knepley PetscInt start, end;
40733879625SMatthew G. Knepley
40833879625SMatthew G. Knepley PetscFunctionBegin;
40933879625SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
4104f572ea9SToby Isaac PetscAssertPointer(array, 4);
4114f572ea9SToby Isaac PetscAssertPointer(ptr, 5);
4129566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &start, &end));
41379532bb4SMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL;
4143ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
41533879625SMatthew G. Knepley }
416