Lines 32-38
Link Here
|
32 |
# err=MEDmeshComputationStepCr(fid, evol) |
32 |
# err=MEDmeshComputationStepCr(fid, evol) |
33 |
|
33 |
|
34 |
isolatednodes, verticesnodes, cellmaxnodes = 1,2,3 |
34 |
isolatednodes, verticesnodes, cellmaxnodes = 1,2,3 |
35 |
#print isolatednodes, verticesnodes, cellmaxnodes |
35 |
#print( isolatednodes, verticesnodes, cellmaxnodes ) |
36 |
MEDmeshAttributeWr(fid,meshnames[0],isolatednodes, verticesnodes, cellmaxnodes) |
36 |
MEDmeshAttributeWr(fid,meshnames[0],isolatednodes, verticesnodes, cellmaxnodes) |
37 |
|
37 |
|
38 |
# meshname = str().zfill(MED_NAME_SIZE ) |
38 |
# meshname = str().zfill(MED_NAME_SIZE ) |
Lines 43-72
Link Here
|
43 |
|
43 |
|
44 |
for it in range(1,MEDnMesh(fid)+1): |
44 |
for it in range(1,MEDnMesh(fid)+1): |
45 |
naxis1=MEDmeshnAxis(fid,it) |
45 |
naxis1=MEDmeshnAxis(fid,it) |
46 |
#print "Nombre d'axes du maillage n",it," : ",naxis1 |
46 |
#print( "Nombre d'axes du maillage n",it," : ",naxis1 ) |
47 |
meshinfo1=MEDmeshInfo(fid,it) |
47 |
meshinfo1=MEDmeshInfo(fid,it) |
48 |
meshname,spacedim1,meshdim1,meshtype1,description1,dtunit1,sortingtype1,nstep1,axistype1,axisname1,axisunit1=meshinfo1 |
48 |
meshname,spacedim1,meshdim1,meshtype1,description1,dtunit1,sortingtype1,nstep1,axistype1,axisname1,axisunit1=meshinfo1 |
49 |
# print meshinfo1 |
49 |
# print( meshinfo1 ) |
50 |
del(meshinfo1[0]);aff1=map(str,meshinfo1); print aff1 |
50 |
del(meshinfo1[0]);aff1=map(str,meshinfo1); print( aff1 ) |
51 |
naxis2 =MEDmeshnAxisByName(fid,meshname) |
51 |
naxis2 =MEDmeshnAxisByName(fid,meshname) |
52 |
if naxis1 != naxis2 : print "Erreur: les informations lues par MEDmeshnAxis (%s) et MEDmeshnAxisByname (%s) differes sur le maillage n%d" % (naxis1,naxis2,it);break |
52 |
if naxis1 != naxis2 : print( "Erreur: les informations lues par MEDmeshnAxis (%s) et MEDmeshnAxisByname (%s) differes sur le maillage n%d" % (naxis1,naxis2,it));break |
53 |
meshinfo2=MEDmeshInfoByName (fid,meshname) |
53 |
meshinfo2=MEDmeshInfoByName (fid,meshname) |
54 |
spacedim2,meshdim2,meshtype2,description2,dtunit2,sortingtype2,nstep2,axistype2,axisname2,axisunit2=meshinfo2 |
54 |
spacedim2,meshdim2,meshtype2,description2,dtunit2,sortingtype2,nstep2,axistype2,axisname2,axisunit2=meshinfo2 |
55 |
aff2=map(str,meshinfo2);#print aff2 |
55 |
aff2=map(str,meshinfo2);#print( aff2 ) |
56 |
if aff1 != aff2 : print "Erreur: les informations lues par MEDmeshInfo et MEDmeshInfoByname different sur le maillage n",it;break |
56 |
if aff1 != aff2 : print( "Erreur: les informations lues par MEDmeshInfo et MEDmeshInfoByname different sur le maillage n",it);break |
57 |
print "\nMaillage n :",it," de nom ",meshname |
57 |
print( "\nMaillage n :",it," de nom ",meshname ) |
58 |
print "\tspacedim:%d \n\tmeshdim:%d \n\tmeshtype:%s \n\tdescription:%s \n\tdtunit:%s \n\tsortingtype:%s \n\tnstep:%d \n\taxistype:%s \n\taxisname:%s \n\taxisunit:%s " % (spacedim2,meshdim2,meshtype2,description2,dtunit2,sortingtype2,nstep2,axistype2,axisname2,axisunit2) |
58 |
print( "\tspacedim:%d \n\tmeshdim:%d \n\tmeshtype:%s \n\tdescription:%s \n\tdtunit:%s \n\tsortingtype:%s \n\tnstep:%d \n\taxistype:%s \n\taxisname:%s \n\taxisunit:%s " % (spacedim2,meshdim2,meshtype2,description2,dtunit2,sortingtype2,nstep2,axistype2,axisname2,axisunit2) ) |
59 |
|
59 |
|
60 |
print MEDmeshSortingTypeRd(fid,meshname) |
60 |
print( MEDmeshSortingTypeRd(fid,meshname) ) |
61 |
print "\n\tNom universel du maillage : ",MEDmeshUniversalNameRd(fid,meshname) |
61 |
print( "\n\tNom universel du maillage : ",MEDmeshUniversalNameRd(fid,meshname) ) |
62 |
attmesh=MEDmeshAttributeRd( fid, meshname ); |
62 |
attmesh=MEDmeshAttributeRd( fid, meshname ); |
63 |
isolatednodes, verticesnodes, cellmaxnodes = attmesh |
63 |
isolatednodes, verticesnodes, cellmaxnodes = attmesh |
64 |
print "\tisolatednodes: ",isolatednodes," verticesnodes: ",verticesnodes,", cellmaxnodes: ",cellmaxnodes |
64 |
print( "\tisolatednodes: ",isolatednodes," verticesnodes: ",verticesnodes,", cellmaxnodes: ",cellmaxnodes ) |
65 |
for csit in range(1,nstep1+1): |
65 |
for csit in range(1,nstep1+1): |
66 |
numdt,numit,dt1 = MEDmeshComputationStepInfo(fid,meshname,csit) |
66 |
numdt,numit,dt1 = MEDmeshComputationStepInfo(fid,meshname,csit) |
67 |
dt2 = MEDmeshComputationStepDtRd( fid, meshname, numdt, numit ) |
67 |
dt2 = MEDmeshComputationStepDtRd( fid, meshname, numdt, numit ) |
68 |
if dt1 != dt2:print "Erreur: la date est différente entre MEDmeshComputationStepInfo et MEDmeshComputationStepDtRd",dt1,dt2 |
68 |
if dt1 != dt2:print( "Erreur: la date est différente entre MEDmeshComputationStepInfo et MEDmeshComputationStepDtRd",dt1,dt2 ) |
69 |
print "\tEtape d'évolution n :",csit," : (numdt=",numdt,",numit=",numit,",dt=",dt1,")" |
69 |
print( "\tEtape d'évolution n :",csit," : (numdt=",numdt,",numit=",numit,",dt=",dt1,")" ) |
70 |
|
70 |
|
71 |
# coo=doubleArray(6) |
71 |
# coo=doubleArray(6) |
72 |
# initcoo=[ 0.0, 0.0, 0.0, 1.1, 1.1, 1.1 ] |
72 |
# initcoo=[ 0.0, 0.0, 0.0, 1.1, 1.1, 1.1 ] |
Lines 88-110
Link Here
|
88 |
try: |
88 |
try: |
89 |
MEDmeshNodeCoordinateWr(fid,'maa1',0,MED_NO_IT,0.1, |
89 |
MEDmeshNodeCoordinateWr(fid,'maa1',0,MED_NO_IT,0.1, |
90 |
MED_FULL_INTERLACE,ncoo2, coo2 ) |
90 |
MED_FULL_INTERLACE,ncoo2, coo2 ) |
91 |
except RuntimeError,ex: |
91 |
except RuntimeError as ex: |
92 |
print "Une RuntimeError exception a été attrapée : ",ex |
92 |
print( "Une RuntimeError exception a été attrapée : ",ex ) |
93 |
|
93 |
|
94 |
coo1_rd=MEDFLOAT(ncoo1*spacedim) |
94 |
coo1_rd=MEDFLOAT(ncoo1*spacedim) |
95 |
MEDmeshNodeCoordinateRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,coo1_rd) |
95 |
MEDmeshNodeCoordinateRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_FULL_INTERLACE,coo1_rd) |
96 |
print coo1_rd |
96 |
print( coo1_rd ) |
97 |
|
97 |
|
98 |
coo2_rd=MEDFLOAT(ncoo2*spacedim) |
98 |
coo2_rd=MEDFLOAT(ncoo2*spacedim) |
99 |
MEDmeshNodeCoordinateRd(fid,'maa1',0,MED_NO_IT,MED_FULL_INTERLACE,coo2_rd) |
99 |
MEDmeshNodeCoordinateRd(fid,'maa1',0,MED_NO_IT,MED_FULL_INTERLACE,coo2_rd) |
100 |
print coo2_rd |
100 |
print( coo2_rd ) |
101 |
|
101 |
|
102 |
nconn1=2 |
102 |
nconn1=2 |
103 |
conn1=MEDINT([1,2,1,2]) |
103 |
conn1=MEDINT([1,2,1,2]) |
104 |
MEDmeshElementConnectivityWr(fid,'maa1',MED_NO_DT,MED_NO_IT,0.0,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE,nconn1,conn1) |
104 |
MEDmeshElementConnectivityWr(fid,'maa1',MED_NO_DT,MED_NO_IT,0.0,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE,nconn1,conn1) |
105 |
conn1_rd=MEDINT(nconn1*(MED_SEG2%100)) |
105 |
conn1_rd=MEDINT(nconn1*(MED_SEG2%100)) |
106 |
MEDmeshElementConnectivityRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE,conn1_rd) |
106 |
MEDmeshElementConnectivityRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE,conn1_rd) |
107 |
if conn1 != conn1_rd : print "Erreur: les informations lues par MEDmeshElementConnectivityRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',MED_NO_DT,MED_NO_IT) |
107 |
if conn1 != conn1_rd : print( "Erreur: les informations lues par MEDmeshElementConnectivityRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',MED_NO_DT,MED_NO_IT) ) |
108 |
|
108 |
|
109 |
|
109 |
|
110 |
nconn2=10000 |
110 |
nconn2=10000 |
Lines 115-132
Link Here
|
115 |
MEDmeshElementConnectivityWr( *(param2 + (nconn2, conn2)) ) |
115 |
MEDmeshElementConnectivityWr( *(param2 + (nconn2, conn2)) ) |
116 |
conn2_rd=MEDINT(nconn2*(MED_SEG2%100)) |
116 |
conn2_rd=MEDINT(nconn2*(MED_SEG2%100)) |
117 |
MEDmeshElementConnectivityRd( fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, conn2_rd ) |
117 |
MEDmeshElementConnectivityRd( fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, conn2_rd ) |
118 |
if conn2 != conn2_rd : print "Erreur: les informations lues par MEDmeshElementConnectivityRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',0,MED_NO_IT) |
118 |
if conn2 != conn2_rd : print( "Erreur: les informations lues par MEDmeshElementConnectivityRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',0,MED_NO_IT)) |
119 |
|
119 |
|
120 |
nnam1=2 |
120 |
nnam1=2 |
121 |
# "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam1)] ) |
121 |
# "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam1)] ) |
122 |
nam1=MEDCHAR( "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam1)] )+'\0' ) |
122 |
nam1=MEDCHAR( "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam1)] )+'\0' ) |
123 |
MEDmeshEntityNameWr(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nnam1,nam1) |
123 |
MEDmeshEntityNameWr(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nnam1,nam1) |
124 |
nam1_rd=MEDCHAR(nnam1*MED_SNAME_SIZE+1) |
124 |
nam1_rd=MEDCHAR(nnam1*MED_SNAME_SIZE+1) |
125 |
print "----------- 1a ---------------" |
125 |
print( "----------- 1a ---------------" ) |
126 |
print MEDmeshEntityNameRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nam1_rd) |
126 |
print( MEDmeshEntityNameRd(fid,'maa1',MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nam1_rd) ) |
127 |
print "----------- 2a ---------------" |
127 |
print( "----------- 2a ---------------" ) |
128 |
#print [x for x in nam1_rd] |
128 |
#print( [x for x in nam1_rd] ) |
129 |
if nam1 != nam1_rd : print "Erreur: les informations lues par MEDmeshEntityNameRd sur le maillage < %s >( %d , %d ) sont inexactes."%('maa1',MED_NO_DT,MED_NO_IT) |
129 |
if nam1 != nam1_rd : print( "Erreur: les informations lues par MEDmeshEntityNameRd sur le maillage < %s >( %d , %d ) sont inexactes."%('maa1',MED_NO_DT,MED_NO_IT) ) |
130 |
|
130 |
|
131 |
nnam2=10 |
131 |
nnam2=10 |
132 |
# "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam2)] ) |
132 |
# "".join( [str(i).zfill(MED_SNAME_SIZE) for i in range(nnam2)] ) |
Lines 134-140
Link Here
|
134 |
MEDmeshEntityNameWr(fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,nnam2,nam2) |
134 |
MEDmeshEntityNameWr(fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,nnam2,nam2) |
135 |
nam2_rd=MEDCHAR(nnam2*MED_SNAME_SIZE+1) |
135 |
nam2_rd=MEDCHAR(nnam2*MED_SNAME_SIZE+1) |
136 |
MEDmeshEntityNameRd(fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,nam2_rd) |
136 |
MEDmeshEntityNameRd(fid,'maa1',0,MED_NO_IT,MED_CELL,MED_SEG2,nam2_rd) |
137 |
if nam2 != nam2_rd : print "Erreur: les informations lues par MEDmeshEntityNameRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',0,MED_NO_IT) |
137 |
if nam2 != nam2_rd : print( "Erreur: les informations lues par MEDmeshEntityNameRd sur le maillage <%s>(%d,%d) sont inexactes."%('maa1',0,MED_NO_IT) ) |
138 |
|
138 |
|
139 |
#TODO : Tester les attributes MESH |
139 |
#TODO : Tester les attributes MESH |
140 |
|
140 |
|
Lines 193-199
Link Here
|
193 |
#X=type('X',(),{'foo':lambda self:'foo'}) |
193 |
#X=type('X',(),{'foo':lambda self:'foo'}) |
194 |
#FIELD=type('FIELD',(),field1) |
194 |
#FIELD=type('FIELD',(),field1) |
195 |
# a=FIELD() |
195 |
# a=FIELD() |
196 |
# print a |
196 |
# print( a ) |
197 |
# dir(a) |
197 |
# dir(a) |
198 |
|
198 |
|
199 |
# err,meshname_field1_rd,lmesh_field1_rd,type_field1_rd,comp_field1_rd,unit_field1_rd,dtunit_field1_rd,ncstp_field1_rd=MEDfieldInfoByName(fid,fieldname1) |
199 |
# err,meshname_field1_rd,lmesh_field1_rd,type_field1_rd,comp_field1_rd,unit_field1_rd,dtunit_field1_rd,ncstp_field1_rd=MEDfieldInfoByName(fid,fieldname1) |
Lines 213-219
Link Here
|
213 |
field1_info3=dict([ (x,field1_info2[x]) for x in fieldinfo_keys if x in field1.keys()] ) |
213 |
field1_info3=dict([ (x,field1_info2[x]) for x in fieldinfo_keys if x in field1.keys()] ) |
214 |
|
214 |
|
215 |
|
215 |
|
216 |
if field1 != field1_info2 : print "Erreur: les informations lues par MEDfieldInfoByName sur le champ <%s> sont inexactes."% field1['fieldname'] |
216 |
if field1 != field1_info2 : print( "Erreur: les informations lues par MEDfieldInfoByName sur le champ <%s> sont inexactes."% field1['fieldname'] ) |
217 |
|
217 |
|
218 |
nentity_field1=10 |
218 |
nentity_field1=10 |
219 |
value_field1=MEDFLOAT(range(nentity_field1)) |
219 |
value_field1=MEDFLOAT(range(nentity_field1)) |
Lines 228-234
Link Here
|
228 |
|
228 |
|
229 |
it=value_field1.begin() |
229 |
it=value_field1.begin() |
230 |
while it!=value_field1.end(): |
230 |
while it!=value_field1.end(): |
231 |
print it.value();it+=1 |
231 |
print( it.value() );it+=1 |
232 |
|
232 |
|
233 |
value_field1_rd=MEDFLOAT(nentity_field1*field1['ncomponent']) |
233 |
value_field1_rd=MEDFLOAT(nentity_field1*field1['ncomponent']) |
234 |
MEDfieldValueRd(fid, |
234 |
MEDfieldValueRd(fid, |
Lines 238-244
Link Here
|
238 |
MED_FULL_INTERLACE,MED_ALL_CONSTITUENT, |
238 |
MED_FULL_INTERLACE,MED_ALL_CONSTITUENT, |
239 |
value_field1_rd); |
239 |
value_field1_rd); |
240 |
|
240 |
|
241 |
if value_field1 != value_field1_rd : print "Erreur: les informations lues par MEDfieldValueRd sur le champ <%s>(%d,%d) sont inexactes."%('fieldname1',MED_NO_DT,MED_NO_IT) |
241 |
if value_field1 != value_field1_rd : print( "Erreur: les informations lues par MEDfieldValueRd sur le champ <%s>(%d,%d) sont inexactes."%('fieldname1',MED_NO_DT,MED_NO_IT) ) |
242 |
|
242 |
|
243 |
|
243 |
|
244 |
#Opérations algébrique sur les tableaux stl (cf algo.) vs numpy |
244 |
#Opérations algébrique sur les tableaux stl (cf algo.) vs numpy |
Lines 285-290
Link Here
|
285 |
MED_FULL_INTERLACE,MED_ALL_CONSTITUENT, |
285 |
MED_FULL_INTERLACE,MED_ALL_CONSTITUENT, |
286 |
value_field2_rd); |
286 |
value_field2_rd); |
287 |
|
287 |
|
288 |
if value_field2 != value_field2_rd : print "Erreur: les informations lues par MEDfieldValueRd sur le champ <%s>(%d,%d) sont inexactes."%('fieldname2',MED_NO_DT,MED_NO_IT) |
288 |
if value_field2 != value_field2_rd : print( "Erreur: les informations lues par MEDfieldValueRd sur le champ <%s>(%d,%d) sont inexactes."%('fieldname2',MED_NO_DT,MED_NO_IT) ) |
289 |
|
289 |
|
290 |
MEDfileClose(fid) |
290 |
MEDfileClose(fid) |