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 21*60225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointLocalField()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointLocalRead()`, `DMPlexPointLocalRef()` 22552f7358SJed Brown @*/ 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); 29dadcf809SJacob Faibussowitsch if (start) PetscValidIntPointer(start, 3); 30dadcf809SJacob Faibussowitsch if (end) PetscValidIntPointer(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*60225df5SJacob Faibussowitsch 54552f7358SJed Brown A common usage when data sizes are known statically: 55a1cb98faSBarry Smith .vb 56a1cb98faSBarry Smith const struct { PetscScalar foo,bar,baz; } *ptr; 57a1cb98faSBarry Smith DMPlexPointLocalRead(dm,point,array,&ptr); 58a1cb98faSBarry Smith x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz; 59a1cb98faSBarry Smith .ve 60552f7358SJed Brown 611cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRead()` 62552f7358SJed Brown @*/ 63d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalRead(DM dm, PetscInt point, const PetscScalar *array, void *ptr) 64d71ae5a4SJacob Faibussowitsch { 65a89cf0ddSMatthew G. Knepley PetscInt start, end; 66552f7358SJed Brown 67552f7358SJed Brown PetscFunctionBegin; 68552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 69552f7358SJed Brown PetscValidScalarPointer(array, 3); 70552f7358SJed Brown PetscValidPointer(ptr, 4); 719566063dSJacob Faibussowitsch PetscCall(DMGetLocalOffset_Private(dm, point, &start, &end)); 72a89cf0ddSMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start : NULL; 733ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 74552f7358SJed Brown } 75552f7358SJed Brown 76552f7358SJed Brown /*@ 77552f7358SJed Brown DMPlexPointLocalRef - return read/write access to a point in local array 78552f7358SJed Brown 79552f7358SJed Brown Not Collective 80552f7358SJed Brown 814165533cSJose E. Roman Input Parameters: 82a1cb98faSBarry Smith + dm - `DM` defining topological space 83552f7358SJed Brown . point - topological point 84552f7358SJed Brown - array - array to index into 85552f7358SJed Brown 864165533cSJose E. Roman Output Parameter: 87552f7358SJed Brown . ptr - address of reference to point data, type generic so user can place in structure 88552f7358SJed Brown 89552f7358SJed Brown Level: intermediate 90552f7358SJed Brown 91552f7358SJed Brown Note: 92*60225df5SJacob Faibussowitsch 93552f7358SJed Brown A common usage when data sizes are known statically: 94a1cb98faSBarry Smith .vb 95a1cb98faSBarry Smith struct { PetscScalar foo,bar,baz; } *ptr; 96a1cb98faSBarry Smith DMPlexPointLocalRef(dm,point,array,&ptr); 97a1cb98faSBarry Smith ptr->foo = 2; ptr->bar = 3; ptr->baz = 5; 98a1cb98faSBarry Smith .ve 99552f7358SJed Brown 1001cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()` 101552f7358SJed Brown @*/ 102d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalRef(DM dm, PetscInt point, PetscScalar *array, void *ptr) 103d71ae5a4SJacob Faibussowitsch { 104a89cf0ddSMatthew G. Knepley PetscInt start, end; 105552f7358SJed Brown 106552f7358SJed Brown PetscFunctionBegin; 107552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 108552f7358SJed Brown PetscValidScalarPointer(array, 3); 109552f7358SJed Brown PetscValidPointer(ptr, 4); 1109566063dSJacob Faibussowitsch PetscCall(DMGetLocalOffset_Private(dm, point, &start, &end)); 111a89cf0ddSMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start : NULL; 1123ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 113a89cf0ddSMatthew G. Knepley } 114a89cf0ddSMatthew G. Knepley 115a89cf0ddSMatthew G. Knepley /*@ 116a89cf0ddSMatthew G. Knepley DMPlexGetPointLocalField - get location of point field data in local Vec 117a89cf0ddSMatthew G. Knepley 118a89cf0ddSMatthew G. Knepley Not Collective 119a89cf0ddSMatthew G. Knepley 1204165533cSJose E. Roman Input Parameters: 121a1cb98faSBarry Smith + dm - `DM` defining the topological space 122a89cf0ddSMatthew G. Knepley . point - topological point 123a89cf0ddSMatthew G. Knepley - field - the field number 124a89cf0ddSMatthew G. Knepley 1254165533cSJose E. Roman Output Parameters: 126a89cf0ddSMatthew G. Knepley + start - start of point data 127a89cf0ddSMatthew G. Knepley - end - end of point data 128a89cf0ddSMatthew G. Knepley 129a89cf0ddSMatthew G. Knepley Level: intermediate 130a89cf0ddSMatthew G. Knepley 131a1cb98faSBarry Smith Note: 132a1cb98faSBarry Smith This is a half open interval [start, end) 133a1cb98faSBarry Smith 134*60225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointLocal()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointLocalRead()`, `DMPlexPointLocalRef()` 135a89cf0ddSMatthew G. Knepley @*/ 136d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointLocalField(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end) 137d71ae5a4SJacob Faibussowitsch { 138a89cf0ddSMatthew G. Knepley PetscInt s, e; 139a89cf0ddSMatthew G. Knepley 140a89cf0ddSMatthew G. Knepley PetscFunctionBegin; 141a89cf0ddSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 142dadcf809SJacob Faibussowitsch if (start) PetscValidIntPointer(start, 4); 143dadcf809SJacob Faibussowitsch if (end) PetscValidIntPointer(end, 5); 1449566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &s, &e)); 145a89cf0ddSMatthew G. Knepley if (start) *start = s; 146a89cf0ddSMatthew G. Knepley if (end) *end = e; 1473ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 148552f7358SJed Brown } 149552f7358SJed Brown 1501ce3176fSMatthew G. Knepley /*@ 1511ce3176fSMatthew G. Knepley DMPlexPointLocalFieldRead - return read access to a field on a point in local array 1521ce3176fSMatthew G. Knepley 1531ce3176fSMatthew G. Knepley Not Collective 1541ce3176fSMatthew G. Knepley 1554165533cSJose E. Roman Input Parameters: 156a1cb98faSBarry Smith + dm - `DM` defining topological space 1571ce3176fSMatthew G. Knepley . point - topological point 1581ce3176fSMatthew G. Knepley . field - field number 1591ce3176fSMatthew G. Knepley - array - array to index into 1601ce3176fSMatthew G. Knepley 1614165533cSJose E. Roman Output Parameter: 1621ce3176fSMatthew G. Knepley . ptr - address of read reference to point data, type generic so user can place in structure 1631ce3176fSMatthew G. Knepley 1641ce3176fSMatthew G. Knepley Level: intermediate 1651ce3176fSMatthew G. Knepley 1661cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()` 1671ce3176fSMatthew G. Knepley @*/ 168d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalFieldRead(DM dm, PetscInt point, PetscInt field, const PetscScalar *array, void *ptr) 169d71ae5a4SJacob Faibussowitsch { 170a89cf0ddSMatthew G. Knepley PetscInt start, end; 1711ce3176fSMatthew G. Knepley 1721ce3176fSMatthew G. Knepley PetscFunctionBegin; 1731ce3176fSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 174064a246eSJacob Faibussowitsch PetscValidScalarPointer(array, 4); 175064a246eSJacob Faibussowitsch PetscValidPointer(ptr, 5); 1769566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &start, &end)); 1771ce3176fSMatthew G. Knepley *(const PetscScalar **)ptr = array + start; 1783ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 1791ce3176fSMatthew G. Knepley } 1801ce3176fSMatthew G. Knepley 1814824f456SMatthew G. Knepley /*@ 1824824f456SMatthew G. Knepley DMPlexPointLocalFieldRef - return read/write access to a field on a point in local array 1834824f456SMatthew G. Knepley 1844824f456SMatthew G. Knepley Not Collective 1854824f456SMatthew G. Knepley 1864165533cSJose E. Roman Input Parameters: 187a1cb98faSBarry Smith + dm - `DM` defining topological space 1884824f456SMatthew G. Knepley . point - topological point 1894824f456SMatthew G. Knepley . field - field number 1904824f456SMatthew G. Knepley - array - array to index into 1914824f456SMatthew G. Knepley 1924165533cSJose E. Roman Output Parameter: 1934824f456SMatthew G. Knepley . ptr - address of reference to point data, type generic so user can place in structure 1944824f456SMatthew G. Knepley 1954824f456SMatthew G. Knepley Level: intermediate 1964824f456SMatthew G. Knepley 1971cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()` 1984824f456SMatthew G. Knepley @*/ 199d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointLocalFieldRef(DM dm, PetscInt point, PetscInt field, PetscScalar *array, void *ptr) 200d71ae5a4SJacob Faibussowitsch { 201a89cf0ddSMatthew G. Knepley PetscInt start, end; 2024824f456SMatthew G. Knepley 2034824f456SMatthew G. Knepley PetscFunctionBegin; 2044824f456SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 205064a246eSJacob Faibussowitsch PetscValidScalarPointer(array, 4); 206064a246eSJacob Faibussowitsch PetscValidPointer(ptr, 5); 2079566063dSJacob Faibussowitsch PetscCall(DMGetLocalFieldOffset_Private(dm, point, field, &start, &end)); 2084824f456SMatthew G. Knepley *(PetscScalar **)ptr = array + start; 2093ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 2104824f456SMatthew G. Knepley } 2114824f456SMatthew G. Knepley 212552f7358SJed Brown /*@ 213552f7358SJed Brown DMPlexGetPointGlobal - get location of point data in global Vec 214552f7358SJed Brown 215552f7358SJed Brown Not Collective 216552f7358SJed Brown 2174165533cSJose E. Roman Input Parameters: 218a1cb98faSBarry Smith + dm - `DM` defining the topological space 219552f7358SJed Brown - point - topological point 220552f7358SJed Brown 2214165533cSJose E. Roman Output Parameters: 222a89cf0ddSMatthew G. Knepley + start - start of point data; returns -(globalStart+1) if point is not owned 223a89cf0ddSMatthew G. Knepley - end - end of point data; returns -(globalEnd+1) if point is not owned 224a89cf0ddSMatthew G. Knepley 225552f7358SJed Brown Level: intermediate 226552f7358SJed Brown 227a1cb98faSBarry Smith Note: 228a1cb98faSBarry Smith This is a half open interval [start, end) 229a1cb98faSBarry Smith 230*60225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointGlobalField()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointGlobalRead()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()` 231552f7358SJed Brown @*/ 232d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointGlobal(DM dm, PetscInt point, PetscInt *start, PetscInt *end) 233d71ae5a4SJacob Faibussowitsch { 234a89cf0ddSMatthew G. Knepley PetscInt s, e; 235552f7358SJed Brown 236552f7358SJed Brown PetscFunctionBegin; 237552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 238dadcf809SJacob Faibussowitsch if (start) PetscValidIntPointer(start, 3); 239dadcf809SJacob Faibussowitsch if (end) PetscValidIntPointer(end, 4); 2409566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &s, &e)); 241a89cf0ddSMatthew G. Knepley if (start) *start = s; 242a89cf0ddSMatthew G. Knepley if (end) *end = e; 2433ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 244552f7358SJed Brown } 245552f7358SJed Brown 246552f7358SJed Brown /*@ 247552f7358SJed Brown DMPlexPointGlobalRead - return read access to a point in global array 248552f7358SJed Brown 249552f7358SJed Brown Not Collective 250552f7358SJed Brown 2514165533cSJose E. Roman Input Parameters: 252a1cb98faSBarry Smith + dm - `DM` defining topological space 253552f7358SJed Brown . point - topological point 254552f7358SJed Brown - array - array to index into 255552f7358SJed Brown 2564165533cSJose E. Roman Output Parameter: 2570298fd71SBarry 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 258552f7358SJed Brown 259552f7358SJed Brown Level: intermediate 260552f7358SJed Brown 261552f7358SJed Brown Note: 262*60225df5SJacob Faibussowitsch 263552f7358SJed Brown A common usage when data sizes are known statically: 264a1cb98faSBarry Smith .vb 265a1cb98faSBarry Smith const struct { PetscScalar foo,bar,baz; } *ptr; 266a1cb98faSBarry Smith DMPlexPointGlobalRead(dm,point,array,&ptr); 267a1cb98faSBarry Smith x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz; 268a1cb98faSBarry Smith .ve 269552f7358SJed Brown 2701cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRead()`, `DMPlexPointGlobalRef()` 271552f7358SJed Brown @*/ 272d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalRead(DM dm, PetscInt point, const PetscScalar *array, const void *ptr) 273d71ae5a4SJacob Faibussowitsch { 27479532bb4SMatthew G. Knepley PetscInt start, end; 275552f7358SJed Brown 276552f7358SJed Brown PetscFunctionBegin; 277552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 278552f7358SJed Brown PetscValidScalarPointer(array, 3); 279552f7358SJed Brown PetscValidPointer(ptr, 4); 2809566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &start, &end)); 28179532bb4SMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL; 2823ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 283552f7358SJed Brown } 284552f7358SJed Brown 285552f7358SJed Brown /*@ 286552f7358SJed Brown DMPlexPointGlobalRef - return read/write access to a point in global array 287552f7358SJed Brown 288552f7358SJed Brown Not Collective 289552f7358SJed Brown 2904165533cSJose E. Roman Input Parameters: 291a1cb98faSBarry Smith + dm - `DM` defining topological space 292552f7358SJed Brown . point - topological point 293552f7358SJed Brown - array - array to index into 294552f7358SJed Brown 2954165533cSJose E. Roman Output Parameter: 2960298fd71SBarry Smith . ptr - address of reference to point data, type generic so user can place in structure; returns NULL if global point is not owned 297552f7358SJed Brown 298552f7358SJed Brown Level: intermediate 299552f7358SJed Brown 300552f7358SJed Brown Note: 301*60225df5SJacob Faibussowitsch 302552f7358SJed Brown A common usage when data sizes are known statically: 303a1cb98faSBarry Smith .vb 304a1cb98faSBarry Smith struct { PetscScalar foo,bar,baz; } *ptr; 305a1cb98faSBarry Smith DMPlexPointGlobalRef(dm,point,array,&ptr); 306a1cb98faSBarry Smith ptr->foo = 2; ptr->bar = 3; ptr->baz = 5; 307a1cb98faSBarry Smith .ve 308552f7358SJed Brown 3091cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRef()`, `DMPlexPointGlobalRead()` 310552f7358SJed Brown @*/ 311d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalRef(DM dm, PetscInt point, PetscScalar *array, void *ptr) 312d71ae5a4SJacob Faibussowitsch { 31379532bb4SMatthew G. Knepley PetscInt start, end; 314552f7358SJed Brown 315552f7358SJed Brown PetscFunctionBegin; 316552f7358SJed Brown PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 317552f7358SJed Brown PetscValidScalarPointer(array, 3); 318552f7358SJed Brown PetscValidPointer(ptr, 4); 3199566063dSJacob Faibussowitsch PetscCall(DMGetGlobalOffset_Private(dm, point, &start, &end)); 32079532bb4SMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL; 3213ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 322552f7358SJed Brown } 32333879625SMatthew G. Knepley 324a89cf0ddSMatthew G. Knepley /*@ 325a1cb98faSBarry Smith DMPlexGetPointGlobalField - get location of point field data in global `Vec` 326a89cf0ddSMatthew G. Knepley 327a89cf0ddSMatthew G. Knepley Not Collective 328a89cf0ddSMatthew G. Knepley 3294165533cSJose E. Roman Input Parameters: 330a1cb98faSBarry Smith + dm - `DM` defining the topological space 331a89cf0ddSMatthew G. Knepley . point - topological point 332a89cf0ddSMatthew G. Knepley - field - the field number 333a89cf0ddSMatthew G. Knepley 3344165533cSJose E. Roman Output Parameters: 335a89cf0ddSMatthew G. Knepley + start - start of point data; returns -(globalStart+1) if point is not owned 336a89cf0ddSMatthew G. Knepley - end - end of point data; returns -(globalEnd+1) if point is not owned 337a89cf0ddSMatthew G. Knepley 338a89cf0ddSMatthew G. Knepley Level: intermediate 339a89cf0ddSMatthew G. Knepley 340a1cb98faSBarry Smith Note: 341a1cb98faSBarry Smith This is a half open interval [start, end) 342a1cb98faSBarry Smith 343*60225df5SJacob Faibussowitsch .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetPointGlobal()`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexPointGlobalRead()`, `DMPlexGetPointLocal()`, `DMPlexPointGlobalRef()` 344a89cf0ddSMatthew G. Knepley @*/ 345d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexGetPointGlobalField(DM dm, PetscInt point, PetscInt field, PetscInt *start, PetscInt *end) 346d71ae5a4SJacob Faibussowitsch { 347a89cf0ddSMatthew G. Knepley PetscInt s, e; 348a89cf0ddSMatthew G. Knepley 349a89cf0ddSMatthew G. Knepley PetscFunctionBegin; 350a89cf0ddSMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 351dadcf809SJacob Faibussowitsch if (start) PetscValidIntPointer(start, 4); 352dadcf809SJacob Faibussowitsch if (end) PetscValidIntPointer(end, 5); 3539566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &s, &e)); 354a89cf0ddSMatthew G. Knepley if (start) *start = s; 355a89cf0ddSMatthew G. Knepley if (end) *end = e; 3563ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 357a89cf0ddSMatthew G. Knepley } 358a89cf0ddSMatthew G. Knepley 35933879625SMatthew G. Knepley /*@ 36033879625SMatthew G. Knepley DMPlexPointGlobalFieldRead - return read access to a field on a point in global array 36133879625SMatthew G. Knepley 36233879625SMatthew G. Knepley Not Collective 36333879625SMatthew G. Knepley 3644165533cSJose E. Roman Input Parameters: 365a1cb98faSBarry Smith + dm - `DM` defining topological space 36633879625SMatthew G. Knepley . point - topological point 36733879625SMatthew G. Knepley . field - field number 36833879625SMatthew G. Knepley - array - array to index into 36933879625SMatthew G. Knepley 3704165533cSJose E. Roman Output Parameter: 37133879625SMatthew 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 37233879625SMatthew G. Knepley 37333879625SMatthew G. Knepley Level: intermediate 37433879625SMatthew G. Knepley 3751cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRead()`, `DMPlexPointGlobalRef()` 37633879625SMatthew G. Knepley @*/ 377d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalFieldRead(DM dm, PetscInt point, PetscInt field, const PetscScalar *array, void *ptr) 378d71ae5a4SJacob Faibussowitsch { 37979532bb4SMatthew G. Knepley PetscInt start, end; 38033879625SMatthew G. Knepley 38133879625SMatthew G. Knepley PetscFunctionBegin; 38233879625SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 383064a246eSJacob Faibussowitsch PetscValidScalarPointer(array, 4); 384064a246eSJacob Faibussowitsch PetscValidPointer(ptr, 5); 3859566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &start, &end)); 38679532bb4SMatthew G. Knepley *(const PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL; 3873ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 38833879625SMatthew G. Knepley } 38933879625SMatthew G. Knepley 39033879625SMatthew G. Knepley /*@ 39133879625SMatthew G. Knepley DMPlexPointGlobalFieldRef - return read/write access to a field on a point in global array 39233879625SMatthew G. Knepley 39333879625SMatthew G. Knepley Not Collective 39433879625SMatthew G. Knepley 3954165533cSJose E. Roman Input Parameters: 396a1cb98faSBarry Smith + dm - `DM` defining topological space 39733879625SMatthew G. Knepley . point - topological point 39833879625SMatthew G. Knepley . field - field number 39933879625SMatthew G. Knepley - array - array to index into 40033879625SMatthew G. Knepley 4014165533cSJose E. Roman Output Parameter: 40233879625SMatthew 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 40333879625SMatthew G. Knepley 40433879625SMatthew G. Knepley Level: intermediate 40533879625SMatthew G. Knepley 4061cc06b55SBarry Smith .seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMGetLocalSection()`, `PetscSectionGetOffset()`, `PetscSectionGetDof()`, `DMPlexGetPointGlobal()`, `DMPlexPointLocalRef()`, `DMPlexPointGlobalRead()` 40733879625SMatthew G. Knepley @*/ 408d71ae5a4SJacob Faibussowitsch PetscErrorCode DMPlexPointGlobalFieldRef(DM dm, PetscInt point, PetscInt field, PetscScalar *array, void *ptr) 409d71ae5a4SJacob Faibussowitsch { 41079532bb4SMatthew G. Knepley PetscInt start, end; 41133879625SMatthew G. Knepley 41233879625SMatthew G. Knepley PetscFunctionBegin; 41333879625SMatthew G. Knepley PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 414064a246eSJacob Faibussowitsch PetscValidScalarPointer(array, 4); 415064a246eSJacob Faibussowitsch PetscValidPointer(ptr, 5); 4169566063dSJacob Faibussowitsch PetscCall(DMGetGlobalFieldOffset_Private(dm, point, field, &start, &end)); 41779532bb4SMatthew G. Knepley *(PetscScalar **)ptr = (start < end) ? array + start - dm->map->rstart : NULL; 4183ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS); 41933879625SMatthew G. Knepley } 420