1 #include "MEDMEM_Exception.hxx"
2 #include "MEDMEM_define.hxx"
4 #include "MEDMEM_Med.hxx"
5 #include "MEDMEM_Field.hxx"
6 #include "MEDMEM_Mesh.hxx"
7 #include "MEDMEM_Interpolation.hxx"
15 const char * fromFileName = "ResultatSyrthes.med";
16 const char * toFileName = "MaillageAster.med";
17 const char * resultFileName = "ResultatInterpolation.med";
19 const char * fromFieldName = "THERDEP_TEMP____________________";
21 const char * fromMeshName = "MA";
22 const char * toMeshName = "MAILLAGE_IDEAS";
27 string flag="================[MAIN MESSAGES]================> ";
29 cout<<flag<<"Lecture de la structure MED : "<<flush;
30 MED fromMED (MED_DRIVER,fromFileName);
33 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
34 fromMED.updateSupport();
36 cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
37 MESH toMesh (MED_DRIVER,toFileName,toMeshName);
40 cout<<flag<<"Lecture des pas de temps : "<<flush;
41 deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
44 deque<DT_IT_>::const_iterator currentStep;
46 INTERPOLATION<3> * myInter ;
47 FIELD<double> * toField ;
48 int flagNewMapping = 1;
50 for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
52 cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
54 cout<<flag<<"Lecture du FIELD_ "<<flush;
55 FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ;
58 cout<<flag<<"Transtypage en FIELD : "<<flush;
59 FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
62 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
63 fromField->getSupport()->getMesh()->read();
65 cout<<flag<<"Lecture des valeurs du FIELD : "<<flush; fromField->read();
68 if (currentStep==pasDeTemps.begin())
70 cout<<flag<<"Préparation de l'interpolation pour le premier pas de temps : "<<flush;
71 myInter = new INTERPOLATION<3>(*fromField,toMesh) ;
74 cout<<flag<<"Interpolation effective du premier pas de temps : "<<flush;
75 toField = myInter->interpolate(1,1);
80 cout<<flag<<"Interpolation nextStep : "<<flush;
81 toField = myInter->interpolateNextStep(*fromField,flagNewMapping);
85 cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
86 toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
89 cout<<flag<<"Ecriture du Field résultat : "<<flush;
93 if (flagNewMapping==1)
95 cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
96 handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
99 cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
100 toMesh.write(handle);
105 } catch (MEDEXCEPTION& ex){