1 #include <petsc/private/dmmbimpl.h> /*I "petscdmmoab.h" I*/ 2 #include <petsc/private/vecimpl.h> 3 4 #include <petscdmmoab.h> 5 #include <MBTagConventions.hpp> 6 #include <moab/ReadUtilIface.hpp> 7 #include <moab/MergeMesh.hpp> 8 #include <moab/CN.hpp> 9 10 typedef struct { 11 // options 12 PetscInt A,B,C,M,N,K,dim; 13 PetscInt blockSizeVertexXYZ[3]; // Number of element blocks per partition 14 PetscInt blockSizeElementXYZ[3]; 15 PetscReal xyzbounds[6]; // the physical size of the domain 16 bool newMergeMethod,keep_skins,simplex,adjEnts; 17 18 // compute params 19 PetscReal dx,dy,dz; 20 PetscInt NX,NY,NZ,nex,ney,nez; 21 PetscInt q,xstride,ystride,zstride; 22 PetscBool usrxyzgrid,usrprocgrid,usrrefgrid; 23 } DMMoabMeshGeneratorCtx; 24 25 26 #undef __FUNCT__ 27 #define __FUNCT__ "DMMoab_SetTensorElementConnectivity_Private" 28 PetscInt DMMoab_SetTensorElementConnectivity_Private(DMMoabMeshGeneratorCtx& genCtx, PetscInt offset, PetscInt corner, std::vector<PetscInt>& subent_conn, moab::EntityHandle *connectivity) 29 { 30 switch(genCtx.dim) { 31 case 1: 32 subent_conn.resize(2); 33 moab::CN::SubEntityVertexIndices(moab::MBEDGE, 1, 0, subent_conn.data()); 34 connectivity[offset+subent_conn[0]] = corner; 35 connectivity[offset+subent_conn[1]] = corner + 1; 36 break; 37 case 2: 38 subent_conn.resize(4); 39 moab::CN::SubEntityVertexIndices(moab::MBQUAD, 2, 0, subent_conn.data()); 40 connectivity[offset+subent_conn[0]] = corner; 41 connectivity[offset+subent_conn[1]] = corner + 1; 42 connectivity[offset+subent_conn[2]] = corner + 1 + genCtx.ystride; 43 connectivity[offset+subent_conn[3]] = corner + genCtx.ystride; 44 break; 45 case 3: 46 default: 47 subent_conn.resize(8); 48 moab::CN::SubEntityVertexIndices(moab::MBHEX, 3, 0, subent_conn.data()); 49 connectivity[offset+subent_conn[0]] = corner; 50 connectivity[offset+subent_conn[1]] = corner + 1; 51 connectivity[offset+subent_conn[2]] = corner + 1 + genCtx.ystride; 52 connectivity[offset+subent_conn[3]] = corner + genCtx.ystride; 53 connectivity[offset+subent_conn[4]] = corner + genCtx.zstride; 54 connectivity[offset+subent_conn[5]] = corner + 1 + genCtx.zstride; 55 connectivity[offset+subent_conn[6]] = corner + 1 + genCtx.ystride + genCtx.zstride; 56 connectivity[offset+subent_conn[7]] = corner + genCtx.ystride + genCtx.zstride; 57 break; 58 } 59 return subent_conn.size(); 60 } 61 62 63 #undef __FUNCT__ 64 #define __FUNCT__ "DMMoab_SetSimplexElementConnectivity_Private" 65 PetscInt DMMoab_SetSimplexElementConnectivity_Private(DMMoabMeshGeneratorCtx& genCtx, PetscInt subelem, PetscInt offset, PetscInt corner, std::vector<PetscInt>& subent_conn, moab::EntityHandle *connectivity) 66 { 67 PetscInt A, B, C, D, E, F, G, H; 68 A = corner; 69 B = corner + 1; 70 switch(genCtx.dim) { 71 case 1: 72 subent_conn.resize(2); /* only linear EDGE supported now */ 73 moab::CN::SubEntityVertexIndices(moab::MBEDGE, 1, 0, subent_conn.data()); 74 connectivity[offset+subent_conn[0]] = A; 75 connectivity[offset+subent_conn[1]] = B; 76 break; 77 case 2: 78 C = corner + 1 + genCtx.ystride; 79 D = corner + genCtx.ystride; 80 subent_conn.resize(3); /* only linear TRI supported */ 81 moab::CN::SubEntityVertexIndices(moab::MBTRI, 2, 0, subent_conn.data()); 82 if (subelem) { /* 0 1 2 of a QUAD */ 83 connectivity[offset+subent_conn[0]] = A; 84 connectivity[offset+subent_conn[1]] = B; 85 connectivity[offset+subent_conn[2]] = C; 86 } 87 else { /* 2 3 0 of a QUAD */ 88 connectivity[offset+subent_conn[0]] = C; 89 connectivity[offset+subent_conn[1]] = D; 90 connectivity[offset+subent_conn[2]] = A; 91 } 92 break; 93 case 3: 94 default: 95 C = corner + 1 + genCtx.ystride; 96 D = corner + genCtx.ystride; 97 E = corner + genCtx.zstride; 98 F = corner + 1 + genCtx.zstride; 99 G = corner + 1 + genCtx.ystride + genCtx.zstride; 100 H = corner + genCtx.ystride + genCtx.zstride; 101 subent_conn.resize(4); /* only linear TET supported */ 102 moab::CN::SubEntityVertexIndices(moab::MBTET, 3, 0, subent_conn.data()); 103 switch(subelem) { 104 case 0: /* 4 3 7 6 of a HEX */ 105 connectivity[offset+subent_conn[0]] = E; 106 connectivity[offset+subent_conn[1]] = D; 107 connectivity[offset+subent_conn[2]] = H; 108 connectivity[offset+subent_conn[3]] = G; 109 break; 110 case 1: /* 0 1 2 5 of a HEX */ 111 connectivity[offset+subent_conn[0]] = A; 112 connectivity[offset+subent_conn[1]] = B; 113 connectivity[offset+subent_conn[2]] = C; 114 connectivity[offset+subent_conn[3]] = F; 115 break; 116 case 2: /* 0 3 4 5 of a HEX */ 117 connectivity[offset+subent_conn[0]] = A; 118 connectivity[offset+subent_conn[1]] = D; 119 connectivity[offset+subent_conn[2]] = E; 120 connectivity[offset+subent_conn[3]] = F; 121 break; 122 case 3: /* 2 6 3 5 of a HEX */ 123 connectivity[offset+subent_conn[0]] = C; 124 connectivity[offset+subent_conn[1]] = G; 125 connectivity[offset+subent_conn[2]] = D; 126 connectivity[offset+subent_conn[3]] = F; 127 break; 128 case 4: /* 0 2 3 5 of a HEX */ 129 connectivity[offset+subent_conn[0]] = A; 130 connectivity[offset+subent_conn[1]] = C; 131 connectivity[offset+subent_conn[2]] = D; 132 connectivity[offset+subent_conn[3]] = F; 133 break; 134 case 5: /* 3 6 4 5 of a HEX */ 135 connectivity[offset+subent_conn[0]] = D; 136 connectivity[offset+subent_conn[1]] = G; 137 connectivity[offset+subent_conn[2]] = E; 138 connectivity[offset+subent_conn[3]] = F; 139 break; 140 } 141 break; 142 } 143 return subent_conn.size(); 144 } 145 146 147 #undef __FUNCT__ 148 #define __FUNCT__ "DMMoab_SetElementConnectivity_Private" 149 std::pair<PetscInt,PetscInt> DMMoab_SetElementConnectivity_Private(DMMoabMeshGeneratorCtx& genCtx, PetscInt offset, PetscInt corner, moab::EntityHandle *connectivity) 150 { 151 PetscInt vcount=0; 152 PetscInt simplices_per_tensor[4] = {0,1,2,6}; 153 std::vector<PetscInt> subent_conn; /* only linear edge, tri, tet supported now */ 154 subent_conn.reserve(27); 155 PetscInt m,subelem; 156 if (genCtx.simplex) { 157 subelem=simplices_per_tensor[genCtx.dim]; 158 for (m=0; m<subelem; m++) { 159 vcount=DMMoab_SetSimplexElementConnectivity_Private(genCtx, m, offset, corner, subent_conn, connectivity); 160 offset+=vcount; 161 } 162 } 163 else { 164 subelem=1; 165 vcount=DMMoab_SetTensorElementConnectivity_Private(genCtx, offset, corner, subent_conn, connectivity); 166 } 167 return std::pair<PetscInt,PetscInt>(vcount*subelem,subelem); 168 } 169 170 171 #undef __FUNCT__ 172 #define __FUNCT__ "DMMoab_GenerateVertices_Private" 173 PetscErrorCode DMMoab_GenerateVertices_Private(moab::Interface *mbImpl, moab::ReadUtilIface *iface, DMMoabMeshGeneratorCtx& genCtx, PetscInt m, PetscInt n, PetscInt k, 174 PetscInt a, PetscInt b, PetscInt c, moab::Tag& global_id_tag, moab::EntityHandle& startv, moab::Range& uverts) 175 { 176 PetscInt x,y,z,ix,nnodes; 177 PetscInt ii,jj,kk; 178 std::vector<PetscReal*> arrays; 179 std::vector<PetscInt> gids; 180 moab::ErrorCode merr; 181 182 PetscFunctionBegin; 183 /* we will generate (q*block+1)^3 vertices, and block^3 hexas; q is 1 for linear, 2 for quadratic 184 * the global id of the vertices will come from m, n, k, a, b, c 185 * x will vary from m*A*q*block + a*q*block to m*A*q*block+(a+1)*q*block etc. 186 */ 187 nnodes = genCtx.blockSizeVertexXYZ[0]*(genCtx.dim>1? genCtx.blockSizeVertexXYZ[1]*(genCtx.dim>2 ? genCtx.blockSizeVertexXYZ[2]:1) :1); 188 189 merr = iface->get_node_coords(3, nnodes, 0, startv, arrays);MBERR("Can't get node coords.", merr); 190 191 /* will start with the lower corner: */ 192 x = ( m * genCtx.A + a ) * genCtx.q * genCtx.blockSizeElementXYZ[0]; 193 y = ( n * genCtx.B + b ) * genCtx.q * genCtx.blockSizeElementXYZ[1]; 194 z = ( k * genCtx.C + c ) * genCtx.q * genCtx.blockSizeElementXYZ[2]; 195 ix = 0; 196 gids.resize(nnodes); 197 moab::Range verts(startv, startv + nnodes - 1); 198 for (kk = 0; kk < (genCtx.dim>2?genCtx.blockSizeVertexXYZ[2]:1); kk++) { 199 for (jj = 0; jj < (genCtx.dim>1?genCtx.blockSizeVertexXYZ[1]:1); jj++) { 200 for (ii = 0; ii < genCtx.blockSizeVertexXYZ[0]; ii++,ix++) { 201 /* set coordinates for the vertices */ 202 arrays[0][ix] = (x + ii)*genCtx.dx + genCtx.xyzbounds[0]; 203 arrays[1][ix] = (y + jj)*genCtx.dy + genCtx.xyzbounds[2]; 204 arrays[2][ix] = (z + kk)*genCtx.dz + genCtx.xyzbounds[4]; 205 206 /* If we want to set some tags on the vertices -> use the following entity handle definition: 207 moab::EntityHandle v = startv + ix; 208 */ 209 /* compute the global ID for vertex */ 210 gids[ix] = 1 + (x + ii) + (y + jj) * genCtx.NX + (z + kk) * (genCtx.NX * genCtx.NY); 211 } 212 } 213 } 214 /* set global ID data on vertices */ 215 mbImpl->tag_set_data(global_id_tag, verts, &gids[0]); 216 verts.swap(uverts); 217 PetscFunctionReturn(0); 218 } 219 220 #undef __FUNCT__ 221 #define __FUNCT__ "DMMoab_GenerateElements_Private" 222 PetscErrorCode DMMoab_GenerateElements_Private(moab::Interface* mbImpl, moab::ReadUtilIface* iface, DMMoabMeshGeneratorCtx& genCtx, PetscInt m, PetscInt n, PetscInt k, 223 PetscInt a, PetscInt b, PetscInt c, moab::Tag& global_id_tag, moab::EntityHandle startv, moab::Range& cells) 224 { 225 moab::ErrorCode merr; 226 PetscInt ix,ie,xe,ye,ze; 227 PetscInt ii,jj,kk,nvperelem; 228 PetscInt simplices_per_tensor[4] = {0,1,2,6}; 229 PetscInt ntensorelems = genCtx.blockSizeElementXYZ[0]*(genCtx.dim>1? genCtx.blockSizeElementXYZ[1]*(genCtx.dim>2 ? genCtx.blockSizeElementXYZ[2]:1) :1); /*pow(genCtx.blockSizeElement,genCtx.dim);*/ 230 PetscInt nelems = ntensorelems; 231 moab::EntityHandle starte; // connectivity 232 moab::EntityHandle* conn; 233 234 PetscFunctionBegin; 235 switch(genCtx.dim) { 236 case 1: 237 nvperelem = 2; 238 merr = iface->get_element_connect(nelems, 2, moab::MBEDGE, 0, starte, conn);MBERR("Can't get EDGE2 element connectivity.", merr); 239 break; 240 case 2: 241 if (genCtx.simplex) { 242 nvperelem = 3; 243 nelems = ntensorelems*simplices_per_tensor[genCtx.dim]; 244 merr = iface->get_element_connect(nelems, 3, moab::MBTRI, 0, starte, conn);MBERR("Can't get TRI3 element connectivity.", merr); 245 } 246 else { 247 nvperelem = 4; 248 merr = iface->get_element_connect(nelems, 4, moab::MBQUAD, 0, starte, conn);MBERR("Can't get QUAD4 element connectivity.", merr); 249 } 250 break; 251 case 3: 252 default: 253 if (genCtx.simplex) { 254 nvperelem = 4; 255 nelems = ntensorelems*simplices_per_tensor[genCtx.dim]; 256 merr = iface->get_element_connect(nelems, 4, moab::MBTET, 0, starte, conn);MBERR("Can't get TET4 element connectivity.", merr); 257 } 258 else { 259 nvperelem = 8; 260 merr = iface->get_element_connect(nelems, 8, moab::MBHEX, 0, starte, conn);MBERR("Can't get HEX8 element connectivity.", merr); 261 } 262 break; 263 } 264 265 ix = ie = 0; // index now in the elements, for global ids 266 267 /* create a temporary range to store local element handles */ 268 moab::Range tmp(starte, starte + nelems - 1); 269 std::vector<PetscInt> gids(nelems); 270 271 /* identify the elements at the lower corner, for their global ids */ 272 xe = m * genCtx.A * genCtx.blockSizeElementXYZ[0] + a * genCtx.blockSizeElementXYZ[0]; 273 ye = (genCtx.dim > 1 ? n * genCtx.B * genCtx.blockSizeElementXYZ[1] + b * genCtx.blockSizeElementXYZ[1] : 0); 274 ze = (genCtx.dim > 2 ? k * genCtx.C * genCtx.blockSizeElementXYZ[2] + c * genCtx.blockSizeElementXYZ[2] : 0); 275 276 /* create owned elements requested by genCtx */ 277 for (kk = 0; kk < (genCtx.dim>2?genCtx.blockSizeElementXYZ[2]:1); kk++) { 278 for (jj = 0; jj < (genCtx.dim>1?genCtx.blockSizeElementXYZ[1]:1); jj++) { 279 for (ii = 0; ii < genCtx.blockSizeElementXYZ[0]; ii++) { 280 281 moab::EntityHandle corner = startv + genCtx.q * ii + genCtx.q * jj * genCtx.ystride + genCtx.q * kk * genCtx.zstride; 282 283 std::pair<PetscInt,PetscInt> entoffset = DMMoab_SetElementConnectivity_Private(genCtx, ix, corner, conn); 284 285 for (PetscInt j = 0; j < entoffset.second; j++) { 286 /* The entity handle for the particular element -> if we want to set some tags is 287 moab::EntityHandle eh = starte + ie + j; 288 */ 289 gids[ie+j] = 1 + ((xe + ii) + (ye + jj) * genCtx.nex + (ze + kk) * (genCtx.nex * genCtx.ney)); 290 //gids[ie+j] = ie + j + ((xe + ii) + (ye + jj) * genCtx.nex + (ze + kk) * (genCtx.nex * genCtx.ney)) ; 291 //gids[ie+j] = 1 + ie; 292 //ie++; 293 } 294 295 ix += entoffset.first; 296 ie += entoffset.second; 297 } 298 } 299 } 300 if (genCtx.adjEnts) { /* we need to update adjacencies now, because some elements are new */ 301 merr = iface->update_adjacencies(starte, nelems, nvperelem, conn);MBERR("Can't update adjacencies", merr); 302 } 303 tmp.swap(cells); 304 merr = mbImpl->tag_set_data(global_id_tag, cells, &gids[0]);MBERR("Can't set global ids to elements.", merr); 305 PetscFunctionReturn(0); 306 } 307 308 #undef __FUNCT__ 309 #define __FUNCT__ "DMMBUtil_InitializeOptions" 310 PetscErrorCode DMMBUtil_InitializeOptions(DMMoabMeshGeneratorCtx& genCtx, PetscInt dim, PetscBool simplex, PetscInt rank, PetscInt nprocs, const PetscReal* bounds, PetscInt nele) 311 { 312 PetscInt fraction=0,remainder=0; 313 PetscFunctionBegin; 314 /* Initialize all genCtx data */ 315 genCtx.dim=dim; 316 genCtx.simplex=simplex; 317 genCtx.newMergeMethod=genCtx.keep_skins=genCtx.adjEnts=true; 318 /* determine other global quantities for the mesh used for nodes increments */ 319 genCtx.q = 1; 320 321 if (!genCtx.usrxyzgrid) { /* not overridden by genCtx - assume nele equally and that genCtx wants a uniform cube mesh */ 322 //genCtx.blockSizeElementXYZ[0]=genCtx.blockSizeElementXYZ[1]=genCtx.blockSizeElementXYZ[2]=std::pow(nlocalele,1.0/dim); 323 if (dim==1) { 324 fraction=nele/nprocs; /* partition only by the largest dimension */ 325 remainder=nele%nprocs; /* remainder after partition which gets evenly distributed by round-robin */ 326 if(rank < remainder) /* This process gets "fraction+1" elements */ 327 fraction++; 328 } 329 genCtx.blockSizeElementXYZ[0]=(dim>1?nele:fraction); 330 genCtx.blockSizeElementXYZ[1]=(dim>2?nele:nele/nprocs); 331 genCtx.blockSizeElementXYZ[2]=(dim>2?nele/nprocs:1); 332 } 333 334 /* partition only by the largest dimension */ 335 /* Total number of local elements := genCtx.blockSizeElementXYZ[0]*(genCtx.dim>1? genCtx.blockSizeElementXYZ[1]*(genCtx.dim>2 ? genCtx.blockSizeElementXYZ[2]:1) :1); */ 336 if (bounds) { 337 for (PetscInt i=0; i<6; i++) 338 genCtx.xyzbounds[i]=bounds[i]; 339 } 340 else { 341 genCtx.xyzbounds[0]=genCtx.xyzbounds[2]=genCtx.xyzbounds[4]=0.0; 342 genCtx.xyzbounds[1]=genCtx.xyzbounds[3]=genCtx.xyzbounds[5]=1.0; 343 } 344 345 if (!genCtx.usrprocgrid) { 346 genCtx.M=genCtx.N=genCtx.K=std::pow(nprocs,1.0/dim); 347 switch(genCtx.dim) { 348 case 1: 349 genCtx.M=nprocs; 350 genCtx.N=genCtx.K=1; 351 break; 352 case 2: 353 genCtx.K=1; 354 genCtx.N=nprocs/(genCtx.M); 355 break; 356 default: 357 genCtx.K=nprocs/(genCtx.M*genCtx.N); 358 break; 359 } 360 } 361 362 if (!genCtx.usrrefgrid) { 363 genCtx.A=genCtx.B=genCtx.C=1; 364 } 365 366 /* more default values */ 367 genCtx.nex=genCtx.ney=genCtx.nez=0; 368 genCtx.xstride=genCtx.ystride=genCtx.zstride=0; 369 genCtx.NX=genCtx.NY=genCtx.NZ=0; 370 genCtx.nex=genCtx.ney=genCtx.nez=0; 371 genCtx.blockSizeVertexXYZ[0]=genCtx.blockSizeVertexXYZ[1]=genCtx.blockSizeVertexXYZ[2]=1; 372 373 //genCtx.blockSizeElementXYZ[0]=genCtx.blockSizeElementXYZ[1]=genCtx.blockSizeElementXYZ[2]=nele; 374 //genCtx.blockSizeVertexXYZ[0]=genCtx.blockSizeVertexXYZ[1]=genCtx.blockSizeVertexXYZ[2]=nele+1; 375 376 switch(genCtx.dim) { 377 case 3: 378 //genCtx.blockSizeElementXYZ[2]=std::max(1,genCtx.blockSizeElementXYZ[2]/nprocs); 379 //genCtx.blockSizeElementXYZ[2]=std::max(1,nele/nprocs); 380 genCtx.blockSizeVertexXYZ[0] = genCtx.q*genCtx.blockSizeElementXYZ[0] + 1; 381 genCtx.blockSizeVertexXYZ[1] = genCtx.q*genCtx.blockSizeElementXYZ[1] + 1; 382 //genCtx.blockSizeElementXYZ[2]=fraction/(genCtx.blockSizeElementXYZ[0]*genCtx.blockSizeElementXYZ[1]); 383 genCtx.blockSizeVertexXYZ[2] = genCtx.q*genCtx.blockSizeElementXYZ[2] + 1; 384 385 genCtx.nex = genCtx.M * genCtx.A * genCtx.blockSizeElementXYZ[0]; /* number of elements in x direction, used for global id on element */ 386 genCtx.dx = (genCtx.xyzbounds[1]-genCtx.xyzbounds[0])/(genCtx.nex*genCtx.q); /* distance between 2 nodes in x direction */ 387 genCtx.NX = (genCtx.q * genCtx.nex + 1); 388 genCtx.xstride = 1; 389 genCtx.ney = genCtx.N * genCtx.B * genCtx.blockSizeElementXYZ[1]; /* number of elements in y direction .... */ 390 genCtx.dy = (genCtx.xyzbounds[3]-genCtx.xyzbounds[2])/(genCtx.ney*genCtx.q); /* distance between 2 nodes in y direction */ 391 genCtx.NY = (genCtx.q * genCtx.ney + 1); 392 genCtx.ystride = genCtx.blockSizeVertexXYZ[0]; 393 genCtx.nez = genCtx.K * genCtx.C * genCtx.blockSizeElementXYZ[2]; /* number of elements in z direction .... */ 394 genCtx.dz = (genCtx.xyzbounds[5]-genCtx.xyzbounds[4])/(genCtx.nez*genCtx.q); /* distance between 2 nodes in z direction */ 395 genCtx.NZ = (genCtx.q * genCtx.nez + 1); 396 genCtx.zstride = genCtx.blockSizeVertexXYZ[0] * genCtx.blockSizeVertexXYZ[1]; 397 break; 398 case 2: 399 //genCtx.blockSizeElementXYZ[1]=genCtx.blockSizeElementXYZ[2]=std::max(1,nele/nprocs); 400 //genCtx.blockSizeElementXYZ[1]=fraction/genCtx.blockSizeElementXYZ[0]; 401 genCtx.blockSizeVertexXYZ[0] = genCtx.q*genCtx.blockSizeElementXYZ[0] + 1; 402 genCtx.blockSizeVertexXYZ[1] = genCtx.q*genCtx.blockSizeElementXYZ[1] + 1; 403 genCtx.blockSizeElementXYZ[2]=0; 404 405 genCtx.nex = genCtx.M * genCtx.A * genCtx.blockSizeElementXYZ[0]; /* number of elements in x direction, used for global id on element */ 406 genCtx.dx = (genCtx.xyzbounds[1]-genCtx.xyzbounds[0])/(genCtx.nex*genCtx.q); /* distance between 2 nodes in x direction */ 407 genCtx.NX = (genCtx.q * genCtx.nex + 1); 408 genCtx.xstride = 1; 409 genCtx.ney = genCtx.N * genCtx.B * genCtx.blockSizeElementXYZ[1]; /* number of elements in y direction .... */ 410 genCtx.dy = (genCtx.xyzbounds[3]-genCtx.xyzbounds[2])/(genCtx.ney*genCtx.q); /* distance between 2 nodes in y direction */ 411 genCtx.NY = (genCtx.q * genCtx.ney + 1); 412 genCtx.ystride = genCtx.blockSizeVertexXYZ[0]; 413 break; 414 case 1: 415 genCtx.blockSizeElementXYZ[1]=genCtx.blockSizeElementXYZ[2]=0; 416 //genCtx.blockSizeElementXYZ[0]=nele; 417 genCtx.blockSizeVertexXYZ[0] = genCtx.q*genCtx.blockSizeElementXYZ[0] + 1; 418 419 genCtx.nex = genCtx.M * genCtx.A * genCtx.blockSizeElementXYZ[0]; /* number of elements in x direction, used for global id on element */ 420 genCtx.dx = (genCtx.xyzbounds[1]-genCtx.xyzbounds[0])/(genCtx.nex*genCtx.q); /* distance between 2 nodes in x direction */ 421 genCtx.NX = (genCtx.q * genCtx.nex + 1); 422 genCtx.xstride = 1; 423 break; 424 } 425 426 /* 427 PetscInfo3(NULL, "Local elements:= %d, %d, %d\n",genCtx.blockSizeElementXYZ[0],genCtx.blockSizeElementXYZ[1],genCtx.blockSizeElementXYZ[2]); 428 PetscInfo3(NULL, "Local vertices:= %d, %d, %d\n",genCtx.blockSizeVertexXYZ[0],genCtx.blockSizeVertexXYZ[1],genCtx.blockSizeVertexXYZ[2]); 429 PetscInfo3(NULL, "Local nexyz:= %d, %d, %d\n",genCtx.nex,genCtx.ney,genCtx.nez); 430 PetscInfo3(NULL, "Local delxyz:= %g, %g, %g\n",genCtx.dx,genCtx.dy,genCtx.dz); 431 PetscInfo3(NULL, "Local strides:= %d, %d, %d\n",genCtx.xstride,genCtx.ystride,genCtx.zstride); 432 */ 433 PetscFunctionReturn(0); 434 } 435 436 /*@ 437 DMMoabCreateBoxMesh - Creates a mesh on the tensor product (box) of intervals with genCtx specified bounds. 438 439 Collective on MPI_Comm 440 441 Input Parameters: 442 + comm - The communicator for the DM object 443 . dim - The spatial dimension 444 . bounds - The bounds of the box specified with [x-left, x-right, y-bottom, y-top, z-bottom, z-top] depending on the spatial dimension 445 . nele - The number of discrete elements in each direction 446 . user_nghost - The number of ghosted layers needed in the partitioned mesh 447 448 Output Parameter: 449 . dm - The DM object 450 451 Level: beginner 452 453 .keywords: DM, create 454 .seealso: DMSetType(), DMCreate(), DMMoabLoadFromFile() 455 @*/ 456 PetscErrorCode DMMoabCreateBoxMesh(MPI_Comm comm, PetscInt dim, PetscBool useSimplex, const PetscReal* bounds, PetscInt nele, PetscInt nghost, DM *dm) 457 { 458 PetscErrorCode ierr; 459 moab::ErrorCode merr; 460 PetscInt a,b,c,n,global_size,global_rank=-1; 461 DM_Moab *dmmoab; 462 moab::Interface *mbImpl; 463 moab::ParallelComm *pcomm; 464 moab::ReadUtilIface *readMeshIface; 465 moab::Range verts,cells,edges,faces,adj,dim3,dim2; 466 DMMoabMeshGeneratorCtx genCtx; 467 const PetscInt npts=nele+1; /* Number of points in every dimension */ 468 469 moab::Tag global_id_tag,part_tag,geom_tag; 470 moab::Range ownedvtx,ownedelms,localvtxs,localelms; 471 moab::EntityHandle regionset; 472 PetscInt ml=0,nl=0,kl=0,leftover; 473 474 PetscFunctionBegin; 475 if(dim < 1 || dim > 3) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Invalid dimension argument for mesh: dim=[1,3].\n"); 476 477 ierr = MPI_Comm_size(comm, &global_size);CHKERRQ(ierr); 478 /* total number of vertices in all dimensions */ 479 n=pow(npts,dim); 480 481 /* do some error checking */ 482 if(n < 2) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Number of points must be >= 2.\n"); 483 if(global_size > n) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Number of processors must be less than or equal to number of elements.\n"); 484 if(nghost < 0) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Number of ghost layers cannot be negative.\n"); 485 486 /* Create the basic DMMoab object and keep the default parameters created by DM impls */ 487 ierr = DMMoabCreateMoab(comm, NULL, NULL, NULL, NULL, dm);CHKERRQ(ierr); 488 489 /* get all the necessary handles from the private DM object */ 490 dmmoab = (DM_Moab*)(*dm)->data; 491 mbImpl = dmmoab->mbiface; 492 pcomm = dmmoab->pcomm; 493 global_id_tag = dmmoab->ltog_tag; 494 global_rank = pcomm->rank(); 495 dmmoab->dim = dim; 496 dmmoab->nghostrings=nghost; 497 498 /* create a file set to associate all entities in current mesh */ 499 merr = mbImpl->create_meshset(moab::MESHSET_SET, dmmoab->fileset);MBERR("Creating file set failed", merr); 500 501 /* No errors yet; proceed with building the mesh */ 502 merr = mbImpl->query_interface(readMeshIface);MBERRNM(merr); 503 504 //PetscObjectOptionsBegin(dm); 505 PetscOptionsBegin(comm,"","DMMoab Creation Options","DMMOAB"); 506 /* Handle DMMoab spatial resolution */ 507 PetscOptionsInt("-dmb_grid_x","Number of grid points in x direction","DMMoabSetSizes",genCtx.blockSizeElementXYZ[0],&genCtx.blockSizeElementXYZ[0],&genCtx.usrxyzgrid); 508 if (dim > 1) {PetscOptionsInt("-dmb_grid_y","Number of grid points in y direction","DMMoabSetSizes",genCtx.blockSizeElementXYZ[1],&genCtx.blockSizeElementXYZ[1],&genCtx.usrxyzgrid);} 509 if (dim > 2) {PetscOptionsInt("-dmb_grid_z","Number of grid points in z direction","DMMoabSetSizes",genCtx.blockSizeElementXYZ[2],&genCtx.blockSizeElementXYZ[2],&genCtx.usrxyzgrid);} 510 511 /* Handle DMMoab parallel distibution */ 512 PetscOptionsInt("-dmb_processors_x","Number of processors in x direction","DMMoabSetNumProcs",genCtx.M,&genCtx.M,&genCtx.usrprocgrid); 513 if (dim > 1) {PetscOptionsInt("-dmb_processors_y","Number of processors in y direction","DMMoabSetNumProcs",genCtx.N,&genCtx.N,&genCtx.usrprocgrid);} 514 if (dim > 2) {PetscOptionsInt("-dmb_processors_z","Number of processors in z direction","DMMoabSetNumProcs",genCtx.K,&genCtx.K,&genCtx.usrprocgrid);} 515 516 /* Handle DMMoab block refinement */ 517 PetscOptionsInt("-dmb_refine_x","Number of refinement blocks in x direction","DMMoabSetRefinement",genCtx.A,&genCtx.A,&genCtx.usrrefgrid); 518 if (dim > 1) {PetscOptionsInt("-dmb_refine_y","Number of refinement blocks in y direction","DMMoabSetRefinement",genCtx.B,&genCtx.B,&genCtx.usrrefgrid);} 519 if (dim > 2) {PetscOptionsInt("-dmb_refine_z","Number of refinement blocks in z direction","DMMoabSetRefinement",genCtx.C,&genCtx.C,&genCtx.usrrefgrid);} 520 PetscOptionsEnd(); 521 522 ierr = DMMBUtil_InitializeOptions(genCtx, dim, useSimplex, global_rank, global_size, bounds, nele);CHKERRQ(ierr); 523 524 //if(nele<nprocs) SETERRQ2(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"The dimensional discretization size should be greater or equal to number of processors: %D < %D",nele,nprocs); 525 526 /* Lets check for some valid input */ 527 if (genCtx.dim < 1 || genCtx.dim > 3) SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Invalid topological dimension specified: %d.\n",genCtx.dim); 528 if (genCtx.M * genCtx.N * genCtx.K != global_size) SETERRQ4(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Invalid [m, n, k] data: %d, %d, %d. Product must be equal to global size = %d.\n",genCtx.M,genCtx.N,genCtx.K,global_size); 529 if (genCtx.xyzbounds) { 530 /* validate the bounds data */ 531 if(genCtx.xyzbounds[0] >= genCtx.xyzbounds[1]) SETERRQ2(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"X-dim: Left boundary cannot be greater than right. [%G >= %G]\n",genCtx.xyzbounds[0],genCtx.xyzbounds[1]); 532 if(genCtx.dim > 1 && (genCtx.xyzbounds[2] >= genCtx.xyzbounds[3])) SETERRQ2(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Y-dim: Left boundary cannot be greater than right. [%G >= %G]\n",genCtx.xyzbounds[2],genCtx.xyzbounds[3]); 533 if(genCtx.dim > 2 && (genCtx.xyzbounds[4] >= genCtx.xyzbounds[5])) SETERRQ2(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"Z-dim: Left boundary cannot be greater than right. [%G >= %G]\n",genCtx.xyzbounds[4],genCtx.xyzbounds[5]); 534 } 535 if (genCtx.adjEnts) genCtx.keep_skins = true; /* do not delete anything - consumes more memory */ 536 537 /* determine m, n, k for processor rank */ 538 kl = (genCtx.dim>2?global_rank/(genCtx.M*genCtx.N):0); 539 leftover = global_rank%(genCtx.M*genCtx.N); 540 nl = leftover/genCtx.M; 541 ml = leftover%genCtx.M; 542 543 /* 544 * so there are a total of M * A * blockSizeElement elements in x direction (so M * A * blockSizeElement + 1 verts in x direction) 545 * so there are a total of N * B * blockSizeElement elements in y direction (so N * B * blockSizeElement + 1 verts in y direction) 546 * so there are a total of K * C * blockSizeElement elements in z direction (so K * C * blockSizeElement + 1 verts in z direction) 547 548 * there are ( M * A blockSizeElement ) * ( N * B * blockSizeElement) * (K * C * blockSizeElement ) hexas 549 * there are ( M * A * blockSizeElement + 1) * ( N * B * blockSizeElement + 1 ) * (K * C * blockSizeElement + 1) vertices 550 * x is the first dimension that varies 551 */ 552 553 /* generate the block at (a, b, c); it will represent a partition , it will get a partition tag */ 554 PetscInt dum_id=-1; 555 merr = mbImpl->tag_get_handle("GLOBAL_ID", 1, moab::MB_TYPE_INTEGER, global_id_tag);MBERR("Getting Tag handle failed", merr); 556 557 merr = mbImpl->tag_get_handle("PARALLEL_PARTITION", 1, moab::MB_TYPE_INTEGER, part_tag, moab::MB_TAG_CREAT|moab::MB_TAG_SPARSE, &dum_id);MBERR("Getting Tag handle failed", merr); 558 559 /* lets create some sets */ 560 merr = mbImpl->tag_get_handle(GEOM_DIMENSION_TAG_NAME, 1, moab::MB_TYPE_INTEGER, geom_tag, moab::MB_TAG_CREAT|moab::MB_TAG_SPARSE, &dum_id);MBERRNM(merr); 561 merr = mbImpl->create_meshset(moab::MESHSET_SET, regionset);MBERRNM(merr); 562 563 for (a=0; a<(genCtx.dim>0?genCtx.A:genCtx.A); a++) { 564 for (b=0; b<(genCtx.dim>1?genCtx.B:1); b++) { 565 for (c=0; c<(genCtx.dim>2?genCtx.C:1); c++) { 566 567 moab::EntityHandle startv; 568 569 ierr = DMMoab_GenerateVertices_Private(mbImpl, readMeshIface, genCtx, ml, nl, kl, a, b, c, global_id_tag, startv, verts);CHKERRQ(ierr); 570 571 ierr = DMMoab_GenerateElements_Private(mbImpl, readMeshIface, genCtx, ml, nl, kl, a, b, c, global_id_tag, startv, cells);CHKERRQ(ierr); 572 573 PetscInt part_num=0; 574 switch(genCtx.dim) { 575 case 3: 576 part_num += (c+kl*genCtx.C)*(genCtx.M*genCtx.A * genCtx.N*genCtx.B); 577 case 2: 578 part_num += (b+nl*genCtx.B)*(genCtx.M*genCtx.A); 579 case 1: 580 part_num += (a+ml*genCtx.A); 581 break; 582 } 583 584 moab::EntityHandle part_set; 585 merr = mbImpl->create_meshset(moab::MESHSET_SET, part_set);MBERR("Can't create mesh set.", merr); 586 587 merr = mbImpl->add_entities(part_set, verts);MBERR("Can't add vertices to set.", merr); 588 merr = mbImpl->add_entities(part_set, cells);MBERR("Can't add entities to set.", merr); 589 // PetscInfo2(NULL, "Generated local mesh: %D vertices and %D elements.\n", verts.size(), cells.size()); 590 591 merr = mbImpl->add_entities(regionset, cells);MBERR("Can't add entities to set.", merr); 592 593 /* if needed, add all edges and faces */ 594 if (genCtx.adjEnts) 595 { 596 if (genCtx.dim > 1) { 597 merr = mbImpl->get_adjacencies(cells, 1, true, edges, moab::Interface::UNION);MBERR("Can't get edges", merr); 598 merr = mbImpl->add_entities(part_set, edges);MBERR("Can't add edges to partition set.", merr); 599 } 600 if (genCtx.dim > 2) { 601 merr = mbImpl->get_adjacencies(cells, 2, true, faces, moab::Interface::UNION);MBERR("Can't get faces", merr); 602 merr = mbImpl->add_entities(part_set, faces);MBERR("Can't add faces to partition set.", merr); 603 } 604 edges.clear(); 605 faces.clear(); 606 } 607 verts.clear(); cells.clear(); 608 609 merr = mbImpl->tag_set_data(part_tag, &part_set, 1, &part_num);MBERR("Can't set part tag on set", merr); 610 if (dmmoab->fileset) { 611 merr = mbImpl->add_parent_child(dmmoab->fileset, part_set);MBERR("Can't add part set to file set.", merr); 612 merr = mbImpl->unite_meshset(dmmoab->fileset, part_set);MBERRNM(merr); 613 } 614 merr = mbImpl->add_entities(dmmoab->fileset, &part_set, 1);MBERRNM(merr); 615 } 616 } 617 } 618 619 /* set geometric dimension tag for regions */ 620 merr = mbImpl->tag_set_data(geom_tag, ®ionset, 1, &dmmoab->dim);MBERRNM(merr); 621 merr = mbImpl->add_parent_child(dmmoab->fileset,regionset);MBERRNM(merr); 622 623 /* Only in parallel: resolve shared entities between processors and exchange ghost layers */ 624 if (global_size>1) { 625 626 merr = mbImpl->get_entities_by_dimension(dmmoab->fileset, genCtx.dim, cells);MBERR("Can't get all d-dimensional elements.", merr); 627 merr = mbImpl->get_entities_by_dimension(dmmoab->fileset, 0, verts);MBERR("Can't get all vertices.", merr); 628 629 if (genCtx.A*genCtx.B*genCtx.C!=1) { // merge needed 630 moab::MergeMesh mm(mbImpl); 631 if (genCtx.newMergeMethod) { 632 merr = mm.merge_using_integer_tag(verts, global_id_tag);MBERR("Can't merge with GLOBAL_ID tag", merr); 633 } 634 else { 635 merr = mm.merge_entities(cells, 0.0001);MBERR("Can't merge with coordinates", merr); 636 } 637 } 638 639 /* check the handles */ 640 merr = pcomm->check_all_shared_handles();MBERRV(mbImpl,merr); 641 642 /* resolve the shared entities by exchanging information to adjacent processors */ 643 merr = pcomm->resolve_shared_ents(dmmoab->fileset,cells,dim,dim-1,NULL,&global_id_tag);MBERRV(mbImpl,merr); 644 if (dmmoab->fileset) { 645 merr = pcomm->exchange_ghost_cells(dim,0,nghost,dim,true,false,&dmmoab->fileset);MBERRV(mbImpl,merr); 646 } 647 else { 648 merr = pcomm->exchange_ghost_cells(dim,0,nghost,dim,true,false);MBERRV(mbImpl,merr); 649 } 650 651 /* Reassign global IDs on all entities. */ 652 merr = pcomm->assign_global_ids(dmmoab->fileset,dim,1,false,true,false);MBERRNM(merr); 653 } 654 655 if (!genCtx.keep_skins) { // default is to delete the 1- and 2-dimensional entities 656 // delete all quads and edges 657 moab::Range toDelete; 658 if (genCtx.dim > 1) { 659 merr = mbImpl->get_entities_by_dimension(dmmoab->fileset, 1, toDelete);MBERR("Can't get edges", merr); 660 } 661 662 if (genCtx.dim > 2) { 663 merr = mbImpl->get_entities_by_dimension(dmmoab->fileset, 2, toDelete);MBERR("Can't get faces", merr); 664 } 665 666 merr = dmmoab->pcomm->delete_entities(toDelete) ;MBERR("Can't delete entities", merr); 667 } 668 PetscFunctionReturn(0); 669 } 670 671 672 #undef __FUNCT__ 673 #define __FUNCT__ "DMMoab_GetReadOptions_Private" 674 PetscErrorCode DMMoab_GetReadOptions_Private(PetscBool by_rank, PetscInt numproc, PetscInt dim, PetscInt nghost, MoabReadMode mode, PetscInt dbglevel, const char* dm_opts, const char* extra_opts, const char** read_opts) 675 { 676 char *ropts; 677 char ropts_par[PETSC_MAX_PATH_LEN],ropts_pargh[PETSC_MAX_PATH_LEN]; 678 char ropts_dbg[PETSC_MAX_PATH_LEN]; 679 PetscErrorCode ierr; 680 681 PetscFunctionBegin; 682 ierr = PetscMalloc1(PETSC_MAX_PATH_LEN,&ropts);CHKERRQ(ierr); 683 ierr = PetscMemzero(&ropts_par,PETSC_MAX_PATH_LEN);CHKERRQ(ierr); 684 ierr = PetscMemzero(&ropts_pargh,PETSC_MAX_PATH_LEN);CHKERRQ(ierr); 685 ierr = PetscMemzero(&ropts_dbg,PETSC_MAX_PATH_LEN);CHKERRQ(ierr); 686 687 /* do parallel read unless using only one processor */ 688 if (numproc > 1) { 689 // ierr = PetscSNPrintf(ropts_par, PETSC_MAX_PATH_LEN, "PARALLEL=%s;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;PARALLEL_GHOSTS=%d.0.1%s;",MoabReadModes[mode],dim,(by_rank ? ";PARTITION_BY_RANK":""));CHKERRQ(ierr); 690 ierr = PetscSNPrintf(ropts_par, PETSC_MAX_PATH_LEN, "PARALLEL=%s;PARTITION=PARALLEL_PARTITION;PARTITION_DISTRIBUTE;PARALLEL_RESOLVE_SHARED_ENTS;%s",MoabReadModes[mode],(by_rank ? "PARTITION_BY_RANK;":""));CHKERRQ(ierr); 691 if (nghost) { 692 ierr = PetscSNPrintf(ropts_pargh, PETSC_MAX_PATH_LEN, "PARALLEL_GHOSTS=%d.0.%d;",dim,nghost);CHKERRQ(ierr); 693 } 694 } 695 696 if (dbglevel) { 697 if (numproc>1) { 698 ierr = PetscSNPrintf(ropts_dbg, PETSC_MAX_PATH_LEN, "CPUTIME;DEBUG_IO=%d;DEBUG_PIO=%d;",dbglevel,dbglevel);CHKERRQ(ierr); 699 } 700 else { 701 ierr = PetscSNPrintf(ropts_dbg, PETSC_MAX_PATH_LEN, "CPUTIME;DEBUG_IO=%d;",dbglevel);CHKERRQ(ierr); 702 } 703 } 704 705 ierr = PetscSNPrintf(ropts, PETSC_MAX_PATH_LEN, "%s%s%s%s%s",ropts_par,(nghost?ropts_pargh:""),ropts_dbg,(extra_opts?extra_opts:""),(dm_opts?dm_opts:""));CHKERRQ(ierr); 706 *read_opts = ropts; 707 PetscFunctionReturn(0); 708 } 709 710 711 /*@ 712 DMMoabLoadFromFile - Creates a DM object by loading the mesh from a user specified file. 713 714 Collective on MPI_Comm 715 716 Input Parameters: 717 + comm - The communicator for the DM object 718 . dim - The spatial dimension 719 . filename - The name of the mesh file to be loaded 720 . usrreadopts - The options string to read a MOAB mesh. 721 Reference (Parallel Mesh Initialization: http://www.mcs.anl.gov/~fathom/moab-docs/html/contents.html#fivetwo) 722 723 Output Parameter: 724 . dm - The DM object 725 726 Level: beginner 727 728 .keywords: DM, create 729 730 .seealso: DMSetType(), DMCreate(), DMMoabCreateBoxMesh() 731 @*/ 732 PetscErrorCode DMMoabLoadFromFile(MPI_Comm comm,PetscInt dim,PetscInt nghost,const char* filename,const char* usrreadopts,DM *dm) 733 { 734 moab::ErrorCode merr; 735 PetscInt nprocs; 736 DM_Moab *dmmoab; 737 moab::Interface *mbiface; 738 moab::ParallelComm *pcomm; 739 moab::Range verts,elems; 740 const char *readopts; 741 PetscErrorCode ierr; 742 743 PetscFunctionBegin; 744 PetscValidPointer(dm,6); 745 746 /* Create the basic DMMoab object and keep the default parameters created by DM impls */ 747 ierr = DMMoabCreateMoab(comm, NULL, NULL, NULL, NULL, dm);CHKERRQ(ierr); 748 749 /* get all the necessary handles from the private DM object */ 750 dmmoab = (DM_Moab*)(*dm)->data; 751 mbiface = dmmoab->mbiface; 752 pcomm = dmmoab->pcomm; 753 nprocs = pcomm->size(); 754 /* TODO: Decipher dimension based on the loaded mesh instead of getting from user */ 755 dmmoab->dim = dim; 756 dmmoab->nghostrings=nghost; 757 758 /* create a file set to associate all entities in current mesh */ 759 merr = dmmoab->mbiface->create_meshset(moab::MESHSET_SET, dmmoab->fileset);MBERR("Creating file set failed", merr); 760 761 /* add mesh loading options specific to the DM */ 762 ierr = DMMoab_GetReadOptions_Private(dmmoab->partition_by_rank, nprocs, dim, nghost, dmmoab->read_mode, 763 dmmoab->rw_dbglevel, dmmoab->extra_read_options, usrreadopts, &readopts);CHKERRQ(ierr); 764 765 PetscInfo2(*dm, "Reading file %s with options: %s\n",filename,readopts); 766 767 /* Load the mesh from a file. */ 768 if (dmmoab->fileset) { 769 merr = mbiface->load_file(filename, &dmmoab->fileset, readopts);MBERRVM(mbiface,"Reading MOAB file failed.", merr); 770 } 771 else { 772 merr = mbiface->load_file(filename, 0, readopts);MBERRVM(mbiface,"Reading MOAB file failed.", merr); 773 } 774 775 /* Reassign global IDs on all entities. */ 776 merr = pcomm->assign_global_ids(dmmoab->fileset,dim,1,true,true,true);MBERRNM(merr); 777 778 /* load the local vertices */ 779 merr = mbiface->get_entities_by_type(dmmoab->fileset, moab::MBVERTEX, verts, true);MBERRNM(merr); 780 /* load the local elements */ 781 merr = mbiface->get_entities_by_dimension(dmmoab->fileset, dim, elems, true);MBERRNM(merr); 782 783 /* Everything is set up, now just do a tag exchange to update tags 784 on all of the ghost vertexes */ 785 merr = pcomm->exchange_tags(dmmoab->ltog_tag,verts);MBERRV(mbiface,merr); 786 merr = pcomm->exchange_tags(dmmoab->ltog_tag,elems);MBERRV(mbiface,merr); 787 merr = pcomm->collective_sync_partition();MBERR("Collective sync failed", merr); 788 789 PetscInfo3(*dm, "MOAB file '%s' was successfully loaded. Found %D vertices and %D elements.\n", filename, verts.size(), elems.size()); 790 ierr = PetscFree(readopts);CHKERRQ(ierr); 791 PetscFunctionReturn(0); 792 } 793 794