med_int nmfifcow(const med_idt const *fid, const char const *comment, const med_int *commentlen) #endif { med_int _ret; char* _fs1; _fs1 = _MED2cstring((char *) comment, (med_int) *commentlen); if (!_fs1) return(-1); _ret = (med_int) MEDfileCommentWr(*fid, _fs1); _MEDcstringFree(_fs1); return(_ret); }
int main (int argc, char **argv) { med_err ret = 0; med_idt fid; char des[MED_COMMENT_SIZE+1]="Ceci est une courte description de mon fichier test1.med"; /* Creation du fichier "test1.med" */ fid = MEDfileOpen("test1.med",MODE_ACCES); if (fid < 0) { MESSAGE("Erreur à la creation du fichier"); return -1; } /* Ecriture d'un en-tete dans le fichier */ if (MEDfileCommentWr(fid,des) < 0) { MESSAGE("Erreur à l'ecriture de l'en-tete du fichier"); ret = -1; } /* Fermeture du fichier */ if ((ret = MEDfileClose(fid)) < 0) { MESSAGE("Erreur à la fermeture du fichier"); return -1; } /* Re-ouverture du fichier en lecture seule */ fid = MEDfileOpen("test1.med",MED_ACC_RDONLY); if (fid < 0) { MESSAGE("Erreur à l'ouverture du fichier en mode MED_LECTURE"); return -1; } /* Fermeture du fichier */ if (MEDfileClose(fid) < 0) ret = -1; return ret; }
int main (int argc, char **argv) { med_idt fid; const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh"; const med_int spacedim = 2; const med_int meshdim = 2; const char axisname[2*MED_SNAME_SIZE+1] = "x y "; const char unitname[2*MED_SNAME_SIZE+1] = "cm cm "; const med_float initial_coordinates[30] = { 2.,1., 7.,1., 12.,1., 17.,1., 22.,1., 2.,6., 7.,6., 12.,6., 17.,6., 22.,6., 2.,11., 7.,11., 12.,11., 17.,11., 22.,11.}; const med_int nnodes = 15; const med_int triaconnectivity[24] = { 1,7,6, 2,7,1, 3,7,2, 8,7,3, 13,7,8, 12,7,13, 11,7,12, 6,7,11 }; const med_int ntria3 = 8; const med_int quadconnectivity[16] = {3,4,9,8, 4,5,10,9, 15,14,9,10, 13,8,9,14}; const med_int nquad4 = 4; /* matrix transformation (step 1) : rotation about the Y-axis : 45 degrees */ const med_float tansfMatrix_step1 [7] = { 0.0, 0.0, 0.0, 0.92388, 0.0, 0.38268, 0.0 }; /* matrix transformation (step 2) : rotation about the Y-axis : 90 degrees */ const med_float tansfMatrix_step2 [7] = { 0.0, 0.0, 0.0, 0.707, 0.0, 0.707, 0.0 }; int ret=-1; /* open MED file */ fid = MEDfileOpen("UsesCase_MEDmesh_9.med",MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); goto ERROR; } /* write a comment in the file */ if (MEDfileCommentWr(fid,"A 2D unstructured mesh : 15 nodes, 12 cells") < 0) { MESSAGE("ERROR : write file description ..."); goto ERROR; } /* mesh creation : a 2D unstructured mesh */ if (MEDmeshCr(fid, meshname, spacedim, meshdim, MED_UNSTRUCTURED_MESH, "A 2D structured mesh","",MED_SORT_DTIT,MED_CARTESIAN, axisname, unitname) < 0) { MESSAGE("ERROR : mesh creation ..."); goto ERROR; } /* nodes coordinates in a cartesian axis in full interlace mode (X1,Y1, X2,Y2, X3,Y3, ...) with no iteration and computation step */ if (MEDmeshNodeCoordinateWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nnodes, initial_coordinates) < 0) { MESSAGE("ERROR : nodes coordinates ..."); goto ERROR; } /* cells connectiviy is defined in nodal mode */ if (MEDmeshElementConnectivityWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_TRIA3, MED_NODAL, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, ntria3, triaconnectivity) < 0) { MESSAGE("ERROR : triangular cells connectivity ..."); goto ERROR; } if (MEDmeshElementConnectivityWithProfileWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_QUAD4, MED_NODAL, MED_COMPACT_STMODE, MED_NO_PROFILE, MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nquad4, quadconnectivity) < 0) { MESSAGE("ERROR : quadrangular cells connectivity ..."); goto ERROR; } /* * Mesh deformation (nodes coordinates) in 2 steps * A rotation by step for each node */ /* STEP 1 : dt1 = 5.5, it = 1*/ if ( MEDmeshNodeCoordinateTrsfWr(fid, meshname, 1, 1, 5.5, tansfMatrix_step1) < 0) { MESSAGE("Erreur a l'ecriture de la transformation géométrique n°1"); goto ERROR; } /* STEP 2 : dt2 = 8.9, it = 1*/ if ( MEDmeshNodeCoordinateTrsfWr(fid, meshname, 2, 2, 8.9, tansfMatrix_step2 ) < 0) { MESSAGE("Erreur a l'ecriture de la transformation géométrique n°1"); goto ERROR; } /* create family 0 : by default, all mesh entities family number is 0 */ if (MEDfamilyCr(fid, meshname,MED_NO_NAME, 0, 0, MED_NO_GROUP) < 0) { MESSAGE("ERROR : create family ..."); goto ERROR; } ret=0; ERROR: /* close MED file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); ret=-1; } return ret; }
int main (int argc, char **argv) { med_idt fid; const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh"; const med_int spacedim = 2; const med_int meshdim = 2; /* 12345678901234561234567890123456 */ const char axisname[2*MED_SNAME_SIZE+1] = "x y "; const char unitname[2*MED_SNAME_SIZE+1] = "cm cm "; const med_float coordinates[30] = { 2.,1., 7.,1., 12.,1., 17.,1., 22.,1., 2.,6., 7.,6., 12.,6., 17.,6., 22.,6., 2.,11., 7.,11., 12.,11., 17.,11., 22.,11.}; const med_int nnodes = 15; const med_int triaconnectivity[24] = { 1,7,6, 2,7,1, 3,7,2, 8,7,3, 13,7,8, 12,7,13, 11,7,12, 6,7,11 }; const med_int ntria3 = 8; const med_int quadconnectivity[16] = {3,4,9,8, 4,5,10,9, 15,14,9,10, 13,8,9,14}; const med_int nquad4 = 4; med_err ret=-1; /* open MED file */ fid = MEDfileOpen("UsesCase_MEDmesh_1.med",MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); goto ERROR; } /* write a comment in the file */ if (MEDfileCommentWr(fid,"A 2D unstructured mesh : 15 nodes, 12 cells") < 0) { MESSAGE("ERROR : write file description ..."); goto ERROR; } /* mesh creation : a 2D unstructured mesh */ if (MEDmeshCr(fid, meshname, spacedim, meshdim, MED_UNSTRUCTURED_MESH, "A 2D unstructured mesh","",MED_SORT_DTIT,MED_CARTESIAN, axisname, unitname) < 0) { MESSAGE("ERROR : mesh creation ..."); goto ERROR; } /* nodes coordinates in a cartesian axis in full interlace mode (X1,Y1, X2,Y2, X3,Y3, ...) with no iteration and computation step */ if (MEDmeshNodeCoordinateWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_FULL_INTERLACE, nnodes, coordinates) < 0) { MESSAGE("ERROR : nodes coordinates ..."); goto ERROR; } /* cells connectiviy is defined in nodal mode with no iteration and computation step */ if (MEDmeshElementConnectivityWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_TRIA3, MED_NODAL, MED_FULL_INTERLACE, ntria3, triaconnectivity) < 0) { MESSAGE("ERROR : triangular cells connectivity ..."); goto ERROR; } if (MEDmeshElementConnectivityWr(fid, meshname, MED_NO_DT, MED_NO_IT, 0.0, MED_CELL, MED_QUAD4, MED_NODAL, MED_FULL_INTERLACE, nquad4, quadconnectivity) < 0) { MESSAGE("ERROR : quadrangular cells connectivity ..."); goto ERROR; } /* create family 0 : by default, all mesh entities family number is 0 */ if (MEDfamilyCr(fid, meshname,MED_NO_NAME, 0, 0, MED_NO_GROUP) < 0) { MESSAGE("ERROR : family 0 creation ..."); goto ERROR; } ret = 0; ERROR : /* close MED file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); return -1; } return ret; }
int main (int argc, char **argv) { med_idt fid; const char filename[] = "Unittest_MEDparameter_1.med"; const char comment[] = "Parameters unit tests"; const char p1name[] = "FLOAT_PARAMETER"; const char p2name[] = "INT_PARAMETER_1"; const char p3name[] = "INT_PARAMETER_2"; const med_parameter_type p1type = MED_FLOAT64; const med_parameter_type p2type = MED_INT; const med_parameter_type p3type = MED_INT; const char p1description[] = "PARAMETER 1 DESCRIPTION"; const char p2description[] = "PARAMETER 2 DESCRIPTION"; const char p3description[] = "PARAMETER 3 DESCRIPTION"; const char dtunit1[] = "DT UNIT P1"; const char dtunit2[] = "DT UNIT P2"; const char dtunit3[] = "DT UNIT P3"; med_int np; char nameToRead[MED_NAME_SIZE+1]; char descriptionToRead[MED_COMMENT_SIZE+1]; med_parameter_type typeToRead; char dtunitToRead[MED_SNAME_SIZE+1]; med_int nstepToRead; int i,j; med_float p1v1 = 6.98; med_float p1v2 = 19.07; med_float p1v3 = 78.0; med_int p1numdt1 = MED_NO_DT; med_int p1numdt2 = 1; med_int p1numdt3 = 1; med_int p1numit1 = MED_NO_IT; med_int p1numit2 = 3; med_int p1numit3 = 2; med_float p1dt1 = 0.0; med_float p1dt2 = 0.1; med_float p1dt3 = 5.5; const med_int p1ncpst = 3; med_int p2v1 = 5; med_int p2v2 = 6; med_int p2numit1 = MED_NO_IT; med_int p2numdt1 = MED_NO_DT; med_float p2dt1 = 0.0; const med_int p2ncpst = 1; med_int p3v1 = 77; med_int p3v2 = 89; med_int p3numdt1 = 1; med_int p3numit1 = 1; med_float p3dt1 = 18.9; med_int p3numdt2 = MED_NO_DT; med_int p3numit2 = MED_NO_IT; med_float p3dt2 = 0.0; const med_int p3ncpst = 2; med_int numdtToRead; med_int numitToRead; med_float dtToRead; med_float fvalueToRead; med_int ivalueToRead; /* file creation */ fid = MEDfileOpen(filename,MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); SSCRUTE(filename); return -1; } if (MEDfileCommentWr(fid,comment) < 0) { MESSAGE("ERROR : write comment ..."); SSCRUTE(comment); return -1; } /* create a MED_FLOAT64 parameter */ if (MEDparameterCr(fid, p1name, p1type, p1description, dtunit1) < 0) { MESSAGE("ERROR : parameter p1 creation ..."); SSCRUTE(p1name); return -1; } if (MEDparameterValueWr(fid, p1name, p1numdt1, p1numit1, p1dt1, (unsigned char*) &p1v1) < 0) { MESSAGE("ERROR : write p1v1 ..."); SSCRUTE(p1name); return -1; } if (MEDparameterValueWr(fid, p1name, p1numdt2, p1numit2, p1dt2, (unsigned char*) &p1v2) < 0) { MESSAGE("ERROR : write p1v2 ..."); SSCRUTE(p1name); return -1; } if (MEDparameterValueWr(fid, p1name, p1numdt3, p1numit3, p1dt3, (unsigned char*) &p1v3) < 0) { MESSAGE("ERROR : write p1v3 ..."); SSCRUTE(p1name); return -1; } /* create a MED_INT parameter with different values */ if (MEDparameterCr(fid, p2name, p2type, p2description, dtunit2) < 0) { MESSAGE("ERROR : paramter p2 creation ..."); SSCRUTE(p2name); return -1; } if (MEDparameterValueWr(fid, p2name, p2numdt1, p2numit1, p2dt1, (unsigned char*) &p2v1) < 0) { MESSAGE("ERROR : write p2v1 ..."); SSCRUTE(p2name); return -1; } if (MEDparameterValueWr(fid, p2name, p2numdt1, p2numit1, p2dt1, (unsigned char*) &p2v2) < 0) { MESSAGE("ERROR : write p2v2 on same computation step ..."); SSCRUTE(p2name); return -1; } /* create another MED_INT parameter */ if (MEDparameterCr(fid, p3name, p3type, p3description, dtunit3) < 0) { MESSAGE("ERROR : paramter p3 creation ..."); SSCRUTE(p3name); return -1; } if (MEDparameterValueWr(fid, p3name, p3numdt1, p3numit1, p3dt1, (unsigned char*) &p3v1) < 0) { MESSAGE("ERROR : write p3v1 ..."); SSCRUTE(p3name); return -1; } if (MEDparameterValueWr(fid, p3name, p3numdt2, p3numit2, p3dt2, (unsigned char*) &p3v2) < 0) { MESSAGE("ERROR : write p3v2 ..."); SSCRUTE(p3name); return -1; } /* close file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : file closing ..."); return -1; } /* open file in READ ONLY access mode */ fid = MEDfileOpen(filename,MED_ACC_RDONLY); if (fid < 0) { MESSAGE("ERROR : open in READ ONLY ACCESS mode ..."); SSCRUTE(filename); return -1; } /* direct access to parameters */ if (MEDparameterInfoByName(fid, p1name, &typeToRead, descriptionToRead, dtunitToRead, &nstepToRead) < 0) { MESSAGE("ERROR : read information for parameter p1 ..."); SSCRUTE(p1name); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if ((typeToRead != p1type) || strcmp(descriptionToRead, p1description) || strcmp(dtunitToRead,dtunit1) || (nstepToRead != p1ncpst)) { MESSAGE("ERROR : read information for parameter p1 : attributes ..."); SSCRUTE(p1name); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if (MEDparameterInfoByName(fid, p2name, &typeToRead, descriptionToRead, dtunitToRead, &nstepToRead) < 0) { MESSAGE("ERROR : read information for parameter p2 ..."); SSCRUTE(p2name); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if ((typeToRead != p2type) || strcmp(descriptionToRead, p2description) || strcmp(dtunitToRead,dtunit2) || (nstepToRead != p2ncpst)) { MESSAGE("ERROR : read information for parameter p2 : attributes ..."); SSCRUTE(p2name); ISCRUTE(typeToRead); ISCRUTE(p2type); SSCRUTE(descriptionToRead); SSCRUTE(p2description); SSCRUTE(dtunitToRead); SSCRUTE(dtunit2); ISCRUTE(nstepToRead); ISCRUTE(p2ncpst); return -1; } if (MEDparameterInfoByName(fid, p3name, &typeToRead, descriptionToRead, dtunitToRead, &nstepToRead) < 0) { MESSAGE("ERROR : read information for parameter p3 ..."); SSCRUTE(p3name); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if ((typeToRead != p3type) || strcmp(descriptionToRead, p3description) || strcmp(dtunitToRead,dtunit3) || (nstepToRead != p3ncpst)) { MESSAGE("ERROR : read information for parameter p2 : attributes ..."); SSCRUTE(p3name); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } /* how many parameter(s) in the file ? */ if ((np = MEDnParameter(fid)) < 0) { MESSAGE("ERROR : read number of paremeter ..."); ISCRUTE(np); return -1; } if (np != 3) { MESSAGE("The number of parameter is 3 !"); ISCRUTE(np); return -1; } /* TODO : A SUPPRIMER */ np=0; /* read informations for each parameter */ for (i=0;i<np;i++) { if (MEDparameterInfo(fid, i+1, nameToRead, &typeToRead, descriptionToRead, dtunitToRead, &nstepToRead) < 0) { MESSAGE("ERROR : read information for parameter p3 ..."); SSCRUTE(nameToRead); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if (i == 0) if (strcmp(nameToRead, p1name) || (typeToRead != p1type) || strcmp(descriptionToRead, p1description) || strcmp(dtunitToRead,dtunit1) || (nstepToRead != p1ncpst)) { MESSAGE("ERROR : read information for parameter p1 : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if (i == 1) if ( strcmp(nameToRead, p2name) || (typeToRead != p2type) || strcmp(descriptionToRead, p2description) || strcmp(dtunitToRead,dtunit2) || (nstepToRead != p2ncpst)) { MESSAGE("ERROR : read information for parameter p2 : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } if (i == 3) if (strcmp(nameToRead,p3name) || (typeToRead != p3type) || strcmp(descriptionToRead, p3description) || strcmp(dtunitToRead,dtunit3) || (nstepToRead != p3ncpst)) { MESSAGE("ERROR : read information for parameter p2 : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(typeToRead); SSCRUTE(descriptionToRead); SSCRUTE(dtunitToRead); ISCRUTE(nstepToRead); return -1; } /* read informations about each computation step and then read value for each parameter */ for (j=0; j<nstepToRead; j++) { if (MEDparameterComputationStepInfo(fid, nameToRead, j+1, &numdtToRead, &numitToRead, &dtToRead) < 0) { MESSAGE("ERROR : read information about computation step ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(numitToRead); return -1; } if (typeToRead == MED_FLOAT64) if (MEDparameterValueRd(fid, nameToRead, numdtToRead, numitToRead, (unsigned char *) &fvalueToRead) < 0) { MESSAGE("ERROR : read parameter value ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(numitToRead); return -1; } if (typeToRead != MED_FLOAT64) if (MEDparameterValueRd(fid, nameToRead, numdtToRead, numitToRead, (unsigned char *) &ivalueToRead) < 0) { MESSAGE("ERROR : read parameter value ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(numitToRead); ISCRUTE(ivalueToRead); return -1; } /* data verifications */ if ((i==0) && (j==0)) if ((numdtToRead != p1numdt1) || (numitToRead != p1numit1) || (dtToRead != p1dt1) || (fvalueToRead != p1v1)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p1numdt1); ISCRUTE(numitToRead); ISCRUTE(p1numit1); return -1; } if ((i==0) && (j==1)) if ((numdtToRead != p1numdt3) || (numitToRead != p1numit3) || (dtToRead != p1dt3) || (fvalueToRead != p1v3)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p1numdt3); ISCRUTE(numitToRead); ISCRUTE(p1numit3); return -1; } if ((i==0) && (j==2)) if ((numdtToRead != p1numdt2) || (numitToRead != p1numit2) || (dtToRead != p1dt2) || (fvalueToRead != p1v2)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p1numdt2); ISCRUTE(numitToRead); ISCRUTE(p1numit2); return -1; } if (i==1) if ((numdtToRead != p2numdt1) || (numitToRead != p2numit1) || (dtToRead != p2dt1) || (ivalueToRead != p2v2)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p2numdt1); ISCRUTE(numitToRead); ISCRUTE(p2numit1); return -1; } if ((i == 2) && (j == 0)) if ((numdtToRead != p3numdt2) || (numitToRead != p3numit2) || (dtToRead != p3dt2) || (ivalueToRead != p3v2)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p3numdt2); ISCRUTE(numitToRead); ISCRUTE(p3numit2); return -1; } if ((i == 2) && (j == 1)) if ((numdtToRead != p3numdt1) || (numitToRead != p3numit1) || (dtToRead != p3dt1) || (ivalueToRead != p3v1)) { MESSAGE("ERROR : false informations for computation step : attributes ..."); SSCRUTE(nameToRead); ISCRUTE(j); ISCRUTE(numdtToRead); ISCRUTE(p3numdt1); ISCRUTE(numitToRead); ISCRUTE(p3numit1); return -1; } } } /* close file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); return -1; } return 0; }
int main (int argc, char **argv) { med_idt fid; const char meshname[MED_NAME_SIZE+1] = "3D Unstructured Mesh With 2 polyhedrons"; const med_int spacedim = 3; const med_int meshdim = 3; /* 12345678901234561234567890123456 */ const char axisname[3*MED_SNAME_SIZE+1] = "x y z "; const char unitname[3*MED_SNAME_SIZE+1] = "cm cm cm "; const med_int nnodes = 16; const med_float coordinates[3 * 16] = { /* [ 1 ] */ -10.0, -10.0, +0.0, /* [ 2 ] */ -10.0, -10.0, +10., /* [ 3 ] */ -10.0, +10.0, +10., /* [ 4 ] */ -10.0, +10.0, +0.0, /* [ 5 ] */ +10.0, -10.0, +0.0, /* [ 6 ] */ +10.0, -10.0, +10., /* [ 7 ] */ +10.0, +10.0, +10., /* [ 8 ] */ +10.0, +10.0, +0.0, /* [ 9 ] */ -10.0, +0.0 , +10.0, /* [ 10 ] */ -10.0, +0.0 , +0.0 , /* [ 11 ] */ +0.0 , -10.0 , +10.0, /* [ 12 ] */ +0.0 , -10.0 , +0.0 , /* [ 13 ] */ +0.0 , +10.0 , +10.0, /* [ 14 ] */ +10.0, +0.0 , +10.0, /* [ 15 ] */ +0.0 , +10.0 , +0.0 , /* [ 16 ] */ +10.0, +0.0 , +0.0 }; /*Il y a 58 numéros de noeuds dans le tableau de connextivité*/ const med_int connectivity[26+32] = { /* - Poly 1 : */ /* - Face 1 : */ 1, 2 , 9 , 3 , 10, /* - Face 2 : */ 1, 12 , 5 , 6 , 11, 2, /* - Face 3 : */ 2, 11 , 6 , 3 , 9 , /* - Face 4 : */ 3, 6 , 5 , /* - Face 5 : */ 3, 5 , 10 , /* - Face 6 : */ 1, 10 , 5 , 12, /* - Poly 2 : */ /* - Face 1 : */ 3, 13 , 7 , 8 , 15, 4, /* - Face 2 : */ 3, 4 , 10 , /* - Face 3 : */ 4, 15 , 8 , 16 , 5, 10, /* - Face 4 : */ 3, 6 , 14 , 7 , 13, /* - Face 5 : */ 5, 16 , 8 , 7 , 14, 6, /* - Face 6 : */ 3, 10 , 5 , /* - Face 7 : */ 3, 5 , 6 }; /* Il y a deux polyèdres, le premier a 6 faces, le second 7 faces */ /* La face 7 du Poly 2 utilise 59-56=3 noeuds */ const med_int nodeindex[6+7+1] = { 1, 6, 12, 17, 20, 23, 27, 33, 36, 42, 47, 53, 56, 59}; /* Il y a un total de 13 faces */ /* NodeIndexSize == Nbre De Faces +1 */ const med_int nodeindexSize = 6+7+1; /* Il y a deux polyèdres, le premier a 6 faces, le second 7 faces */ /* Pn+1 == FaceIndex[n+1]== NodeIndexSize== Nbre De Faces +1 */ const med_int faceindex[3] = {1,7,14}; const med_int faceindexSize = 3; /* open MED file */ fid = MEDfileOpen("UsesCase_MEDmesh_15.med", MED_ACC_CREAT); if (fid < 0) { MESSAGE("ERROR : file creation ..."); return -1; } /* write a comment in the file */ if (MEDfileCommentWr(fid, "A 3D unstructured mesh : 2 polyhedrons") < 0) { MESSAGE("ERROR : write file description ..."); return -1; } /* mesh creation : a 3D unstructured mesh */ if (MEDmeshCr(fid, meshname, spacedim, meshdim, MED_UNSTRUCTURED_MESH, "A 3D mesh with 2 polyhedron", "", MED_SORT_DTIT, MED_CARTESIAN, axisname, unitname) < 0) { MESSAGE("ERROR : mesh creation ..."); return -1; } /* nodes coordinates in a cartesian axis in full interlace mode (X1,Y1, X2,Y2, X3,Y3, ...) with no iteration and computation step */ if (MEDmeshNodeCoordinateWr(fid, meshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_FULL_INTERLACE, nnodes, coordinates) < 0) { MESSAGE("ERROR : nodes coordinates ..."); return -1; } /* cells connectiviy is defined in nodal mode */ if (MEDmeshPolyhedronWr(fid, meshname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_CELL, MED_NODAL, faceindexSize, faceindex, nodeindexSize, nodeindex, connectivity) < 0) { MESSAGE("ERROR : polyhedron connectivity ..."); return -1; } /* create family 0 : by default, all mesh entities family number is 0 */ if (MEDfamilyCr(fid, meshname, "", 0, 0, "") < 0) { MESSAGE("ERROR : quadrangular cells connectivity ..."); return -1; } /* close MED file */ if (MEDfileClose(fid) < 0) { MESSAGE("ERROR : close file ..."); return -1; } return 0; }