File: | dm/impls/plex/plexgmsh.c |
Warning: | line 849, column 29 Array access (from variable 'nodeTags') results in a null pointer dereference |
[?] Use j/k keys for keyboard navigation
1 | #define PETSCDM_DLL | |||
2 | #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ | |||
3 | #include <petsc/private/hashmapi.h> | |||
4 | ||||
5 | typedef struct { | |||
6 | PetscViewer viewer; | |||
7 | int fileFormat; | |||
8 | int dataSize; | |||
9 | PetscBool binary; | |||
10 | PetscBool byteSwap; | |||
11 | size_t wlen; | |||
12 | void *wbuf; | |||
13 | size_t slen; | |||
14 | void *sbuf; | |||
15 | } GmshFile; | |||
16 | ||||
17 | static PetscErrorCode GmshBufferGet(GmshFile *gmsh, size_t count, size_t eltsize, void *buf) | |||
18 | { | |||
19 | size_t size = count * eltsize; | |||
20 | PetscErrorCode ierr; | |||
21 | ||||
22 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 22; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
23 | if (gmsh->wlen < size) { | |||
24 | ierr = PetscFree(gmsh->wbuf)((*PetscTrFree)((void*)(gmsh->wbuf),24,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((gmsh->wbuf) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),24,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
25 | ierr = PetscMalloc(size, &gmsh->wbuf)((*PetscTrMalloc)((size),PETSC_FALSE,25,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(void**)(&gmsh->wbuf)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),25,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
26 | gmsh->wlen = size; | |||
27 | } | |||
28 | *(void**)buf = size ? gmsh->wbuf : NULL((void*)0); | |||
29 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
30 | } | |||
31 | ||||
32 | static PetscErrorCode GmshBufferSizeGet(GmshFile *gmsh, size_t count, void *buf) | |||
33 | { | |||
34 | size_t dataSize = (size_t)gmsh->dataSize; | |||
35 | size_t size = count * dataSize; | |||
36 | PetscErrorCode ierr; | |||
37 | ||||
38 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 38; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
39 | if (gmsh->slen < size) { | |||
40 | ierr = PetscFree(gmsh->sbuf)((*PetscTrFree)((void*)(gmsh->sbuf),40,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((gmsh->sbuf) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),40,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
41 | ierr = PetscMalloc(size, &gmsh->sbuf)((*PetscTrMalloc)((size),PETSC_FALSE,41,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(void**)(&gmsh->sbuf)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),41,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
42 | gmsh->slen = size; | |||
43 | } | |||
44 | *(void**)buf = size ? gmsh->sbuf : NULL((void*)0); | |||
45 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
46 | } | |||
47 | ||||
48 | static PetscErrorCode GmshRead(GmshFile *gmsh, void *buf, PetscInt count, PetscDataType dtype) | |||
49 | { | |||
50 | PetscErrorCode ierr; | |||
51 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 51; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
52 | ierr = PetscViewerRead(gmsh->viewer, buf, count, NULL((void*)0), dtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),52,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
53 | if (gmsh->byteSwap) {ierr = PetscByteSwap(buf, dtype, count);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),53,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
54 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
55 | } | |||
56 | ||||
57 | static PetscErrorCode GmshReadString(GmshFile *gmsh, char *buf, PetscInt count) | |||
58 | { | |||
59 | PetscErrorCode ierr; | |||
60 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 60; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
61 | ierr = PetscViewerRead(gmsh->viewer, buf, count, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),61,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
62 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
63 | } | |||
64 | ||||
65 | static PetscErrorCode GmshMatch(PETSC_UNUSED__attribute((unused)) GmshFile *gmsh, const char Section[], char line[PETSC_MAX_PATH_LEN4096], PetscBool *match) | |||
66 | { | |||
67 | PetscErrorCode ierr; | |||
68 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 68; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
69 | ierr = PetscStrcmp(line, Section, match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),69,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
70 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
71 | } | |||
72 | ||||
73 | static PetscErrorCode GmshExpect(GmshFile *gmsh, const char Section[], char line[PETSC_MAX_PATH_LEN4096]) | |||
74 | { | |||
75 | PetscBool match; | |||
76 | PetscErrorCode ierr; | |||
77 | ||||
78 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 78; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
79 | ierr = GmshMatch(gmsh, Section, line, &match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),79,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
80 | if (!match) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file, expecting %s",Section)return PetscError(((MPI_Comm)0x44000001),80,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file, expecting %s" ,Section); | |||
81 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
82 | } | |||
83 | ||||
84 | static PetscErrorCode GmshReadSection(GmshFile *gmsh, char line[PETSC_MAX_PATH_LEN4096]) | |||
85 | { | |||
86 | PetscBool match; | |||
87 | PetscErrorCode ierr; | |||
88 | ||||
89 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 89; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
90 | while (PETSC_TRUE) { | |||
91 | ierr = GmshReadString(gmsh, line, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),91,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
92 | ierr = GmshMatch(gmsh, "$Comments", line, &match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),92,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
93 | if (!match) break; | |||
94 | while (PETSC_TRUE) { | |||
95 | ierr = GmshReadString(gmsh, line, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),95,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
96 | ierr = GmshMatch(gmsh, "$EndComments", line, &match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),96,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
97 | if (match) break; | |||
98 | } | |||
99 | } | |||
100 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
101 | } | |||
102 | ||||
103 | static PetscErrorCode GmshReadEndSection(GmshFile *gmsh, const char EndSection[], char line[PETSC_MAX_PATH_LEN4096]) | |||
104 | { | |||
105 | PetscErrorCode ierr; | |||
106 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 106; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
107 | ierr = GmshReadString(gmsh, line, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),107,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
108 | ierr = GmshExpect(gmsh, EndSection, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),108,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
109 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
110 | } | |||
111 | ||||
112 | static PetscErrorCode GmshReadSize(GmshFile *gmsh, PetscInt *buf, PetscInt count) | |||
113 | { | |||
114 | PetscInt i; | |||
115 | size_t dataSize = (size_t)gmsh->dataSize; | |||
116 | PetscErrorCode ierr; | |||
117 | ||||
118 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 118; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
119 | if (dataSize == sizeof(PetscInt)) { | |||
120 | ierr = GmshRead(gmsh, buf, count, PETSC_INT);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),120,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
121 | } else if (dataSize == sizeof(int)) { | |||
122 | int *ibuf = NULL((void*)0); | |||
123 | ierr = GmshBufferSizeGet(gmsh, count, &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),123,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
124 | ierr = GmshRead(gmsh, ibuf, count, PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),124,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
125 | for (i = 0; i < count; ++i) buf[i] = (PetscInt)ibuf[i]; | |||
126 | } else if (dataSize == sizeof(long)) { | |||
127 | long *ibuf = NULL((void*)0); | |||
128 | ierr = GmshBufferSizeGet(gmsh, count, &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),128,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
129 | ierr = GmshRead(gmsh, ibuf, count, PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),129,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
130 | for (i = 0; i < count; ++i) buf[i] = (PetscInt)ibuf[i]; | |||
131 | } else if (dataSize == sizeof(PetscInt64)) { | |||
132 | PetscInt64 *ibuf = NULL((void*)0); | |||
133 | ierr = GmshBufferSizeGet(gmsh, count, &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),133,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
134 | ierr = GmshRead(gmsh, ibuf, count, PETSC_INT64);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
135 | for (i = 0; i < count; ++i) buf[i] = (PetscInt)ibuf[i]; | |||
136 | } | |||
137 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
138 | } | |||
139 | ||||
140 | static PetscErrorCode GmshReadInt(GmshFile *gmsh, int *buf, PetscInt count) | |||
141 | { | |||
142 | PetscErrorCode ierr; | |||
143 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 143; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
144 | ierr = GmshRead(gmsh, buf, count, PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),144,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
145 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
146 | } | |||
147 | ||||
148 | static PetscErrorCode GmshReadDouble(GmshFile *gmsh, double *buf, PetscInt count) | |||
149 | { | |||
150 | PetscErrorCode ierr; | |||
151 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 151; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
152 | ierr = GmshRead(gmsh, buf, count, PETSC_DOUBLE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),152,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
153 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
154 | } | |||
155 | ||||
156 | typedef struct { | |||
157 | PetscInt id; /* Entity number */ | |||
158 | PetscInt dim; /* Entity dimension */ | |||
159 | double bbox[6]; /* Bounding box */ | |||
160 | PetscInt numTags; /* Size of tag array */ | |||
161 | int tags[4]; /* Tag array */ | |||
162 | } GmshEntity; | |||
163 | ||||
164 | typedef struct { | |||
165 | GmshEntity *entity[4]; | |||
166 | PetscHMapI entityMap[4]; | |||
167 | } GmshEntities; | |||
168 | ||||
169 | static PetscErrorCode GmshEntitiesCreate(PetscInt count[4], GmshEntities **entities) | |||
170 | { | |||
171 | PetscInt dim; | |||
172 | PetscErrorCode ierr; | |||
173 | ||||
174 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 174; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
175 | ierr = PetscNew(entities)PetscMallocA(1,PETSC_TRUE,175,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(1)*sizeof(**((entities))),((entities)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),175,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
176 | for (dim = 0; dim < 4; ++dim) { | |||
177 | ierr = PetscCalloc1(count[dim], &(*entities)->entity[dim])PetscMallocA(1,PETSC_TRUE,177,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(count[dim])*sizeof(**(&(*entities)->entity[dim ])),(&(*entities)->entity[dim]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),177,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
178 | ierr = PetscHMapICreate(&(*entities)->entityMap[dim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),178,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
179 | } | |||
180 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
181 | } | |||
182 | ||||
183 | static PetscErrorCode GmshEntitiesAdd(GmshEntities *entities, PetscInt index, PetscInt dim, PetscInt eid, GmshEntity** entity) | |||
184 | { | |||
185 | PetscErrorCode ierr; | |||
186 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 186; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
187 | ierr = PetscHMapISet(entities->entityMap[dim], eid, index);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),187,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
188 | entities->entity[dim][index].dim = dim; | |||
189 | entities->entity[dim][index].id = eid; | |||
190 | if (entity) *entity = &entities->entity[dim][index]; | |||
191 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
192 | } | |||
193 | ||||
194 | static PetscErrorCode GmshEntitiesGet(GmshEntities *entities, PetscInt dim, PetscInt eid, GmshEntity** entity) | |||
195 | { | |||
196 | PetscInt index; | |||
197 | PetscErrorCode ierr; | |||
198 | ||||
199 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 199; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
200 | ierr = PetscHMapIGet(entities->entityMap[dim], eid, &index);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),200,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
201 | *entity = &entities->entity[dim][index]; | |||
202 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
203 | } | |||
204 | ||||
205 | static PetscErrorCode GmshEntitiesDestroy(GmshEntities **entities) | |||
206 | { | |||
207 | PetscInt dim; | |||
208 | PetscErrorCode ierr; | |||
209 | ||||
210 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 210; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
211 | if (!*entities) PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
212 | for (dim = 0; dim < 4; ++dim) { | |||
213 | ierr = PetscFree((*entities)->entity[dim])((*PetscTrFree)((void*)((*entities)->entity[dim]),213,__func__ ,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c") || (((*entities)->entity[dim]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),213,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
214 | ierr = PetscHMapIDestroy(&(*entities)->entityMap[dim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),214,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
215 | } | |||
216 | ierr = PetscFree((*entities))((*PetscTrFree)((void*)((*entities)),216,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || (((*entities)) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),216,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
217 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
218 | } | |||
219 | ||||
220 | typedef struct { | |||
221 | PetscInt id; /* Entity number */ | |||
222 | PetscInt dim; /* Entity dimension */ | |||
223 | PetscInt cellType; /* Cell type */ | |||
224 | PetscInt numNodes; /* Size of node array */ | |||
225 | PetscInt nodes[8]; /* Node array */ | |||
226 | PetscInt numTags; /* Size of tag array */ | |||
227 | int tags[4]; /* Tag array */ | |||
228 | } GmshElement; | |||
229 | ||||
230 | static PetscErrorCode DMPlexCreateGmsh_ReadNodes_v22(GmshFile *gmsh, int shift, PetscInt *numVertices, double **gmsh_nodes) | |||
231 | { | |||
232 | PetscViewer viewer = gmsh->viewer; | |||
233 | PetscBool byteSwap = gmsh->byteSwap; | |||
234 | char line[PETSC_MAX_PATH_LEN4096]; | |||
235 | int v, num, nid, snum; | |||
236 | double *coordinates; | |||
237 | PetscErrorCode ierr; | |||
238 | ||||
239 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 239; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
240 | ierr = PetscViewerRead(viewer, line, 1, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),240,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
241 | snum = sscanf(line, "%d", &num); | |||
242 | if (snum != 1) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),242,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
243 | ierr = PetscMalloc1(num*3, &coordinates)PetscMallocA(1,PETSC_FALSE,243,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(num*3)*sizeof(**(&coordinates)),(&coordinates ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),243,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
244 | *numVertices = num; | |||
245 | *gmsh_nodes = coordinates; | |||
246 | for (v = 0; v < num; ++v) { | |||
247 | double *xyz = coordinates + v*3; | |||
248 | ierr = PetscViewerRead(viewer, &nid, 1, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),248,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
249 | if (byteSwap) {ierr = PetscByteSwap(&nid, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),249,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
250 | if (nid != v+shift) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unexpected node number %d should be %d", nid, v+shift)return PetscError(((MPI_Comm)0x44000001),250,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unexpected node number %d should be %d" ,nid,v+shift); | |||
251 | ierr = PetscViewerRead(viewer, xyz, 3, NULL((void*)0), PETSC_DOUBLE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),251,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
252 | if (byteSwap) {ierr = PetscByteSwap(xyz, PETSC_DOUBLE, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),252,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
253 | } | |||
254 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
255 | } | |||
256 | ||||
257 | /* Gmsh elements can be of any dimension/co-dimension, so we need to traverse the | |||
258 | file contents multiple times to figure out the true number of cells and facets | |||
259 | in the given mesh. To make this more efficient we read the file contents only | |||
260 | once and store them in memory, while determining the true number of cells. */ | |||
261 | static PetscErrorCode DMPlexCreateGmsh_ReadElements_v22(GmshFile* gmsh, PETSC_UNUSED__attribute((unused)) int shift, PetscInt *numCells, GmshElement **gmsh_elems) | |||
262 | { | |||
263 | PetscViewer viewer = gmsh->viewer; | |||
264 | PetscBool binary = gmsh->binary; | |||
265 | PetscBool byteSwap = gmsh->byteSwap; | |||
266 | char line[PETSC_MAX_PATH_LEN4096]; | |||
267 | GmshElement *elements; | |||
268 | int i, c, p, num, ibuf[1+4+512], snum; | |||
269 | int cellType, dim, numNodes, numNodesIgnore, numElem, numTags; | |||
270 | PetscErrorCode ierr; | |||
271 | ||||
272 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 272; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
273 | ierr = PetscViewerRead(viewer, line, 1, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),273,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);; | |||
274 | snum = sscanf(line, "%d", &num); | |||
275 | if (snum != 1) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),275,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
276 | ierr = PetscMalloc1(num, &elements)PetscMallocA(1,PETSC_FALSE,276,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(num)*sizeof(**(&elements)),(&elements));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),276,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
277 | *numCells = num; | |||
278 | *gmsh_elems = elements; | |||
279 | for (c = 0; c < num;) { | |||
280 | ierr = PetscViewerRead(viewer, ibuf, 3, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),280,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
281 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),281,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
282 | if (binary) { | |||
283 | cellType = ibuf[0]; | |||
284 | numElem = ibuf[1]; | |||
285 | numTags = ibuf[2]; | |||
286 | } else { | |||
287 | elements[c].id = ibuf[0]; | |||
288 | cellType = ibuf[1]; | |||
289 | numTags = ibuf[2]; | |||
290 | numElem = 1; | |||
291 | } | |||
292 | /* http://gmsh.info/doc/texinfo/gmsh.html#MSH-ASCII-file-format */ | |||
293 | numNodesIgnore = 0; | |||
294 | switch (cellType) { | |||
295 | case 1: /* 2-node line */ | |||
296 | dim = 1; | |||
297 | numNodes = 2; | |||
298 | break; | |||
299 | case 2: /* 3-node triangle */ | |||
300 | dim = 2; | |||
301 | numNodes = 3; | |||
302 | break; | |||
303 | case 3: /* 4-node quadrangle */ | |||
304 | dim = 2; | |||
305 | numNodes = 4; | |||
306 | break; | |||
307 | case 4: /* 4-node tetrahedron */ | |||
308 | dim = 3; | |||
309 | numNodes = 4; | |||
310 | break; | |||
311 | case 5: /* 8-node hexahedron */ | |||
312 | dim = 3; | |||
313 | numNodes = 8; | |||
314 | break; | |||
315 | case 6: /* 6-node wedge */ | |||
316 | dim = 3; | |||
317 | numNodes = 6; | |||
318 | break; | |||
319 | case 8: /* 3-node 2nd order line */ | |||
320 | dim = 1; | |||
321 | numNodes = 2; | |||
322 | numNodesIgnore = 1; | |||
323 | break; | |||
324 | case 9: /* 6-node 2nd order triangle */ | |||
325 | dim = 2; | |||
326 | numNodes = 3; | |||
327 | numNodesIgnore = 3; | |||
328 | break; | |||
329 | case 13: /* 18-node 2nd wedge */ | |||
330 | dim = 3; | |||
331 | numNodes = 6; | |||
332 | numNodesIgnore = 12; | |||
333 | break; | |||
334 | case 15: /* 1-node vertex */ | |||
335 | dim = 0; | |||
336 | numNodes = 1; | |||
337 | break; | |||
338 | case 7: /* 5-node pyramid */ | |||
339 | case 10: /* 9-node 2nd order quadrangle */ | |||
340 | case 11: /* 10-node 2nd order tetrahedron */ | |||
341 | case 12: /* 27-node 2nd order hexhedron */ | |||
342 | case 14: /* 14-node 2nd order pyramid */ | |||
343 | default: | |||
344 | SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unsupported Gmsh element type %d", cellType)return PetscError(((MPI_Comm)0x44000001),344,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unsupported Gmsh element type %d",cellType ); | |||
345 | } | |||
346 | if (binary) { | |||
347 | const int nint = 1 + numTags + numNodes + numNodesIgnore; | |||
348 | /* Loop over element blocks */ | |||
349 | for (i = 0; i < numElem; ++i, ++c) { | |||
350 | ierr = PetscViewerRead(viewer, ibuf, nint, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),350,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
351 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, nint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),351,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
352 | elements[c].dim = dim; | |||
353 | elements[c].numNodes = numNodes; | |||
354 | elements[c].numTags = numTags; | |||
355 | elements[c].id = ibuf[0]; | |||
356 | elements[c].cellType = cellType; | |||
357 | for (p = 0; p < numTags; p++) elements[c].tags[p] = ibuf[1 + p]; | |||
358 | for (p = 0; p < numNodes; p++) elements[c].nodes[p] = ibuf[1 + numTags + p]; | |||
359 | } | |||
360 | } else { | |||
361 | const int nint = numTags + numNodes + numNodesIgnore; | |||
362 | elements[c].dim = dim; | |||
363 | elements[c].numNodes = numNodes; | |||
364 | elements[c].numTags = numTags; | |||
365 | elements[c].cellType = cellType; | |||
366 | ierr = PetscViewerRead(viewer, ibuf, nint, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),366,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
367 | for (p = 0; p < numTags; p++) elements[c].tags[p] = ibuf[p]; | |||
368 | for (p = 0; p < numNodes; p++) elements[c].nodes[p] = ibuf[numTags + p]; | |||
369 | c++; | |||
370 | } | |||
371 | } | |||
372 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
373 | } | |||
374 | ||||
375 | /* | |||
376 | $Entities | |||
377 | numPoints(unsigned long) numCurves(unsigned long) | |||
378 | numSurfaces(unsigned long) numVolumes(unsigned long) | |||
379 | // points | |||
380 | tag(int) boxMinX(double) boxMinY(double) boxMinZ(double) | |||
381 | boxMaxX(double) boxMaxY(double) boxMaxZ(double) | |||
382 | numPhysicals(unsigned long) phyisicalTag[...](int) | |||
383 | ... | |||
384 | // curves | |||
385 | tag(int) boxMinX(double) boxMinY(double) boxMinZ(double) | |||
386 | boxMaxX(double) boxMaxY(double) boxMaxZ(double) | |||
387 | numPhysicals(unsigned long) physicalTag[...](int) | |||
388 | numBREPVert(unsigned long) tagBREPVert[...](int) | |||
389 | ... | |||
390 | // surfaces | |||
391 | tag(int) boxMinX(double) boxMinY(double) boxMinZ(double) | |||
392 | boxMaxX(double) boxMaxY(double) boxMaxZ(double) | |||
393 | numPhysicals(unsigned long) physicalTag[...](int) | |||
394 | numBREPCurve(unsigned long) tagBREPCurve[...](int) | |||
395 | ... | |||
396 | // volumes | |||
397 | tag(int) boxMinX(double) boxMinY(double) boxMinZ(double) | |||
398 | boxMaxX(double) boxMaxY(double) boxMaxZ(double) | |||
399 | numPhysicals(unsigned long) physicalTag[...](int) | |||
400 | numBREPSurfaces(unsigned long) tagBREPSurfaces[...](int) | |||
401 | ... | |||
402 | $EndEntities | |||
403 | */ | |||
404 | static PetscErrorCode DMPlexCreateGmsh_ReadEntities_v40(GmshFile *gmsh, GmshEntities **entities) | |||
405 | { | |||
406 | PetscViewer viewer = gmsh->viewer; | |||
407 | PetscBool byteSwap = gmsh->byteSwap; | |||
408 | long index, num, lbuf[4]; | |||
409 | int dim, eid, numTags, *ibuf, t; | |||
410 | PetscInt count[4], i; | |||
411 | GmshEntity *entity = NULL((void*)0); | |||
412 | PetscErrorCode ierr; | |||
413 | ||||
414 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 414; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
415 | ierr = PetscViewerRead(viewer, lbuf, 4, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),415,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
416 | if (byteSwap) {ierr = PetscByteSwap(lbuf, PETSC_LONG, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),416,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
417 | for (i = 0; i < 4; ++i) count[i] = lbuf[i]; | |||
418 | ierr = GmshEntitiesCreate(count, entities);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),418,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
419 | for (dim = 0; dim < 4; ++dim) { | |||
420 | for (index = 0; index < count[dim]; ++index) { | |||
421 | ierr = PetscViewerRead(viewer, &eid, 1, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),421,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
422 | if (byteSwap) {ierr = PetscByteSwap(&eid, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),422,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
423 | ierr = GmshEntitiesAdd(*entities, (PetscInt)index, dim, eid, &entity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),423,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
424 | ierr = PetscViewerRead(viewer, entity->bbox, 6, NULL((void*)0), PETSC_DOUBLE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),424,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
425 | if (byteSwap) {ierr = PetscByteSwap(entity->bbox, PETSC_DOUBLE, 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),425,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
426 | ierr = PetscViewerRead(viewer, &num, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),426,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
427 | if (byteSwap) {ierr = PetscByteSwap(&num, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),427,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
428 | ierr = GmshBufferGet(gmsh, num, sizeof(int), &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),428,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
429 | ierr = PetscViewerRead(viewer, ibuf, num, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),429,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
430 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, num);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),430,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
431 | entity->numTags = numTags = (int) PetscMin(num, 4)(((num)<(4)) ? (num) : (4)); | |||
432 | for (t = 0; t < numTags; ++t) entity->tags[t] = ibuf[t]; | |||
433 | if (dim == 0) continue; | |||
434 | ierr = PetscViewerRead(viewer, &num, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),434,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
435 | if (byteSwap) {ierr = PetscByteSwap(&num, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),435,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
436 | ierr = GmshBufferGet(gmsh, num, sizeof(int), &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),436,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
437 | ierr = PetscViewerRead(viewer, ibuf, num, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),437,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
438 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, num);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),438,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
439 | } | |||
440 | } | |||
441 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
442 | } | |||
443 | ||||
444 | /* | |||
445 | $Nodes | |||
446 | numEntityBlocks(unsigned long) numNodes(unsigned long) | |||
447 | tagEntity(int) dimEntity(int) typeNode(int) numNodes(unsigned long) | |||
448 | tag(int) x(double) y(double) z(double) | |||
449 | ... | |||
450 | ... | |||
451 | $EndNodes | |||
452 | */ | |||
453 | static PetscErrorCode DMPlexCreateGmsh_ReadNodes_v40(GmshFile *gmsh, int shift, PetscInt *numVertices, double **gmsh_nodes) | |||
454 | { | |||
455 | PetscViewer viewer = gmsh->viewer; | |||
456 | PetscBool byteSwap = gmsh->byteSwap; | |||
457 | long block, node, v, numEntityBlocks, numTotalNodes, numNodes; | |||
458 | int info[3], nid; | |||
459 | double *coordinates; | |||
460 | char *cbuf; | |||
461 | PetscErrorCode ierr; | |||
462 | ||||
463 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 463; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
464 | ierr = PetscViewerRead(viewer, &numEntityBlocks, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),464,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
465 | if (byteSwap) {ierr = PetscByteSwap(&numEntityBlocks, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),465,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
466 | ierr = PetscViewerRead(viewer, &numTotalNodes, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),466,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
467 | if (byteSwap) {ierr = PetscByteSwap(&numTotalNodes, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),467,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
468 | ierr = PetscMalloc1(numTotalNodes*3, &coordinates)PetscMallocA(1,PETSC_FALSE,468,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numTotalNodes*3)*sizeof(**(&coordinates)),(& coordinates));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),468,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
469 | *numVertices = numTotalNodes; | |||
470 | *gmsh_nodes = coordinates; | |||
471 | for (v = 0, block = 0; block < numEntityBlocks; ++block) { | |||
472 | ierr = PetscViewerRead(viewer, info, 3, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),472,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
473 | ierr = PetscViewerRead(viewer, &numNodes, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),473,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
474 | if (byteSwap) {ierr = PetscByteSwap(&numNodes, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),474,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
475 | if (gmsh->binary) { | |||
476 | int nbytes = sizeof(int) + 3*sizeof(double); | |||
477 | ierr = GmshBufferGet(gmsh, numNodes, nbytes, &cbuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),477,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
478 | ierr = PetscViewerRead(viewer, cbuf, numNodes*nbytes, NULL((void*)0), PETSC_CHAR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),478,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
479 | for (node = 0; node < numNodes; ++node, ++v) { | |||
480 | char *cnid = cbuf + node*nbytes, *cxyz = cnid + sizeof(int); | |||
481 | double *xyz = coordinates + v*3; | |||
482 | if (!PetscBinaryBigEndian()) {ierr = PetscByteSwap(cnid, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),482,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
483 | if (!PetscBinaryBigEndian()) {ierr = PetscByteSwap(cxyz, PETSC_DOUBLE, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),483,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
484 | ierr = PetscMemcpy(&nid, cnid, sizeof(int));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),484,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
485 | ierr = PetscMemcpy(xyz, cxyz, 3*sizeof(double));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),485,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
486 | if (byteSwap) {ierr = PetscByteSwap(&nid, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),486,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
487 | if (byteSwap) {ierr = PetscByteSwap(xyz, PETSC_DOUBLE, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),487,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
488 | if (nid != v+shift) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unexpected node number %d should be %d", nid, v+shift)return PetscError(((MPI_Comm)0x44000001),488,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unexpected node number %d should be %d" ,nid,v+shift); | |||
489 | } | |||
490 | } else { | |||
491 | for (node = 0; node < numNodes; ++node, ++v) { | |||
492 | double *xyz = coordinates + v*3; | |||
493 | ierr = PetscViewerRead(viewer, &nid, 1, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),493,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
494 | if (byteSwap) {ierr = PetscByteSwap(&nid, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),494,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
495 | if (nid != v+shift) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unexpected node number %d should be %d", nid, v+shift)return PetscError(((MPI_Comm)0x44000001),495,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unexpected node number %d should be %d" ,nid,v+shift); | |||
496 | ierr = PetscViewerRead(viewer, xyz, 3, NULL((void*)0), PETSC_DOUBLE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),496,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
497 | if (byteSwap) {ierr = PetscByteSwap(xyz, PETSC_DOUBLE, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),497,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
498 | } | |||
499 | } | |||
500 | } | |||
501 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
502 | } | |||
503 | ||||
504 | /* | |||
505 | $Elements | |||
506 | numEntityBlocks(unsigned long) numElements(unsigned long) | |||
507 | tagEntity(int) dimEntity(int) typeEle(int) numElements(unsigned long) | |||
508 | tag(int) numVert[...](int) | |||
509 | ... | |||
510 | ... | |||
511 | $EndElements | |||
512 | */ | |||
513 | static PetscErrorCode DMPlexCreateGmsh_ReadElements_v40(GmshFile *gmsh, PETSC_UNUSED__attribute((unused)) int shift, GmshEntities *entities, PetscInt *numCells, GmshElement **gmsh_elems) | |||
514 | { | |||
515 | PetscViewer viewer = gmsh->viewer; | |||
516 | PetscBool byteSwap = gmsh->byteSwap; | |||
517 | long c, block, numEntityBlocks, numTotalElements, elem, numElements; | |||
518 | int p, info[3], *ibuf = NULL((void*)0); | |||
519 | int eid, dim, numTags, *tags, cellType, numNodes; | |||
520 | GmshEntity *entity = NULL((void*)0); | |||
521 | GmshElement *elements; | |||
522 | PetscErrorCode ierr; | |||
523 | ||||
524 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 524; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
525 | ierr = PetscViewerRead(viewer, &numEntityBlocks, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),525,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
526 | if (byteSwap) {ierr = PetscByteSwap(&numEntityBlocks, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),526,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
527 | ierr = PetscViewerRead(viewer, &numTotalElements, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),527,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
528 | if (byteSwap) {ierr = PetscByteSwap(&numTotalElements, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),528,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
529 | ierr = PetscCalloc1(numTotalElements, &elements)PetscMallocA(1,PETSC_TRUE,529,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numTotalElements)*sizeof(**(&elements)),(&elements ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),529,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
530 | *numCells = numTotalElements; | |||
531 | *gmsh_elems = elements; | |||
532 | for (c = 0, block = 0; block < numEntityBlocks; ++block) { | |||
533 | ierr = PetscViewerRead(viewer, info, 3, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),533,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
534 | if (byteSwap) {ierr = PetscByteSwap(info, PETSC_ENUM, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),534,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
535 | eid = info[0]; dim = info[1]; cellType = info[2]; | |||
536 | ierr = GmshEntitiesGet(entities, dim, eid, &entity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),536,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
537 | numTags = entity->numTags; | |||
538 | tags = entity->tags; | |||
539 | switch (cellType) { | |||
540 | case 1: /* 2-node line */ | |||
541 | numNodes = 2; | |||
542 | break; | |||
543 | case 2: /* 3-node triangle */ | |||
544 | numNodes = 3; | |||
545 | break; | |||
546 | case 3: /* 4-node quadrangle */ | |||
547 | numNodes = 4; | |||
548 | break; | |||
549 | case 4: /* 4-node tetrahedron */ | |||
550 | numNodes = 4; | |||
551 | break; | |||
552 | case 5: /* 8-node hexahedron */ | |||
553 | numNodes = 8; | |||
554 | break; | |||
555 | case 6: /* 6-node wedge */ | |||
556 | numNodes = 6; | |||
557 | break; | |||
558 | case 15: /* 1-node vertex */ | |||
559 | numNodes = 1; | |||
560 | break; | |||
561 | default: | |||
562 | SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unsupported Gmsh element type %d", cellType)return PetscError(((MPI_Comm)0x44000001),562,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unsupported Gmsh element type %d",cellType ); | |||
563 | } | |||
564 | ierr = PetscViewerRead(viewer, &numElements, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),564,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
565 | if (byteSwap) {ierr = PetscByteSwap(&numElements, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),565,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
566 | ierr = GmshBufferGet(gmsh, (1+numNodes)*numElements, sizeof(int), &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),566,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
567 | ierr = PetscViewerRead(viewer, ibuf, (1+numNodes)*numElements, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),567,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
568 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, (1+numNodes)*numElements);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),568,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
569 | for (elem = 0; elem < numElements; ++elem, ++c) { | |||
570 | int *id = ibuf + elem*(1+numNodes), *nodes = id + 1; | |||
571 | GmshElement *element = elements + c; | |||
572 | element->dim = dim; | |||
573 | element->cellType = cellType; | |||
574 | element->numNodes = numNodes; | |||
575 | element->numTags = numTags; | |||
576 | element->id = id[0]; | |||
577 | for (p = 0; p < numNodes; p++) element->nodes[p] = nodes[p]; | |||
578 | for (p = 0; p < numTags; p++) element->tags[p] = tags[p]; | |||
579 | } | |||
580 | } | |||
581 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
582 | } | |||
583 | ||||
584 | static PetscErrorCode DMPlexCreateGmsh_ReadPeriodic_v40(GmshFile *gmsh, int shift, PetscInt slaveMap[], PetscBT bt) | |||
585 | { | |||
586 | PetscViewer viewer = gmsh->viewer; | |||
587 | int fileFormat = gmsh->fileFormat; | |||
588 | PetscBool binary = gmsh->binary; | |||
589 | PetscBool byteSwap = gmsh->byteSwap; | |||
590 | int numPeriodic, snum, i; | |||
591 | char line[PETSC_MAX_PATH_LEN4096]; | |||
592 | PetscErrorCode ierr; | |||
593 | ||||
594 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 594; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
595 | if (fileFormat == 22 || !binary) { | |||
596 | ierr = PetscViewerRead(viewer, line, 1, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),596,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
597 | snum = sscanf(line, "%d", &numPeriodic); | |||
598 | if (snum != 1) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),598,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
599 | } else { | |||
600 | ierr = PetscViewerRead(viewer, &numPeriodic, 1, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),600,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
601 | if (byteSwap) {ierr = PetscByteSwap(&numPeriodic, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),601,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
602 | } | |||
603 | for (i = 0; i < numPeriodic; i++) { | |||
604 | int ibuf[3], slaveDim = -1, slaveTag = -1, masterTag = -1, slaveNode, masterNode; | |||
605 | long j, nNodes; | |||
606 | double affine[16]; | |||
607 | ||||
608 | if (fileFormat == 22 || !binary) { | |||
609 | ierr = PetscViewerRead(viewer, line, 3, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),609,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
610 | snum = sscanf(line, "%d %d %d", &slaveDim, &slaveTag, &masterTag); | |||
611 | if (snum != 3) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),611,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
612 | } else { | |||
613 | ierr = PetscViewerRead(viewer, ibuf, 3, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),613,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
614 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),614,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
615 | slaveDim = ibuf[0]; slaveTag = ibuf[1]; masterTag = ibuf[2]; | |||
616 | } | |||
617 | (void)slaveDim; (void)slaveTag; (void)masterTag; /* unused */ | |||
618 | ||||
619 | if (fileFormat == 22 || !binary) { | |||
620 | ierr = PetscViewerRead(viewer, line, 1, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),620,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
621 | snum = sscanf(line, "%ld", &nNodes); | |||
622 | if (snum != 1) { /* discard tranformation and try again */ | |||
623 | ierr = PetscViewerRead(viewer, line, -PETSC_MAX_PATH_LEN4096, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),623,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
624 | ierr = PetscViewerRead(viewer, line, 1, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),624,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
625 | snum = sscanf(line, "%ld", &nNodes); | |||
626 | if (snum != 1) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),626,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
627 | } | |||
628 | } else { | |||
629 | ierr = PetscViewerRead(viewer, &nNodes, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),629,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
630 | if (byteSwap) {ierr = PetscByteSwap(&nNodes, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),630,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
631 | if (nNodes == -1) { /* discard tranformation and try again */ | |||
632 | ierr = PetscViewerRead(viewer, affine, 16, NULL((void*)0), PETSC_DOUBLE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),632,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
633 | ierr = PetscViewerRead(viewer, &nNodes, 1, NULL((void*)0), PETSC_LONG);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),633,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
634 | if (byteSwap) {ierr = PetscByteSwap(&nNodes, PETSC_LONG, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),634,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
635 | } | |||
636 | } | |||
637 | ||||
638 | for (j = 0; j < nNodes; j++) { | |||
639 | if (fileFormat == 22 || !binary) { | |||
640 | ierr = PetscViewerRead(viewer, line, 2, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),640,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
641 | snum = sscanf(line, "%d %d", &slaveNode, &masterNode); | |||
642 | if (snum != 2) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),642,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
643 | } else { | |||
644 | ierr = PetscViewerRead(viewer, ibuf, 2, NULL((void*)0), PETSC_ENUM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),644,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
645 | if (byteSwap) {ierr = PetscByteSwap(ibuf, PETSC_ENUM, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),645,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
646 | slaveNode = ibuf[0]; masterNode = ibuf[1]; | |||
647 | } | |||
648 | slaveMap[slaveNode - shift] = masterNode - shift; | |||
649 | ierr = PetscBTSet(bt, slaveNode - shift);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),649,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
650 | ierr = PetscBTSet(bt, masterNode - shift);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),650,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
651 | } | |||
652 | } | |||
653 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
654 | } | |||
655 | ||||
656 | /* | |||
657 | $Entities | |||
658 | numPoints(size_t) numCurves(size_t) | |||
659 | numSurfaces(size_t) numVolumes(size_t) | |||
660 | pointTag(int) X(double) Y(double) Z(double) | |||
661 | numPhysicalTags(size_t) physicalTag(int) ... | |||
662 | ... | |||
663 | curveTag(int) minX(double) minY(double) minZ(double) | |||
664 | maxX(double) maxY(double) maxZ(double) | |||
665 | numPhysicalTags(size_t) physicalTag(int) ... | |||
666 | numBoundingPoints(size_t) pointTag(int) ... | |||
667 | ... | |||
668 | surfaceTag(int) minX(double) minY(double) minZ(double) | |||
669 | maxX(double) maxY(double) maxZ(double) | |||
670 | numPhysicalTags(size_t) physicalTag(int) ... | |||
671 | numBoundingCurves(size_t) curveTag(int) ... | |||
672 | ... | |||
673 | volumeTag(int) minX(double) minY(double) minZ(double) | |||
674 | maxX(double) maxY(double) maxZ(double) | |||
675 | numPhysicalTags(size_t) physicalTag(int) ... | |||
676 | numBoundngSurfaces(size_t) surfaceTag(int) ... | |||
677 | ... | |||
678 | $EndEntities | |||
679 | */ | |||
680 | static PetscErrorCode DMPlexCreateGmsh_ReadEntities_v41(GmshFile *gmsh, GmshEntities **entities) | |||
681 | { | |||
682 | PetscInt count[4], index, numTags, i; | |||
683 | int dim, eid, *tags = NULL((void*)0); | |||
684 | GmshEntity *entity = NULL((void*)0); | |||
685 | PetscErrorCode ierr; | |||
686 | ||||
687 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 687; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
688 | ierr = GmshReadSize(gmsh, count, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),688,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
689 | ierr = GmshEntitiesCreate(count, entities);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),689,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
690 | for (dim = 0; dim < 4; ++dim) { | |||
691 | for (index = 0; index < count[dim]; ++index) { | |||
692 | ierr = GmshReadInt(gmsh, &eid, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),692,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
693 | ierr = GmshEntitiesAdd(*entities, (PetscInt)index, dim, eid, &entity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),693,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
694 | ierr = GmshReadDouble(gmsh, entity->bbox, (dim == 0) ? 3 : 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),694,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
695 | ierr = GmshReadSize(gmsh, &numTags, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),695,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
696 | ierr = GmshBufferGet(gmsh, numTags, sizeof(int), &tags);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),696,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
697 | ierr = GmshReadInt(gmsh, tags, numTags);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),697,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
698 | entity->numTags = PetscMin(numTags, 4)(((numTags)<(4)) ? (numTags) : (4)); | |||
699 | for (i = 0; i < entity->numTags; ++i) entity->tags[i] = tags[i]; | |||
700 | if (dim == 0) continue; | |||
701 | ierr = GmshReadSize(gmsh, &numTags, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),701,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
702 | ierr = GmshBufferGet(gmsh, numTags, sizeof(int), &tags);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),702,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
703 | ierr = GmshReadInt(gmsh, tags, numTags);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),703,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
704 | } | |||
705 | } | |||
706 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
707 | } | |||
708 | ||||
709 | /* | |||
710 | $Nodes | |||
711 | numEntityBlocks(size_t) numNodes(size_t) | |||
712 | minNodeTag(size_t) maxNodeTag(size_t) | |||
713 | entityDim(int) entityTag(int) parametric(int; 0 or 1) numNodesBlock(size_t) | |||
714 | nodeTag(size_t) | |||
715 | ... | |||
716 | x(double) y(double) z(double) | |||
717 | < u(double; if parametric and entityDim = 1 or entityDim = 2) > | |||
718 | < v(double; if parametric and entityDim = 2) > | |||
719 | ... | |||
720 | ... | |||
721 | $EndNodes | |||
722 | */ | |||
723 | static PetscErrorCode DMPlexCreateGmsh_ReadNodes_v41(GmshFile *gmsh, int shift, PetscInt *numVertices, double **gmsh_nodes) | |||
724 | { | |||
725 | int info[3]; | |||
726 | PetscInt sizes[4], numEntityBlocks, numNodes, numNodesBlock = 0, *nodeTag = NULL((void*)0), block, node, i; | |||
727 | double *coordinates; | |||
728 | PetscErrorCode ierr; | |||
729 | ||||
730 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 730; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
731 | ierr = GmshReadSize(gmsh, sizes, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),731,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
732 | numEntityBlocks = sizes[0]; numNodes = sizes[1]; | |||
733 | ierr = PetscMalloc1(numNodes*3, &coordinates)PetscMallocA(1,PETSC_FALSE,733,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numNodes*3)*sizeof(**(&coordinates)),(&coordinates ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),733,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
734 | *numVertices = numNodes; | |||
735 | *gmsh_nodes = coordinates; | |||
736 | for (block = 0, node = 0; block < numEntityBlocks; ++block, node += numNodesBlock) { | |||
737 | ierr = GmshReadInt(gmsh, info, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),737,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
738 | ierr = GmshReadSize(gmsh, &numNodesBlock, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),738,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
739 | ierr = GmshBufferGet(gmsh, numNodesBlock, sizeof(PetscInt), &nodeTag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),739,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
740 | ierr = GmshReadSize(gmsh, nodeTag, numNodesBlock);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),740,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
741 | for (i = 0; i < numNodesBlock; ++i) if (nodeTag[i] != node+i+shift) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unexpected node number %d should be %d", nodeTag[i], node+i+shift)return PetscError(((MPI_Comm)0x44000001),741,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unexpected node number %d should be %d" ,nodeTag[i],node+i+shift); | |||
742 | if (info[2] != 0) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Parametric coordinates not supported")return PetscError(((MPI_Comm)0x44000001),742,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Parametric coordinates not supported" ); | |||
743 | ierr = GmshReadDouble(gmsh, coordinates+node*3, numNodesBlock*3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),743,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
744 | } | |||
745 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
746 | } | |||
747 | ||||
748 | /* | |||
749 | $Elements | |||
750 | numEntityBlocks(size_t) numElements(size_t) | |||
751 | minElementTag(size_t) maxElementTag(size_t) | |||
752 | entityDim(int) entityTag(int) elementType(int; see below) numElementsBlock(size_t) | |||
753 | elementTag(size_t) nodeTag(size_t) ... | |||
754 | ... | |||
755 | ... | |||
756 | $EndElements | |||
757 | */ | |||
758 | static PetscErrorCode DMPlexCreateGmsh_ReadElements_v41(GmshFile *gmsh, PETSC_UNUSED__attribute((unused)) int shift, GmshEntities *entities, PetscInt *numCells, GmshElement **gmsh_elems) | |||
759 | { | |||
760 | int info[3], eid, dim, cellType, *tags; | |||
761 | PetscInt sizes[4], *ibuf = NULL((void*)0), numEntityBlocks, numElements, numBlockElements, numNodes, numTags, block, elem, c, p; | |||
762 | GmshEntity *entity = NULL((void*)0); | |||
763 | GmshElement *elements; | |||
764 | PetscErrorCode ierr; | |||
765 | ||||
766 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 766; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
767 | ierr = GmshReadSize(gmsh, sizes, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),767,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
768 | numEntityBlocks = sizes[0]; numElements = sizes[1]; | |||
769 | ierr = PetscCalloc1(numElements, &elements)PetscMallocA(1,PETSC_TRUE,769,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numElements)*sizeof(**(&elements)),(&elements ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),769,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
770 | *numCells = numElements; | |||
771 | *gmsh_elems = elements; | |||
772 | for (c = 0, block = 0; block < numEntityBlocks; ++block) { | |||
773 | ierr = GmshReadInt(gmsh, info, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),773,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
774 | dim = info[0]; eid = info[1]; cellType = info[2]; | |||
775 | ierr = GmshEntitiesGet(entities, dim, eid, &entity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),775,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
776 | numTags = entity->numTags; | |||
777 | tags = entity->tags; | |||
778 | switch (cellType) { | |||
779 | case 1: /* 2-node line */ | |||
780 | numNodes = 2; | |||
781 | break; | |||
782 | case 2: /* 3-node triangle */ | |||
783 | numNodes = 3; | |||
784 | break; | |||
785 | case 3: /* 4-node quadrangle */ | |||
786 | numNodes = 4; | |||
787 | break; | |||
788 | case 4: /* 4-node tetrahedron */ | |||
789 | numNodes = 4; | |||
790 | break; | |||
791 | case 5: /* 8-node hexahedron */ | |||
792 | numNodes = 8; | |||
793 | break; | |||
794 | case 6: /* 6-node wedge */ | |||
795 | numNodes = 6; | |||
796 | break; | |||
797 | case 15: /* 1-node vertex */ | |||
798 | numNodes = 1; | |||
799 | break; | |||
800 | default: | |||
801 | SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unsupported Gmsh element type %d", cellType)return PetscError(((MPI_Comm)0x44000001),801,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unsupported Gmsh element type %d",cellType ); | |||
802 | } | |||
803 | ierr = GmshReadSize(gmsh, &numBlockElements, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),803,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
804 | ierr = GmshBufferGet(gmsh, (1+numNodes)*numBlockElements, sizeof(PetscInt), &ibuf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),804,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
805 | ierr = GmshReadSize(gmsh, ibuf, (1+numNodes)*numBlockElements);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),805,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
806 | for (elem = 0; elem < numBlockElements; ++elem, ++c) { | |||
807 | GmshElement *element = elements + c; | |||
808 | PetscInt *id = ibuf + elem*(1+numNodes), *nodes = id + 1; | |||
809 | element->id = id[0]; | |||
810 | element->dim = dim; | |||
811 | element->cellType = cellType; | |||
812 | element->numNodes = numNodes; | |||
813 | element->numTags = numTags; | |||
814 | for (p = 0; p < numNodes; p++) element->nodes[p] = nodes[p]; | |||
815 | for (p = 0; p < numTags; p++) element->tags[p] = tags[p]; | |||
816 | } | |||
817 | } | |||
818 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
819 | } | |||
820 | ||||
821 | /* | |||
822 | $Periodic | |||
823 | numPeriodicLinks(size_t) | |||
824 | entityDim(int) entityTag(int) entityTagMaster(int) | |||
825 | numAffine(size_t) value(double) ... | |||
826 | numCorrespondingNodes(size_t) | |||
827 | nodeTag(size_t) nodeTagMaster(size_t) | |||
828 | ... | |||
829 | ... | |||
830 | $EndPeriodic | |||
831 | */ | |||
832 | static PetscErrorCode DMPlexCreateGmsh_ReadPeriodic_v41(GmshFile *gmsh, int shift, PetscInt slaveMap[], PetscBT bt) | |||
833 | { | |||
834 | int info[3]; | |||
835 | PetscInt numPeriodicLinks, numAffine, numCorrespondingNodes, *nodeTags = NULL((void*)0), link, node; | |||
| ||||
836 | double dbuf[16]; | |||
837 | PetscErrorCode ierr; | |||
838 | ||||
839 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 839; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
840 | ierr = GmshReadSize(gmsh, &numPeriodicLinks, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),840,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
841 | for (link = 0; link < numPeriodicLinks; ++link) { | |||
842 | ierr = GmshReadInt(gmsh, info, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),842,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
843 | ierr = GmshReadSize(gmsh, &numAffine, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),843,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
844 | ierr = GmshReadDouble(gmsh, dbuf, numAffine);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),844,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
845 | ierr = GmshReadSize(gmsh, &numCorrespondingNodes, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),845,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
846 | ierr = GmshBufferGet(gmsh, numCorrespondingNodes, sizeof(PetscInt), &nodeTags);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),846,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
847 | ierr = GmshReadSize(gmsh, nodeTags, numCorrespondingNodes*2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),847,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
848 | for (node = 0; node < numCorrespondingNodes; ++node) { | |||
849 | PetscInt slaveNode = nodeTags[node*2+0] - shift; | |||
| ||||
850 | PetscInt masterNode = nodeTags[node*2+1] - shift; | |||
851 | slaveMap[slaveNode] = masterNode; | |||
852 | ierr = PetscBTSet(bt, slaveNode);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),852,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
853 | ierr = PetscBTSet(bt, masterNode);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),853,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
854 | } | |||
855 | } | |||
856 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
857 | } | |||
858 | ||||
859 | /* | |||
860 | $MeshFormat // same as MSH version 2 | |||
861 | version(ASCII double; currently 4.1) | |||
862 | file-type(ASCII int; 0 for ASCII mode, 1 for binary mode) | |||
863 | data-size(ASCII int; sizeof(size_t)) | |||
864 | < int with value one; only in binary mode, to detect endianness > | |||
865 | $EndMeshFormat | |||
866 | */ | |||
867 | static PetscErrorCode DMPlexCreateGmsh_ReadMeshFormat(GmshFile *gmsh) | |||
868 | { | |||
869 | char line[PETSC_MAX_PATH_LEN4096]; | |||
870 | int snum, fileType, fileFormat, dataSize, checkEndian; | |||
871 | float version; | |||
872 | PetscErrorCode ierr; | |||
873 | ||||
874 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 874; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
875 | ierr = GmshReadString(gmsh, line, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),875,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
876 | snum = sscanf(line, "%f %d %d", &version, &fileType, &dataSize); | |||
877 | if (snum != 3) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse Gmsh file header: %s", line)return PetscError(((MPI_Comm)0x44000001),877,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unable to parse Gmsh file header: %s" ,line); | |||
878 | if (version < 2.2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f must be at least 2.2", (double)version)return PetscError(((MPI_Comm)0x44000001),878,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f must be at least 2.2" ,(double)version); | |||
879 | if ((int)version == 3) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f not supported", (double)version)return PetscError(((MPI_Comm)0x44000001),879,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f not supported" ,(double)version); | |||
880 | if (version > 4.1) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f must be at most 4.1", (double)version)return PetscError(((MPI_Comm)0x44000001),880,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f must be at most 4.1" ,(double)version); | |||
881 | if (gmsh->binary && !fileType) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Viewer is binary but Gmsh file is ASCII")return PetscError(((MPI_Comm)0x44000001),881,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Viewer is binary but Gmsh file is ASCII" ); | |||
882 | if (!gmsh->binary && fileType) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Viewer is ASCII but Gmsh file is binary")return PetscError(((MPI_Comm)0x44000001),882,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Viewer is ASCII but Gmsh file is binary" ); | |||
883 | fileFormat = (int)(version*10); /* XXX Should use (int)roundf(version*10) ? */ | |||
884 | if (fileFormat <= 40 && dataSize != sizeof(double)) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Data size %d is not valid for a Gmsh file", dataSize)return PetscError(((MPI_Comm)0x44000001),884,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Data size %d is not valid for a Gmsh file" ,dataSize); | |||
885 | if (fileFormat >= 41 && dataSize != sizeof(int) && dataSize != sizeof(PetscInt64)) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Data size %d is not valid for a Gmsh file", dataSize)return PetscError(((MPI_Comm)0x44000001),885,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Data size %d is not valid for a Gmsh file" ,dataSize); | |||
886 | gmsh->fileFormat = fileFormat; | |||
887 | gmsh->dataSize = dataSize; | |||
888 | gmsh->byteSwap = PETSC_FALSE; | |||
889 | if (gmsh->binary) { | |||
890 | ierr = GmshReadInt(gmsh, &checkEndian, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),890,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
891 | if (checkEndian != 1) { | |||
892 | ierr = PetscByteSwap(&checkEndian, PETSC_ENUM, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),892,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
893 | if (checkEndian != 1) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to detect endianness in Gmsh file header: %s", line)return PetscError(((MPI_Comm)0x44000001),893,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unable to detect endianness in Gmsh file header: %s" ,line); | |||
894 | gmsh->byteSwap = PETSC_TRUE; | |||
895 | } | |||
896 | } | |||
897 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
898 | } | |||
899 | ||||
900 | /* | |||
901 | PhysicalNames | |||
902 | numPhysicalNames(ASCII int) | |||
903 | dimension(ASCII int) physicalTag(ASCII int) "name"(127 characters max) | |||
904 | ... | |||
905 | $EndPhysicalNames | |||
906 | */ | |||
907 | static PetscErrorCode DMPlexCreateGmsh_ReadPhysicalNames(GmshFile *gmsh) | |||
908 | { | |||
909 | char line[PETSC_MAX_PATH_LEN4096], name[128+2], *p, *q; | |||
910 | int snum, numRegions, region, dim, tag; | |||
911 | PetscErrorCode ierr; | |||
912 | ||||
913 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 913; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
914 | ierr = GmshReadString(gmsh, line, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),914,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
915 | snum = sscanf(line, "%d", &numRegions); | |||
916 | if (snum != 1) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),916,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
917 | for (region = 0; region < numRegions; ++region) { | |||
918 | ierr = GmshReadString(gmsh, line, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),918,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
919 | snum = sscanf(line, "%d %d", &dim, &tag); | |||
920 | if (snum != 2) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),920,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
921 | ierr = GmshReadString(gmsh, line, -(PetscInt)sizeof(line));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),921,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
922 | ierr = PetscStrchr(line, '"', &p);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),922,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
923 | if (!p) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),923,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
924 | ierr = PetscStrrchr(line, '"', &q);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),924,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
925 | if (q == p) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "File is not a valid Gmsh file")return PetscError(((MPI_Comm)0x44000001),925,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"File is not a valid Gmsh file"); | |||
926 | ierr = PetscStrncpy(name, p+1, (size_t)(q-p-1));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),926,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
927 | } | |||
928 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
929 | } | |||
930 | ||||
931 | /*@C | |||
932 | DMPlexCreateGmshFromFile - Create a DMPlex mesh from a Gmsh file | |||
933 | ||||
934 | + comm - The MPI communicator | |||
935 | . filename - Name of the Gmsh file | |||
936 | - interpolate - Create faces and edges in the mesh | |||
937 | ||||
938 | Output Parameter: | |||
939 | . dm - The DM object representing the mesh | |||
940 | ||||
941 | Level: beginner | |||
942 | ||||
943 | .seealso: DMPlexCreateFromFile(), DMPlexCreateGmsh(), DMPlexCreate() | |||
944 | @*/ | |||
945 | PetscErrorCode DMPlexCreateGmshFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm) | |||
946 | { | |||
947 | PetscViewer viewer; | |||
948 | PetscMPIInt rank; | |||
949 | int fileType; | |||
950 | PetscViewerType vtype; | |||
951 | PetscErrorCode ierr; | |||
952 | ||||
953 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 953; petscstack->petscroutine [petscstack->currentsize] = PETSC_TRUE; petscstack->currentsize ++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0); ; } while (0); | |||
954 | ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),954,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
955 | ||||
956 | /* Determine Gmsh file type (ASCII or binary) from file header */ | |||
957 | if (!rank) { | |||
958 | GmshFile gmsh_, *gmsh = &gmsh_; | |||
959 | char line[PETSC_MAX_PATH_LEN4096]; | |||
960 | int snum; | |||
961 | float version; | |||
962 | ||||
963 | ierr = PetscArrayzero(gmsh,1)PetscMemzero(gmsh,(1)*sizeof(*(gmsh)));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),963,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
964 | ierr = PetscViewerCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &gmsh->viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),964,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
965 | ierr = PetscViewerSetType(gmsh->viewer, PETSCVIEWERASCII"ascii");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),965,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
966 | ierr = PetscViewerFileSetMode(gmsh->viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),966,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
967 | ierr = PetscViewerFileSetName(gmsh->viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),967,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
968 | /* Read only the first two lines of the Gmsh file */ | |||
969 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),969,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
970 | ierr = GmshExpect(gmsh, "$MeshFormat", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),970,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
971 | ierr = GmshReadString(gmsh, line, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),971,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
972 | snum = sscanf(line, "%f %d", &version, &fileType); | |||
973 | if (snum != 2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse Gmsh file header: %s", line)return PetscError(((MPI_Comm)0x44000001),973,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Unable to parse Gmsh file header: %s" ,line); | |||
974 | if (version < 2.2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f must be at least 2.2", (double)version)return PetscError(((MPI_Comm)0x44000001),974,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f must be at least 2.2" ,(double)version); | |||
975 | if ((int)version == 3) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f not supported", (double)version)return PetscError(((MPI_Comm)0x44000001),975,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f not supported" ,(double)version); | |||
976 | if (version > 4.1) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Gmsh file version %3.1f must be at most 4.1", (double)version)return PetscError(((MPI_Comm)0x44000001),976,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Gmsh file version %3.1f must be at most 4.1" ,(double)version); | |||
977 | ierr = PetscViewerDestroy(&gmsh->viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),977,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
978 | } | |||
979 | ierr = MPI_Bcast(&fileType, 1, MPI_INT, 0, comm)((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast ((&fileType),(1),(((MPI_Datatype)0x4c000405)),(0),(comm)) );CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),979,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
980 | vtype = (fileType == 0) ? PETSCVIEWERASCII"ascii" : PETSCVIEWERBINARY"binary"; | |||
981 | ||||
982 | /* Create appropriate viewer and build plex */ | |||
983 | ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),983,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
984 | ierr = PetscViewerSetType(viewer, vtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),984,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
985 | ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),985,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
986 | ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),986,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
987 | ierr = DMPlexCreateGmsh(comm, viewer, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),987,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
988 | ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),988,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
989 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
990 | } | |||
991 | ||||
992 | /*@ | |||
993 | DMPlexCreateGmsh - Create a DMPlex mesh from a Gmsh file viewer | |||
994 | ||||
995 | Collective | |||
996 | ||||
997 | Input Parameters: | |||
998 | + comm - The MPI communicator | |||
999 | . viewer - The Viewer associated with a Gmsh file | |||
1000 | - interpolate - Create faces and edges in the mesh | |||
1001 | ||||
1002 | Output Parameter: | |||
1003 | . dm - The DM object representing the mesh | |||
1004 | ||||
1005 | Note: http://gmsh.info/doc/texinfo/gmsh.html#MSH-file-format | |||
1006 | ||||
1007 | Level: beginner | |||
1008 | ||||
1009 | .seealso: DMPLEX, DMCreate() | |||
1010 | @*/ | |||
1011 | PetscErrorCode DMPlexCreateGmsh(MPI_Comm comm, PetscViewer viewer, PetscBool interpolate, DM *dm) | |||
1012 | { | |||
1013 | PetscViewer parentviewer = NULL((void*)0); | |||
1014 | double *coordsIn = NULL((void*)0); | |||
1015 | GmshEntities *entities = NULL((void*)0); | |||
1016 | GmshElement *gmsh_elem = NULL((void*)0); | |||
1017 | PetscSection coordSection; | |||
1018 | Vec coordinates; | |||
1019 | PetscBT periodicV = NULL((void*)0), periodicC = NULL((void*)0); | |||
1020 | PetscScalar *coords; | |||
1021 | PetscInt dim = 0, embedDim = -1, coordSize, c, v, d, cell, *periodicMap = NULL((void*)0), *periodicMapI = NULL((void*)0), *hybridMap = NULL((void*)0), cMax = PETSC_DETERMINE-1; | |||
1022 | PetscInt numVertices = 0, numCells = 0, trueNumCells = 0; | |||
1023 | int i, shift = 1; | |||
1024 | PetscMPIInt rank; | |||
1025 | PetscBool binary, zerobase = PETSC_FALSE, usemarker = PETSC_FALSE; | |||
1026 | PetscBool enable_hybrid = interpolate, periodic = PETSC_TRUE; | |||
1027 | PetscErrorCode ierr; | |||
1028 | ||||
1029 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c"; petscstack ->line[petscstack->currentsize] = 1029; petscstack-> petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1030 | ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1030,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1031 | ierr = PetscObjectOptionsBegin((PetscObject)viewer)0; do { PetscOptionItems PetscOptionsObjectBase; PetscOptionItems *PetscOptionsObject = &PetscOptionsObjectBase; PetscOptionsObject ->options = ((PetscObject)(PetscObject)viewer)->options ; for (PetscOptionsObject->count=(PetscOptionsPublish?-1:1 ); PetscOptionsObject->count<2; PetscOptionsObject-> count++) { PetscErrorCode _5_ierr = PetscObjectOptionsBegin_Private (PetscOptionsObject,(PetscObject)viewer);do {if (__builtin_expect (!!(_5_ierr),0)) return PetscError(((MPI_Comm)0x44000001),1031 ,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1031,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1032 | ierr = PetscOptionsHead(PetscOptionsObject,"DMPlex Gmsh options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1032,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1033 | ierr = PetscOptionsBool("-dm_plex_gmsh_hybrid", "Generate hybrid cell bounds", "DMPlexCreateGmsh", enable_hybrid, &enable_hybrid, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_gmsh_hybrid" ,"Generate hybrid cell bounds","DMPlexCreateGmsh",enable_hybrid ,&enable_hybrid,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1033,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1034 | ierr = PetscOptionsBool("-dm_plex_gmsh_periodic","Read Gmsh periodic section", "DMPlexCreateGmsh", periodic, &periodic, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_gmsh_periodic" ,"Read Gmsh periodic section","DMPlexCreateGmsh",periodic,& periodic,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1034,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1035 | ierr = PetscOptionsBool("-dm_plex_gmsh_use_marker", "Generate marker label", "DMPlexCreateGmsh", usemarker, &usemarker, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_gmsh_use_marker" ,"Generate marker label","DMPlexCreateGmsh",usemarker,&usemarker ,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1035,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1036 | ierr = PetscOptionsBool("-dm_plex_gmsh_zero_base", "Read Gmsh file with zero base indices", "DMPlexCreateGmsh", zerobase, &zerobase, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_gmsh_zero_base" ,"Read Gmsh file with zero base indices","DMPlexCreateGmsh",zerobase ,&zerobase,((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1036,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1037 | ierr = PetscOptionsBoundedInt("-dm_plex_gmsh_spacedim", "Embedding space dimension", "DMPlexCreateGmsh", embedDim, &embedDim, NULL,PETSC_DECIDE)PetscOptionsInt_Private(PetscOptionsObject,"-dm_plex_gmsh_spacedim" ,"Embedding space dimension","DMPlexCreateGmsh",embedDim,& embedDim,((void*)0),-1,2147483647);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1037,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1038 | ierr = PetscOptionsTail()0; do {if (PetscOptionsObject->count != 1) do { do { ; if ( petscstack && petscstack->currentsize > 0) { petscstack ->currentsize--; petscstack->function[petscstack->currentsize ] = 0; petscstack->file[petscstack->currentsize] = 0; petscstack ->line[petscstack->currentsize] = 0; petscstack->petscroutine [petscstack->currentsize] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)< (0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); return (0);} while (0);} while(0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1038,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1039 | ierr = PetscOptionsEnd()_5_ierr = PetscOptionsEnd_Private(PetscOptionsObject);do {if ( __builtin_expect(!!(_5_ierr),0)) return PetscError(((MPI_Comm )0x44000001),1039,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,_5_ierr,PETSC_ERROR_REPEAT," ");} while (0);}} while (0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1039,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1040 | if (zerobase) shift = 0; | |||
1041 | ||||
1042 | ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1042,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1043 | ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1043,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1044 | ierr = PetscLogEventBegin(DMPLEX_CreateGmsh,*dm,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_CreateGmsh].active) ? (*PetscLogPLB)((DMPLEX_CreateGmsh ),0,(PetscObject)(*dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1044,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1045 | ||||
1046 | ierr = PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERBINARY"binary", &binary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1046,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1047 | ||||
1048 | /* Binary viewers read on all ranks, get subviewer to read only in rank 0 */ | |||
1049 | if (binary) { | |||
1050 | parentviewer = viewer; | |||
1051 | ierr = PetscViewerGetSubViewer(parentviewer, PETSC_COMM_SELF((MPI_Comm)0x44000001), &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1051,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1052 | } | |||
1053 | ||||
1054 | if (!rank) { | |||
1055 | GmshFile gmsh_, *gmsh = &gmsh_; | |||
1056 | char line[PETSC_MAX_PATH_LEN4096]; | |||
1057 | PetscBool match; | |||
1058 | ||||
1059 | ierr = PetscArrayzero(gmsh,1)PetscMemzero(gmsh,(1)*sizeof(*(gmsh)));;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1059,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1060 | gmsh->viewer = viewer; | |||
1061 | gmsh->binary = binary; | |||
1062 | ||||
1063 | /* Read mesh format */ | |||
1064 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1064,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1065 | ierr = GmshExpect(gmsh, "$MeshFormat", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1065,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1066 | ierr = DMPlexCreateGmsh_ReadMeshFormat(gmsh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1066,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1067 | ierr = GmshReadEndSection(gmsh, "$EndMeshFormat", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1067,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1068 | ||||
1069 | /* OPTIONAL Read physical names */ | |||
1070 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1070,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1071 | ierr = GmshMatch(gmsh,"$PhysicalNames", line, &match);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1071,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1072 | if (match) { | |||
1073 | ierr = DMPlexCreateGmsh_ReadPhysicalNames(gmsh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1073,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1074 | ierr = GmshReadEndSection(gmsh, "$EndPhysicalNames", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1074,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1075 | /* Initial read for entity section */ | |||
1076 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1076,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1077 | } | |||
1078 | ||||
1079 | /* Read entities */ | |||
1080 | if (gmsh->fileFormat >= 40) { | |||
1081 | ierr = GmshExpect(gmsh, "$Entities", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1081,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1082 | switch (gmsh->fileFormat) { | |||
1083 | case 41: ierr = DMPlexCreateGmsh_ReadEntities_v41(gmsh, &entities);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1083,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1084 | default: ierr = DMPlexCreateGmsh_ReadEntities_v40(gmsh, &entities);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1084,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1085 | } | |||
1086 | ierr = GmshReadEndSection(gmsh, "$EndEntities", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1086,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1087 | /* Initial read for nodes section */ | |||
1088 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1088,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1089 | } | |||
1090 | ||||
1091 | /* Read nodes */ | |||
1092 | ierr = GmshExpect(gmsh, "$Nodes", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1092,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1093 | switch (gmsh->fileFormat) { | |||
1094 | case 41: ierr = DMPlexCreateGmsh_ReadNodes_v41(gmsh, shift, &numVertices, &coordsIn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1094,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1095 | case 40: ierr = DMPlexCreateGmsh_ReadNodes_v40(gmsh, shift, &numVertices, &coordsIn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1095,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1096 | default: ierr = DMPlexCreateGmsh_ReadNodes_v22(gmsh, shift, &numVertices, &coordsIn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1096,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1097 | } | |||
1098 | ierr = GmshReadEndSection(gmsh, "$EndNodes", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1098,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1099 | ||||
1100 | /* Read elements */ | |||
1101 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1101,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);; | |||
1102 | ierr = GmshExpect(gmsh, "$Elements", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1102,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1103 | switch (gmsh->fileFormat) { | |||
1104 | case 41: ierr = DMPlexCreateGmsh_ReadElements_v41(gmsh, shift, entities, &numCells, &gmsh_elem);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1104,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1105 | case 40: ierr = DMPlexCreateGmsh_ReadElements_v40(gmsh, shift, entities, &numCells, &gmsh_elem);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1105,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1106 | default: ierr = DMPlexCreateGmsh_ReadElements_v22(gmsh, shift, &numCells, &gmsh_elem);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1106,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1107 | } | |||
1108 | ierr = GmshReadEndSection(gmsh, "$EndElements", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1108,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1109 | ||||
1110 | /* OPTIONAL Read periodic section */ | |||
1111 | if (periodic) { | |||
1112 | ierr = GmshReadSection(gmsh, line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1112,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1113 | ierr = GmshMatch(gmsh, "$Periodic", line, &periodic);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1113,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1114 | } | |||
1115 | if (periodic) { | |||
1116 | PetscInt pVert, *periodicMapT, *aux; | |||
1117 | ||||
1118 | ierr = PetscMalloc1(numVertices, &periodicMapT)PetscMallocA(1,PETSC_FALSE,1118,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numVertices)*sizeof(**(&periodicMapT)),(&periodicMapT ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1118,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1119 | ierr = PetscBTCreate(numVertices, &periodicV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1119,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1120 | for (i = 0; i < numVertices; i++) periodicMapT[i] = i; | |||
1121 | ||||
1122 | ierr = GmshExpect(gmsh, "$Periodic", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1122,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1123 | switch (gmsh->fileFormat) { | |||
1124 | case 41: ierr = DMPlexCreateGmsh_ReadPeriodic_v41(gmsh, shift, periodicMapT, periodicV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1124,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1125 | default: ierr = DMPlexCreateGmsh_ReadPeriodic_v40(gmsh, shift, periodicMapT, periodicV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1125,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); break; | |||
1126 | } | |||
1127 | ierr = GmshReadEndSection(gmsh, "$EndPeriodic", line);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1127,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1128 | ||||
1129 | /* we may have slaves of slaves */ | |||
1130 | for (i = 0; i < numVertices; i++) { | |||
1131 | while (periodicMapT[periodicMapT[i]] != periodicMapT[i]) { | |||
1132 | periodicMapT[i] = periodicMapT[periodicMapT[i]]; | |||
1133 | } | |||
1134 | } | |||
1135 | /* periodicMap : from old to new numbering (periodic vertices excluded) | |||
1136 | periodicMapI: from new to old numbering */ | |||
1137 | ierr = PetscMalloc1(numVertices, &periodicMap)PetscMallocA(1,PETSC_FALSE,1137,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numVertices)*sizeof(**(&periodicMap)),(&periodicMap ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1137,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1138 | ierr = PetscMalloc1(numVertices, &periodicMapI)PetscMallocA(1,PETSC_FALSE,1138,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numVertices)*sizeof(**(&periodicMapI)),(&periodicMapI ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1138,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1139 | ierr = PetscMalloc1(numVertices, &aux)PetscMallocA(1,PETSC_FALSE,1139,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(numVertices)*sizeof(**(&aux)),(&aux));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1139,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1140 | for (i = 0, pVert = 0; i < numVertices; i++) { | |||
1141 | if (periodicMapT[i] != i) { | |||
1142 | pVert++; | |||
1143 | } else { | |||
1144 | aux[i] = i - pVert; | |||
1145 | periodicMapI[i - pVert] = i; | |||
1146 | } | |||
1147 | } | |||
1148 | for (i = 0 ; i < numVertices; i++) { | |||
1149 | periodicMap[i] = aux[periodicMapT[i]]; | |||
1150 | } | |||
1151 | ierr = PetscFree(periodicMapT)((*PetscTrFree)((void*)(periodicMapT),1151,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((periodicMapT) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1151,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1152 | ierr = PetscFree(aux)((*PetscTrFree)((void*)(aux),1152,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((aux) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1152,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1153 | /* remove periodic vertices */ | |||
1154 | numVertices = numVertices - pVert; | |||
1155 | } | |||
1156 | ||||
1157 | ierr = GmshEntitiesDestroy(&entities);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1157,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1158 | ierr = PetscFree(gmsh->wbuf)((*PetscTrFree)((void*)(gmsh->wbuf),1158,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((gmsh->wbuf) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1158,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1159 | ierr = PetscFree(gmsh->sbuf)((*PetscTrFree)((void*)(gmsh->sbuf),1159,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((gmsh->sbuf) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1159,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1160 | } | |||
1161 | ||||
1162 | if (parentviewer) { | |||
1163 | ierr = PetscViewerRestoreSubViewer(parentviewer, PETSC_COMM_SELF((MPI_Comm)0x44000001), &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1163,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1164 | } | |||
1165 | ||||
1166 | if (!rank) { | |||
1167 | PetscBool hybrid = PETSC_FALSE; | |||
1168 | PetscInt cellType = -1; | |||
1169 | ||||
1170 | for (trueNumCells = 0, c = 0; c < numCells; ++c) { | |||
1171 | if (gmsh_elem[c].dim > dim) {dim = gmsh_elem[c].dim; trueNumCells = 0; hybrid = PETSC_FALSE; cellType = -1;} | |||
1172 | if (gmsh_elem[c].dim < dim) continue; | |||
1173 | if (cellType == -1) cellType = gmsh_elem[c].cellType; | |||
1174 | /* different cell type indicate an hybrid mesh in PLEX */ | |||
1175 | if (cellType != gmsh_elem[c].cellType) hybrid = PETSC_TRUE; | |||
1176 | /* wedges always indicate an hybrid mesh in PLEX */ | |||
1177 | if (cellType == 6 || cellType == 13) hybrid = PETSC_TRUE; | |||
1178 | trueNumCells++; | |||
1179 | } | |||
1180 | /* Renumber cells for hybrid grids */ | |||
1181 | if (hybrid && enable_hybrid) { | |||
1182 | PetscInt hc1 = 0, hc2 = 0, *hybridCells1 = NULL((void*)0), *hybridCells2 = NULL((void*)0); | |||
1183 | PetscInt cell, tn, *tp; | |||
1184 | int n1 = 0,n2 = 0; | |||
1185 | ||||
1186 | ierr = PetscMalloc1(trueNumCells, &hybridCells1)PetscMallocA(1,PETSC_FALSE,1186,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(trueNumCells)*sizeof(**(&hybridCells1)),(&hybridCells1 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1186,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1187 | ierr = PetscMalloc1(trueNumCells, &hybridCells2)PetscMallocA(1,PETSC_FALSE,1187,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(trueNumCells)*sizeof(**(&hybridCells2)),(&hybridCells2 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1187,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1188 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1189 | if (gmsh_elem[c].dim == dim) { | |||
1190 | if (!n1) n1 = gmsh_elem[c].cellType; | |||
1191 | else if (!n2 && n1 != gmsh_elem[c].cellType) n2 = gmsh_elem[c].cellType; | |||
1192 | ||||
1193 | if (gmsh_elem[c].cellType == n1) hybridCells1[hc1++] = cell; | |||
1194 | else if (gmsh_elem[c].cellType == n2) hybridCells2[hc2++] = cell; | |||
1195 | else SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP, "Cannot handle more than 2 cell types")return PetscError(((MPI_Comm)0x44000001),1195,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Cannot handle more than 2 cell types" ); | |||
1196 | cell++; | |||
1197 | } | |||
1198 | } | |||
1199 | ||||
1200 | switch (n1) { | |||
1201 | case 2: /* triangles */ | |||
1202 | case 9: | |||
1203 | switch (n2) { | |||
1204 | case 0: /* single type mesh */ | |||
1205 | case 3: /* quads */ | |||
1206 | case 10: | |||
1207 | break; | |||
1208 | default: | |||
1209 | SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported cell types %d and %d",n1, n2)return PetscError(((MPI_Comm)0x44000001),1209,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Unsupported cell types %d and %d",n1 ,n2); | |||
1210 | } | |||
1211 | break; | |||
1212 | case 3: | |||
1213 | case 10: | |||
1214 | switch (n2) { | |||
1215 | case 0: /* single type mesh */ | |||
1216 | case 2: /* swap since we list simplices first */ | |||
1217 | case 9: | |||
1218 | tn = hc1; | |||
1219 | hc1 = hc2; | |||
1220 | hc2 = tn; | |||
1221 | ||||
1222 | tp = hybridCells1; | |||
1223 | hybridCells1 = hybridCells2; | |||
1224 | hybridCells2 = tp; | |||
1225 | break; | |||
1226 | default: | |||
1227 | SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported cell types %d and %d",n1, n2)return PetscError(((MPI_Comm)0x44000001),1227,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Unsupported cell types %d and %d",n1 ,n2); | |||
1228 | } | |||
1229 | break; | |||
1230 | case 4: /* tetrahedra */ | |||
1231 | case 11: | |||
1232 | switch (n2) { | |||
1233 | case 0: /* single type mesh */ | |||
1234 | case 6: /* wedges */ | |||
1235 | case 13: | |||
1236 | break; | |||
1237 | default: | |||
1238 | SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported cell types %d and %d",n1, n2)return PetscError(((MPI_Comm)0x44000001),1238,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Unsupported cell types %d and %d",n1 ,n2); | |||
1239 | } | |||
1240 | break; | |||
1241 | case 6: | |||
1242 | case 13: | |||
1243 | switch (n2) { | |||
1244 | case 0: /* single type mesh */ | |||
1245 | case 4: /* swap since we list simplices first */ | |||
1246 | case 11: | |||
1247 | tn = hc1; | |||
1248 | hc1 = hc2; | |||
1249 | hc2 = tn; | |||
1250 | ||||
1251 | tp = hybridCells1; | |||
1252 | hybridCells1 = hybridCells2; | |||
1253 | hybridCells2 = tp; | |||
1254 | break; | |||
1255 | default: | |||
1256 | SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported cell types %d and %d",n1, n2)return PetscError(((MPI_Comm)0x44000001),1256,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Unsupported cell types %d and %d",n1 ,n2); | |||
1257 | } | |||
1258 | break; | |||
1259 | default: | |||
1260 | SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported cell types %d and %d",n1, n2)return PetscError(((MPI_Comm)0x44000001),1260,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Unsupported cell types %d and %d",n1 ,n2); | |||
1261 | } | |||
1262 | cMax = hc1; | |||
1263 | ierr = PetscMalloc1(trueNumCells, &hybridMap)PetscMallocA(1,PETSC_FALSE,1263,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,(size_t)(trueNumCells)*sizeof(**(&hybridMap)),(&hybridMap ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1263,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1264 | for (cell = 0; cell < hc1; cell++) hybridMap[hybridCells1[cell]] = cell; | |||
1265 | for (cell = 0; cell < hc2; cell++) hybridMap[hybridCells2[cell]] = cell + hc1; | |||
1266 | ierr = PetscFree(hybridCells1)((*PetscTrFree)((void*)(hybridCells1),1266,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((hybridCells1) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1266,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1267 | ierr = PetscFree(hybridCells2)((*PetscTrFree)((void*)(hybridCells2),1267,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((hybridCells2) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1267,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1268 | } | |||
1269 | ||||
1270 | } | |||
1271 | ||||
1272 | /* Allocate the cell-vertex mesh */ | |||
1273 | ierr = DMPlexSetChart(*dm, 0, trueNumCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1273,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1274 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1275 | if (gmsh_elem[c].dim == dim) { | |||
1276 | ierr = DMPlexSetConeSize(*dm, hybridMap ? hybridMap[cell] : cell, gmsh_elem[c].numNodes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1276,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1277 | cell++; | |||
1278 | } | |||
1279 | } | |||
1280 | ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1280,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1281 | /* Add cell-vertex connections */ | |||
1282 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1283 | if (gmsh_elem[c].dim == dim) { | |||
1284 | PetscInt pcone[8], corner; | |||
1285 | for (corner = 0; corner < gmsh_elem[c].numNodes; ++corner) { | |||
1286 | const PetscInt cc = gmsh_elem[c].nodes[corner] - shift; | |||
1287 | pcone[corner] = (periodicMap ? periodicMap[cc] : cc) + trueNumCells; | |||
1288 | } | |||
1289 | if (dim == 3) { | |||
1290 | /* Tetrahedra are inverted */ | |||
1291 | if (gmsh_elem[c].cellType == 4) { | |||
1292 | PetscInt tmp = pcone[0]; | |||
1293 | pcone[0] = pcone[1]; | |||
1294 | pcone[1] = tmp; | |||
1295 | } | |||
1296 | /* Hexahedra are inverted */ | |||
1297 | if (gmsh_elem[c].cellType == 5) { | |||
1298 | PetscInt tmp = pcone[1]; | |||
1299 | pcone[1] = pcone[3]; | |||
1300 | pcone[3] = tmp; | |||
1301 | } | |||
1302 | /* Prisms are inverted */ | |||
1303 | if (gmsh_elem[c].cellType == 6) { | |||
1304 | PetscInt tmp; | |||
1305 | ||||
1306 | tmp = pcone[1]; | |||
1307 | pcone[1] = pcone[2]; | |||
1308 | pcone[2] = tmp; | |||
1309 | tmp = pcone[4]; | |||
1310 | pcone[4] = pcone[5]; | |||
1311 | pcone[5] = tmp; | |||
1312 | } | |||
1313 | } else if (dim == 2 && hybridMap && hybridMap[cell] >= cMax) { /* hybrid cells */ | |||
1314 | /* quads are input to PLEX as prisms */ | |||
1315 | if (gmsh_elem[c].cellType == 3) { | |||
1316 | PetscInt tmp = pcone[2]; | |||
1317 | pcone[2] = pcone[3]; | |||
1318 | pcone[3] = tmp; | |||
1319 | } | |||
1320 | } | |||
1321 | ierr = DMPlexSetCone(*dm, hybridMap ? hybridMap[cell] : cell, pcone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1321,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1322 | cell++; | |||
1323 | } | |||
1324 | } | |||
1325 | ierr = MPI_Bcast(&dim, 1, MPIU_INT, 0, comm)((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast ((&dim),(1),(((MPI_Datatype)0x4c000405)),(0),(comm)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1325,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1326 | ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1326,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1327 | ierr = DMPlexSetHybridBounds(*dm, cMax, PETSC_DETERMINE-1, PETSC_DETERMINE-1, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1327,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1328 | ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1328,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1329 | ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1329,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1330 | if (interpolate) { | |||
1331 | DM idm; | |||
1332 | ||||
1333 | ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1333,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1334 | ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1334,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1335 | *dm = idm; | |||
1336 | } | |||
1337 | ||||
1338 | if (usemarker && !interpolate && dim > 1) SETERRQ(comm,PETSC_ERR_SUP,"Cannot create marker label without interpolation")return PetscError(comm,1338,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,56,PETSC_ERROR_INITIAL,"Cannot create marker label without interpolation" ); | |||
1339 | if (!rank && usemarker) { | |||
1340 | PetscInt f, fStart, fEnd; | |||
1341 | ||||
1342 | ierr = DMCreateLabel(*dm, "marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1342,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1343 | ierr = DMPlexGetHeightStratum(*dm, 1, &fStart, &fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1343,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1344 | for (f = fStart; f < fEnd; ++f) { | |||
1345 | PetscInt suppSize; | |||
1346 | ||||
1347 | ierr = DMPlexGetSupportSize(*dm, f, &suppSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1347,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1348 | if (suppSize == 1) { | |||
1349 | PetscInt *cone = NULL((void*)0), coneSize, p; | |||
1350 | ||||
1351 | ierr = DMPlexGetTransitiveClosure(*dm, f, PETSC_TRUE, &coneSize, &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1351,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1352 | for (p = 0; p < coneSize; p += 2) { | |||
1353 | ierr = DMSetLabelValue(*dm, "marker", cone[p], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1353,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1354 | } | |||
1355 | ierr = DMPlexRestoreTransitiveClosure(*dm, f, PETSC_TRUE, &coneSize, &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1355,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1356 | } | |||
1357 | } | |||
1358 | } | |||
1359 | ||||
1360 | if (!rank) { | |||
1361 | PetscInt vStart, vEnd; | |||
1362 | ||||
1363 | ierr = DMPlexGetDepthStratum(*dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1363,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1364 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1365 | ||||
1366 | /* Create face sets */ | |||
1367 | if (interpolate && gmsh_elem[c].dim == dim-1) { | |||
1368 | const PetscInt *join; | |||
1369 | PetscInt joinSize, pcone[8], corner; | |||
1370 | /* Find the relevant facet with vertex joins */ | |||
1371 | for (corner = 0; corner < gmsh_elem[c].numNodes; ++corner) { | |||
1372 | const PetscInt cc = gmsh_elem[c].nodes[corner] - shift; | |||
1373 | pcone[corner] = (periodicMap ? periodicMap[cc] : cc) + vStart; | |||
1374 | } | |||
1375 | ierr = DMPlexGetFullJoin(*dm, gmsh_elem[c].numNodes, pcone, &joinSize, &join);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1375,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1376 | if (joinSize != 1) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Could not determine Plex facet for GMsh element %d (Plex cell %D)", gmsh_elem[c].id, c)return PetscError(((MPI_Comm)0x44000001),1376,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,62,PETSC_ERROR_INITIAL,"Could not determine Plex facet for GMsh element %d (Plex cell %D)" ,gmsh_elem[c].id,c); | |||
1377 | ierr = DMSetLabelValue(*dm, "Face Sets", join[0], gmsh_elem[c].tags[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1377,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1378 | ierr = DMPlexRestoreJoin(*dm, gmsh_elem[c].numNodes, (const PetscInt *) pcone, &joinSize, &join);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1378,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1379 | } | |||
1380 | ||||
1381 | /* Create cell sets */ | |||
1382 | if (gmsh_elem[c].dim == dim) { | |||
1383 | if (gmsh_elem[c].numTags > 0) { | |||
1384 | ierr = DMSetLabelValue(*dm, "Cell Sets", hybridMap ? hybridMap[cell] : cell, gmsh_elem[c].tags[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1384,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1385 | } | |||
1386 | cell++; | |||
1387 | } | |||
1388 | ||||
1389 | /* Create vertex sets */ | |||
1390 | if (gmsh_elem[c].dim == 0) { | |||
1391 | if (gmsh_elem[c].numTags > 0) { | |||
1392 | const PetscInt cc = gmsh_elem[c].nodes[0] - shift; | |||
1393 | const PetscInt vid = (periodicMap ? periodicMap[cc] : cc) + vStart; | |||
1394 | ierr = DMSetLabelValue(*dm, "Vertex Sets", vid, gmsh_elem[c].tags[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1394,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1395 | } | |||
1396 | } | |||
1397 | } | |||
1398 | } | |||
1399 | ||||
1400 | /* Create coordinates */ | |||
1401 | if (embedDim < 0) embedDim = dim; | |||
1402 | ierr = DMSetCoordinateDim(*dm, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1402,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1403 | ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1403,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1404 | ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1404,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1405 | ierr = PetscSectionSetFieldComponents(coordSection, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1405,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1406 | if (periodicMap) { /* we need to localize coordinates on cells */ | |||
1407 | ierr = PetscSectionSetChart(coordSection, 0, trueNumCells + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1407,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1408 | } else { | |||
1409 | ierr = PetscSectionSetChart(coordSection, trueNumCells, trueNumCells + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1409,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1410 | } | |||
1411 | for (v = trueNumCells; v < trueNumCells+numVertices; ++v) { | |||
1412 | ierr = PetscSectionSetDof(coordSection, v, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1412,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1413 | ierr = PetscSectionSetFieldDof(coordSection, v, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1413,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1414 | } | |||
1415 | if (periodicMap) { | |||
1416 | ierr = PetscBTCreate(trueNumCells, &periodicC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1416,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1417 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1418 | if (gmsh_elem[c].dim == dim) { | |||
1419 | PetscInt corner; | |||
1420 | PetscBool pc = PETSC_FALSE; | |||
1421 | for (corner = 0; corner < gmsh_elem[c].numNodes; ++corner) { | |||
1422 | pc = (PetscBool)(pc || PetscBTLookup(periodicV, gmsh_elem[c].nodes[corner] - shift)); | |||
1423 | } | |||
1424 | if (pc) { | |||
1425 | PetscInt dof = gmsh_elem[c].numNodes*embedDim; | |||
1426 | PetscInt ucell = hybridMap ? hybridMap[cell] : cell; | |||
1427 | ierr = PetscBTSet(periodicC, ucell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1427,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1428 | ierr = PetscSectionSetDof(coordSection, ucell, dof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1428,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1429 | ierr = PetscSectionSetFieldDof(coordSection, ucell, 0, dof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1429,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1430 | } | |||
1431 | cell++; | |||
1432 | } | |||
1433 | } | |||
1434 | } | |||
1435 | ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1435,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1436 | ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1436,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1437 | ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1437,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1438 | ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1438,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1439 | ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1439,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1440 | ierr = VecSetBlockSize(coordinates, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1440,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1441 | ierr = VecSetType(coordinates, VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1441,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1442 | ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1442,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1443 | if (periodicMap) { | |||
1444 | PetscInt off; | |||
1445 | ||||
1446 | for (cell = 0, c = 0; c < numCells; ++c) { | |||
1447 | PetscInt pcone[8], corner; | |||
1448 | if (gmsh_elem[c].dim == dim) { | |||
1449 | PetscInt ucell = hybridMap ? hybridMap[cell] : cell; | |||
1450 | if (PetscUnlikely(PetscBTLookup(periodicC, ucell))__builtin_expect(!!(PetscBTLookup(periodicC, ucell)),0)) { | |||
1451 | for (corner = 0; corner < gmsh_elem[c].numNodes; ++corner) { | |||
1452 | pcone[corner] = gmsh_elem[c].nodes[corner] - shift; | |||
1453 | } | |||
1454 | if (dim == 3) { | |||
1455 | /* Tetrahedra are inverted */ | |||
1456 | if (gmsh_elem[c].cellType == 4) { | |||
1457 | PetscInt tmp = pcone[0]; | |||
1458 | pcone[0] = pcone[1]; | |||
1459 | pcone[1] = tmp; | |||
1460 | } | |||
1461 | /* Hexahedra are inverted */ | |||
1462 | if (gmsh_elem[c].cellType == 5) { | |||
1463 | PetscInt tmp = pcone[1]; | |||
1464 | pcone[1] = pcone[3]; | |||
1465 | pcone[3] = tmp; | |||
1466 | } | |||
1467 | /* Prisms are inverted */ | |||
1468 | if (gmsh_elem[c].cellType == 6) { | |||
1469 | PetscInt tmp; | |||
1470 | ||||
1471 | tmp = pcone[1]; | |||
1472 | pcone[1] = pcone[2]; | |||
1473 | pcone[2] = tmp; | |||
1474 | tmp = pcone[4]; | |||
1475 | pcone[4] = pcone[5]; | |||
1476 | pcone[5] = tmp; | |||
1477 | } | |||
1478 | } else if (dim == 2 && hybridMap && hybridMap[cell] >= cMax) { /* hybrid cells */ | |||
1479 | /* quads are input to PLEX as prisms */ | |||
1480 | if (gmsh_elem[c].cellType == 3) { | |||
1481 | PetscInt tmp = pcone[2]; | |||
1482 | pcone[2] = pcone[3]; | |||
1483 | pcone[3] = tmp; | |||
1484 | } | |||
1485 | } | |||
1486 | ierr = PetscSectionGetOffset(coordSection, ucell, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1486,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1487 | for (corner = 0; corner < gmsh_elem[c].numNodes; ++corner) { | |||
1488 | v = pcone[corner]; | |||
1489 | for (d = 0; d < embedDim; ++d) { | |||
1490 | coords[off++] = (PetscReal) coordsIn[v*3+d]; | |||
1491 | } | |||
1492 | } | |||
1493 | } | |||
1494 | cell++; | |||
1495 | } | |||
1496 | } | |||
1497 | for (v = 0; v < numVertices; ++v) { | |||
1498 | ierr = PetscSectionGetOffset(coordSection, v + trueNumCells, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1498,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1499 | for (d = 0; d < embedDim; ++d) { | |||
1500 | coords[off+d] = (PetscReal) coordsIn[periodicMapI[v]*3+d]; | |||
1501 | } | |||
1502 | } | |||
1503 | } else { | |||
1504 | for (v = 0; v < numVertices; ++v) { | |||
1505 | for (d = 0; d < embedDim; ++d) { | |||
1506 | coords[v*embedDim+d] = (PetscReal) coordsIn[v*3+d]; | |||
1507 | } | |||
1508 | } | |||
1509 | } | |||
1510 | ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1510,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1511 | ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1511,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1512 | ||||
1513 | periodic = periodicMap ? PETSC_TRUE : PETSC_FALSE; | |||
1514 | ierr = MPI_Bcast(&periodic, 1, MPIU_BOOL, 0, comm)((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Bcast ((&periodic),(1),(MPIU_BOOL),(0),(comm)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1514,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1515 | ierr = DMSetPeriodicity(*dm, periodic, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1515,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1516 | ||||
1517 | ierr = PetscFree(coordsIn)((*PetscTrFree)((void*)(coordsIn),1517,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((coordsIn) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1517,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1518 | ierr = PetscFree(gmsh_elem)((*PetscTrFree)((void*)(gmsh_elem),1518,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((gmsh_elem) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1518,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1519 | ierr = PetscFree(hybridMap)((*PetscTrFree)((void*)(hybridMap),1519,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((hybridMap) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1519,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1520 | ierr = PetscFree(periodicMap)((*PetscTrFree)((void*)(periodicMap),1520,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((periodicMap) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1520,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1521 | ierr = PetscFree(periodicMapI)((*PetscTrFree)((void*)(periodicMapI),1521,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ) || ((periodicMapI) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1521,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1522 | ierr = PetscBTDestroy(&periodicV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1522,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1523 | ierr = PetscBTDestroy(&periodicC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1523,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1524 | ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1524,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1525 | ||||
1526 | ierr = PetscLogEventEnd(DMPLEX_CreateGmsh,*dm,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_CreateGmsh].active) ? (*PetscLogPLE)((DMPLEX_CreateGmsh ),0,(PetscObject)(*dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1526,__func__,"/sandbox/petsc/petsc.next/src/dm/impls/plex/plexgmsh.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1527 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
1528 | } |