00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <med.h>
00025 #define MESGERR 1
00026 #include <med_utils.h>
00027
00028 #include <string.h>
00029
00030 int main (int argc, char **argv) {
00031 med_idt fid;
00032 const char meshname[MED_NAME_SIZE+1] = "3D Unstructured Mesh With 2 polyhedrons";
00033 const med_int spacedim = 3;
00034 const med_int meshdim = 3;
00035
00036 const char axisname[3*MED_SNAME_SIZE+1] = "x y z ";
00037 const char unitname[3*MED_SNAME_SIZE+1] = "cm cm cm ";
00038
00039 const med_int nnodes = 16;
00040 const med_float coordinates[3 * 16] = {
00041 -10.0, -10.0, +0.0,
00042 -10.0, -10.0, +10.,
00043 -10.0, +10.0, +10.,
00044 -10.0, +10.0, +0.0,
00045 +10.0, -10.0, +0.0,
00046 +10.0, -10.0, +10.,
00047 +10.0, +10.0, +10.,
00048 +10.0, +10.0, +0.0,
00049 -10.0, +0.0 , +10.0,
00050 -10.0, +0.0 , +0.0 ,
00051 +0.0 , -10.0 , +10.0,
00052 +0.0 , -10.0 , +0.0 ,
00053 +0.0 , +10.0 , +10.0,
00054 +10.0, +0.0 , +10.0,
00055 +0.0 , +10.0 , +0.0 ,
00056 +10.0, +0.0 , +0.0
00057 };
00058
00059
00060 const med_int connectivity[26+32] = {
00061
00062 1, 2 , 9 , 3 , 10,
00063 1, 12 , 5 , 6 , 11, 2,
00064 2, 11 , 6 , 3 , 9 ,
00065 3, 6 , 5 ,
00066 3, 5 , 10 ,
00067 1, 10 , 5 , 12,
00068
00069 3, 13 , 7 , 8 , 15, 4,
00070 3, 4 , 10 ,
00071 4, 15 , 8 , 16 , 5, 10,
00072 3, 6 , 14 , 7 , 13,
00073 5, 16 , 8 , 7 , 14, 6,
00074 3, 10 , 5 ,
00075 3, 5 , 6
00076 };
00077
00078
00079
00080 const med_int nodeindex[6+7+1] = { 1, 6, 12, 17, 20, 23,
00081 27, 33, 36, 42, 47, 53, 56, 59};
00082
00083
00084 const med_int nodeindexSize = 6+7+1;
00085
00086
00087
00088 const med_int faceindex[3] = {1,7,14};
00089 const med_int faceindexSize = 3;
00090
00091
00092
00093 fid = MEDfileOpen("UsesCase_MEDmesh_15.med",
00094 MED_ACC_CREAT);
00095 if (fid < 0) {
00096 MESSAGE("ERROR : file creation ...");
00097 return -1;
00098 }
00099
00100
00101 if (MEDfileCommentWr(fid,
00102 "A 3D unstructured mesh : 2 polyhedrons") < 0) {
00103 MESSAGE("ERROR : write file description ...");
00104 return -1;
00105 }
00106
00107
00108 if (MEDmeshCr(fid, meshname, spacedim, meshdim,
00109 MED_UNSTRUCTURED_MESH, "A 3D mesh with 2 polyhedron",
00110 "", MED_SORT_DTIT,
00111 MED_CARTESIAN, axisname, unitname) < 0) {
00112 MESSAGE("ERROR : mesh creation ...");
00113 return -1;
00114 }
00115
00116
00117
00118
00119 if (MEDmeshNodeCoordinateWr(fid, meshname,
00120 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00121 MED_FULL_INTERLACE, nnodes, coordinates) < 0) {
00122 MESSAGE("ERROR : nodes coordinates ...");
00123 return -1;
00124 }
00125
00126
00127 if (MEDmeshPolyhedronWr(fid, meshname,
00128 MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00129 MED_CELL, MED_NODAL,
00130 faceindexSize, faceindex,
00131 nodeindexSize, nodeindex,
00132 connectivity) < 0) {
00133 MESSAGE("ERROR : polyhedron connectivity ...");
00134 return -1;
00135 }
00136
00137
00138 if (MEDfamilyCr(fid, meshname, "", 0, 0, "") < 0) {
00139 MESSAGE("ERROR : quadrangular cells connectivity ...");
00140 return -1;
00141 }
00142
00143
00144 if (MEDfileClose(fid) < 0) {
00145 MESSAGE("ERROR : close file ...");
00146 return -1;
00147 }
00148
00149 return 0;
00150 }