134541f0dSBarry Smith #include <petsc-private/dmpleximpl.h> /*I "petscdmplex.h" I*/ 2ad7c26b0SJed Brown #include <petsc-private/isimpl.h> /* for inline access to atlasOff */ 3552f7358SJed Brown 4552f7358SJed Brown #undef __FUNCT__ 5552f7358SJed Brown #define __FUNCT__ "DMPlexGetLocalOffset_Private" 6552f7358SJed Brown PETSC_STATIC_INLINE PetscErrorCode DMPlexGetLocalOffset_Private(DM dm,PetscInt point,PetscInt *offset) 7552f7358SJed Brown { 8552f7358SJed Brown PetscFunctionBegin; 9552f7358SJed Brown #if defined(PETSC_USE_DEBUG) 10552f7358SJed Brown { 11552f7358SJed Brown PetscErrorCode ierr; 12552f7358SJed Brown ierr = PetscSectionGetOffset(dm->defaultSection,point,offset);CHKERRQ(ierr); 13552f7358SJed Brown } 14552f7358SJed Brown #else 15552f7358SJed Brown { 16552f7358SJed Brown PetscSection s = dm->defaultSection; 174c0d72c2SMatthew G. Knepley *offset = s->atlasOff[point - s->pStart]; 18552f7358SJed Brown } 19552f7358SJed Brown #endif 20552f7358SJed Brown PetscFunctionReturn(0); 21552f7358SJed Brown } 22552f7358SJed Brown 23552f7358SJed Brown #undef __FUNCT__ 244824f456SMatthew G. Knepley #define __FUNCT__ "DMPlexGetLocalFieldOffset_Private" 254824f456SMatthew G. Knepley PETSC_STATIC_INLINE PetscErrorCode DMPlexGetLocalFieldOffset_Private(DM dm,PetscInt point,PetscInt field,PetscInt *offset) 264824f456SMatthew G. Knepley { 274824f456SMatthew G. Knepley PetscFunctionBegin; 284824f456SMatthew G. Knepley #if defined(PETSC_USE_DEBUG) 294824f456SMatthew G. Knepley { 304824f456SMatthew G. Knepley PetscErrorCode ierr; 314824f456SMatthew G. Knepley ierr = PetscSectionGetFieldOffset(dm->defaultSection,point,field,offset);CHKERRQ(ierr); 324824f456SMatthew G. Knepley } 334824f456SMatthew G. Knepley #else 344824f456SMatthew G. Knepley { 354824f456SMatthew G. Knepley PetscSection s = dm->defaultSection->field[field]; 364824f456SMatthew G. Knepley *offset = s->atlasOff[point - s->pStart]; 374824f456SMatthew G. Knepley } 384824f456SMatthew G. Knepley #endif 394824f456SMatthew G. Knepley PetscFunctionReturn(0); 404824f456SMatthew G. Knepley } 414824f456SMatthew G. Knepley 424824f456SMatthew G. Knepley #undef __FUNCT__ 43552f7358SJed Brown #define __FUNCT__ "DMPlexGetGlobalOffset_Private" 44552f7358SJed Brown PETSC_STATIC_INLINE PetscErrorCode DMPlexGetGlobalOffset_Private(DM dm,PetscInt point,PetscInt *offset) 45552f7358SJed Brown { 46552f7358SJed Brown PetscFunctionBegin; 47552f7358SJed Brown #if defined(PETSC_USE_DEBUG) 48552f7358SJed Brown { 49552f7358SJed Brown PetscErrorCode ierr; 50552f7358SJed Brown PetscInt dof,cdof; 51552f7358SJed Brown ierr = PetscSectionGetOffset(dm->defaultGlobalSection,point,offset);CHKERRQ(ierr); 52552f7358SJed Brown ierr = PetscSectionGetDof(dm->defaultGlobalSection,point,&dof);CHKERRQ(ierr); 53552f7358SJed Brown ierr = PetscSectionGetConstraintDof(dm->defaultGlobalSection,point,&cdof);CHKERRQ(ierr); 54552f7358SJed Brown if (dof-cdof <= 0) *offset = -1; /* Indicates no data */ 55552f7358SJed Brown } 56552f7358SJed Brown #else 57552f7358SJed Brown { 58552f7358SJed Brown PetscSection s = dm->defaultGlobalSection; 59552f7358SJed Brown PetscInt dof,cdof; 604c0d72c2SMatthew G. Knepley *offset = s->atlasOff[point - s->pStart]; 614c0d72c2SMatthew G. Knepley dof = s->atlasDof[point - s->pStart]; 624c0d72c2SMatthew G. Knepley cdof = s->bc ? s->bc->atlasDof[point - s->bc->pStart] : 0; 63552f7358SJed Brown if (dof-cdof <= 0) *offset = -1; 64552f7358SJed Brown } 65552f7358SJed Brown #endif 66552f7358SJed Brown PetscFunctionReturn(0); 67552f7358SJed Brown } 68552f7358SJed Brown 69552f7358SJed Brown #undef __FUNCT__ 70*33879625SMatthew G. Knepley #define __FUNCT__ "DMPlexGetGlobalFieldOffset_Private" 71*33879625SMatthew G. Knepley PETSC_STATIC_INLINE PetscErrorCode DMPlexGetGlobalFieldOffset_Private(DM dm,PetscInt point,PetscInt field,PetscInt *offset) 72*33879625SMatthew G. Knepley { 73*33879625SMatthew G. Knepley PetscFunctionBegin; 74*33879625SMatthew G. Knepley #if defined(PETSC_USE_DEBUG) 75*33879625SMatthew G. Knepley { 76*33879625SMatthew G. Knepley PetscErrorCode ierr; 77*33879625SMatthew G. Knepley PetscInt loff,lfoff,dof,cdof; 78*33879625SMatthew G. Knepley ierr = PetscSectionGetOffset(dm->defaultGlobalSection,point,offset);CHKERRQ(ierr); 79*33879625SMatthew G. Knepley ierr = PetscSectionGetOffset(dm->defaultSection,point,&loff);CHKERRQ(ierr); 80*33879625SMatthew G. Knepley ierr = PetscSectionGetFieldOffset(dm->defaultSection,point,field,&lfoff);CHKERRQ(ierr); 81*33879625SMatthew G. Knepley ierr = PetscSectionGetFieldDof(dm->defaultSection,point,field,&dof);CHKERRQ(ierr); 82*33879625SMatthew G. Knepley ierr = PetscSectionGetFieldConstraintDof(dm->defaultSection,point,field,&cdof);CHKERRQ(ierr); 83*33879625SMatthew G. Knepley *offset += lfoff - loff; 84*33879625SMatthew G. Knepley if (dof-cdof <= 0) *offset = -1; /* Indicates no data */ 85*33879625SMatthew G. Knepley } 86*33879625SMatthew G. Knepley #else 87*33879625SMatthew G. Knepley { 88*33879625SMatthew G. Knepley 1/0; 89*33879625SMatthew G. Knepley PetscSection s = dm->defaultGlobalSection->field[field]; 90*33879625SMatthew G. Knepley PetscInt dof,cdof; 91*33879625SMatthew G. Knepley *offset = s->atlasOff[point - s->pStart]; 92*33879625SMatthew G. Knepley dof = s->atlasDof[point - s->pStart]; 93*33879625SMatthew G. Knepley cdof = s->bc ? s->bc->atlasDof[point - s->bc->pStart] : 0; 94*33879625SMatthew G. Knepley if (dof-cdof <= 0) *offset = -1; 95*33879625SMatthew G. Knepley } 96*33879625SMatthew G. Knepley #endif 97*33879625SMatthew G. Knepley PetscFunctionReturn(0); 98*33879625SMatthew G. Knepley } 99*33879625SMatthew G. Knepley 100*33879625SMatthew G. Knepley #undef __FUNCT__ 101552f7358SJed Brown #define __FUNCT__ "DMPlexGetPointLocal" 102552f7358SJed Brown /*@ 103552f7358SJed Brown DMPlexGetPointLocal - get location of point data in local Vec 104552f7358SJed Brown 105552f7358SJed Brown Not Collective 106552f7358SJed Brown 107552f7358SJed Brown Input Arguments: 108552f7358SJed Brown + dm - DM defining the topological space 109552f7358SJed Brown - point - topological point 110552f7358SJed Brown 111552f7358SJed Brown Output Arguments: 112552f7358SJed Brown + start - start of point data 113552f7358SJed Brown - end - end of point data 114552f7358SJed Brown 115552f7358SJed Brown Level: intermediate 116552f7358SJed Brown 117552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexPointLocalRead(), DMPlexPointLocalRead(), DMPlexPointLocalRef() 118552f7358SJed Brown @*/ 119552f7358SJed Brown PetscErrorCode DMPlexGetPointLocal(DM dm,PetscInt point,PetscInt *start,PetscInt *end) 120552f7358SJed Brown { 121552f7358SJed Brown PetscErrorCode ierr; 122552f7358SJed Brown PetscInt offset,dof; 123552f7358SJed Brown 124552f7358SJed Brown PetscFunctionBegin; 125552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 126552f7358SJed Brown ierr = PetscSectionGetOffset(dm->defaultSection,point,&offset);CHKERRQ(ierr); 127552f7358SJed Brown ierr = PetscSectionGetDof(dm->defaultSection,point,&dof);CHKERRQ(ierr); 128552f7358SJed Brown if (start) *start = offset; 129552f7358SJed Brown if (end) *end = offset + dof; 130552f7358SJed Brown PetscFunctionReturn(0); 131552f7358SJed Brown } 132552f7358SJed Brown 133552f7358SJed Brown #undef __FUNCT__ 134552f7358SJed Brown #define __FUNCT__ "DMPlexPointLocalRead" 135552f7358SJed Brown /*@ 136552f7358SJed Brown DMPlexPointLocalRead - return read access to a point in local array 137552f7358SJed Brown 138552f7358SJed Brown Not Collective 139552f7358SJed Brown 140552f7358SJed Brown Input Arguments: 141552f7358SJed Brown + dm - DM defining topological space 142552f7358SJed Brown . point - topological point 143552f7358SJed Brown - array - array to index into 144552f7358SJed Brown 145552f7358SJed Brown Output Arguments: 146552f7358SJed Brown . ptr - address of read reference to point data, type generic so user can place in structure 147552f7358SJed Brown 148552f7358SJed Brown Level: intermediate 149552f7358SJed Brown 150552f7358SJed Brown Note: 151552f7358SJed Brown A common usage when data sizes are known statically: 152552f7358SJed Brown 153552f7358SJed Brown $ const struct { PetscScalar foo,bar,baz; } *ptr; 154552f7358SJed Brown $ DMPlexPointLocalRead(dm,point,array,&ptr); 155552f7358SJed Brown $ x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz; 156552f7358SJed Brown 157552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointLocal(), DMPlexPointGlobalRead() 158552f7358SJed Brown @*/ 159552f7358SJed Brown PetscErrorCode DMPlexPointLocalRead(DM dm,PetscInt point,const PetscScalar *array,const void *ptr) 160552f7358SJed Brown { 161552f7358SJed Brown PetscErrorCode ierr; 162552f7358SJed Brown PetscInt start; 163552f7358SJed Brown 164552f7358SJed Brown PetscFunctionBegin; 165552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 166552f7358SJed Brown PetscValidScalarPointer(array,3); 167552f7358SJed Brown PetscValidPointer(ptr,4); 168552f7358SJed Brown ierr = DMPlexGetLocalOffset_Private(dm,point,&start);CHKERRQ(ierr); 169552f7358SJed Brown *(const PetscScalar**)ptr = array + start; 170552f7358SJed Brown PetscFunctionReturn(0); 171552f7358SJed Brown } 172552f7358SJed Brown 173552f7358SJed Brown #undef __FUNCT__ 174552f7358SJed Brown #define __FUNCT__ "DMPlexPointLocalRef" 175552f7358SJed Brown /*@ 176552f7358SJed Brown DMPlexPointLocalRef - return read/write access to a point in local array 177552f7358SJed Brown 178552f7358SJed Brown Not Collective 179552f7358SJed Brown 180552f7358SJed Brown Input Arguments: 181552f7358SJed Brown + dm - DM defining topological space 182552f7358SJed Brown . point - topological point 183552f7358SJed Brown - array - array to index into 184552f7358SJed Brown 185552f7358SJed Brown Output Arguments: 186552f7358SJed Brown . ptr - address of reference to point data, type generic so user can place in structure 187552f7358SJed Brown 188552f7358SJed Brown Level: intermediate 189552f7358SJed Brown 190552f7358SJed Brown Note: 191552f7358SJed Brown A common usage when data sizes are known statically: 192552f7358SJed Brown 193552f7358SJed Brown $ struct { PetscScalar foo,bar,baz; } *ptr; 194552f7358SJed Brown $ DMPlexPointLocalRef(dm,point,array,&ptr); 195552f7358SJed Brown $ ptr->foo = 2; ptr->bar = 3; ptr->baz = 5; 196552f7358SJed Brown 197552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointLocal(), DMPlexPointGlobalRef() 198552f7358SJed Brown @*/ 199552f7358SJed Brown PetscErrorCode DMPlexPointLocalRef(DM dm,PetscInt point,PetscScalar *array,void *ptr) 200552f7358SJed Brown { 201552f7358SJed Brown PetscErrorCode ierr; 202552f7358SJed Brown PetscInt start; 203552f7358SJed Brown 204552f7358SJed Brown PetscFunctionBegin; 205552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 206552f7358SJed Brown PetscValidScalarPointer(array,3); 207552f7358SJed Brown PetscValidPointer(ptr,4); 208552f7358SJed Brown ierr = DMPlexGetLocalOffset_Private(dm,point,&start);CHKERRQ(ierr); 209552f7358SJed Brown *(PetscScalar**)ptr = array + start; 210552f7358SJed Brown PetscFunctionReturn(0); 211552f7358SJed Brown } 212552f7358SJed Brown 213552f7358SJed Brown #undef __FUNCT__ 2141ce3176fSMatthew G. Knepley #define __FUNCT__ "DMPlexPointLocalFieldRead" 2151ce3176fSMatthew G. Knepley /*@ 2161ce3176fSMatthew G. Knepley DMPlexPointLocalFieldRead - return read access to a field on a point in local array 2171ce3176fSMatthew G. Knepley 2181ce3176fSMatthew G. Knepley Not Collective 2191ce3176fSMatthew G. Knepley 2201ce3176fSMatthew G. Knepley Input Arguments: 2211ce3176fSMatthew G. Knepley + dm - DM defining topological space 2221ce3176fSMatthew G. Knepley . point - topological point 2231ce3176fSMatthew G. Knepley . field - field number 2241ce3176fSMatthew G. Knepley - array - array to index into 2251ce3176fSMatthew G. Knepley 2261ce3176fSMatthew G. Knepley Output Arguments: 2271ce3176fSMatthew G. Knepley . ptr - address of read reference to point data, type generic so user can place in structure 2281ce3176fSMatthew G. Knepley 2291ce3176fSMatthew G. Knepley Level: intermediate 2301ce3176fSMatthew G. Knepley 2311ce3176fSMatthew G. Knepley .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointLocal(), DMPlexPointGlobalRef() 2321ce3176fSMatthew G. Knepley @*/ 2331ce3176fSMatthew G. Knepley PetscErrorCode DMPlexPointLocalFieldRead(DM dm,PetscInt point,PetscInt field,const PetscScalar *array,const void *ptr) 2341ce3176fSMatthew G. Knepley { 2351ce3176fSMatthew G. Knepley PetscErrorCode ierr; 2361ce3176fSMatthew G. Knepley PetscInt start; 2371ce3176fSMatthew G. Knepley 2381ce3176fSMatthew G. Knepley PetscFunctionBegin; 2391ce3176fSMatthew G. Knepley PetscValidHeaderSpecific(dm,DM_CLASSID,1); 2401ce3176fSMatthew G. Knepley PetscValidScalarPointer(array,3); 2411ce3176fSMatthew G. Knepley PetscValidPointer(ptr,4); 2421ce3176fSMatthew G. Knepley ierr = DMPlexGetLocalFieldOffset_Private(dm,point,field,&start);CHKERRQ(ierr); 2431ce3176fSMatthew G. Knepley *(const PetscScalar**)ptr = array + start; 2441ce3176fSMatthew G. Knepley PetscFunctionReturn(0); 2451ce3176fSMatthew G. Knepley } 2461ce3176fSMatthew G. Knepley 2471ce3176fSMatthew G. Knepley #undef __FUNCT__ 2484824f456SMatthew G. Knepley #define __FUNCT__ "DMPlexPointLocalFieldRef" 2494824f456SMatthew G. Knepley /*@ 2504824f456SMatthew G. Knepley DMPlexPointLocalFieldRef - return read/write access to a field on a point in local array 2514824f456SMatthew G. Knepley 2524824f456SMatthew G. Knepley Not Collective 2534824f456SMatthew G. Knepley 2544824f456SMatthew G. Knepley Input Arguments: 2554824f456SMatthew G. Knepley + dm - DM defining topological space 2564824f456SMatthew G. Knepley . point - topological point 2574824f456SMatthew G. Knepley . field - field number 2584824f456SMatthew G. Knepley - array - array to index into 2594824f456SMatthew G. Knepley 2604824f456SMatthew G. Knepley Output Arguments: 2614824f456SMatthew G. Knepley . ptr - address of reference to point data, type generic so user can place in structure 2624824f456SMatthew G. Knepley 2634824f456SMatthew G. Knepley Level: intermediate 2644824f456SMatthew G. Knepley 2654824f456SMatthew G. Knepley .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointLocal(), DMPlexPointGlobalRef() 2664824f456SMatthew G. Knepley @*/ 2674824f456SMatthew G. Knepley PetscErrorCode DMPlexPointLocalFieldRef(DM dm,PetscInt point,PetscInt field,PetscScalar *array,void *ptr) 2684824f456SMatthew G. Knepley { 2694824f456SMatthew G. Knepley PetscErrorCode ierr; 2704824f456SMatthew G. Knepley PetscInt start; 2714824f456SMatthew G. Knepley 2724824f456SMatthew G. Knepley PetscFunctionBegin; 2734824f456SMatthew G. Knepley PetscValidHeaderSpecific(dm,DM_CLASSID,1); 2744824f456SMatthew G. Knepley PetscValidScalarPointer(array,3); 2754824f456SMatthew G. Knepley PetscValidPointer(ptr,4); 2764824f456SMatthew G. Knepley ierr = DMPlexGetLocalFieldOffset_Private(dm,point,field,&start);CHKERRQ(ierr); 2774824f456SMatthew G. Knepley *(PetscScalar**)ptr = array + start; 2784824f456SMatthew G. Knepley PetscFunctionReturn(0); 2794824f456SMatthew G. Knepley } 2804824f456SMatthew G. Knepley 2814824f456SMatthew G. Knepley #undef __FUNCT__ 282552f7358SJed Brown #define __FUNCT__ "DMPlexGetPointGlobal" 283552f7358SJed Brown /*@ 284552f7358SJed Brown DMPlexGetPointGlobal - get location of point data in global Vec 285552f7358SJed Brown 286552f7358SJed Brown Not Collective 287552f7358SJed Brown 288552f7358SJed Brown Input Arguments: 289552f7358SJed Brown + dm - DM defining the topological space 290552f7358SJed Brown - point - topological point 291552f7358SJed Brown 292552f7358SJed Brown Output Arguments: 293552f7358SJed Brown + start - start of point data; returns -(global_start+1) if point is not owned 294552f7358SJed Brown - end - end of point data; returns -(global_end+1) if point is not owned 295552f7358SJed Brown 296552f7358SJed Brown Level: intermediate 297552f7358SJed Brown 298552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexPointGlobalRead(), DMPlexGetPointLocal(), DMPlexPointGlobalRead(), DMPlexPointGlobalRef() 299552f7358SJed Brown @*/ 300552f7358SJed Brown PetscErrorCode DMPlexGetPointGlobal(DM dm,PetscInt point,PetscInt *start,PetscInt *end) 301552f7358SJed Brown { 302552f7358SJed Brown PetscErrorCode ierr; 303552f7358SJed Brown PetscInt offset,dof; 304552f7358SJed Brown 305552f7358SJed Brown PetscFunctionBegin; 306552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 307552f7358SJed Brown ierr = PetscSectionGetOffset(dm->defaultGlobalSection,point,&offset);CHKERRQ(ierr); 308552f7358SJed Brown ierr = PetscSectionGetDof(dm->defaultGlobalSection,point,&dof);CHKERRQ(ierr); 309552f7358SJed Brown if (start) *start = offset; 310552f7358SJed Brown if (end) *end = offset + dof; 311552f7358SJed Brown PetscFunctionReturn(0); 312552f7358SJed Brown } 313552f7358SJed Brown 314552f7358SJed Brown #undef __FUNCT__ 315552f7358SJed Brown #define __FUNCT__ "DMPlexPointGlobalRead" 316552f7358SJed Brown /*@ 317552f7358SJed Brown DMPlexPointGlobalRead - return read access to a point in global array 318552f7358SJed Brown 319552f7358SJed Brown Not Collective 320552f7358SJed Brown 321552f7358SJed Brown Input Arguments: 322552f7358SJed Brown + dm - DM defining topological space 323552f7358SJed Brown . point - topological point 324552f7358SJed Brown - array - array to index into 325552f7358SJed Brown 326552f7358SJed Brown Output Arguments: 3270298fd71SBarry 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 328552f7358SJed Brown 329552f7358SJed Brown Level: intermediate 330552f7358SJed Brown 331552f7358SJed Brown Note: 332552f7358SJed Brown A common usage when data sizes are known statically: 333552f7358SJed Brown 334552f7358SJed Brown $ const struct { PetscScalar foo,bar,baz; } *ptr; 335552f7358SJed Brown $ DMPlexPointGlobalRead(dm,point,array,&ptr); 336552f7358SJed Brown $ x = 2*ptr->foo + 3*ptr->bar + 5*ptr->baz; 337552f7358SJed Brown 338552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointGlobal(), DMPlexPointLocalRead(), DMPlexPointGlobalRef() 339552f7358SJed Brown @*/ 340552f7358SJed Brown PetscErrorCode DMPlexPointGlobalRead(DM dm,PetscInt point,const PetscScalar *array,const void *ptr) 341552f7358SJed Brown { 342552f7358SJed Brown PetscErrorCode ierr; 343552f7358SJed Brown PetscInt start; 344552f7358SJed Brown 345552f7358SJed Brown PetscFunctionBegin; 346552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 347552f7358SJed Brown PetscValidScalarPointer(array,3); 348552f7358SJed Brown PetscValidPointer(ptr,4); 349552f7358SJed Brown ierr = DMPlexGetGlobalOffset_Private(dm,point,&start);CHKERRQ(ierr); 3500298fd71SBarry Smith *(const PetscScalar**)ptr = (start >= 0) ? array + start - dm->map->rstart : NULL; 351552f7358SJed Brown PetscFunctionReturn(0); 352552f7358SJed Brown } 353552f7358SJed Brown 354552f7358SJed Brown #undef __FUNCT__ 355552f7358SJed Brown #define __FUNCT__ "DMPlexPointGlobalRef" 356552f7358SJed Brown /*@ 357552f7358SJed Brown DMPlexPointGlobalRef - return read/write access to a point in global array 358552f7358SJed Brown 359552f7358SJed Brown Not Collective 360552f7358SJed Brown 361552f7358SJed Brown Input Arguments: 362552f7358SJed Brown + dm - DM defining topological space 363552f7358SJed Brown . point - topological point 364552f7358SJed Brown - array - array to index into 365552f7358SJed Brown 366552f7358SJed Brown Output Arguments: 3670298fd71SBarry Smith . ptr - address of reference to point data, type generic so user can place in structure; returns NULL if global point is not owned 368552f7358SJed Brown 369552f7358SJed Brown Level: intermediate 370552f7358SJed Brown 371552f7358SJed Brown Note: 372552f7358SJed Brown A common usage when data sizes are known statically: 373552f7358SJed Brown 374552f7358SJed Brown $ struct { PetscScalar foo,bar,baz; } *ptr; 375552f7358SJed Brown $ DMPlexPointGlobalRef(dm,point,array,&ptr); 376552f7358SJed Brown $ ptr->foo = 2; ptr->bar = 3; ptr->baz = 5; 377552f7358SJed Brown 378552f7358SJed Brown .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointGlobal(), DMPlexPointLocalRef(), DMPlexPointGlobalRead() 379552f7358SJed Brown @*/ 380552f7358SJed Brown PetscErrorCode DMPlexPointGlobalRef(DM dm,PetscInt point,PetscScalar *array,void *ptr) 381552f7358SJed Brown { 382552f7358SJed Brown PetscErrorCode ierr; 383552f7358SJed Brown PetscInt start; 384552f7358SJed Brown 385552f7358SJed Brown PetscFunctionBegin; 386552f7358SJed Brown PetscValidHeaderSpecific(dm,DM_CLASSID,1); 387552f7358SJed Brown PetscValidScalarPointer(array,3); 388552f7358SJed Brown PetscValidPointer(ptr,4); 389552f7358SJed Brown ierr = DMPlexGetGlobalOffset_Private(dm,point,&start);CHKERRQ(ierr); 3900298fd71SBarry Smith *(PetscScalar**)ptr = (start >= 0) ? array + start - dm->map->rstart : NULL; 391552f7358SJed Brown PetscFunctionReturn(0); 392552f7358SJed Brown } 393*33879625SMatthew G. Knepley 394*33879625SMatthew G. Knepley #undef __FUNCT__ 395*33879625SMatthew G. Knepley #define __FUNCT__ "DMPlexPointGlobalFieldRead" 396*33879625SMatthew G. Knepley /*@ 397*33879625SMatthew G. Knepley DMPlexPointGlobalFieldRead - return read access to a field on a point in global array 398*33879625SMatthew G. Knepley 399*33879625SMatthew G. Knepley Not Collective 400*33879625SMatthew G. Knepley 401*33879625SMatthew G. Knepley Input Arguments: 402*33879625SMatthew G. Knepley + dm - DM defining topological space 403*33879625SMatthew G. Knepley . point - topological point 404*33879625SMatthew G. Knepley . field - field number 405*33879625SMatthew G. Knepley - array - array to index into 406*33879625SMatthew G. Knepley 407*33879625SMatthew G. Knepley Output Arguments: 408*33879625SMatthew 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 409*33879625SMatthew G. Knepley 410*33879625SMatthew G. Knepley Level: intermediate 411*33879625SMatthew G. Knepley 412*33879625SMatthew G. Knepley .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointGlobal(), DMPlexPointLocalRead(), DMPlexPointGlobalRef() 413*33879625SMatthew G. Knepley @*/ 414*33879625SMatthew G. Knepley PetscErrorCode DMPlexPointGlobalFieldRead(DM dm,PetscInt point,PetscInt field,const PetscScalar *array,const void *ptr) 415*33879625SMatthew G. Knepley { 416*33879625SMatthew G. Knepley PetscErrorCode ierr; 417*33879625SMatthew G. Knepley PetscInt start; 418*33879625SMatthew G. Knepley 419*33879625SMatthew G. Knepley PetscFunctionBegin; 420*33879625SMatthew G. Knepley PetscValidHeaderSpecific(dm,DM_CLASSID,1); 421*33879625SMatthew G. Knepley PetscValidScalarPointer(array,3); 422*33879625SMatthew G. Knepley PetscValidPointer(ptr,4); 423*33879625SMatthew G. Knepley ierr = DMPlexGetGlobalFieldOffset_Private(dm,point,field,&start);CHKERRQ(ierr); 424*33879625SMatthew G. Knepley *(const PetscScalar**)ptr = (start >= 0) ? array + start - dm->map->rstart : NULL; 425*33879625SMatthew G. Knepley PetscFunctionReturn(0); 426*33879625SMatthew G. Knepley } 427*33879625SMatthew G. Knepley 428*33879625SMatthew G. Knepley #undef __FUNCT__ 429*33879625SMatthew G. Knepley #define __FUNCT__ "DMPlexPointGlobalFieldRef" 430*33879625SMatthew G. Knepley /*@ 431*33879625SMatthew G. Knepley DMPlexPointGlobalFieldRef - return read/write access to a field on a point in global array 432*33879625SMatthew G. Knepley 433*33879625SMatthew G. Knepley Not Collective 434*33879625SMatthew G. Knepley 435*33879625SMatthew G. Knepley Input Arguments: 436*33879625SMatthew G. Knepley + dm - DM defining topological space 437*33879625SMatthew G. Knepley . point - topological point 438*33879625SMatthew G. Knepley . field - field number 439*33879625SMatthew G. Knepley - array - array to index into 440*33879625SMatthew G. Knepley 441*33879625SMatthew G. Knepley Output Arguments: 442*33879625SMatthew 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 443*33879625SMatthew G. Knepley 444*33879625SMatthew G. Knepley Level: intermediate 445*33879625SMatthew G. Knepley 446*33879625SMatthew G. Knepley .seealso: DMGetDefaultSection(), PetscSectionGetOffset(), PetscSectionGetDof(), DMPlexGetPointGlobal(), DMPlexPointLocalRef(), DMPlexPointGlobalRead() 447*33879625SMatthew G. Knepley @*/ 448*33879625SMatthew G. Knepley PetscErrorCode DMPlexPointGlobalFieldRef(DM dm,PetscInt point,PetscInt field,PetscScalar *array,void *ptr) 449*33879625SMatthew G. Knepley { 450*33879625SMatthew G. Knepley PetscErrorCode ierr; 451*33879625SMatthew G. Knepley PetscInt start; 452*33879625SMatthew G. Knepley 453*33879625SMatthew G. Knepley PetscFunctionBegin; 454*33879625SMatthew G. Knepley PetscValidHeaderSpecific(dm,DM_CLASSID,1); 455*33879625SMatthew G. Knepley PetscValidScalarPointer(array,3); 456*33879625SMatthew G. Knepley PetscValidPointer(ptr,4); 457*33879625SMatthew G. Knepley ierr = DMPlexGetGlobalFieldOffset_Private(dm,point,field,&start);CHKERRQ(ierr); 458*33879625SMatthew G. Knepley *(PetscScalar**)ptr = (start >= 0) ? array + start - dm->map->rstart : NULL; 459*33879625SMatthew G. Knepley PetscFunctionReturn(0); 460*33879625SMatthew G. Knepley } 461