35 long posnp,posnt,posncor,posned,posnq,posreq,posreqed,posntreq,posnqreq;
36 MMG5_int k,
tmp,ncor,norient,nreq,ntreq,nreqed,nqreq,nref;
44 posnp = posnt = posncor = posned = posnq = posreq = posreqed = posntreq = posnqreq = 0;
45 ncor = nreq = nreqed = ntreq = nqreq = 0;
54 ptr = strstr(data,
".mesh");
56 strcat(data,
".meshb");
57 if (!(inm = fopen(data,
"rb")) ) {
58 ptr = strstr(data,
".mesh");
61 if (!(inm = fopen(data,
"rb")) ) {
69 ptr = strstr(data,
".meshb");
73 if( !(inm = fopen(data,
"rb")) ) {
79 fprintf(stdout,
" %%%% %s OPENED\n",data);
85 while(fscanf(inm,
"%127s",&chaine[0])!=EOF && strncmp(chaine,
"End",strlen(
"End")) ) {
86 if ( chaine[0] ==
'#' ) {
90 if(s[strlen(s)-1]==
'\n')
break;
95 if(!strncmp(chaine,
"MeshVersionFormatted",strlen(
"MeshVersionFormatted"))) {
99 else if(!strncmp(chaine,
"Dimension",strlen(
"Dimension"))) {
103 fprintf(stdout,
"WRONG USE OF 3dMedit option \n");
109 fprintf(stdout,
"BAD DIMENSION : %d\n",
mesh->
dim);
114 else if(!strncmp(chaine,
"Vertices",strlen(
"Vertices"))) {
119 else if(!strncmp(chaine,
"Triangles",strlen(
"Triangles"))) {
124 else if(!strncmp(chaine,
"Quadrilaterals",strlen(
"Quadrilaterals"))) {
129 else if(!strncmp(chaine,
"RequiredQuadrilaterals",strlen(
"RequiredQuadrilaterals"))) {
131 posnqreq = ftell(inm);
134 else if(!strncmp(chaine,
"Corners",strlen(
"Corners"))) {
136 posncor = ftell(inm);
139 else if(!strncmp(chaine,
"RequiredVertices",strlen(
"RequiredVertices"))) {
144 else if(!strncmp(chaine,
"Edges",strlen(
"Edges"))) {
149 else if(!strncmp(chaine,
"RequiredEdges",strlen(
"RequiredEdges"))) {
151 posreqed = ftell(inm);
154 else if(!strncmp(chaine,
"RequiredTriangles",strlen(
"RequiredTriangles"))) {
156 posntreq = ftell(inm);
168 fprintf(stdout,
"BAD FILE ENCODING\n");
172 while(fread(&binch,
MMG5_SW,1,inm)!=0 && binch!=54 ) {
175 if(!bdim && binch==3) {
182 fprintf(stdout,
"BAD MESH DIMENSION : %d\n",
mesh->
dim);
186 }
else if(!
mesh->
np && binch==4) {
193 fseek(inm,bpos,SEEK_SET);
195 }
else if(!
mesh->
nt && binch==6) {
202 fseek(inm,bpos,SEEK_SET);
210 posntreq = ftell(inm);
212 fseek(inm,bpos,SEEK_SET);
221 fseek(inm,bpos,SEEK_SET);
223 }
else if(binch==18) {
228 posnqreq = ftell(inm);
230 fseek(inm,bpos,SEEK_SET);
232 }
else if(!ncor && binch==13) {
237 posncor = ftell(inm);
239 fseek(inm,bpos,SEEK_SET);
241 }
else if(!
mesh->
na && binch==5) {
248 fseek(inm,bpos,SEEK_SET);
250 }
else if(!nreqed && binch==16) {
255 posreqed = ftell(inm);
257 fseek(inm,bpos,SEEK_SET);
259 }
else if(!nreq && binch==15) {
266 fseek(inm,bpos,SEEK_SET);
274 fseek(inm,bpos,SEEK_SET);
281 fprintf(stdout,
" ** MISSING DATA : no point\n");
289 fprintf(stdout,
" ** MISSING DATA\n");
298 fseek(inm,posnp,SEEK_SET);
299 for (k=1; k<=
mesh->
np; k++) {
304 for (i=0 ; i<3 ; i++) {
307 ppt->
c[i] = (double) fc;
310 for (i=0 ; i<2 ; i++) {
312 ppt->
c[i] = (double) fc;
318 fprintf(stderr,
" ## Warning: %s: binary not available with"
319 " -msh option.\n",__func__);
322 for (i=0 ; i<2 ; i++) {
325 ppt->
c[i] = (double) fc;
333 MMG_FSCANF(inm,
"%lf %lf %lf %" MMG5_PRId
"",&ppt->
c[0],&ppt->
c[1],&dtmp,&ppt->
ref);
335 MMG_FSCANF(inm,
"%lf %lf %" MMG5_PRId
"",&ppt->
c[0],&ppt->
c[1],&ppt->
ref);
339 for (i=0 ; i<2 ; i++) {
347 if ( ppt->
ref < 0 ) {
356 fseek(inm,posned,SEEK_SET);
357 for (k=1; k<=
mesh->
na; k++) {
360 MMG_FSCANF(inm,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"",&ped->
a,&ped->
b,&ped->
ref);
370 if ( ped->
ref < 0 ) {
380 fseek(inm,posnt,SEEK_SET);
382 for (k=1; k<=
mesh->
nt; k++) {
385 MMG_FSCANF(inm,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"",&pt->
v[0],&pt->
v[1],&pt->
v[2],&pt->
ref);
388 for (i=0 ; i<3 ; i++) {
395 for (i=0; i<3; i++) {
419 fprintf(stdout,
"\n $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n");
420 fprintf(stdout,
" BAD ORIENTATION : vol < 0 -- %8" MMG5_PRId
" element(s) reoriented\n",norient);
421 fprintf(stdout,
" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n\n");
426 fseek(inm,posntreq,SEEK_SET);
427 for (k=1; k<=ntreq; k++) {
436 fprintf(stderr,
"\n ## Warning: %s: required triangle number %8" MMG5_PRId
""
437 " ignored.\n",__func__,i);
448 for (k=1; k<=
mesh->
np; k++) {
457 fseek(inm,posnq,SEEK_SET);
462 MMG_FSCANF(inm,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"",&pq1->
v[0],&pq1->
v[1],&pq1->
v[2],
463 &pq1->
v[3],&pq1->
ref);
466 for (i=0 ; i<4 ; i++) {
473 for (i=0; i<4; i++) {
478 if ( pq1->
ref < 0 ) {
486 fseek(inm,posnqreq,SEEK_SET);
487 for (k=1; k<=nqreq; k++) {
496 fprintf(stderr,
"\n ## Warning: %s: required quadrilaterals number"
497 " %8" MMG5_PRId
" ignored.\n",__func__,i);
512 fseek(inm,posncor,SEEK_SET);
513 for (k=1; k<=ncor; k++) {
529 fseek(inm,posreq,SEEK_SET);
530 for (k=1; k<=nreq; k++) {
547 fseek(inm,posreqed,SEEK_SET);
548 for (k=1; k<=nreqed; k++) {
564 fprintf(stdout,
"\n $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n");
565 fprintf(stdout,
" WARNING : %" MMG5_PRId
" entities with unexpected refs (ref< 0).\n",nref);
566 fprintf(stdout,
" We take their absolute values.\n");
567 fprintf(stdout,
" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n\n");
571 fprintf(stdout,
" NUMBER OF VERTICES %8" MMG5_PRId
" CORNERS %6" MMG5_PRId
"\n",
mesh->
np,ncor);
572 fprintf(stdout,
" NUMBER OF TRIANGLES %8" MMG5_PRId
"\n",
mesh->
nt);
574 fprintf(stdout,
" NUMBER OF QUADRILATERALS %8" MMG5_PRId
"\n",
mesh->
nquad);
577 fprintf(stdout,
" NUMBER OF EDGES %8" MMG5_PRId
"\n",
mesh->
na);
579 if ( nreq || nreqed || ntreq || nqreq ) {
580 fprintf(stdout,
" NUMBER OF REQUIRED ENTITIES: \n");
582 fprintf(stdout,
" VERTICES %8" MMG5_PRId
" \n",nreq);
584 fprintf(stdout,
" EDGES %8" MMG5_PRId
" \n",nreqed);
586 fprintf(stdout,
" TRIANGLES %8" MMG5_PRId
" \n",ntreq);
588 fprintf(stdout,
" QUADRILATERALS %8" MMG5_PRId
" \n",nqreq);
591 fprintf(stdout,
" NUMBER OF CORNERS %8" MMG5_PRId
" \n",ncor);
599 const char *filenameptr,*solnameptr;
616 fprintf(stderr,
" ## Error: %s: please provide input file name"
617 " (either in the mesh structure or as function argument).\n",
623 strcpy(
tmp,filenameptr);
645 if (
ier < 1 ) {
break; }
650 strcpy(soltmp,solnameptr);
653 fprintf(stderr,
"\n ## ERROR: WRONG DATA TYPE OR WRONG SOLUTION NUMBER.\n");
685 for (k=1; k<=
mesh->
np; k++) {
692 for ( k=1; k<=
mesh->
np; ++k ) {
694 if ( !
MG_VOK(ppt) )
continue;
696 z += fabs(ppt->
c[2]);
699 fprintf(stderr,
"\n ## Error: %s: Input mesh must be a two-dimensional mesh.\n",
708 long posNodes,posElts,*posNodeData;
716 &posNodes,&posElts,&posNodeData,
717 &bin,&iswp,&nelts,&nsols);
718 if (
ier < 1 )
return (
ier);
721 fprintf(stderr,
"Error: SEVERAL SOLUTIONS FOUND (%d)\n",nsols);
734 fprintf(stderr,
"\n ## Error: %s: Input mesh must be a two-dimensional mesh.\n",
741 fprintf(stdout,
" ** WARNING NO GIVEN TRIANGLE\n");
750 posNodes,posElts,posNodeData,
751 bin,iswp,nelts,nsols);
754 if (
ier < 1 )
return ier;
760 fprintf(stderr,
" ** ERROR WHEN PARSING THE INPUT FILE\n");
774 long posNodes,posElts,*posNodeData;
782 &posNodes,&posElts,&posNodeData,
783 &bin,&iswp,&nelts,&nsols);
784 if (
ier < 1 )
return (
ier);
790 printf(
" Exit program.\n"); fclose(inm);
802 fprintf(stderr,
"\n ## Error: %s: Input mesh must be a two-dimensional mesh.\n",
809 fprintf(stdout,
" ** WARNING NO GIVEN TRIANGLE\n");
818 posNodes,posElts,posNodeData,
819 bin,iswp,nelts,nsols);
823 fprintf(stderr,
" ** ERROR WHEN PARSING THE INPUT FILE\n");
851 for (i=0; i<
sol->size; i++) {
854 sol->m[
sol->size*pos+i] = (double)fbuf;
859 sol->m[
sol->size*pos+i] = (double)fbuf;
882 for (i=0; i<
sol->size; i++) {
885 sol->m[
sol->size*pos+i] = (double)dbuf;
890 sol->m[
sol->size*pos+i] = (double)dbuf;
908 int iswp,
ier,meshDim,*type,nsols,dim;
924 if (
ier < 1 )
return ier;
927 fprintf(stderr,
"Error: SEVERAL SOLUTIONS FOUND (%d)\n",nsols);
934 fprintf(stderr,
" ** MISMATCHES DATA: THE NUMBER OF VERTICES IN "
935 "THE MESH (%" MMG5_PRId
") DIFFERS FROM THE NUMBER OF VERTICES IN "
936 "THE SOLUTION (%" MMG5_PRId
") \n",
mesh->
np,np);
958 if ( ver )
sol->
ver = ver;
964 fseek(inm,posnp,SEEK_SET);
968 for (k=1; k<=
sol->
np; k++) {
973 for (k=1; k<=
sol->
np; k++) {
1000 int iswp,
ier,meshDim,nsols,*type;
1004 static int8_t mmgWarn = 0;
1015 if (
ier < 1 )
return ier;
1018 fprintf(stderr,
" ** MISMATCHES DATA: THE NUMBER OF VERTICES IN "
1019 "THE MESH (%" MMG5_PRId
") DIFFERS FROM THE NUMBER OF VERTICES IN "
1020 "THE SOLUTION (%" MMG5_PRId
") \n",
mesh->
np,np);
1030 fprintf(stderr,
"\n ## Error: %s: unexpected number of data (%d).\n",
1040 printf(
" Exit program.\n"); fclose(inm);
1045 for ( j=0; j<nsols; ++j) {
1050 sprintf(data,
"sol_%d",j);
1054 fprintf(stderr,
"\n ## Warning: %s: unable to set solution name for"
1055 " at least 1 solution.\n",__func__);
1067 if ( ver ) psl->
ver = ver;
1073 fseek(inm,posnp,SEEK_SET);
1075 if ( (*
sol)[0].ver == 1 ) {
1077 for (k=1; k<=
mesh->
np; k++) {
1078 for ( j=0; j<nsols; ++j ) {
1086 for (k=1; k<=
mesh->
np; k++) {
1087 for ( j=0; j<nsols; ++j ) {
1108 MMG5_int k,ne,np,nc,nreq,nereq,nedreq,nq,nqreq,bpos,ref;
1109 int bin, binch,gmsh;
1120 ptr = strstr(data,
".mesh");
1122 strcat(data,
".meshb");
1123 if( !(inm = fopen(data,
"wb")) ) {
1124 ptr = strstr(data,
".mesh");
1126 strcat(data,
".mesh");
1127 if( !(inm = fopen(data,
"wb")) ) {
1137 ptr = strstr(data,
".meshb");
1139 if( !(inm = fopen(data,
"wb")) ) {
1140 fprintf(stderr,
" ** UNABLE TO OPEN %s.\n",data);
1147 fprintf(stdout,
" %%%% %s OPENED\n",data);
1153 strcpy(&chaine[0],
"MeshVersionFormatted 2\n");
1154 fprintf(inm,
"%s",chaine);
1156 strcpy(&chaine[0],
"\n\nDimension 3\n");
1159 strcpy(&chaine[0],
"\n\nDimension 2\n");
1161 fprintf(inm,
"%s ",chaine);
1182 for (k=1; k<=
mesh->
np; k++) {
1189 strcpy(&chaine[0],
"\n\nVertices\n");
1190 fprintf(inm,
"%s",chaine);
1191 fprintf(inm,
"%" MMG5_PRId
"\n",np);
1206 for (k=1; k<=
mesh->
np; k++) {
1212 fprintf(inm,
"%.15lg %.15lg 0 %" MMG5_PRId
"\n",ppt->
c[0],ppt->
c[1],ref);
1215 fwrite((
unsigned char*)&ppt->
c[0],
MMG5_SD,1,inm);
1216 fwrite((
unsigned char*)&ppt->
c[1],
MMG5_SD,1,inm);
1217 fwrite((
unsigned char*)&dblb,
MMG5_SD,1,inm);
1218 fwrite((
unsigned char*)&ref,
MMG5_SW,1,inm);
1223 fprintf(inm,
"%.15lg %.15lg %" MMG5_PRId
"\n",ppt->
c[0],ppt->
c[1],ref);
1237 for (k=1; k<=
mesh->
np; k++) {
1244 strcpy(&chaine[0],
"\n\nCorners\n");
1245 fprintf(inm,
"%s",chaine);
1246 fprintf(inm,
"%" MMG5_PRId
"\n",nc);
1257 for (k=1; k<=
mesh->
np; k++) {
1261 fprintf(inm,
"%" MMG5_PRId
"\n",ppt->
tmp);
1272 for (k=1; k<=
mesh->
np; k++) {
1281 strcpy(&chaine[0],
"\n\nRequiredVertices\n");
1282 fprintf(inm,
"%s",chaine);
1283 fprintf(inm,
"%" MMG5_PRId
"\n",nreq);
1292 for (k=1; k<=
mesh->
np; k++) {
1299 fprintf(inm,
"%" MMG5_PRId
"\n",ppt->
tmp);
1311 strcpy(&chaine[0],
"\n\nEdges\n");
1312 fprintf(inm,
"%s",chaine);
1313 fprintf(inm,
"%" MMG5_PRId
"\n",
mesh->
na);
1322 for (k=1; k<=
mesh->
na; k++) {
1337 strcpy(&chaine[0],
"\n\nRequiredEdges\n");
1338 fprintf(inm,
"%s",chaine);
1339 fprintf(inm,
"%" MMG5_PRId
"\n",nedreq);
1345 fwrite(&nedreq,
MMG5_SW,1,inm);
1348 for (k=1; k<=
mesh->
na; k++) {
1352 fprintf(inm,
"%" MMG5_PRId
"\n",ne);
1364 for (k=1; k<=
mesh->
nt; k++) {
1366 if ( !
MG_EOK(pt) )
continue;
1374 strcpy(&chaine[0],
"\n\nTriangles\n");
1375 fprintf(inm,
"%s",chaine);
1376 fprintf(inm,
"%" MMG5_PRId
"\n",ne);
1385 for (k=1; k<=
mesh->
nt; k++) {
1390 fprintf(inm,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",
mesh->
point[pt->
v[0]].
tmp,
1404 strcpy(&chaine[0],
"\n\nRequiredTriangles\n");
1405 fprintf(inm,
"%s",chaine);
1406 fprintf(inm,
"%" MMG5_PRId
"\n",nereq);
1415 for (k=1; k<=
mesh->
nt; k++) {
1417 if ( !
MG_EOK(pt) )
continue;
1422 fprintf(inm,
"%" MMG5_PRId
"\n",ne);
1451 strcpy(&chaine[0],
"\n\nQuadrilaterals\n");
1452 fprintf(inm,
"%s",chaine);
1453 fprintf(inm,
"%" MMG5_PRId
"\n",nq);
1463 if ( !
MG_EOK(pq) )
continue;
1466 fprintf(inm,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",
mesh->
point[pq->
v[0]].
tmp,
1483 strcpy(&chaine[0],
"\n\nRequiredQuadrilaterals\n");
1484 fprintf(inm,
"%s",chaine);
1485 fprintf(inm,
"%" MMG5_PRId
"\n",nqreq);
1498 fprintf(inm,
"%" MMG5_PRId
"\n",k);
1508 strcpy(&chaine[0],
"\n\nEnd\n");
1509 fprintf(inm,
"%s",chaine);
1519 fprintf(stdout,
" NUMBER OF VERTICES %8" MMG5_PRId
" CORNERS %8" MMG5_PRId
""
1520 " REQUIRED %8" MMG5_PRId
"\n",np,nc,nreq);
1523 fprintf(stdout,
" NUMBER OF EDGES %8" MMG5_PRId
" REQUIRED %8" MMG5_PRId
"\n",
mesh->
na,nedreq);
1525 fprintf(stdout,
" NUMBER OF TRIANGLES %8" MMG5_PRId
" REQUIRED %8" MMG5_PRId
"\n",
1528 fprintf(stdout,
" NUMBER OF QUADRILATERALS %8" MMG5_PRId
" REQUIRED %8" MMG5_PRId
"\n",nq,nqreq);
1558 isol = pos *
sol->size;
1562 switch (
sol->size ) {
1564 fprintf(inm,
" %.15lg",
sol->m[isol]);
1567 fprintf(inm,
" %.15lg %.15lg 0",
sol->m[isol],
sol->m[isol+1]);
1570 fprintf(inm,
" %.15lg %.15lg %.15lg 0 0 1",
sol->m[isol],
sol->m[isol+1],
sol->m[isol+2]);
1577 switch (
sol->size ) {
1597 for (i=0; i<
sol->size; i++)
1598 fprintf(inm,
" %.15lg",
sol->m[isol + i]);
1601 for (i=0; i<
sol->size; i++)
1621 int binch,bin,dim,
ier,gmsh;
1623 if ( !
sol->
np )
return 1;
1627 fprintf(stderr,
"\n ## Warning: %s: no metric data to save.\n",__func__);
1635 if (
sol->
dim==2 && gmsh ) {
1646 if (
ier < 1 )
return ier;
1648 for (k=1; k<=
mesh->
np; k++) {
1650 if ( !
MG_VOK(ppt) )
continue;
1658 fprintf(inm,
"\n\nEnd\n");
1683 int binch,bin,npointSols,ncellSols,*size;
1684 int *type,*entities,
ier,gmsh,dim;
1687 if ( !(*
sol)[0].np )
return 1;
1716 printf(
"\n ## Warning: %s: unexpected entity type for solution %" MMG5_PRId
": %s."
1721 type[k] = (*sol)[k].type;
1722 size[k] = (*sol)[k].size;
1723 entities[k] = (*sol)[k].entities;
1731 if (
ier < 1 )
return ier;
1733 for (k=1; k<=
mesh->
np; k++) {
1735 if ( !
MG_VOK(ppt) )
continue;
1748 ncellSols,entities,type,size );
1750 for (k=1; k<=
mesh->
nt; k++) {
1752 if ( !
MG_EOK(ptt) )
continue;
1769 fprintf(inm,
"\n\nEnd\n");
1785 MMG5_int k,np,nt,nc;
1792 fprintf(out,
"MeshVersionFormatted %d\n\nDimension %d\n\n",1,2);
1795 for (k=1; k<=
mesh->
np; k++) {
1797 if ( pack &&
MG_VOK(ppt) ) {
1806 fprintf(out,
"Vertices\n %" MMG5_PRId
"\n\n",np);
1807 for (k=1; k<=
mesh->
np; k++) {
1809 if ( ( pack &&
MG_VOK(ppt) ) || !pack )
1810 fprintf(out,
"%f %f %" MMG5_PRId
"\n",ppt->
c[0],ppt->
c[1],ppt->
ref);
1814 for (k=1; k<=
mesh->
nt; k++) {
1819 fprintf(out,
"Triangles\n %" MMG5_PRId
"\n\n",nt);
1820 for (k=1; k<=
mesh->
nt; k++) {
1827 fprintf(out,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",p0->
tmp,p1->
tmp,p2->
tmp,pt->
ref);
1830 fprintf(out,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",pt->
v[0],pt->
v[1],pt->
v[2],pt->
ref);
1837 fprintf(out,
"Edges\n %" MMG5_PRId
"\n\n",
mesh->
na);
1838 for (k=1; k<=
mesh->
na; k++) {
1842 if ( pack ) fprintf(out,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",p1->
tmp,p2->
tmp,pa->
ref);
1843 else fprintf(out,
"%" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
"\n",pa->
a,pa->
b,pa->
ref);
1849 for (k=1; k<=
mesh->
np; k++) {
1855 fprintf(out,
"Corners\n %" MMG5_PRId
"\n\n",nc);
1856 for (k=1; k<=
mesh->
np; k++) {
1859 if ( pack ) fprintf(out,
"%" MMG5_PRId
"\n",ppt->
tmp);
1860 else fprintf(out,
"%" MMG5_PRId
"\n",k);
1866 fprintf(out,
"End\n");
1877 char *ptr,typ=0,*data;
1880 if ( met->
size == 1 ) typ =1;
1881 else if ( met->
size == 3 ) typ = 3;
1885 ptr = strstr(data,
".mesh");
1889 strcat(data,
".sol");
1890 out = fopen(data,
"w");
1895 for (k=1; k<=
mesh->
np; k++)
1899 fprintf(out,
"MeshVersionFormatted %d\n\nDimension %d\n\n",1,2);
1902 for (k=1; k<=
mesh->
np; k++) {
1904 if ( pack &&
MG_VOK(ppt) ) {
1914 fprintf(out,
"SolAtVertices\n %" MMG5_PRId
"\n%d %d\n\n",np,1,typ);
1915 for (k=1; k<=
mesh->
np; k++) {
1917 if ( ( pack &&
MG_VOK(ppt) ) || !pack ) {
1918 if ( met->
size == 1 )
1919 fprintf(out,
"%f\n",met->
m[k]);
1920 else if ( met->
size == 3 )
1921 fprintf(out,
"%f %f %f\n",met->
m[3*k+0],met->
m[3*k+1],met->
m[3*k+2]);
1926 fprintf(out,
"End\n");
1942 ptr = strstr(data,
".mesh");
1946 strcat(data,
".nor.sol");
1947 out = fopen(data,
"w");
1952 for (k=1; k<=
mesh->
np; k++)
1956 fprintf(out,
"MeshVersionFormatted %d\n\nDimension %d\n\n",1,2);
1959 for (k=1; k<=
mesh->
np; k++) {
1961 if ( pack &&
MG_VOK(ppt) ) {
1971 fprintf(out,
"SolAtVertices\n %" MMG5_PRId
"\n%d %d\n\n",np,1,2);
1972 for (k=1; k<=
mesh->
np; k++) {
1974 if ( ( pack &&
MG_VOK(ppt) ) || !pack ) {
1976 else fprintf(out,
"%f %f\n",0.0,0.0);
1981 fprintf(out,
"End\n");
1997 ptr = strstr(data,
".sol");
2001 strcat(data,
".disp.sol");
2002 out = fopen(data,
"w");
2006 for (k=1; k<=
mesh->
np; k++)
2010 fprintf(out,
"MeshVersionFormatted %d\n\nDimension %d\n\n",1,2);
2013 for (k=1; k<=
mesh->
np; k++) {
2015 if ( pack &&
MG_VOK(ppt) ) {
2025 fprintf(out,
"SolAtVertices\n %" MMG5_PRId
"\n%d %d\n\n",np,1,2);
2026 for (k=1; k<=
mesh->
np; k++) {
2028 if ( ( pack &&
MG_VOK(ppt) ) || !pack )
2029 fprintf(out,
"%f %f\n",disp->
m[2*(k-1)+1],disp->
m[2*(k-1)+2]);
2033 fprintf(out,
"End\n");
2055 printf(
"\n ## Error: %s: unable to save a file without a valid filename\n.",
2063 ptr = strstr(data,
".node");
2069 strcat(data,
".ele");
2070 if( !(inm = fopen(data,
"wb")) ) {
2071 fprintf(stderr,
" ** UNABLE TO OPEN %s.\n",data);
2076 fprintf(stdout,
" %%%% %s OPENED\n",data);
2080 for (k=1; k<=
mesh->
nt; k++) {
2082 if ( !
MG_EOK(pt) )
continue;
2087 fprintf(inm,
"%" MMG5_PRId
" %d %d\n\n",ne,
mesh->
dim+1,1);
2090 for ( k=1; k<=
mesh->
nt; ++k ) {
2094 fprintf(inm,
"%" MMG5_PRId
" ",++ne);
2097 for ( i=0; i<=
mesh->
dim; ++i ) {
2102 fprintf(inm,
"%" MMG5_PRId
"\n",pt->
ref);
2105 fprintf(stdout,
" NUMBER OF ELEMENT %8" MMG5_PRId
"\n",ne);
2116 MMG5_int k,i,ne,idx;
2127 printf(
"\n ## Error: %s: unable to save a file without a valid filename\n.",
2135 ptr = strstr(data,
".node");
2141 strcat(data,
".neigh");
2142 if( !(inm = fopen(data,
"wb")) ) {
2143 fprintf(stderr,
" ** UNABLE TO OPEN %s.\n",data);
2148 fprintf(stdout,
" %%%% %s OPENED\n",data);
2153 printf(
"\n ## Error: %s: unable to compute triangle adjacencies\n.",__func__);
2159 for (k=1; k<=
mesh->
nt; k++) {
2161 if ( !
MG_EOK(pt) )
continue;
2166 fprintf(inm,
"%" MMG5_PRId
" %d\n\n",ne,
mesh->
dim+1);
2169 for ( k=1; k<=
mesh->
nt; ++k ) {
2173 fprintf(inm,
"%" MMG5_PRId
" ",++ne);
2176 for ( i=1; i<=
mesh->
dim+1; ++i ) {
2179 fprintf(inm,
"%" MMG5_PRId
" ",idx);
2198 printf(
"\n ## Error: %s: unable to save boundary edges\n.",__func__);
2205 printf(
"\n ## Error: %s: unable to count and append internal edges\n.",__func__);
2237 const char *filenameptr,*solnameptr;
2254 fprintf(stderr,
" ## Error: %s: please provide input file name"
2255 " (either in the mesh structure or as function argument).\n",
2261 strcpy(
tmp,filenameptr);
2267 int8_t savesolFile = 0;
2289 if (
ier && savesolFile ) {
2293 strcpy(soltmp,solnameptr);
2296 fprintf(stderr,
"\n ## ERROR: WRONG DATA TYPE OR WRONG SOLUTION NUMBER.\n");
const char * MMG5_Get_formatName(enum MMG5_Format fmt)
const char * MMG5_Get_entitiesName(enum MMG5_entities ent)
int MMG5_Get_format(char *ptr, int fmt)
char * MMG5_Get_filenameExt(char *filename)
int MMG2D_Set_solSize(MMG5_pMesh mesh, MMG5_pSol sol, int typEntity, MMG5_int np, int typSol)
Set the size and type of a solution field.
int MMG2D_Set_inputSolName(MMG5_pMesh mesh, MMG5_pSol sol, const char *solin)
Set the name of the input solution file.
MMG5_pMesh MMG5_pSol * sol
if(!ier) exit(EXIT_FAILURE)
MMG5_pMesh char * filename
int MMG2D_hashTria(MMG5_pMesh mesh)
int MMG5_chkMetricType(MMG5_pMesh mesh, int *type, int *entities, FILE *inm)
void MMG5_printSolStats(MMG5_pMesh mesh, MMG5_pSol *sol)
float MMG5_swapf(float sbin)
int MMG5_saveSolAtTrianglesHeader(MMG5_pMesh mesh, FILE *inm, int ver, int bin, MMG5_int *bpos, int nsols, int nsolsAtTriangles, int *entities, int *type, int *size)
int MMG5_saveNode(MMG5_pMesh mesh, const char *filename)
int MMG5_saveEdge(MMG5_pMesh mesh, const char *filename, const char *ext)
int MMG5_saveSolHeader(MMG5_pMesh mesh, const char *filename, FILE **inm, int ver, int *bin, MMG5_int *bpos, MMG5_int np, int dim, int nsols, int *entities, int *type, int *size)
int MMG5_loadMshMesh_part1(MMG5_pMesh mesh, const char *filename, FILE **inm, long *posNodes, long *posElts, long **posNodeData, int *bin, int *iswp, MMG5_int *nelts, int *nsols)
double MMG5_swapd(double sbin)
int MMG5_loadMshMesh_part2(MMG5_pMesh mesh, MMG5_pSol *sol, FILE **inm, const long posNodes, const long posElts, const long *posNodeData, const int bin, const int iswp, const MMG5_int nelts, const int nsols)
int MMG5_saveMshMesh(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename, int metricData)
void MMG5_printMetStats(MMG5_pMesh mesh, MMG5_pSol met)
int MMG5_loadSolHeader(const char *filename, int meshDim, FILE **inm, int *ver, int *bin, int *iswp, MMG5_int *np, int *dim, int *nsols, int **type, long *posnp, int imprim)
int MMG5_swapbin(int sbin)
static int MMG2D_readDoubleSol(MMG5_pSol sol, FILE *inm, int bin, int iswp, MMG5_int pos)
int MMG2D_loadGenericMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Read mesh data in a format determined by the filename extension.
int MMG2D_saveTetgenMesh(MMG5_pMesh mesh, const char *filename)
Save data in Tetgen's Triangle format.
int MMG2D_saveMesh(MMG5_pMesh mesh, const char *filename)
Save a mesh in .mesh/.meshb format.
int MMG2D_saveMshMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
Save a mesh and multiple data fields in MSH format, ascii or binary depending on the filename extensi...
int MMG2D_loadMshMesh_and_allData(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
Load a mesh and all data from a file in MSH format.
static int MMG2D_readFloatSol(MMG5_pSol sol, FILE *inm, int bin, int iswp, MMG5_int pos)
int MMG2D_saveMshMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save a mesh and optionally one data field in MSH format, ascii or binary depending on the filename ex...
static int MMG2D_saveNeigh(MMG5_pMesh mesh, const char *filename)
int MMG2D_savedisp_db(MMG5_pMesh mesh, MMG5_pSol disp, char *filename, int8_t pack)
int MMG2D_saveGenericMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save mesh data in a file whose format depends on the filename extension.
int MMG2D_saveAllSols(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
Save one or more solutions in a solution file in medit file format.
int MMG2D_saveSol(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save metric field in medit solution file format.
int MMG2D_loadMesh(MMG5_pMesh mesh, const char *filename)
Load a mesh (in .mesh/.mesb format) from file.
static int MMG2D_saveEle(MMG5_pMesh mesh, const char *filename)
int MMG2D_savemesh_db(MMG5_pMesh mesh, char *filename, int8_t pack)
int MMG2D_loadSol(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Load a metric field (or other solution) in medit's .sol format.
int MMG2D_loadMshMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Load a mesh and possibly a solution in .msh format from file.
int MMG2D_savemet_db(MMG5_pMesh mesh, MMG5_pSol met, char *filename, int8_t pack)
int MMG2D_2dMeshCheck(MMG5_pMesh mesh)
static int MMG2D_saveEdge(MMG5_pMesh mesh, const char *filename)
int MMG2D_savenor_db(MMG5_pMesh mesh, char *filename, int8_t pack)
int MMG2D_loadAllSols(MMG5_pMesh mesh, MMG5_pSol *sol, const char *filename)
Load one or more solutions in a solution file in medit file format.
static void MMG2D_writeDoubleSol(MMG5_pSol sol, FILE *inm, int bin, MMG5_int pos, int gmsh)
int MMG2D_loadVtkMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Load a mesh and possibly data in VTK format from file.
int MMG2D_saveVtkMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save a mesh and optionally one solution in VTK format.
int MMG2D_saveVtuMesh(MMG5_pMesh mesh, MMG5_pSol sol, const char *filename)
Save a mesh and optionally one data field in VTU format.
int MMG2D_loadVtuMesh(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pSol sol, const char *filename)
Load a mesh and possibly data in VTU (VTK) format from file.
API headers and documentation for the mmg2d library.
LIBMMG2D_EXPORT int MMG2D_Get_numberOfNonBdyEdges(MMG5_pMesh mesh, MMG5_int *nb_edges)
Get the number of non-boundary edges.
int MMG2D_zaldy(MMG5_pMesh mesh)
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
double MMG2D_quickarea(double a[2], double b[2], double c[2])
#define MMG5_ADD_MEM(mesh, size, message, law)
#define MMG_FREAD(ptr, size, count, stream)
#define MMG5_SAFE_MALLOC(ptr, size, type, law)
#define MMG5_FILESTR_LGTH
#define MMG5_SAFE_FREE(ptr)
#define MMG_FSCANF(stream, format,...)
#define MMG5_DEL_MEM(mesh, ptr)
Structure to store edges of am MMG mesh.
Structure to store vertices of an MMG mesh.
Structure to store quadrangles of an MMG mesh.
Structure to store triangles of a MMG mesh.