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"
13 using namespace MEDMEM;
14 using namespace MED_EN;
18 const char * fromFileName = "ResultatSyrthes.med";
19 const char * toFileName = "MaillageAster.med";
20 const char * resultFileName = "ResultatInterpolation.med";
22 const char * fromFieldName = "THERDEP_TEMP____________________";
24 const char * fromMeshName = "MA";
25 const char * toMeshName = "MAILLAGE_IDEAS";
30 string flag="================[MAIN MESSAGES]================> ";
32 cout<<flag<<"Lecture de la structure MED : "<<flush;
33 MED fromMED (MED_DRIVER,fromFileName);
36 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
37 fromMED.updateSupport();
39 cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
40 MESH toMesh (MED_DRIVER,toFileName,toMeshName);
43 cout<<flag<<"Lecture des pas de temps : "<<flush;
44 deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
47 deque<DT_IT_>::const_iterator currentStep;
49 INTERPOLATION<3> * myInter ;
50 FIELD<double> * toField ;
51 int flagNewMapping = 1;
53 for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
55 cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
57 cout<<flag<<"Lecture du FIELD_ "<<flush;
58 FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ;
61 cout<<flag<<"Transtypage en FIELD : "<<flush;
62 FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
65 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
66 fromField->getSupport()->getMesh()->read();
68 cout<<flag<<"Lecture des valeurs du FIELD : "<<flush; fromField->read();
71 if (currentStep==pasDeTemps.begin())
73 cout<<flag<<"Préparation de l'interpolation pour le premier pas de temps : "<<flush;
74 myInter = new INTERPOLATION<3>(*fromField,toMesh) ;
77 cout<<flag<<"Interpolation effective du premier pas de temps : "<<flush;
78 toField = myInter->interpolate(1,1);
83 cout<<flag<<"Interpolation nextStep : "<<flush;
84 toField = myInter->interpolateNextStep(*fromField,flagNewMapping);
88 cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
89 toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
92 cout<<flag<<"Ecriture du Field résultat : "<<flush;
96 if (flagNewMapping==1)
98 cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
99 handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
102 cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
103 toMesh.write(handle);
108 } catch (MEDEXCEPTION& ex){