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";
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 const med_int nnodes = 12;
00039 const med_float coordinates[3 * 12] =
00040 { 1.618, 1., 0.,
00041 -1.618, 1., 0.,
00042 1.618, -1., 0.,
00043 -1.618, -1., 0.,
00044 1., 0., 1.618,
00045 1., 0., -1.618,
00046 -1., 0., 1.618,
00047 -1., 0., -1.618,
00048 0., 1.618, 1.,
00049 0., -1.618, 1.,
00050 0., 1.618, 1.,
00051 0., -1.618, 1. };
00052 const med_int nodeindex[2] = {1,21};
00053 const med_int nodeIndexSize = 2;
00054 const med_int faceindex[21] = { 1, 4, 7,10,13,16,19,22,25,28,
00055 31,34,37,40,43,46,49,52,55,58,61 };
00056 const med_int faceIndexSize = 21;
00057
00058 const med_int connectivity[60] = { 1, 9, 5,
00059 1, 6, 11,
00060 3, 5, 10,
00061 3, 12, 6,
00062 2, 7, 9,
00063 2, 11, 8,
00064 4, 10, 7,
00065 4, 8, 12,
00066 1, 11, 9,
00067 2, 9, 11,
00068 3, 10, 12,
00069 4, 10, 12,
00070 5, 3, 1,
00071 6, 1, 3,
00072 7, 2, 4,
00073 8, 4, 2,
00074 9, 7, 5,
00075 10, 5, 7,
00076 11, 6, 8,
00077 12, 8, 6 };
00078
00079
00080 fid = MEDfileOpen("UsesCase_MEDmesh_15.med",
00081 MED_ACC_CREAT);
00082 if (fid < 0) {
00083 MESSAGE("ERROR : file creation ...");
00084 return -1;
00085 }
00086
00087
00088 if (MEDfileCommentWr(fid,
00089 "A 3D unstructured mesh : 1 icosahedron") < 0) {
00090 MESSAGE("ERROR : write file description ...");
00091 return -1;
00092 }
00093
00094
00095 if (MEDmeshCr(fid,
00096 meshname,
00097 spacedim,
00098 meshdim,
00099 MED_UNSTRUCTURED_MESH,
00100 "A 3D mesh with 1 icosahedron",
00101 "",
00102 MED_SORT_DTIT,
00103 MED_CARTESIAN,
00104 axisname,
00105 unitname) < 0) {
00106 MESSAGE("ERROR : mesh creation ...");
00107 return -1;
00108 }
00109
00110
00111
00112
00113 if (MEDmeshNodeCoordinateWr(fid,
00114 meshname,
00115 MED_NO_DT,
00116 MED_NO_IT,
00117 MED_UNDEF_DT,
00118 MED_FULL_INTERLACE,
00119 nnodes,
00120 coordinates) < 0) {
00121 MESSAGE("ERROR : nodes coordinates ...");
00122 return -1;
00123 }
00124
00125
00126
00127 if (MEDmeshPolyhedronWr(fid,
00128 meshname,
00129 MED_NO_DT,
00130 MED_NO_IT,
00131 MED_UNDEF_DT,
00132 MED_CELL,
00133 MED_NODAL,
00134 nodeIndexSize,
00135 nodeindex,
00136 faceIndexSize,
00137 faceindex,
00138 connectivity) < 0) {
00139 MESSAGE("ERROR : polyhedron connectivity ...");
00140 return -1;
00141 }
00142
00143
00144 if (MEDfamilyCr(fid,
00145 meshname,
00146 "",
00147 0,
00148 0,
00149 "") < 0) {
00150 MESSAGE("ERROR : quadrangular cells connectivity ...");
00151 return -1;
00152 }
00153
00154
00155 if (MEDfileClose(fid) < 0) {
00156 MESSAGE("ERROR : close file ...");
00157 return -1;
00158 }
00159
00160 return 0;
00161 }