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
00031 int main (int argc, char **argv) {
00032 med_idt fid=0,mfid=0,sfid=0;
00033 const med_int spacedim = 3;
00034 const char meshname[MED_NAME_SIZE+1] = "COMPUT_MESH";
00035 const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE";
00036 const med_int ncomponent = 1;
00037
00038 const char componentname[MED_SNAME_SIZE+1] = "TEMP ";
00039 const char componentunit[MED_SNAME_SIZE+1] = "CELSIUS ";
00040 med_geometry_type geotype=MED_NONE;
00041 const med_int nbeam = 1;
00042 char structelementname[MED_NAME_SIZE+1];
00043 const med_float tempvalue[3*1*4] = { 1.1, 2.2, 3.3, 4.4,
00044 5.5, 6.6, 7.7, 8.8,
00045 9.9, 10.1,11.11, 12.12};
00046 const char localization[MED_NAME_SIZE+1] = "BEAM_INTEGRATION_POINTS";
00047 const char localization2[MED_NAME_SIZE+1] = "BEAM_INTEGRATION_TRANSF";
00048 const med_float elementcoordinate[3*3] = { 0.0,0.0,0.0,
00049 0.0,0.0,0.0,
00050 0.0,0.0,0.0,};
00051 const med_float ipointcoordinate[3*3] = { 0.0,0.0,2.5,
00052 0.0,0.0,3.5,
00053 0.0,0.0,4.5};
00054 const med_float weight[4] = {1.0/4, 1.0/4, 1.0/4, 1.0/4};
00055 const char beamsectionname[MED_NAME_SIZE+1]="BEAM_SECTION_MESH";
00056 const med_int nipoint = 3;
00057 char interpname[MED_NAME_SIZE+1] = "geometrical transformation";
00058 const med_int nvariable=2;
00059 const med_int maxdegree=1;
00060 const med_int nmaxcoefficient=3;
00061 const med_int ncoefficient1_1 = 3;
00062 const med_int const power1_1[] = {0,0,1,0,0,1};
00063 const med_float const coefficient1_1[] = {1,-1,-1};
00064 const med_int ncoefficient1_2 = 1;
00065 const med_int const power1_2[] = {1,0};
00066 const med_float const coefficient1_2[] = {1};
00067 const med_int ncoefficient1_3 = 1;
00068 const med_int const power1_3[] = {0,1};
00069 const med_float const coefficient1_3[] = {1};
00070 int ret=-1;
00071
00072
00073
00074 fid = MEDfileOpen("UsesCase_MEDfield_17.med",MED_ACC_CREAT);
00075 if (fid < 0) {
00076 MESSAGE("ERROR : file creation ...");
00077 goto ERROR;
00078 }
00079
00080 if (( mfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_MESH_SUPPORT)) < 0 ) {
00081 MESSAGE("ERROR : file mounting ...");
00082 goto ERROR;
00083 }
00084
00085 if (( sfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
00086 MESSAGE("ERROR : file mounting ...");
00087 goto ERROR;
00088 }
00089
00090
00091 if (MEDlinkWr(fid,meshname,"./UsesCase_MEDstructElement_1.med") < 0) {
00092 MESSAGE("ERROR : create mesh link ...");
00093 goto ERROR;
00094 }
00095
00096
00097
00098
00099 strcpy(structelementname,MED_BEAM_NAME);
00100 geotype = MEDstructElementGeotype(fid,structelementname);
00101
00102
00103
00104 if (MEDinterpCr(fid, interpname, geotype, MED_FALSE, nvariable, maxdegree, nmaxcoefficient) < 0) {
00105 MESSAGE("ERROR : interpolation family creation ...");
00106 goto ERROR;
00107 }
00108
00109 if (MEDinterpBaseFunctionWr(fid,interpname,1,ncoefficient1_1,power1_1,coefficient1_1) < 0) {
00110 MESSAGE("ERROR : first base function creation ...");
00111 goto ERROR;
00112 }
00113
00114 if (MEDinterpBaseFunctionWr(fid,interpname,2,ncoefficient1_2,power1_2,coefficient1_2) < 0) {
00115 MESSAGE("ERROR : second base function creation ...");
00116 goto ERROR;
00117 }
00118
00119 if (MEDinterpBaseFunctionWr(fid,interpname,3,ncoefficient1_3,power1_3,coefficient1_3) < 0) {
00120 MESSAGE("ERROR : third base function creation ...");
00121 goto ERROR;
00122 }
00123
00124
00125
00126
00127 if (MEDlocalizationWr(fid, localization, geotype, spacedim,
00128 elementcoordinate, MED_FULL_INTERLACE,
00129 nipoint, ipointcoordinate, weight,
00130 MED_NO_INTERPOLATION, beamsectionname) < 0) {
00131 MESSAGE("ERROR : create famlily of integration points ...");
00132 goto ERROR;
00133 }
00134
00135 if (MEDlocalizationWr(fid, localization2, geotype, spacedim,
00136 elementcoordinate, MED_FULL_INTERLACE,
00137 nipoint, ipointcoordinate, weight,
00138 interpname, beamsectionname) < 0) {
00139 MESSAGE("ERROR : create famlily of integration points ...");
00140 goto ERROR;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
00150 ncomponent, componentname, componentunit,
00151 "ms", meshname) < 0) {
00152 MESSAGE("ERROR : create field");
00153 goto ERROR;
00154 }
00155
00156 if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00157 MED_STRUCT_ELEMENT, geotype,
00158 MED_COMPACT_PFLMODE, MED_NO_PROFILE, localization,
00159 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
00160 nbeam, (unsigned char*) tempvalue) < 0) {
00161 MESSAGE("ERROR : write field values on MED_BEAM ");
00162 goto ERROR;
00163 }
00164
00165 if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, 1, MED_UNDEF_DT,
00166 MED_STRUCT_ELEMENT, geotype,
00167 MED_COMPACT_PFLMODE, MED_NO_PROFILE, localization2,
00168 MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
00169 nbeam, (unsigned char*) tempvalue) < 0) {
00170 MESSAGE("ERROR : write field values on MED_BEAM ");
00171 goto ERROR;
00172 }
00173
00174
00175
00176
00177 if ( MEDfileObjectsUnmount(fid, mfid, MED_MESH_SUPPORT) < 0 ) {
00178 MESSAGE("ERROR : file unmounting ...");
00179 goto ERROR;
00180 }
00181
00182 if ( MEDfileObjectsUnmount(fid, sfid, MED_ELSTRUCT) < 0 ) {
00183 MESSAGE("ERROR : file unmounting ...");
00184 goto ERROR;
00185 }
00186
00187 ret=0;
00188 ERROR:
00189
00190
00191 if (MEDfileClose(fid) < 0) {
00192 MESSAGE("ERROR : close file ...");
00193 ret=-1;
00194 }
00195
00196 return ret;
00197 }
00198