1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MEDMEM_Exception.hxx"
23 #include "MEDMEM_define.hxx"
25 #include "MEDMEM_Med.hxx"
26 #include "MEDMEM_Field.hxx"
27 #include "MEDMEM_Mesh.hxx"
28 #include "MEDMEM_Interpolation.hxx"
34 using namespace MEDMEM;
35 using namespace MED_EN;
38 const char * fromFileName = "ResultatSyrthes.med";
39 const char * toFileName = "MaillageAster.med";
40 const char * resultFileName = "ResultatInterpolation.med";
42 const char * fromFieldName = "THERDEP_TEMP____________________";
44 const char * fromMeshName = "MA";
45 const char * toMeshName = "MAILLAGE_IDEAS";
50 string flag="================[MAIN MESSAGE_MEDS]================> ";
52 cout<<flag<<"Lecture de la structure MED : "<<flush;
53 MED fromMED (MED_DRIVER,fromFileName);
56 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
57 fromMED.updateSupport();
59 cout<<flag<<"Lecture du Mailllage Cible : "<<flush;
60 MESH toMesh (MED_DRIVER,toFileName,toMeshName);
63 cout<<flag<<"Lecture des pas de temps : "<<flush;
64 deque<DT_IT_> pasDeTemps=fromMED.getFieldIteration (fromFieldName);
67 deque<DT_IT_>::const_iterator currentStep;
69 INTERPOLATION<3> * myInter ;
70 FIELD<double> * toField ;
71 int flagNewMapping = 1;
73 for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++)
75 cout<<flag<<"Traitement du Step ( "<<flush<<(*currentStep).dt<<" ; "<<(*currentStep).it<<" ) : "<<endl;
77 cout<<flag<<"Lecture du FIELD_ "<<flush;
78 FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ;
81 cout<<flag<<"Transtypage en FIELD : "<<flush;
82 FIELD<double> * fromField = dynamic_cast<FIELD<double> *>(fromField_);
85 // Utilisation completement débile, on ne devrait pas avoir a faire l'appel suivant
86 fromField->getSupport()->getMesh()->read();
88 cout<<flag<<"Lecture des valeurs du FIELD : "<<flush; fromField->read();
91 if (currentStep==pasDeTemps.begin())
93 cout<<flag<<"Préparation de l'interpolation pour le premier pas de temps : "<<flush;
94 myInter = new INTERPOLATION<3>(*fromField,toMesh) ;
97 cout<<flag<<"Interpolation effective du premier pas de temps : "<<flush;
98 toField = myInter->interpolate(1,1);
103 cout<<flag<<"Interpolation nextStep : "<<flush;
104 toField = myInter->interpolateNextStep(*fromField,flagNewMapping);
108 cout<<flag<<"Creation du driver d'écriture Field : "<<flush;
109 toField->addDriver(MED_DRIVER,resultFileName,toField->getName());
112 cout<<flag<<"Ecriture du Field résultat : "<<flush;
116 if (flagNewMapping==1)
118 cout<<flag<<"Creation du driver d'écriture Mesh : "<<flush;
119 handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ;
122 cout<<flag<<"Ecriture du Mesh résultat : "<<flush;
123 toMesh.write(handle);
128 } catch (MEDEXCEPTION& ex){
129 MESSAGE_MED(ex.what()) ;