Salome HOME
typo-fix by Kunda
[tools/medcoupling.git] / src / MEDLoader / MEDLoader.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDLoader.hxx"
22 #include "MEDLoaderBase.hxx"
23 #include "MEDFileUtilities.hxx"
24 #include "MEDLoaderNS.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileMesh.hxx"
27 #include "MEDFileField.hxx"
28 #include "CellModel.hxx"
29 #include "MEDCouplingUMesh.hxx"
30 #include "MEDCouplingMemArray.hxx"
31 #include "MEDCouplingFieldDouble.hxx"
32 #include "MEDCouplingFieldFloat.hxx"
33 #include "MEDCouplingFieldInt.hxx"
34 #include "MEDCouplingGaussLocalization.hxx"
35 #include "MEDCouplingTraits.hxx"
36 #include "MCAuto.hxx"
37
38 #include "InterpKernelAutoPtr.hxx"
39
40 #include "med.h"
41
42 #include <string>
43 #include <limits>
44 #include <cstring>
45 #include <sstream>
46 #include <fstream>
47 #include <numeric>
48 #include <iterator>
49 #include <algorithm>
50
51
52 med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
53   MED_SEG2,
54   MED_SEG3,
55   MED_SEG4,
56   MED_TRIA3,
57   MED_QUAD4,
58   MED_TRIA6,
59   MED_TRIA7,
60   MED_QUAD8,
61   MED_QUAD9,
62   MED_TETRA4,
63   MED_PYRA5,
64   MED_PENTA6,
65   MED_HEXA8,
66   MED_OCTA12,
67   MED_TETRA10,
68   MED_PYRA13,
69   MED_PENTA15,
70   MED_PENTA18,
71   MED_HEXA20,
72   MED_HEXA27,
73   MED_POLYGON,
74   MED_POLYGON2,
75   MED_POLYHEDRON };
76
77 med_geometry_type typmainoeud[1] = { MED_NONE };
78
79 INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO] = { INTERP_KERNEL::NORM_POINT1,
80   INTERP_KERNEL::NORM_SEG2,
81   INTERP_KERNEL::NORM_SEG3,
82   INTERP_KERNEL::NORM_SEG4,
83   INTERP_KERNEL::NORM_TRI3,
84   INTERP_KERNEL::NORM_QUAD4,
85   INTERP_KERNEL::NORM_TRI6,
86   INTERP_KERNEL::NORM_TRI7,
87   INTERP_KERNEL::NORM_QUAD8,
88   INTERP_KERNEL::NORM_QUAD9,
89   INTERP_KERNEL::NORM_TETRA4,
90   INTERP_KERNEL::NORM_PYRA5,
91   INTERP_KERNEL::NORM_PENTA6,
92   INTERP_KERNEL::NORM_HEXA8,
93   INTERP_KERNEL::NORM_HEXGP12,
94   INTERP_KERNEL::NORM_TETRA10,
95   INTERP_KERNEL::NORM_PYRA13,
96   INTERP_KERNEL::NORM_PENTA15,
97   INTERP_KERNEL::NORM_PENTA18,
98   INTERP_KERNEL::NORM_HEXA20,
99   INTERP_KERNEL::NORM_HEXA27,
100   INTERP_KERNEL::NORM_POLYGON,
101   INTERP_KERNEL::NORM_QPOLYG,
102   INTERP_KERNEL::NORM_POLYHED };
103
104 med_geometry_type typmai3[34] = { MED_POINT1,//0
105   MED_SEG2,//1
106   MED_SEG3,//2
107   MED_TRIA3,//3
108   MED_QUAD4,//4
109   MED_POLYGON,//5
110   MED_TRIA6,//6
111   MED_TRIA7,//7
112   MED_QUAD8,//8
113   MED_QUAD9,//9
114   MED_SEG4,//10
115   MED_NONE,//11
116   MED_NONE,//12
117   MED_NONE,//13
118   MED_TETRA4,//14
119   MED_PYRA5,//15
120   MED_PENTA6,//16
121   MED_NONE,//17
122   MED_HEXA8,//18
123   MED_NONE,//19
124   MED_TETRA10,//20
125   MED_NONE,//21
126   MED_OCTA12,//22
127   MED_PYRA13,//23
128   MED_NONE,//24
129   MED_PENTA15,//25
130   MED_NONE,//26
131   MED_HEXA27,//27
132   MED_PENTA18,//28
133   MED_NONE,//29
134   MED_HEXA20,//30
135   MED_POLYHEDRON,//31
136   MED_POLYGON2,//32
137   MED_NONE//33
138 };
139
140 double _EPS_FOR_NODE_COMP=1.e-12;
141
142 int _COMP_FOR_CELL=0;
143
144 int _TOO_LONG_STR=0;
145
146 using namespace MEDCoupling;
147
148 /// @cond INTERNAL
149
150 /*!
151  * This method returns a first quick overview of mesh with name \a meshName into the file \a fileName.
152  * @param possibilities the relativeToMeshDim authorized to returned maxdim. This vector is systematically cleared at the begin of this method.
153  * @return the maximal mesh dimension of specified mesh. If nothing found -1 is returned.
154  */
155 int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities)
156 {
157   possibilities.clear();
158   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
159   int ret;
160   std::set<int> poss;
161   char nommaa[MED_NAME_SIZE+1];
162   char maillage_description[MED_COMMENT_SIZE+1];
163   med_mesh_type type_maillage;
164   med_int Sdim,Mdim;
165   std::string trueMeshName;
166   med_int meshId=getIdFromMeshName(fid,meshName,trueMeshName);
167   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
168   med_sorting_type sortingType;
169   med_int nstep;
170   med_axis_type axisType;
171   int naxis(MEDmeshnAxis(fid,meshId));
172   INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
173   INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
174   MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit));
175   // limitation
176   if(nstep!=1)
177     {
178       throw INTERP_KERNEL::Exception("multisteps on mesh not managed yet !");
179     } 
180   med_int numdt,numit;
181   med_float dt;
182   MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,nommaa,1,&numdt,&numit,&dt));
183   // endlimitation
184   for(int i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
185     {
186       med_geometry_type curMedType=typmai[i];
187       med_bool changement,transformation;
188       int curNbOfElemM(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,curMedType,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));
189       int curNbOfElemF(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,curMedType,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));//limitation
190       int curNbOfElem;
191       med_entity_type whichEntity;
192       MEDLoaderNS::dispatchElems(curNbOfElemM,curNbOfElemF,curNbOfElem,whichEntity);
193       if(curNbOfElem>0)
194         {
195           INTERP_KERNEL::NormalizedCellType type=typmai2[i];
196           int curDim=(int)INTERP_KERNEL::CellModel::GetCellModel(type).getDimension();
197           poss.insert(curDim);
198         }
199     }
200   if(!poss.empty())
201     {
202       ret=*poss.rbegin();
203       for(std::set<int>::const_reverse_iterator it=poss.rbegin();it!=poss.rend();it++)
204         possibilities.push_back(*it-ret);
205     }
206   else
207     ret=-2;
208   return ret;
209 }
210
211 med_int MEDLoaderNS::getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName)
212     {
213   if(meshName.empty())
214     {
215       std::vector<std::string> meshes=getMeshNamesFid(fid);
216       if(meshes.empty())
217         throw INTERP_KERNEL::Exception("No mesh in file");
218       trueMeshName=meshes[0];
219       return 1;
220     }
221   std::string meshNameStr(meshName);
222   std::vector<std::string> meshes=getMeshNamesFid(fid);
223   if(meshes.empty())
224     throw INTERP_KERNEL::Exception("No mesh in file");
225   std::vector<std::string>::iterator iter=std::find(meshes.begin(),meshes.end(),meshNameStr);
226   if(iter==meshes.end())
227     {
228       std::ostringstream os2;
229       os2 << "MeshName '" << meshName << "' not in file : meshes available : ";
230       std::copy(meshes.begin(),meshes.end(),std::ostream_iterator<std::string>(os2," "));
231       throw INTERP_KERNEL::Exception(os2.str().c_str());
232     }
233   trueMeshName=meshName;
234   return iter-meshes.begin()+1;
235     }
236
237 std::vector<std::string> MEDLoaderNS::getMeshNamesFid(med_idt fid)
238 {
239   med_mesh_type type_maillage;
240   char maillage_description[MED_COMMENT_SIZE+1];
241   char dtunit[MED_COMMENT_SIZE+1];
242   med_int space_dim;
243   med_int mesh_dim;
244   char nommaa[MED_NAME_SIZE+1];
245   med_axis_type axistype;
246   med_sorting_type stype;
247   med_int n=MEDnMesh(fid);
248   std::vector<std::string> ret(n);
249   for(int i=0;i<n;i++)
250     {
251       int naxis(MEDmeshnAxis(fid,i+1));
252       INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
253       INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
254       int nstep;
255       MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&space_dim,&mesh_dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit));
256       std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
257       ret[i]=cur;
258     }
259   return ret;
260 }
261
262 /*!
263  * This methods allows to merger all entities and to considerate only cell types.
264  */
265 void MEDLoaderNS::dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity)
266 {
267   if(nbOfElemCell>=nbOfElemFace)
268     {
269       whichEntity=MED_CELL;
270       nbOfElem=nbOfElemCell;
271     }
272   else
273     {
274       whichEntity=MED_CELL;
275       nbOfElem=nbOfElemFace;
276     }
277 }
278
279 /// @endcond
280
281 void MEDCoupling::AssignStaticWritePropertiesTo(MEDCoupling::MEDFileWritable& obj)
282 {
283   obj.setTooLongStrPolicy(_TOO_LONG_STR);
284 }
285
286 bool MEDCoupling::HasXDR()
287 {
288 #ifdef HAS_XDR
289   return true;
290 #else
291   return false;
292 #endif
293 }
294
295 std::string MEDCoupling::MEDFileVersionStr()
296 {
297   const int SZ=20;
298   char buf[SZ];
299   std::fill(buf,buf+SZ,'\0');
300   const char START_EXPECTED[]="MED-";
301   med_err ret(MEDlibraryStrVersion(buf));
302   if(ret!=0)
303     throw INTERP_KERNEL::Exception("MEDFileVersionStr : fail to find version of MED file ! It looks very bad !");
304   std::string zeRet(buf);
305   std::size_t pos(zeRet.find(START_EXPECTED,0));
306   if(pos!=0)
307     {
308       std::ostringstream oss; oss << "MEDFileVersionStr : internal error ! The MEDFile returned version (\"" << zeRet << "\") has not the right pattern !";
309       throw INTERP_KERNEL::Exception(oss.str());
310     }
311   return zeRet.substr(sizeof(START_EXPECTED)-1,std::string::npos);
312 }
313
314 std::string MEDCoupling::MEDFileVersionOfFileStr(const std::string& fileName)
315 {
316 #if MED_NUM_MAJEUR>3 || ( MED_NUM_MAJEUR==3 && ( (MED_NUM_MINEUR==2 && MED_NUM_RELEASE>=1) || MED_NUM_MINEUR>=3) )
317   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
318   const int SZ=20;
319   const char START_EXPECTED[]="MED-";
320   char buf[SZ];
321   std::fill(buf,buf+SZ,'\0');
322   MEDFILESAFECALLERRD0(MEDfileStrVersionRd,(fid,buf));
323   std::string ret(buf);
324   std::size_t pos(ret.find(START_EXPECTED,0));
325   if(pos!=0)
326     {
327       std::ostringstream oss; oss << "MEDFileVersionOfFileStr : internal error ! The MEDFile returned version (\"" << ret << "\") has not the right pattern !";
328       throw INTERP_KERNEL::Exception(oss.str());
329     }
330   return ret.substr(sizeof(START_EXPECTED)-1,std::string::npos);
331 #else
332   std::ostringstream oss; oss << "MEDFileVersionOfFileStr : is implemented with MEDFile " << MEDFileVersionStr() << " ! If you need this feature please use version >= 3.2.1.";
333   throw INTERP_KERNEL::Exception(oss.str());
334 #endif
335 }
336
337 void MEDCoupling::MEDFileVersion(int& major, int& minor, int& release)
338 {
339   med_int majj,minn,rell;
340   med_err ret(MEDlibraryNumVersion(&majj,&minn,&rell));
341   if(ret!=0)
342     throw INTERP_KERNEL::Exception("MEDFileVersion : fail to call MEDlibraryNumVersion ! It looks very bad !");
343   major=majj;
344   minor=minn;
345   release=rell;
346 }
347
348 /*!
349  * This method sets the epsilon value used for node comparison when trying to build a profile for a field on node/cell on an already written mesh.
350  */
351 void MEDCoupling::SetEpsilonForNodeComp(double val)
352 {
353   _EPS_FOR_NODE_COMP=val;
354 }
355
356 /*!
357  * This method sets the policy comparison when trying to fit the already written mesh on a field. The semantic of the policy is specified in MEDCouplingUMesh::zipConnectivityTraducer.
358  */
359 void MEDCoupling::SetCompPolicyForCell(int val)
360 {
361   _COMP_FOR_CELL=val;
362 }
363
364 /*!
365  * This method set the behaviour of MEDLoader when a too long string is seen in datastructure before copy it in MED file.
366  * By default (0) an exception is thrown. If equal to 1 a warning is emitted in std_err but no exception is thrown.
367  */
368 void MEDCoupling::SetTooLongStrPolicy(int val)
369 {
370   _TOO_LONG_STR=val;
371 }
372
373 /*!
374  * Given a 'fileName' and a 'meshName' this method returns global information concerning this mesh.
375  * It returns, in this order :
376  * - number of cells sorted by dimension and by geometry type. The first entry in the vector is the maximal dimension, the 2nd in the vector is the maximal dimension-1...
377  * - the mesh dimension
378  * - the space dimension
379  * - the number of nodes
380  */
381 std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > MEDCoupling::GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, int& numberOfNodes)
382 {
383   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
384   std::set<int> poss;
385   char nommaa[MED_NAME_SIZE+1];
386   char maillage_description[MED_COMMENT_SIZE+1];
387   med_mesh_type type_maillage;
388   std::string trueMeshName;
389   med_int meshId=MEDLoaderNS::getIdFromMeshName(fid,meshName,trueMeshName);
390   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
391   med_sorting_type sortingType;
392   med_int nstep;
393   med_axis_type axisType;
394   int naxis(MEDmeshnAxis(fid,meshId));
395   INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
396   INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
397   MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&spaceDim,&meshDim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit));
398   if(type_maillage!=MED_UNSTRUCTURED_MESH)
399     {
400       std::ostringstream oss; oss << "GetUMeshGlobalInfo : Mesh \""<< meshName << "\" in file \"" << fileName;
401       oss << "\" exists but it is not an unstructured mesh ! This method is not relevant for mesh types that are not unstructured !";
402       throw INTERP_KERNEL::Exception(oss.str().c_str());
403     }
404   // limitation
405   if(nstep!=1)
406     throw INTERP_KERNEL::Exception("GetUMeshGlobalInfo : multisteps on mesh not managed !");
407   med_int numdt,numit;
408   med_float dt;
409   MEDFILESAFECALLERRD0(MEDmeshComputationStepInfo,(fid,nommaa,1,&numdt,&numit,&dt));
410   // endlimitation
411   std::vector<int> dims;
412   std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > geoTypes;
413   med_bool changement,transformation;
414   for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
415     {
416       med_geometry_type curMedType=typmai[i];
417       int curNbOfElemM(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,curMedType,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));
418       if(curNbOfElemM>0)
419         {
420           INTERP_KERNEL::NormalizedCellType typp=typmai2[i];
421           int mdimCell=INTERP_KERNEL::CellModel::GetCellModel(typp).getDimension();
422           dims.push_back(mdimCell);
423           geoTypes.push_back(std::pair<INTERP_KERNEL::NormalizedCellType,int>(typp,curNbOfElemM));
424         }
425     }
426   int maxLev=*std::max_element(dims.begin(),dims.end());
427   int lowLev=*std::min_element(dims.begin(),dims.end());
428   int nbOfLevels=maxLev-lowLev+1;
429   std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > ret(nbOfLevels);
430   for(std::size_t i=0;i<dims.size();i++)
431     {
432       ret[maxLev-dims[i]].push_back(geoTypes[i]);
433     }
434   numberOfNodes=MEDmeshnEntity(fid,nommaa,numdt,numit,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
435   return ret;
436 }
437
438 void MEDCoupling::CheckFileForRead(const std::string& fileName)
439 {
440   MEDFileUtilities::CheckFileForRead(fileName);
441 }
442
443 std::vector<std::string> MEDCoupling::GetMeshNames(const std::string& fileName)
444 {
445   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
446   return MEDLoaderNS::getMeshNamesFid(fid);
447 }
448
449 std::vector< std::pair<std::string,std::string> > MEDCoupling::GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName)
450 {
451   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
452   med_int nbFields(MEDnField(fid));
453   std::vector<std::string> fields(nbFields);
454   med_field_type typcha;
455   for(int i=0;i<nbFields;i++)
456     {
457       med_int ncomp(MEDfieldnComponent(fid,i+1));
458       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
459       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
460       INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
461       med_int nbPdt;
462       med_bool localmesh;
463       INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
464       INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
465       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
466       std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE);
467       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
468       if(curFieldName==fieldName)
469         {
470           std::vector< std::pair<std::string,std::string> > ret(ncomp);
471           for(int j=0;j<ncomp;j++)
472             ret[j]=std::pair<std::string,std::string>(MEDLoaderBase::buildStringFromFortran(((char *)comp)+j*MED_SNAME_SIZE,MED_SNAME_SIZE),
473                 MEDLoaderBase::buildStringFromFortran(((char *)unit)+j*MED_SNAME_SIZE,MED_SNAME_SIZE));
474           return ret;
475         }
476       fields[i]=curFieldName;
477     }
478   std::ostringstream oss; oss << "GetComponentsNamesOfField : no such field \"" << fieldName << "\" in file \"" << fileName << "\" !" << std::endl;
479   oss << "Possible field names are : " << std::endl;
480   std::copy(fields.begin(),fields.end(),std::ostream_iterator<std::string>(oss," "));
481   throw INTERP_KERNEL::Exception(oss.str().c_str());
482 }
483
484 std::vector<std::string> MEDCoupling::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName)
485 {
486   std::vector<std::string> ret;
487   //
488   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
489   med_int nbFields=MEDnField(fid);
490   //
491   med_field_type typcha;
492   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
493   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
494   med_bool localmesh;
495   //
496   for(int i=0;i<nbFields;i++)
497     {
498       med_int ncomp(MEDfieldnComponent(fid,i+1));
499       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
500       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
501       med_int nbPdt;
502       INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
503       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
504       std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE);
505       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
506       if(curFieldName==fieldName)
507         ret.push_back(meshName);
508     }
509   return ret;
510 }
511
512 std::vector<std::string> MEDCoupling::GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName)
513 {
514   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
515   med_int nfam=MEDnFamily(fid,meshName.c_str());
516   std::vector<std::string> ret(nfam);
517   char nomfam[MED_NAME_SIZE+1];
518   med_int numfam;
519   for(int i=0;i<nfam;i++)
520     {
521       int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
522       med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
523       INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
524       INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
525       INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
526       INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
527       MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
528       std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
529       ret[i]=cur;
530     }
531   return ret;
532 }
533
534
535 std::vector<std::string> MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName)
536 {
537   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
538   med_int nfam=MEDnFamily(fid,meshName.c_str());
539   std::vector<std::string> ret;
540   char nomfam[MED_NAME_SIZE+1];
541   med_int numfam;
542   for(int i=0;i<nfam;i++)
543     {
544       int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
545       med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
546       INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
547       INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
548       INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
549       INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
550       MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
551       std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
552       for(int j=0;j<ngro;j++)
553         {
554           std::string cur2=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
555           if(cur2==grpName)
556             ret.push_back(cur);
557         }
558     }
559   return ret;
560 }
561
562 std::vector<std::string> MEDCoupling::GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName)
563 {
564   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
565   med_int nfam(MEDnFamily(fid,meshName.c_str()));
566   std::vector<std::string> ret;
567   char nomfam[MED_NAME_SIZE+1];
568   med_int numfam;
569   bool found=false;
570   for(int i=0;i<nfam && !found;i++)
571     {
572       int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
573       med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
574       INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
575       INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
576       INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
577       INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
578       MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
579       std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
580       found=(cur==famName);
581       if(found)
582         for(int j=0;j<ngro;j++)
583           {
584             std::string cur2=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
585             ret.push_back(cur2);
586           }
587     }
588   if(!found)
589     {
590       std::ostringstream oss;
591       oss << "GetMeshGroupsNamesOnFamily : no such family \"" << famName << "\" in file \"" << fileName << "\" in mesh \"" << meshName << "\" !";
592       throw INTERP_KERNEL::Exception(oss.str().c_str());
593     }
594   return ret;
595 }
596
597
598 std::vector<std::string> MEDCoupling::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName)
599 {
600   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
601   med_int nfam=MEDnFamily(fid,meshName.c_str());
602   std::vector<std::string> ret;
603   char nomfam[MED_NAME_SIZE+1];
604   med_int numfam;
605   for(int i=0;i<nfam;i++)
606     {
607       int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
608       med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
609       INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
610       INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
611       INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
612       INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
613       MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
614       for(int j=0;j<ngro;j++)
615         {
616           std::string cur=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
617           if(std::find(ret.begin(),ret.end(),cur)==ret.end())
618             ret.push_back(cur);
619         }
620     }
621   return ret;
622 }
623
624 std::vector<MEDCoupling::TypeOfField> MEDCoupling::GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
625 {
626   std::vector<MEDCoupling::TypeOfField> ret;
627   MCAuto<MEDFileAnyTypeFieldMultiTS> fs(MEDFileAnyTypeFieldMultiTS::New(fileName,fieldName,false));
628   if(fs->getMeshName()!=meshName)
629     {
630       std::ostringstream oss; oss << "GetTypesOfField : The field \"" << fieldName << "\" in file \"" << fileName << "\" is not lying on mesh \"" << meshName << "\"";
631       oss << " The name of the mesh in file is \"" << fs->getMeshName() << "\"!";
632       throw INTERP_KERNEL::Exception(oss.str().c_str());
633     }
634   int nbTS(fs->getNumberOfTS());
635   if(nbTS==0)
636     return ret;
637   for(int i=0;i<nbTS;i++)
638     {
639       MCAuto<MEDFileAnyTypeField1TS> f1ts(fs->getTimeStepAtPos(i));
640       std::vector<MEDCoupling::TypeOfField> tof(f1ts->getTypesOfFieldAvailable());
641       for(std::vector<MEDCoupling::TypeOfField>::const_iterator it=tof.begin();it!=tof.end();it++)
642         if(std::find(ret.begin(),ret.end(),*it)==ret.end())
643           ret.push_back(*it);
644      }
645   // sort ret to put before ON_NODES then ON_CELLS then the remaining.
646   std::vector<MEDCoupling::TypeOfField> ret2;
647   if(std::find(ret.begin(),ret.end(),ON_NODES)!=ret.end())
648     ret2.push_back(ON_NODES);
649   if(std::find(ret.begin(),ret.end(),ON_CELLS)!=ret.end())
650     ret2.push_back(ON_CELLS);
651   for(std::vector<MEDCoupling::TypeOfField>::const_iterator it=ret.begin();it!=ret.end();it++)
652     if(*it!=ON_NODES && *it!=ON_CELLS)
653       ret2.push_back(*it);
654   return ret2;
655 }
656
657 std::vector<std::string> MEDCoupling::GetAllFieldNames(const std::string& fileName)
658 {
659   std::vector<std::string> ret;
660   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
661   med_int nbFields=MEDnField(fid);
662   med_field_type typcha;
663   for(int i=0;i<nbFields;i++)
664     {
665       med_int ncomp(MEDfieldnComponent(fid,i+1));
666       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
667       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
668       INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
669       INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
670       INTERP_KERNEL::AutoPtr<char> dt_unit=new char[MED_LNAME_SIZE+1];
671       med_int nbPdt;
672       med_bool localmesh;
673       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
674       ret.push_back(std::string(nomcha));
675     }
676   return ret;
677 }
678
679 std::vector<std::string> MEDCoupling::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
680 {
681   std::vector<std::string> ret;
682   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
683   med_int nbFields=MEDnField(fid);
684   //
685   med_field_type typcha;
686   char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
687   char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
688   //
689   for(int i=0;i<nbFields;i++)
690     {
691       med_int ncomp(MEDfieldnComponent(fid,i+1));
692       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
693       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
694       INTERP_KERNEL::AutoPtr<char> dt_unit=new char[MED_LNAME_SIZE+1];
695       med_int nbPdt;
696       med_bool localmesh;
697       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
698       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
699       std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1);
700       //
701       if(curMeshName==meshName)
702         ret.push_back(curFieldName);
703     }
704   delete [] maa_ass;
705   delete [] nomcha;
706   return ret;
707 }
708
709 std::vector<std::string> MEDCoupling::GetFieldNamesOnMesh(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName)
710 {
711   MEDCoupling::CheckFileForRead(fileName);
712   switch(type)
713   {
714     case ON_CELLS:
715       return GetCellFieldNamesOnMesh(fileName,meshName);
716     case ON_NODES:
717       return GetNodeFieldNamesOnMesh(fileName,meshName);
718     default:
719       throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !");
720   }
721 }
722
723 std::vector<std::string> MEDCoupling::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
724 {
725   std::vector<std::string> ret;
726   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
727   med_int nbFields=MEDnField(fid);
728   //
729   med_field_type typcha;
730   //med_int nbpdtnor=0,pflsize,*pflval,lnsize;
731   med_int numdt=0,numo=0;
732   med_float dt=0.0;
733   char pflname[MED_NAME_SIZE+1]="";
734   char locname[MED_NAME_SIZE+1]="";
735   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
736   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
737   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
738   med_bool localmesh;
739   med_int nbPdt;
740   //
741   for(int i=0;i<nbFields;i++)
742     {
743       med_int ncomp(MEDfieldnComponent(fid,i+1));
744       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
745       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
746       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
747       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
748       std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1);
749       int profilesize,nbi;
750       if(curMeshName==meshName)
751         {
752           bool found=false;
753           for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
754             {
755               if(nbPdt>0)
756                 {
757                   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt));
758                   med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE,
759                                                             pflname,&profilesize,locname,&nbi));
760                   if(nbOfVal>0)
761                     {
762                       found=true;
763                       ret.push_back(curFieldName);
764                     }
765                 }
766             }
767         }
768     }
769   return ret;
770 }
771
772 std::vector<std::string> MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
773 {
774   std::vector<std::string> ret;
775   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
776   med_int nbFields=MEDnField(fid);
777   char pflname[MED_NAME_SIZE+1]="";
778   char locname[MED_NAME_SIZE+1]="";
779   //
780   med_field_type typcha;
781   med_int numdt=0,numo=0;
782   med_float dt=0.0;
783   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
784   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
785   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
786   med_bool localmesh;
787   //
788   for(int i=0;i<nbFields;i++)
789     {
790       med_int ncomp(MEDfieldnComponent(fid,i+1));
791       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
792       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
793       med_int nbPdt;
794       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
795       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
796       std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1);
797       if(nbPdt>0)
798         {
799           int profilesize,nbi;
800           MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt));
801           med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE,
802                                                     pflname,&profilesize,locname,&nbi));
803           if(curMeshName==meshName && nbOfVal>0)
804             {
805               ret.push_back(curFieldName);
806             }
807         }
808     }
809   return ret;
810 }
811
812 std::vector< std::pair< std::pair<int,int>, double> > MEDCoupling::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName)
813 {
814   std::vector< std::pair< std::pair<int,int>, double > > ret;
815   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
816   med_int nbFields=MEDnField(fid);
817   //
818   med_field_type typcha;
819   med_int numdt=0,numo=0;
820   med_float dt=0.0;
821   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
822   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
823   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
824   med_bool localmesh;
825   //
826   std::ostringstream oss; oss << "GetAllFieldIterations : No field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : ";
827   for(int i=0;i<nbFields;i++)
828     {
829       med_int ncomp(MEDfieldnComponent(fid,i+1));
830       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
831       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
832       med_int nbPdt;
833       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
834       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
835       if(curFieldName==fieldName)
836         {
837           for(int k=0;k<nbPdt;k++)
838             {
839               MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt));
840               ret.push_back(std::make_pair(std::make_pair(numdt,numo),dt));
841             }
842           return ret;
843         }
844       else
845         {
846           oss << "\"" << curFieldName << "\"";
847           if(i!=nbFields-1) oss << ", ";
848         }
849     }
850   oss << " !";
851   throw INTERP_KERNEL::Exception(oss.str().c_str());
852 }
853
854 double MEDCoupling::GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order)
855 {
856   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
857   med_int nbFields=MEDnField(fid);
858   //
859   med_field_type typcha;
860   med_int numdt=0,numo=0;
861   med_float dt=0.0;
862   med_bool local;
863   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
864   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
865   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
866   //
867   bool found=false;
868   bool found2=false;
869   double ret=std::numeric_limits<double>::max();
870   for(int i=0;i<nbFields && !found;i++)
871     {
872       med_int ncomp(MEDfieldnComponent(fid,i+1));
873       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
874       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
875       med_int nbPdt;
876       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&local,&typcha,comp,unit,dt_unit,&nbPdt));
877       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
878       if(curFieldName==fieldName)
879         {
880           found=true;
881           for(int k=0;k<nbPdt;k++)
882             {
883               MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt));
884               if(numdt==iteration && numo==order)
885                 {
886                   found2=true;
887                   ret=dt;
888                 }
889             }
890         }
891     }
892   if(!found || !found2)
893     {
894       std::ostringstream oss;
895       oss << "No such field with name \"" << fieldName << "\" and iteration,order=(" << iteration << "," << order << ") exists in file \"" << fileName << "\" !";
896       throw INTERP_KERNEL::Exception(oss.str().c_str());
897     }
898   return ret;
899 }
900
901 std::vector< std::pair<int,int> > MEDCoupling::GetFieldIterations(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName)
902 {
903   MEDCoupling::CheckFileForRead(fileName);
904   switch(type)
905   {
906     case ON_CELLS:
907       return GetCellFieldIterations(fileName,meshName,fieldName);
908     case ON_NODES:
909       return GetNodeFieldIterations(fileName,meshName,fieldName);
910     default:
911       throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES or ON_CELLS !");
912   }
913 }
914
915 std::vector< std::pair<int,int> > MEDCoupling::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
916 {
917   std::string meshNameCpp(meshName);
918   std::vector< std::pair<int,int> > ret;
919   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
920   med_int nbFields=MEDnField(fid);
921   //
922   med_field_type typcha;
923   med_int numdt=0,numo=0;
924   med_float dt=0.0;
925   char pflname[MED_NAME_SIZE+1]="";
926   char locname[MED_NAME_SIZE+1]="";
927   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
928   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
929   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
930   med_bool localmesh;
931   //
932   std::ostringstream oss; oss << "GetCellFieldIterations : No cell Field field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : ";
933   std::set<std::string> s2;
934   for(int i=0;i<nbFields;i++)
935     {
936       med_int ncomp(MEDfieldnComponent(fid,i+1));
937       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
938       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
939       med_int nbPdt;
940       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
941       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
942       if(curFieldName==fieldName)
943         {
944           bool found=false;
945           for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
946             {
947               for(int k=0;k<nbPdt;k++)
948                 {
949                   int profilesize,nbi;
950                   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt));
951                   med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE,
952                                                             pflname,&profilesize,locname,&nbi));
953                   std::string maa_ass_cpp(maa_ass);
954                   if(nbOfVal>0)
955                     {
956                       if(meshNameCpp==maa_ass_cpp)
957                         {
958                           found=true;
959                           ret.push_back(std::make_pair(numdt,numo));
960                         }
961                       else
962                         s2.insert(maa_ass_cpp);
963                     }
964                 }
965             }
966         }
967       else
968         {
969           oss << "\"" << curFieldName << "\"";
970           if(i!=nbFields-1) oss << ", ";
971         }
972     }
973   if(ret.empty())
974     {
975       if(!s2.empty())
976         {
977           oss << ". Cell Field \"" << fieldName << "\" exists but lies on meshes with names : \"";
978           std::copy(s2.begin(),s2.end(),std::ostream_iterator<std::string>(oss,"\", \""));
979         }
980       oss << " !";
981       throw INTERP_KERNEL::Exception(oss.str().c_str());
982     }
983   return ret;
984 }
985
986 std::vector< std::pair<int,int> > MEDCoupling::GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
987 {
988   std::string meshNameCpp(meshName);
989   std::vector< std::pair<int,int> > ret;
990   MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
991   med_int nbFields=MEDnField(fid);
992   //
993   med_field_type typcha;
994   med_int numdt=0,numo=0;
995   med_float dt=0.0;
996   char pflname[MED_NAME_SIZE+1]="";
997   char locname[MED_NAME_SIZE+1]="";
998   INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
999   INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
1000   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1001   med_bool localmesh;
1002   //
1003   std::ostringstream oss; oss << "GetNodeFieldIterations : No node Field field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : ";
1004   std::set<std::string> s2;
1005   for(int i=0;i<nbFields;i++)
1006     {
1007       med_int ncomp(MEDfieldnComponent(fid,i+1));
1008       INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
1009       INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
1010       med_int nbPdt;
1011       MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt));
1012       std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
1013       if(curFieldName==fieldName)
1014         {
1015           for(int k=0;k<nbPdt;k++)
1016             {
1017               int profilesize,nbi;
1018               MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt));
1019               med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE,
1020                                                         pflname,&profilesize,locname,&nbi));
1021               std::string maa_ass_cpp(maa_ass);
1022               if(nbOfVal>0)
1023                 {
1024                   if(meshNameCpp==maa_ass_cpp)
1025                     { ret.push_back(std::make_pair(numdt,numo)); }
1026                   else
1027                     s2.insert(maa_ass_cpp);
1028                 }
1029             }
1030         }
1031       else
1032         {
1033           oss << "\"" << curFieldName << "\"";
1034           if(i!=nbFields-1) oss << ", ";
1035         }
1036     }
1037   if(ret.empty())
1038     {
1039       if(!s2.empty())
1040         {
1041           oss << ". Node Field \"" << fieldName << "\" exists but lies on meshes with names : \"";
1042           std::copy(s2.begin(),s2.end(),std::ostream_iterator<std::string>(oss,"\", \""));
1043         }
1044       oss << " !";
1045       throw INTERP_KERNEL::Exception(oss.str().c_str());
1046     }
1047   return ret;
1048 }
1049
1050 MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
1051 {
1052   MEDCoupling::CheckFileForRead(fileName);
1053   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1054   MEDFileMesh *mmPtr(mm);
1055   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1056   if(mmuPtr)
1057     return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
1058   MEDFileCMesh *mmcPtr=dynamic_cast<MEDFileCMesh *>(mmPtr);
1059   if(mmcPtr)
1060     {
1061       const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef();
1062       return const_cast<MEDCouplingCMesh *>(ret);
1063     }
1064   MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast<MEDFileCurveLinearMesh *>(mmPtr);
1065   if(mmc2Ptr)
1066     {
1067       const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef();
1068       return const_cast<MEDCouplingCurveLinearMesh *>(ret);
1069     }
1070   std::ostringstream oss; oss << "ReadMeshFromFile : The mesh \"" << meshName << "\" in file \"" << fileName << "\" has not a recognized type !";
1071   throw INTERP_KERNEL::Exception(oss.str().c_str());
1072 }
1073
1074 MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax)
1075 {
1076   MEDCoupling::CheckFileForRead(fileName);
1077   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName));
1078   MEDFileMesh *mmPtr(mm);
1079   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1080   if(mmuPtr)
1081     return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
1082   MEDFileCMesh *mmcPtr=dynamic_cast<MEDFileCMesh *>(mmPtr);
1083   if(mmcPtr)
1084     {
1085       const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef();
1086       return const_cast<MEDCouplingCMesh *>(ret);
1087     }
1088   MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast<MEDFileCurveLinearMesh *>(mmPtr);
1089   if(mmc2Ptr)
1090     {
1091       const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef();
1092       return const_cast<MEDCouplingCurveLinearMesh *>(ret);
1093     }
1094   std::ostringstream oss; oss << "ReadMeshFromFile (2) : The first mesh \"" << mm->getName() << "\" in file \"" << fileName << "\" has not a recognized type !";
1095   throw INTERP_KERNEL::Exception(oss.str().c_str());
1096 }
1097
1098 MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
1099 {
1100   MEDCoupling::CheckFileForRead(fileName);
1101   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1102   MEDFileMesh *mmPtr(mm);
1103   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1104   if(!mmuPtr)
1105     {
1106       std::ostringstream oss; oss << "ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName=\""<< meshName << "\" exists but it is not an unstructured mesh !";
1107       throw INTERP_KERNEL::Exception(oss.str().c_str());
1108     }
1109   return  mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
1110 }
1111
1112 MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax)
1113 {
1114   MEDCoupling::CheckFileForRead(fileName);
1115   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName));
1116   MEDFileMesh *mmPtr(mm);
1117   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1118   if(!mmuPtr)
1119     {
1120       std::ostringstream oss; oss << "ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !";
1121       throw INTERP_KERNEL::Exception(oss.str().c_str());
1122     }
1123   return  mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
1124 }
1125
1126 int MEDCoupling::ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName)
1127 {
1128   MEDCoupling::CheckFileForRead(fileName);
1129   std::vector<int> poss;
1130   return MEDLoaderNS::readUMeshDimFromFile(fileName,meshName,poss);
1131 }
1132
1133 MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& fams)
1134 {
1135   MEDCoupling::CheckFileForRead(fileName);
1136   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1137   MEDFileMesh *mmPtr(mm);
1138   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1139   if(!mmuPtr)
1140     {
1141       std::ostringstream oss; oss << "ReadUMeshFromFamilies : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !";
1142       throw INTERP_KERNEL::Exception(oss.str().c_str());
1143     }
1144   return mmuPtr->getFamilies(meshDimRelToMax,fams,true);
1145 }
1146
1147 MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& grps)
1148 {
1149   MEDCoupling::CheckFileForRead(fileName);
1150   MCAuto<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
1151   MEDFileMesh *mmPtr(mm);
1152   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1153   if(!mmuPtr)
1154     {
1155       std::ostringstream oss; oss << "ReadUMeshFromGroups : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !";
1156       throw INTERP_KERNEL::Exception(oss.str().c_str());
1157     }
1158   return mmuPtr->getGroups(meshDimRelToMax,grps,true);
1159 }
1160
1161 MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName)
1162 {
1163   std::vector<std::string> fieldNames(GetAllFieldNames(fileName));
1164   std::size_t sz(fieldNames.size());
1165   if(sz==0)
1166     {
1167       std::ostringstream oss;
1168       oss << "The file \"" << fileName << "\" contains no field !";
1169       throw INTERP_KERNEL::Exception(oss.str());
1170     }
1171   if(sz>1)
1172     {
1173       std::ostringstream oss;
1174       oss << "In file \"" << fileName << "\" there are more than one field !" << std::endl;
1175       oss << "You are invited to use ReadField(fileName, fieldName) instead to avoid misleading concerning field you want to read !" << std::endl;
1176       oss << "For information, fields available are :" << std::endl;
1177       for(std::vector<std::string>::const_iterator it=fieldNames.begin();it!=fieldNames.end();it++)
1178         oss << " - \"" << *it << "\"" << std::endl;
1179       throw INTERP_KERNEL::Exception(oss.str());
1180     }
1181   return ReadField(fileName,fieldNames[0]);
1182 }
1183
1184 MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName)
1185 {
1186   std::vector< std::pair< std::pair<int,int>, double> > iterations(GetAllFieldIterations(fileName,fieldName));
1187   std::size_t sz(iterations.size());
1188   if(sz==0)
1189     {
1190       std::ostringstream oss;
1191       oss << "In file \"" << fileName << "\" field \"" << fieldName << "\" exists but with no time steps !";
1192       throw INTERP_KERNEL::Exception(oss.str());
1193     }
1194   if(sz>1)
1195     {
1196       std::ostringstream oss;
1197       oss << "In file \"" << fileName << "\" field \"" << fieldName << "\" exists but with more than one time steps !" << std::endl;
1198       oss << "You are invited to use ReadField(fileName, fieldName, iteration, order) instead to avoid misleading concerning time steps." << std::endl;
1199       oss << "For information, time steps available for field \"" << fieldName << "\" are :" << std::endl;
1200       for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator it=iterations.begin();it!=iterations.end();it++)
1201         oss << " - " << (*it).first.first << ", " << (*it).first.second << " (" << (*it).second << ")" << std::endl;
1202       throw INTERP_KERNEL::Exception(oss.str());
1203     }
1204   return ReadField(fileName,fieldName,iterations[0].first.first,iterations[0].first.second);
1205 }
1206
1207 MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order)
1208 {
1209   MCAuto<MEDFileAnyTypeField1TS> f(MEDFileAnyTypeField1TS::New(fileName,fieldName,iteration,order));
1210   MCAuto<MEDFileMesh> mesh(MEDFileMesh::New(fileName,f->getMeshName()));
1211   {
1212     MCAuto<MEDFileField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileField1TS>(f));
1213     if(f1.isNotNull())
1214       {
1215         MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f1->field(mesh));
1216         return MEDCoupling::DynamicCast<MEDCouplingFieldDouble,MEDCouplingField>(ret);
1217       }
1218   }
1219   {
1220     MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
1221     if(f1.isNotNull())
1222       {
1223         MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(f1->field(mesh));
1224         return MEDCoupling::DynamicCast<MEDCouplingFieldInt,MEDCouplingField>(ret);
1225       }
1226   }
1227   {
1228     MCAuto<MEDFileFloatField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileFloatField1TS>(f));
1229     if(f1.isNotNull())
1230       {
1231         MCAuto<MEDCoupling::MEDCouplingFieldFloat> ret(f1->field(mesh));
1232         return MEDCoupling::DynamicCast<MEDCouplingFieldFloat,MEDCouplingField>(ret);
1233       }
1234   }
1235   throw INTERP_KERNEL::Exception("MEDCoupling::ReadField : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
1236   //MCAuto<MEDFileMesh> mesh(MEDFileMesh::New(fileName,f->getMeshName()));
1237   //MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f->field(mesh));
1238   //return ret;
1239 }
1240
1241 MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
1242 {
1243   MEDCoupling::CheckFileForRead(fileName);
1244   switch(type)
1245   {
1246     case ON_CELLS:
1247       return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
1248     case ON_NODES:
1249       return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
1250     case ON_GAUSS_PT:
1251       return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
1252     case ON_GAUSS_NE:
1253       return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
1254     default:
1255       throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES, ON_CELLS, ON_GAUSS_PT or ON_GAUSS_NE !");
1256   }
1257 }
1258
1259 std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsOnSameMesh(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
1260                                                                                      const std::vector<std::pair<int,int> >& its)
1261 {
1262   if(its.empty())
1263     return std::vector<MEDCoupling::MEDCouplingFieldDouble *>();
1264   MEDCoupling::CheckFileForRead(fileName);
1265   std::vector<MEDCoupling::MEDCouplingFieldDouble *> ret(its.size());
1266   std::vector< MCAuto<MEDCouplingFieldDouble> > retSafe(its.size());
1267   if(its.empty())
1268     return ret;
1269   //Retrieving mesh of rank 0 and field on rank 0 too.
1270   MCAuto<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
1271   MEDFileMesh *mmPtr(mm);
1272   MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
1273   if(!mmuPtr)
1274     throw INTERP_KERNEL::Exception("ReadFieldsOnSameMesh : only unstructured mesh is managed !");
1275   MCAuto<MEDCouplingUMesh> m=mmuPtr->getMeshAtLevel(meshDimRelToMax);
1276   const DataArrayInt *o2n=mmuPtr->getNumberFieldAtLevel(meshDimRelToMax);
1277   MCAuto<MEDCouplingUMesh> m2(m->clone(true));
1278   if(o2n)
1279     m2->renumberCells(o2n->begin(),true);
1280   int i=0;
1281   for(std::vector<std::pair<int,int> >::const_iterator it=its.begin();it!=its.end();it++,i++)
1282     {
1283       MCAuto<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,(*it).first,(*it).second);
1284       MCAuto<MEDCouplingFieldDouble> retElt=ff->getFieldOnMeshAtLevel(type,m);
1285       if(o2n)
1286         retElt->renumberCells(o2n->begin(),true);
1287       retElt->setMesh(m2);
1288       retSafe[i]=retElt;
1289     }
1290   i=0;
1291   for(std::vector<std::pair<int,int> >::const_iterator it=its.begin();it!=its.end();it++,i++)
1292     ret[i]=retSafe[i].retn();
1293   return ret;
1294 }
1295
1296 std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsCellOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
1297                                                                                       const std::vector<std::pair<int,int> >& its)
1298 {
1299   return ReadFieldsOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its);
1300 }
1301
1302 std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsNodeOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
1303                                                                                       const std::vector<std::pair<int,int> >& its)
1304 {
1305   return ReadFieldsOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its);
1306 }
1307
1308 std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsGaussOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
1309                                                                                        const std::vector<std::pair<int,int> >& its)
1310 {
1311   return ReadFieldsOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its);
1312 }
1313
1314 std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsGaussNEOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
1315                                                                                          const std::vector<std::pair<int,int> >& its)
1316 {
1317   return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its);
1318 }
1319
1320 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
1321 {
1322   MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
1323   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1324   MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
1325   MEDFileMesh *mPtr(mm);
1326   MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
1327   MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_CELLS,m));
1328   if(muPtr)
1329     {
1330       const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
1331       if(num)
1332         ret->renumberCells(num->begin());
1333     }
1334   return ret.retn();
1335 }
1336
1337 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
1338 {
1339   MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
1340   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1341   MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
1342   MEDFileMesh *mPtr(mm);
1343   MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
1344   MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
1345   if(ff->getPflsReallyUsed().empty())
1346     {
1347       if(muPtr)
1348         {
1349           const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
1350           if(num)
1351             ret->renumberCells(num->begin());
1352         }
1353     }
1354   else
1355     {
1356       DataArrayInt *pfl=0,*arr2=0;
1357       MCAuto<DataArrayDouble> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
1358       MCAuto<DataArrayInt> pflSafe(pfl);
1359       MCAuto<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
1360       MCAuto<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
1361       MCAuto<DataArrayInt> arr2Safe(arr2);
1362       MCAuto<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
1363       MCAuto<DataArrayInt> pflSorted(pflSafe->deepCopy()); pflSorted->sort(true);
1364       if(!arr3->isEqualWithoutConsideringStr(*pflSorted))
1365         throw INTERP_KERNEL::Exception("ReadFieldNode : not implemented yet !");
1366       if(!arr3->isEqualWithoutConsideringStr(*pflSafe))
1367         {
1368           MCAuto<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
1369           MCAuto<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
1370           mzip->renumberNodes(n2o2->begin(),n2o2->getNumberOfTuples());
1371           arr->setName("");
1372           ret->setArray(arr);
1373         }
1374       ret->setMesh(mzip);
1375     }
1376   return ret.retn();
1377 }
1378
1379 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
1380 {
1381   MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
1382   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1383   MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
1384   MEDFileMesh *mPtr(mm);
1385   MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
1386   MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_PT,m));
1387   if(muPtr)
1388     {
1389       const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
1390       if(num)
1391         ret->renumberCells(num->begin());
1392     }
1393   return ret.retn();
1394 }
1395
1396 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
1397 {
1398   MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
1399   MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
1400   MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
1401   MEDFileMesh *mPtr(mm);
1402   MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
1403   MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_NE,m));
1404   if(muPtr)
1405     {
1406       const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
1407       if(num)
1408         ret->renumberCells(num->begin());
1409     }
1410   return ret.retn();
1411 }
1412
1413 void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch)
1414 {
1415   if(!mesh)
1416     throw INTERP_KERNEL::Exception("WriteMesh : input mesh is null !");
1417   const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(mesh));
1418   if(um)
1419     {
1420       WriteUMesh(fileName,um,writeFromScratch);
1421       return ;
1422     }
1423   int mod=writeFromScratch?2:0;
1424   const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(mesh));
1425   if(um2)
1426     {
1427       MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
1428       AssignStaticWritePropertiesTo(*mmu);
1429       mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
1430       mmu->write(fileName,mod);
1431       return ;
1432     }
1433   const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(mesh));
1434   if(um3)
1435     {
1436       MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New());
1437       AssignStaticWritePropertiesTo(*mmc);
1438       mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
1439       mmc->write(fileName,mod);
1440       return ;
1441     }
1442   const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(mesh));
1443   if(um4)
1444     {
1445       MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
1446       AssignStaticWritePropertiesTo(*mmc);
1447       mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
1448       mmc->write(fileName,mod);
1449       return ;
1450     }
1451   throw INTERP_KERNEL::Exception("WriteMesh : only MEDCouplingUMesh, MEDCoupling1GTUMesh, MEDCouplingCMesh, MEDCouplingCurveLinear are dealed in this API for the moment !");
1452 }
1453
1454 void MEDCoupling::WriteUMesh(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch)
1455 {
1456   if(!mesh)
1457     throw INTERP_KERNEL::Exception("WriteUMesh : input mesh is null !");
1458   int mod=writeFromScratch?2:0;
1459   MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
1460   AssignStaticWritePropertiesTo(*m);
1461   MCAuto<MEDCouplingUMesh> mcpy(static_cast<MEDCouplingUMesh *>(mesh->deepCopy()));
1462   m->setMeshAtLevel(0,mcpy,true);
1463   m->write(fileName,mod);
1464 }
1465
1466 void MEDCoupling::WriteUMeshDep(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch)
1467 {
1468   WriteUMesh(fileName,mesh,writeFromScratch);
1469 }
1470
1471 void MEDCoupling::WriteUMeshesPartition(const std::string& fileName, const std::string& meshNameC, const std::vector<const MEDCoupling::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
1472 {
1473   std::string meshName(meshNameC);
1474   if(meshName.empty())
1475     throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change 2nd parameter !");
1476   int status=MEDLoaderBase::getStatusOfFile(fileName);
1477   if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST)
1478     {
1479       std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !";
1480       throw INTERP_KERNEL::Exception(oss.str().c_str());
1481     }
1482   MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
1483   AssignStaticWritePropertiesTo(*m);
1484   m->setGroupsFromScratch(0,meshes,true);
1485   m->setName(meshNameC);
1486   int mod=writeFromScratch?2:0;
1487   m->write(fileName,mod);
1488 }
1489
1490 void MEDCoupling::WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshNameC, const std::vector<const MEDCoupling::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
1491 {
1492   WriteUMeshesPartition(fileName,meshNameC,meshes,writeFromScratch);
1493 }
1494
1495 void MEDCoupling::WriteUMeshes(const std::string& fileName, const std::vector<const MEDCoupling::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
1496 {
1497   int mod(writeFromScratch?2:0);
1498   MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
1499   AssignStaticWritePropertiesTo(*m);
1500   m->setMeshes(meshes,true);
1501   m->write(fileName,mod);
1502 }
1503
1504 template<class T>
1505 void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const typename MEDCoupling::Traits<T>::FieldType *f, bool writeFromScratch)
1506 {
1507   MCAuto< typename MLFieldTraits<T>::F1TSType > ff(MLFieldTraits<T>::F1TSType::New());
1508   AssignStaticWritePropertiesTo(*ff);
1509   MCAuto<typename MEDCoupling::Traits<T>::FieldType> f2(f->deepCopy());
1510   const MEDCouplingMesh *m(f2->getMesh());
1511   const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(m));
1512   const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(m));
1513   const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(m));
1514   const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(m));
1515   MCAuto<MEDFileMesh> mm;
1516   int mod(writeFromScratch?2:0);
1517   if(um)
1518     {
1519       MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
1520       AssignStaticWritePropertiesTo(*mmu);
1521       MCAuto<DataArrayInt> o2n(um->getRenumArrForMEDFileFrmt());
1522       MCAuto<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples()));
1523       f2->renumberCells(o2n->begin(),false);
1524       mmu->setMeshAtLevel(0,const_cast<MEDCouplingUMesh *>(static_cast<const MEDCouplingUMesh *>(f2->getMesh())));
1525       mmu->setRenumFieldArr(0,n2o);
1526       ff->setFieldNoProfileSBT(f2);
1527       mmu->write(fileName,mod);
1528     }
1529   else if(um2)
1530     {
1531       MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
1532       AssignStaticWritePropertiesTo(*mmu);
1533       mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
1534       ff->setFieldNoProfileSBT(f2);
1535       mmu->write(fileName,mod);
1536     }
1537   else if(um3)
1538     {
1539       MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New());
1540       AssignStaticWritePropertiesTo(*mmc);
1541       mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
1542       ff->setFieldNoProfileSBT(f2);
1543       mmc->write(fileName,mod);
1544     }
1545   else if(um4)
1546     {
1547       MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
1548       AssignStaticWritePropertiesTo(*mmc);
1549       mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
1550       ff->setFieldNoProfileSBT(f2);
1551       mmc->write(fileName,mod);
1552     }
1553   else
1554     throw INTERP_KERNEL::Exception("MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile : only MEDCouplingUMesh, MEDCoupling1GTUMesh, MEDCouplingCMesh, MEDCouplingCurveLinear are dealed in this API for the moment !");
1555   ff->write(fileName,0);
1556 }
1557
1558 template<class T>
1559 void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits<T>::FieldType *f, bool writeFromScratch)
1560 {
1561   if(!f)
1562     throw INTERP_KERNEL::Exception("WriteField : input field is NULL !");
1563   f->checkConsistencyLight();
1564   int status(MEDLoaderBase::getStatusOfFile(fileName));
1565   if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST)
1566     {
1567       std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !";
1568       throw INTERP_KERNEL::Exception(oss.str().c_str());
1569     }
1570   if(writeFromScratch || (!writeFromScratch && status==MEDLoaderBase::NOT_EXIST))
1571     {
1572       MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile<T>(fileName,f,true);
1573     }
1574   else
1575     {
1576       std::vector<std::string> meshNames(GetMeshNames(fileName));
1577       if(!f->getMesh())
1578         throw INTERP_KERNEL::Exception("WriteField : trying to write a field with no mesh !");
1579       std::string fileNameCpp(f->getMesh()->getName());
1580       if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end())
1581         MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile<T>(fileName,f,false);
1582       else
1583         {
1584           MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str()));
1585           AssignStaticWritePropertiesTo(*mm);
1586           const MEDFileMesh *mmPtr(mm);
1587           const MEDFileUMesh *mmuPtr(dynamic_cast<const MEDFileUMesh *>(mmPtr));
1588           if(!mmuPtr)
1589             throw INTERP_KERNEL::Exception("WriteField : only umeshes are supported now !");
1590           MCAuto< typename MEDCoupling::Traits<T>::FieldType > f2(f->deepCopy());
1591           MEDCouplingUMesh *m(dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f2->getMesh())));
1592           if(!m)
1593             throw INTERP_KERNEL::Exception("WriteField : only umesh in input field supported !");
1594           MCAuto<DataArrayInt> o2n(m->getRenumArrForMEDFileFrmt());
1595           f2->renumberCells(o2n->begin(),false);
1596           m=static_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f2->getMesh()));
1597           MCAuto<MEDCouplingUMesh> mread(mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension()));
1598           if(f2->getTypeOfField()!=ON_NODES)
1599             {
1600               m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP);
1601               DataArrayInt *part(NULL);
1602               bool b(mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part));
1603               MCAuto<DataArrayInt> partSafe(part);
1604               if(!b)
1605                 {
1606                   std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart) with the mesh you intend to write ! This is maybe due to a too strict policy ! Try with to lease it by calling SetCompPolicyForCell !";
1607                   throw INTERP_KERNEL::Exception(oss.str().c_str());
1608                 }
1609               MCAuto< typename MLFieldTraits<T>::F1TSType > f1ts(MLFieldTraits<T>::F1TSType::New());
1610               AssignStaticWritePropertiesTo(*f1ts);
1611               if(part->isIota(mread->getNumberOfCells()))
1612                 f1ts->setFieldNoProfileSBT(f2);
1613               else
1614                 {
1615                   part->setName(f1ts->createNewNameOfPfl().c_str());
1616                   f1ts->setFieldProfile(f2,mm,m->getMeshDimension()-mm->getMeshDimension(),part);
1617                 }
1618               f1ts->write(fileName,0);
1619               return ;
1620             }
1621           else
1622             {
1623               DataArrayInt *part(NULL);
1624               bool b(mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part));
1625               MCAuto<DataArrayInt> partSafe(part);
1626               if(!b)
1627                 {
1628                   std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart regarding nodes) with the mesh you intend to write ! This is maybe due to a too strict epsilon ! Try with to lease it by calling SetEpsilonForNodeComp !";
1629                   throw INTERP_KERNEL::Exception(oss.str().c_str());
1630                 }
1631               MCAuto< typename MLFieldTraits<T>::F1TSType > f1ts(MLFieldTraits<T>::F1TSType::New());
1632               AssignStaticWritePropertiesTo(*f1ts);
1633               if(part->isIota(mread->getNumberOfNodes()))
1634                 f1ts->setFieldNoProfileSBT(f2);
1635               else
1636                 {
1637                   part->setName(f1ts->createNewNameOfPfl().c_str());
1638                   f1ts->setFieldProfile(f2,mm,m->getMeshDimension()-mm->getMeshDimension(),part);
1639                 }
1640               f1ts->write(fileName,0);
1641             }
1642         }
1643     }
1644 }
1645
1646 void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch)
1647 {
1648   if(!f)
1649     throw INTERP_KERNEL::Exception("WriteField : input field is null !");
1650   {
1651     const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldDouble *>(f));
1652     if(f1)
1653       WriteFieldT<double>(fileName,f1,writeFromScratch);
1654     return ;
1655   }
1656   {
1657     const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt *>(f));
1658     if(f1)
1659       WriteFieldT<int>(fileName,f1,writeFromScratch);
1660     return ;
1661   }
1662   {
1663     const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldFloat *>(f));
1664     if(f1)
1665       WriteFieldT<float>(fileName,f1,writeFromScratch);
1666     return ;
1667   }
1668   throw INTERP_KERNEL::Exception("WriteField : input field is not in FLOAT32, FLOAT64, INT32 !");
1669 }
1670
1671 void MEDCoupling::WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch)
1672 {
1673   WriteField(fileName,f,writeFromScratch);
1674 }
1675
1676 template<class T>
1677 void WriteFieldUsingAlreadyWrittenMeshT(const std::string& fileName, const typename MEDCoupling::Traits<T>::FieldType *f)
1678 {
1679   if(!f)
1680     throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMeshT : input field is null !");
1681   f->checkConsistencyLight();
1682   int status(MEDLoaderBase::getStatusOfFile(fileName));
1683   if(status!=MEDLoaderBase::EXIST_RW)
1684     {
1685       std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !";
1686       throw INTERP_KERNEL::Exception(oss.str().c_str());
1687     }
1688   MCAuto< typename MLFieldTraits<T>::F1TSType > f1ts(MLFieldTraits<T>::F1TSType::New());
1689   AssignStaticWritePropertiesTo(*f1ts);
1690   MEDCouplingUMesh *m(dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f->getMesh())));
1691   if(m)
1692     {
1693       MCAuto<DataArrayInt> o2n(m->getRenumArrForMEDFileFrmt());
1694       MCAuto< typename MEDCoupling::Traits<T>::FieldType > f2(f->deepCopy());
1695       f2->renumberCells(o2n->begin(),false);
1696       f1ts->setFieldNoProfileSBT(f2);
1697     }
1698   else
1699     f1ts->setFieldNoProfileSBT(f);
1700   f1ts->write(fileName,0);
1701 }
1702
1703 void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingField *f)
1704 {
1705   if(!f)
1706     throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !");
1707   {
1708     const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldDouble *>(f));
1709     if(f1)
1710       WriteFieldUsingAlreadyWrittenMeshT<double>(fileName,f1);
1711     return ;
1712   }
1713   {
1714     const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt *>(f));
1715     if(f1)
1716       WriteFieldUsingAlreadyWrittenMeshT<int>(fileName,f1);
1717     return ;
1718   }
1719   {
1720     const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldFloat *>(f));
1721     if(f1)
1722       WriteFieldUsingAlreadyWrittenMeshT<float>(fileName,f1);
1723     return ;
1724   }
1725   throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is not in FLOAT32, FLOAT64, INT32 !");
1726 }