Back to index

salome-med  6.5.0
MEDFileField.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDFileField.hxx"
00021 #include "MEDFileMesh.hxx"
00022 #include "MEDLoaderBase.hxx"
00023 #include "MEDFileUtilities.hxx"
00024 
00025 #include "MEDCouplingFieldDouble.hxx"
00026 #include "MEDCouplingFieldDiscretization.hxx"
00027 
00028 #include "InterpKernelAutoPtr.hxx"
00029 #include "CellModel.hxx"
00030 
00031 #include <algorithm>
00032 #include <iterator>
00033 
00034 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
00035 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
00036 extern med_geometry_type typmainoeud[1];
00037 extern med_geometry_type typmai3[32];
00038 
00039 using namespace ParaMEDMEM;
00040 
00041 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
00042 {
00043   return new MEDFileFieldLoc(fid,locName);
00044 }
00045 
00046 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
00047 {
00048   return new MEDFileFieldLoc(fid,id);
00049 }
00050 
00051 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
00052 {
00053   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
00054 }
00055 
00056 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
00057 {
00058   med_geometry_type geotype;
00059   med_geometry_type sectiongeotype;
00060   int nsectionmeshcell;
00061   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00062   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00063   MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
00064   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
00065   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00066   _nb_node_per_cell=cm.getNumberOfNodes();
00067   _ref_coo.resize(_dim*_nb_node_per_cell);
00068   _gs_coo.resize(_dim*_nb_gauss_pt);
00069   _w.resize(_nb_gauss_pt);
00070   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
00071 }
00072 
00073 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
00074 {
00075   med_geometry_type geotype;
00076   med_geometry_type sectiongeotype;
00077   int nsectionmeshcell;
00078   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00079   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00080   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00081   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
00082   _name=locName;
00083   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
00084   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00085   _nb_node_per_cell=cm.getNumberOfNodes();
00086   _ref_coo.resize(_dim*_nb_node_per_cell);
00087   _gs_coo.resize(_dim*_nb_gauss_pt);
00088   _w.resize(_nb_gauss_pt);
00089   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
00090 }
00091 
00092 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
00093                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
00094                                                                                                                                     _w(w)
00095 {
00096   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00097   _dim=cm.getDimension();
00098   _nb_node_per_cell=cm.getNumberOfNodes();
00099   _nb_gauss_pt=_w.size();
00100 }
00101 
00102 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
00103 {
00104   static const char OFF7[]="\n    ";
00105   oss << "\"" << _name << "\"" << OFF7;
00106   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
00107   oss << "Dimension=" << _dim << OFF7;
00108   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
00109   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
00110   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
00111   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
00112   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
00113 }
00114 
00115 void MEDFileFieldLoc::setName(const char *name)
00116 {
00117   _name=name;
00118 }
00119 
00120 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
00121 {
00122   if(_name!=other._name)
00123     return false;
00124   if(_dim!=other._dim)
00125     return false;
00126   if(_nb_gauss_pt!=other._nb_gauss_pt)
00127     return false;
00128   if(_nb_node_per_cell!=other._nb_node_per_cell)
00129     return false;
00130   if(_geo_type!=other._geo_type)
00131     return false;
00132   if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
00133     return false;
00134   if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
00135     return false;
00136   if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
00137     return false;
00138   
00139   return true;
00140 }
00141 
00142 void MEDFileFieldLoc::writeLL(med_idt fid) const
00143 {
00144   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
00145 }
00146 
00147 std::string MEDFileFieldLoc::repr() const
00148 {
00149   std::ostringstream oss; oss.precision(15);
00150   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00151   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
00152   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
00153   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
00154   oss << "\n  - Ref coords are : ";
00155   int sz=_ref_coo.size();
00156   if(sz%_dim==0)
00157     {
00158       int nbOfTuples=sz/_dim;
00159       for(int i=0;i<nbOfTuples;i++)
00160         {
00161           oss << "(";
00162           for(int j=0;j<_dim;j++)
00163             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
00164           oss << ") ";
00165         }
00166     }
00167   else
00168     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
00169   oss << "\n  - Gauss coords in reference element : ";
00170   sz=_gs_coo.size();
00171   if(sz%_dim==0)
00172     {
00173       int nbOfTuples=sz/_dim;
00174       for(int i=0;i<nbOfTuples;i++)
00175         {
00176           oss << "(";
00177           for(int j=0;j<_dim;j++)
00178             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
00179           oss << ") ";
00180         }
00181     }
00182   else
00183     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
00184   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
00185   return oss.str();
00186 }
00187 
00188 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00189 {
00190   _type=field->getTypeOfField();
00191   const DataArrayDouble *da=field->getArray();
00192   _start=start;
00193   switch(_type)
00194     {
00195     case ON_CELLS:
00196       {
00197         getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
00198         _end=_start+nbOfCells;
00199         _nval=nbOfCells;
00200         break;
00201       }
00202     case ON_GAUSS_NE:
00203       {
00204         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
00205         const int *arrPtr=arr->getConstPointer();
00206         getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
00207         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
00208         _nval=nbOfCells;
00209         break;
00210       }
00211     case ON_GAUSS_PT:
00212       {
00213         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
00214         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
00215         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
00216         if(!disc2)
00217           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
00218         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
00219         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
00220         const int *dai2Ptr=dai2->getConstPointer();
00221         int nbi=gsLoc.getWeights().size();
00222         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
00223         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
00224         const int *da3Ptr=da3->getConstPointer();
00225         if(da3->getNumberOfTuples()!=nbOfCells)
00226           {//profile : for gauss even in NoProfile !!!
00227             std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
00228             _profile=oss.str();
00229             da3->setName(_profile.c_str());
00230             glob.appendProfile(da3);
00231           }
00232         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
00233         _nval=da3->getNbOfElems();
00234         da4->alloc(_nval*nbi,1);
00235         int *da4Ptr=da4->getPointer();
00236         for(int i=0;i<_nval;i++)
00237           {
00238             int ref=dai2Ptr[offset+da3Ptr[i]];
00239             for(int j=0;j<nbi;j++)
00240               *da4Ptr++=ref+j;
00241           }
00242         std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
00243         _localization=oss2.str();
00244         getArray()->setContigPartOfSelectedValues(_start,da,da4);
00245         _end=_start+_nval*nbi;
00246         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
00247         break;
00248       }
00249     default:
00250       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
00251     }
00252   start=_end;
00253 }
00254 
00261 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00262 {
00263   if(pflName)
00264     _profile=pflName;
00265   else
00266     _profile.clear();
00267   _type=field->getTypeOfField();
00268   const DataArrayDouble *da=field->getArray();
00269   _start=start;
00270   switch(_type)
00271     {
00272     case ON_NODES:
00273       {
00274          _nval=idsInPfl->getNumberOfTuples();
00275          getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
00276          _end=_start+_nval;
00277          break;
00278       }
00279     case ON_CELLS:
00280       {
00281         _nval=idsInPfl->getNumberOfTuples();
00282         getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
00283         _end=_start+_nval;
00284         break;
00285       }
00286     case ON_GAUSS_NE:
00287       {
00288         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
00289         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
00290         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples());
00291         arr3->computeOffsets2();
00292         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
00293         int trueNval=tmp->getNumberOfTuples();
00294         _nval=idsInPfl->getNumberOfTuples();
00295         getArray()->setContigPartOfSelectedValues(_start,da,tmp);
00296         _end=_start+trueNval;
00297         break;
00298       }
00299     case ON_GAUSS_PT:
00300       {
00301         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for profiles on gauss points !");
00302       }
00303     default:
00304       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
00305     }
00306   start=_end;
00307 }
00308 
00309 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00310 {
00311   _start=start;
00312   _nval=field->getArray()->getNumberOfTuples();
00313   getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
00314   _end=_start+_nval;
00315   start=_end;
00316 }
00317 
00318 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
00319 {
00320   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
00321 }
00322 
00323 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
00324 {
00325   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
00326 }
00327 
00328 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
00329 try:_type(atype),_father(fath),_profile_it(profileIt)
00330   {
00331   }
00332 catch(INTERP_KERNEL::Exception& e)
00333 {
00334   throw e;
00335 }
00336 
00337 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
00338 {
00339 }
00340 
00341 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
00342 {
00343   return _father;
00344 }
00345 
00346 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
00347 {
00348   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00349   INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
00350   std::string fieldName=getName();
00351   std::string meshName=getMeshName();
00352   int iteration=getIteration();
00353   int order=getOrder();
00354   TypeOfField type=getType();
00355   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
00356   int profilesize,nbi;
00357   med_geometry_type mgeoti;
00358   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
00359   _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
00360                                   pflname,&profilesize,locname,&nbi);
00361   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
00362   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
00363   _start=start;
00364   _end=start+_nval*nbi;
00365   start=_end;
00366   if(type==ON_CELLS && !_localization.empty())
00367     {
00368       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
00369         setType(ON_GAUSS_PT);
00370       else
00371         {
00372           setType(ON_GAUSS_NE);
00373           _localization.clear();
00374         }
00375     }
00376 }
00377 
00378 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
00379 {
00380   std::string fieldName=getName();
00381   std::string meshName=getMeshName();
00382   int iteration=getIteration();
00383   int order=getOrder();
00384   TypeOfField type=getType();
00385   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
00386   med_geometry_type mgeoti;
00387   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
00388   DataArrayDouble *arr=getArray();
00389   double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
00390   switch(ft)
00391     {
00392     case 0:
00393       {
00394         MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
00395                                    _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
00396         break;
00397       }
00398     case 1:
00399       {
00400         INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
00401         MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
00402                                    _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
00403         std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
00404         break;
00405       }
00406     default:
00407       throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
00408     }
00409 }
00410 
00411 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
00412 {
00413   return _father->getIteration();
00414 }
00415 
00416 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
00417 {
00418   return _father->getOrder();
00419 }
00420 
00421 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
00422 {
00423   return _father->getTime();
00424 }
00425 
00426 std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
00427 {
00428   return _father->getName();
00429 }
00430 
00431 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
00432 {
00433   return _father->getMeshName();
00434 }
00435 
00436 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
00437 {
00438   const char startLine[]="    ## ";
00439   std::string startLine2(bkOffset,' ');
00440   startLine2+=startLine;
00441   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
00442   oss << startLine2 << "Localization #" << id << "." << std::endl;
00443   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
00444   delete tmp;
00445   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
00446   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
00447   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
00448 }
00449 
00450 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
00451 {
00452   return _type;
00453 }
00454 
00455 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
00456 {
00457   types.insert(_type);
00458 }
00459 
00460 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
00461 {
00462   _type=newType;
00463 }
00464 
00465 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
00466 {
00467   return _father->getGeoType();
00468 }
00469 
00470 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
00471 {
00472   return _father->getNumberOfComponents();
00473 }
00474 
00475 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
00476 {
00477   return _end-_start;
00478 }
00479 
00480 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
00481 {
00482   return _father->getArray();
00483 }
00484 
00485 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
00486 {
00487   const MEDFileFieldPerMeshPerType *fath=_father;
00488   return fath->getArray();
00489 }
00490 
00491 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
00492 {
00493   return _father->getInfo();
00494 }
00495 
00496 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
00497 {
00498   return _profile;
00499 }
00500 
00501 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
00502 {
00503   _profile=newPflName;
00504 }
00505 
00506 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
00507 {
00508   return _localization;
00509 }
00510 
00511 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
00512 {
00513   _localization=newLocName;
00514 }
00515 
00516 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
00517 {
00518   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
00519     {
00520       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
00521         {
00522           _profile=(*it2).second;
00523           return;
00524         }
00525     }
00526 }
00527 
00528 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
00529 {
00530   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
00531     {
00532       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
00533         {
00534           _localization=(*it2).second;
00535           return;
00536         }
00537     }
00538 }
00539 
00540 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
00541 {
00542   if(type!=_type)
00543     return ;
00544   dads.push_back(std::pair<int,int>(_start,_end));
00545   geoTypes.push_back(getGeoType());
00546   if(_profile.empty())
00547     pfls.push_back(0);
00548   else
00549     {
00550       pfls.push_back(glob->getProfile(_profile.c_str()));
00551     }
00552   if(_localization.empty())
00553     locs.push_back(-1);
00554   else
00555     {
00556       locs.push_back(glob->getLocalizationId(_localization.c_str()));
00557     }
00558 }
00559 
00560 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
00561 {
00562   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
00563   startEntryId++;
00564 }
00565 
00566 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
00567 {
00568   TypeOfField type=getType();
00569   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
00570   med_geometry_type mgeoti;
00571   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
00572   const DataArrayDouble *arr=getArray();
00573   const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
00574   MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
00575                              MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
00576                              reinterpret_cast<const unsigned char*>(locToWrite));
00577 }
00578 
00579 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
00580 {
00581   type=_type;
00582   pfl=_profile;
00583   loc=_localization;
00584   dad.first=_start; dad.second=_end;
00585 }
00586 
00587 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
00588 {
00589   switch(type)
00590     {
00591     case ON_CELLS:
00592       return -2;
00593     case ON_GAUSS_NE:
00594       return -1;
00595     case ON_GAUSS_PT:
00596       return locId;
00597     default:
00598       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
00599     }
00600 }
00601 
00602 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
00603 {
00604   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
00605 }
00606 
00607 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
00608 {
00609   return new MEDFileFieldPerMeshPerType(fath,geoType);
00610 }
00611 
00612 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00613 {
00614   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
00615   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
00616     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
00617 }
00618 
00619 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00620 {
00621   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
00622   if(locIds)
00623     {
00624       //
00625       std::string pflName(locIds->getName());
00626       if(pflName.empty())
00627         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignFieldProfile : existing profile with empty name !");
00628       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00629       std::ostringstream oss; oss << pflName << "_" <<  cm.getRepr();
00630       locIds->setName(oss.str().c_str());
00631       glob.appendProfile(locIds);
00632       //
00633       for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
00634         _field_pm_pt_pd[*it]->assignFieldProfile(start,oss.str().c_str(),multiTypePfl,idsInPfl,field,mesh,glob);
00635     }
00636   else
00637     {
00638       for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
00639         _field_pm_pt_pd[*it]->assignFieldProfile(start,0,multiTypePfl,idsInPfl,field,mesh,glob);
00640     }
00641 }
00642 
00643 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00644 {
00645   _field_pm_pt_pd.resize(1);
00646   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
00647   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
00648 }
00649 
00650 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
00651 {
00652   std::string pflName(pfl->getName());
00653   if(pflName.empty())
00654     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : existing profile with empty name !");
00655   std::ostringstream oss; oss << pflName << "_NODE";
00656   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
00657   pfl2->setName(oss.str().c_str());
00658   glob.appendProfile(pfl2);
00659   //
00660   _field_pm_pt_pd.resize(1);
00661   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
00662   _field_pm_pt_pd[0]->assignFieldProfile(start,oss.str().c_str(),pfl,pfl2,field,0,glob);//mesh is not requested so 0 is send.
00663 }
00664 
00665 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
00666 {
00667   TypeOfField type=field->getTypeOfField();
00668   if(type!=ON_GAUSS_PT)
00669     {
00670       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
00671       int sz=_field_pm_pt_pd.size();
00672       bool found=false;
00673       for(int j=0;j<sz && !found;j++)
00674         {
00675           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
00676             {
00677               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00678               found=true;
00679             }
00680         }
00681       if(!found)
00682         {
00683           _field_pm_pt_pd.resize(sz+1);
00684           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00685         }
00686       std::vector<int> ret(1,0);
00687       return ret;
00688     }
00689   else
00690     {
00691       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
00692       int sz2=ret2.size();
00693       std::vector<int> ret3(sz2);
00694       int k=0;
00695       for(int i=0;i<sz2;i++)
00696         {
00697           int sz=_field_pm_pt_pd.size();
00698           int locIdToFind=ret2[i];
00699           bool found=false;
00700           for(int j=0;j<sz && !found;j++)
00701             {
00702               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
00703                 {
00704                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00705                   ret3[k++]=j;
00706                   found=true;
00707                 }
00708             }
00709           if(!found)
00710             {
00711               _field_pm_pt_pd.resize(sz+1);
00712               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00713               ret3[k++]=sz;
00714             }
00715         }
00716       return ret3;
00717     }
00718 }
00719 
00720 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
00721 {
00722   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
00723   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
00724   if(!disc2)
00725     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
00726   const DataArrayInt *da=disc2->getArrayOfDiscIds();
00727   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
00728   std::set<int> retTmp=da2->getDifferentValues();
00729   if(retTmp.find(-1)!=retTmp.end())
00730     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
00731   std::vector<int> ret(retTmp.begin(),retTmp.end());
00732   return ret;
00733 }
00734 
00735 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
00736 {
00737   TypeOfField type=field->getTypeOfField();
00738   if(type!=ON_GAUSS_PT)
00739     {
00740       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
00741       int sz=_field_pm_pt_pd.size();
00742       bool found=false;
00743       for(int j=0;j<sz && !found;j++)
00744         {
00745           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
00746             {
00747               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00748               found=true;
00749             }
00750         }
00751       if(!found)
00752         {
00753           _field_pm_pt_pd.resize(sz+1);
00754           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00755         }
00756       std::vector<int> ret(1,0);
00757       return ret;
00758     }
00759   else
00760     {
00761       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
00762       int sz2=ret2.size();
00763       std::vector<int> ret3(sz2);
00764       int k=0;
00765       for(int i=0;i<sz2;i++)
00766         {
00767           int sz=_field_pm_pt_pd.size();
00768           int locIdToFind=ret2[i];
00769           bool found=false;
00770           for(int j=0;j<sz && !found;j++)
00771             {
00772               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
00773                 {
00774                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00775                   ret3[k++]=j;
00776                   found=true;
00777                 }
00778             }
00779           if(!found)
00780             {
00781               _field_pm_pt_pd.resize(sz+1);
00782               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
00783               ret3[k++]=sz;
00784             }
00785         }
00786       return ret3;
00787     }
00788 }
00789 
00790 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
00791 {
00792   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
00793   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
00794   if(!disc2)
00795     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
00796   const DataArrayInt *da=disc2->getArrayOfDiscIds();
00797   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
00798   std::set<int> retTmp=da2->getDifferentValues();
00799   if(retTmp.find(-1)!=retTmp.end())
00800     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
00801   std::vector<int> ret(retTmp.begin(),retTmp.end());
00802   return ret;
00803 }
00804 
00805 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
00806 {
00807   return _father;
00808 }
00809 
00810 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
00811 {
00812   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00813   int curDim=(int)cm.getDimension();
00814   dim=std::max(dim,curDim);
00815 }
00816 
00817 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
00818 {
00819   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
00820     {
00821       (*it)->fillTypesOfFieldAvailable(types);
00822     }
00823 }
00824 
00825 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
00826 {
00827   int sz=_field_pm_pt_pd.size();
00828   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
00829   for(int i=0;i<sz;i++)
00830     {
00831       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
00832     }
00833 }
00834 
00835 int MEDFileFieldPerMeshPerType::getIteration() const
00836 {
00837   return _father->getIteration();
00838 }
00839 
00840 int MEDFileFieldPerMeshPerType::getOrder() const
00841 {
00842   return _father->getOrder();
00843 }
00844 
00845 double MEDFileFieldPerMeshPerType::getTime() const
00846 {
00847   return _father->getTime();
00848 }
00849 
00850 std::string MEDFileFieldPerMeshPerType::getName() const
00851 {
00852   return _father->getName();
00853 }
00854 
00855 std::string MEDFileFieldPerMeshPerType::getMeshName() const
00856 {
00857   return _father->getMeshName();
00858 }
00859 
00860 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
00861 {
00862   const char startLine[]="  ## ";
00863   std::string startLine2(bkOffset,' ');
00864   std::string startLine3(startLine2);
00865   startLine3+=startLine;
00866   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
00867     {
00868       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00869       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
00870     }
00871   else
00872     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
00873   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
00874   int i=0;
00875   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
00876     {
00877       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
00878       if(cur)
00879         cur->simpleRepr(bkOffset,oss,i);
00880       else
00881         {
00882           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
00883         }
00884     }
00885 }
00886 
00887 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
00888 {
00889   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
00890     {
00891       globalSz+=(*it)->getNumberOfTuples();
00892     }
00893   nbOfEntries+=(int)_field_pm_pt_pd.size();
00894 }
00895 
00896 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
00897 {
00898   return _geo_type;
00899 }
00900 
00901 
00902 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
00903 {
00904   return _father->getNumberOfComponents();
00905 }
00906 
00907 DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
00908 {
00909   return _father->getArray();
00910 }
00911 
00912 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
00913 {
00914   const MEDFileFieldPerMesh *fath=_father;
00915   return fath->getArray();
00916 }
00917 
00918 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
00919 {
00920   return _father->getInfo();
00921 }
00922 
00923 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
00924 {
00925   std::vector<std::string> ret;
00926   std::set<std::string> ret2;
00927   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00928     {
00929       std::string tmp=(*it1)->getProfile();
00930       if(!tmp.empty())
00931         if(ret2.find(tmp)==ret2.end())
00932           {
00933             ret.push_back(tmp);
00934             ret2.insert(tmp);
00935           }
00936     }
00937   return ret;
00938 }
00939 
00940 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
00941 {
00942   std::vector<std::string> ret;
00943   std::set<std::string> ret2;
00944   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00945     {
00946       std::string tmp=(*it1)->getLocalization();
00947       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
00948         if(ret2.find(tmp)==ret2.end())
00949           {
00950             ret.push_back(tmp);
00951             ret2.insert(tmp);
00952           }
00953     }
00954   return ret;
00955 }
00956 
00957 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
00958 {
00959   std::vector<std::string> ret;
00960   std::set<std::string> ret2;
00961   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00962     {
00963       std::string tmp=(*it1)->getProfile();
00964       if(!tmp.empty())
00965         ret.push_back(tmp);
00966     }
00967   return ret;
00968 }
00969 
00970 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
00971 {
00972   std::vector<std::string> ret;
00973   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00974     {
00975       std::string tmp=(*it1)->getLocalization();
00976       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
00977         ret.push_back(tmp);
00978     }
00979   return ret;
00980 }
00981 
00982 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
00983 {
00984   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00985     (*it1)->changePflsRefsNamesGen(mapOfModif);
00986 }
00987 
00988 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
00989 {
00990   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
00991     (*it1)->changeLocsRefsNamesGen(mapOfModif);
00992 }
00993 
00994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
00995 {
00996   if(_field_pm_pt_pd.empty())
00997     {
00998       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
00999       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
01000       throw INTERP_KERNEL::Exception(oss.str().c_str());
01001     }
01002   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
01003     return _field_pm_pt_pd[locId];
01004   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
01005   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
01006   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
01007   throw INTERP_KERNEL::Exception(oss2.str().c_str());
01008   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
01009 }
01010 
01011 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
01012 {
01013   if(_field_pm_pt_pd.empty())
01014     {
01015       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
01016       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
01017       throw INTERP_KERNEL::Exception(oss.str().c_str());
01018     }
01019   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
01020     return _field_pm_pt_pd[locId];
01021   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
01022   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
01023   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
01024   throw INTERP_KERNEL::Exception(oss2.str().c_str());
01025   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
01026 }
01027 
01028 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
01029 {
01030   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
01031     {
01032       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
01033       if(meshDim!=(int)cm.getDimension())
01034         return ;
01035     }
01036   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
01037     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
01038 }
01039 
01040 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
01041 {
01042   int i=0;
01043   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
01044     {
01045       (*it)->fillValues(i,startEntryId,entries);
01046     }
01047 }
01048 
01049 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
01050 {
01051 }
01052 
01053 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
01054 {
01055   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01056   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01057   med_geometry_type mgeoti;
01058   med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
01059   int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
01060   _field_pm_pt_pd.resize(nbProfiles);
01061   for(int i=0;i<nbProfiles;i++)
01062     {
01063       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
01064     }
01065 }
01066 
01067 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
01068 {
01069   int pflId=0;
01070   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
01071     {
01072       (*it)->prepareLoading(fid,pflId+1,start);
01073     }
01074 }
01075 
01076 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
01077 {
01078   int pflId=0;
01079   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
01080     {
01081       (*it)->finishLoading(fid,pflId+1,ft);
01082     }
01083 }
01084 
01085 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
01086 {
01087   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
01088     {
01089       (*it)->copyOptionsFrom(*this);
01090       (*it)->writeLL(fid);
01091     }
01092 }
01093 
01094 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
01095 {
01096   switch(ikType)
01097     {
01098     case ON_CELLS:
01099       medfGeoType=typmai3[(int)ikGeoType];
01100       return MED_CELL;
01101     case ON_NODES:
01102       medfGeoType=MED_NONE;
01103       return MED_NODE;
01104     case ON_GAUSS_NE:
01105       medfGeoType=typmai3[(int)ikGeoType];
01106       return MED_NODE_ELEMENT;
01107     case ON_GAUSS_PT:
01108       medfGeoType=typmai3[(int)ikGeoType];
01109       return MED_CELL;
01110     default:
01111       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
01112     }
01113   return MED_UNDEF_ENTITY_TYPE;
01114 }
01115 
01116 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
01117 {
01118   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
01119 }
01120 
01121 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh)
01122 {
01123   return new MEDFileFieldPerMesh(fath,mesh);
01124 }
01125 
01126 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
01127 {
01128   std::string startLine(bkOffset,' ');
01129   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
01130   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
01131   int i=0;
01132   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
01133     {
01134       const MEDFileFieldPerMeshPerType *cur=*it;
01135       if(cur)
01136         cur->simpleRepr(bkOffset,oss,i);
01137       else
01138         {
01139           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
01140         }
01141     }
01142 }
01143 
01144 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
01145 {
01146   _mesh_name=mesh->getName();
01147   mesh->getTime(_mesh_iteration,_mesh_order);
01148 }
01149 
01150 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
01151 {
01152   int nbOfTypes=code.size()/3;
01153   bool isProfile=false;
01154   for(int i=0;i<nbOfTypes;i++)
01155     if(code[3*i+2]!=-1)
01156       isProfile=true;
01157   if(!isProfile)
01158     {
01159       if(idsInPflPerType.empty())
01160         assignFieldNoProfileNoRenum(start,code,field,glob);
01161       else
01162         assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
01163     }
01164   else
01165     assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
01166 }
01167 
01168 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
01169 {
01170   int nbOfTypes=code.size()/3;
01171   int offset=0;
01172   for(int i=0;i<nbOfTypes;i++)
01173     {
01174       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
01175       int nbOfCells=code[3*i+1];
01176       int pos=addNewEntryIfNecessary(type);
01177       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
01178       offset+=nbOfCells;
01179     }
01180 }
01181 
01185 void MEDFileFieldPerMesh::assignFieldProfileGeneral(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
01186 {
01187   int nbOfTypes=code.size()/3;
01188   for(int i=0;i<nbOfTypes;i++)
01189     {
01190       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
01191       int pos=addNewEntryIfNecessary(type);
01192       DataArrayInt *pfl=0;
01193       if(code[3*i+2]!=-1)
01194         pfl=idsPerType[code[3*i+2]];
01195       _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,field,mesh,glob);
01196     }
01197 }
01198 
01199 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
01200 {
01201   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
01202   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
01203 }
01204 
01205 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
01206 {
01207   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
01208   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
01209 }
01210 
01211 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
01212 {
01213   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01214     (*it)->prepareLoading(fid,start);
01215 }
01216 
01217 void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
01218 {
01219   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01220     (*it)->finishLoading(fid,ft);
01221 }
01222 
01223 void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
01224 {
01225   int nbOfTypes=_field_pm_pt.size();
01226   for(int i=0;i<nbOfTypes;i++)
01227     {
01228       _field_pm_pt[i]->copyOptionsFrom(*this);
01229       _field_pm_pt[i]->writeLL(fid);
01230     }
01231 }
01232 
01233 void MEDFileFieldPerMesh::getDimension(int& dim) const
01234 {
01235   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01236     (*it)->getDimension(dim);
01237 }
01238 
01239 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
01240 {
01241   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01242     (*it)->fillTypesOfFieldAvailable(types);
01243 }
01244 
01245 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const throw(INTERP_KERNEL::Exception)
01246 {
01247   int sz=_field_pm_pt.size();
01248   std::vector< std::vector<std::pair<int,int> > > ret(sz);
01249   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
01250   for(int i=0;i<sz;i++)
01251     {
01252       types[i]=_field_pm_pt[i]->getGeoType();
01253       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
01254     }
01255   return ret;
01256 }
01257 
01258 double MEDFileFieldPerMesh::getTime() const
01259 {
01260   int tmp1,tmp2;
01261   return _father->getTime(tmp1,tmp2);
01262 }
01263 
01264 int MEDFileFieldPerMesh::getIteration() const
01265 {
01266   return _father->getIteration();
01267 }
01268 
01269 const std::string& MEDFileFieldPerMesh::getDtUnit() const
01270 {
01271   return _father->getDtUnit();
01272 }
01273 
01274 int MEDFileFieldPerMesh::getOrder() const
01275 {
01276   return _father->getOrder();
01277 }
01278 
01279 std::string MEDFileFieldPerMesh::getName() const
01280 {
01281   return _father->getName();
01282 }
01283 
01284 int MEDFileFieldPerMesh::getNumberOfComponents() const
01285 {
01286   return _father->getNumberOfComponents();
01287 }
01288 
01289 DataArrayDouble *MEDFileFieldPerMesh::getArray()
01290 {
01291   return _father->getOrCreateAndGetArray();
01292 }
01293 
01294 const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
01295 {
01296   const MEDFileField1TSWithoutDAS *fath=_father;
01297   return fath->getOrCreateAndGetArray();
01298 }
01299 
01300 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
01301 {
01302   return _father->getInfo();
01303 }
01304 
01313 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
01314 {
01315   int notNullPflsSz=0;
01316   int nbOfArrs=geoTypes.size();
01317   for(int i=0;i<nbOfArrs;i++)
01318     if(pfls[i])
01319       notNullPflsSz++;
01320   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
01321   int nbOfDiffGeoTypes=geoTypes3.size();
01322   code.resize(3*nbOfDiffGeoTypes);
01323   notNullPfls.resize(notNullPflsSz);
01324   notNullPflsSz=0;
01325   int j=0;
01326   for(int i=0;i<nbOfDiffGeoTypes;i++)
01327     {
01328       int startZone=j;
01329       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
01330       std::vector<const DataArrayInt *> notNullTmp;
01331       if(pfls[j])
01332         notNullTmp.push_back(pfls[j]);
01333       j++;
01334       for(;j<nbOfArrs;j++)
01335         if(geoTypes[j]==refType)
01336           {
01337             if(pfls[j])
01338               notNullTmp.push_back(pfls[j]);
01339           }
01340         else
01341           break;
01342       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
01343       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
01344       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
01345       code[3*i]=(int)refType;
01346       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
01347       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
01348       if(notNullTmp.empty())
01349         code[3*i+2]=-1;
01350       else
01351         {
01352           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
01353           code[3*i+2]=notNullPflsSz++;
01354         }
01355     }
01356 }
01357 
01361 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
01362 {
01363   int sz=dads.size();
01364   int ret=0;
01365   for(int i=0;i<sz;i++)
01366     {
01367       if(locs[i]==-1)
01368         {
01369           if(type!=ON_GAUSS_NE)
01370             ret+=dads[i].second-dads[i].first;
01371           else
01372             {
01373               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
01374               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
01375             }
01376         }
01377       else
01378         {
01379           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
01380           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
01381         }
01382     }
01383   return ret;
01384 }
01385 
01386 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
01387 {
01388   std::vector<std::string> ret;
01389   std::set<std::string> ret2;
01390   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01391     {
01392       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
01393       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
01394         if(ret2.find(*it2)==ret2.end())
01395           {
01396             ret.push_back(*it2);
01397             ret2.insert(*it2);
01398           }
01399     }
01400   return ret;
01401 }
01402 
01403 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
01404 {
01405   std::vector<std::string> ret;
01406   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01407     {
01408       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
01409       ret.insert(ret.end(),tmp.begin(),tmp.end());
01410     }
01411   return ret;
01412 }
01413 
01414 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
01415 {
01416   std::vector<std::string> ret;
01417   std::set<std::string> ret2;
01418   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01419     {
01420       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
01421       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
01422         if(ret2.find(*it2)==ret2.end())
01423           {
01424             ret.push_back(*it2);
01425             ret2.insert(*it2);
01426           }
01427     }
01428   return ret;
01429 }
01430 
01431 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
01432 {
01433   std::vector<std::string> ret;
01434   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01435     {
01436       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
01437       ret.insert(ret.end(),tmp.begin(),tmp.end());
01438     }
01439   return ret;
01440 }
01441 
01442 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
01443 {
01444   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01445     (*it)->changePflsRefsNamesGen(mapOfModif);
01446 }
01447 
01448 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
01449 {
01450   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01451     (*it)->changeLocsRefsNamesGen(mapOfModif);
01452 }
01453 
01454 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
01455 {
01456   if(_field_pm_pt.empty())
01457     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
01458   //
01459   std::vector< std::pair<int,int> > dads;
01460   std::vector<const DataArrayInt *> pfls;
01461   std::vector<DataArrayInt *> notNullPflsPerGeoType;
01462   std::vector<int> locs,code;
01463   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
01464   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01465     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
01466   // Sort by types
01467   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
01468   if(code.empty())
01469     {
01470       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
01471       throw INTERP_KERNEL::Exception(oss.str().c_str());
01472     }
01473   //
01474   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
01475   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
01476   if(type!=ON_NODES)
01477     {
01478       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
01479       if(!arr)
01480         return finishField(type,glob,dads,locs,mesh,isPfl);
01481       else
01482         {
01483           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
01484           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
01485         }
01486     }
01487   else
01488     {
01489       if(code.size()!=3)
01490         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
01491       int nb=code[1];
01492       if(code[2]==-1)
01493         {
01494           if(nb!=mesh->getNumberOfNodes())
01495             {
01496               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
01497               oss << " nodes in mesh !";
01498               throw INTERP_KERNEL::Exception(oss.str().c_str());
01499             }
01500           return finishField(type,glob,dads,locs,mesh,isPfl);
01501         }
01502       else
01503         return finishField3(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
01504     }
01505 }
01506 
01507 DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
01508 {
01509   if(_field_pm_pt.empty())
01510     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
01511   //
01512   std::vector<std::pair<int,int> > dads;
01513   std::vector<const DataArrayInt *> pfls;
01514   std::vector<DataArrayInt *> notNullPflsPerGeoType;
01515   std::vector<int> locs,code;
01516   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
01517   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01518     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
01519   // Sort by types
01520   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
01521   if(code.empty())
01522     {
01523       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
01524       throw INTERP_KERNEL::Exception(oss.str().c_str());
01525     }
01526   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
01527   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
01528   if(type!=ON_NODES)
01529     {
01530       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
01531       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
01532     }
01533   else
01534     {
01535       if(code.size()!=3)
01536         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
01537       int nb=code[1];
01538       if(code[2]==-1)
01539         {
01540           if(nb!=mesh->getNumberOfNodes())
01541             {
01542               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
01543               oss << " nodes in mesh !";
01544               throw INTERP_KERNEL::Exception(oss.str().c_str());
01545             }
01546         }
01547       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
01548     }
01549   //
01550   return 0;
01551 }
01552 
01553 DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
01554 {
01555   int globalSz=0;
01556   int nbOfEntries=0;
01557   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01558     {
01559       (*it)->getSizes(globalSz,nbOfEntries);
01560     }
01561   entries.resize(nbOfEntries);
01562   nbOfEntries=0;
01563   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01564     {
01565       (*it)->fillValues(nbOfEntries,entries);
01566     }
01567   return _father->getUndergroundDataArray();
01568 }
01569 
01570 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
01571 {
01572   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01573     {
01574       if((*it)->getGeoType()==typ)
01575         return (*it)->getLeafGivenLocId(locId);
01576     }
01577   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
01578   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
01579   oss << "Possiblities are : ";
01580   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01581     {
01582       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
01583       oss << "\"" << cm2.getRepr() << "\", ";
01584     }
01585   throw INTERP_KERNEL::Exception(oss.str().c_str());
01586 }
01587 
01588 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
01589 {
01590   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01591     {
01592       if((*it)->getGeoType()==typ)
01593         return (*it)->getLeafGivenLocId(locId);
01594     }
01595   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
01596   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
01597   oss << "Possiblities are : ";
01598   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
01599     {
01600       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
01601       oss << "\"" << cm2.getRepr() << "\", ";
01602     }
01603   throw INTERP_KERNEL::Exception(oss.str().c_str());
01604 }
01605 
01606 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
01607 {
01608   int i=0;
01609   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
01610   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
01611   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
01612     {
01613       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
01614       if(type==curType)
01615         return i;
01616       else
01617         {
01618           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
01619           if(pos>pos2)
01620             it2=it+1;
01621         }
01622     }
01623   int ret=std::distance(_field_pm_pt.begin(),it2);
01624   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
01625   return ret;
01626 }
01627 
01631 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
01632                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
01633                                                          const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
01634 {
01635   isPfl=false;
01636   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
01637   ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
01638   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
01639   const std::vector<std::string>& infos=getInfo();
01640   da->setInfoOnComponents(infos);
01641   da->setName("");
01642   ret->setArray(da);
01643   if(type==ON_GAUSS_PT)
01644     {
01645       int offset=0;
01646       int nbOfArrs=dads.size();
01647       for(int i=0;i<nbOfArrs;i++)
01648         {
01649           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
01650           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
01651           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
01652           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
01653           di->alloc(nbOfElems,1);
01654           di->iota(offset);
01655           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
01656           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
01657           offset+=nbOfElems;
01658         }
01659     }
01660   //
01661   ret->incrRef();
01662   return ret;
01663 }
01664 
01671 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
01672                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
01673                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
01674                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
01675 {
01676   if(da->isIdentity())
01677     {
01678       int nbOfTuples=da->getNumberOfTuples();
01679       if(nbOfTuples==ComputeNbOfElems(glob,type,geoTypes,dads,locs))
01680         return finishField(type,glob,dads,locs,mesh,isPfl);
01681     }
01682   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,mesh,isPfl);
01683   isPfl=true;
01684   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
01685   m2->setName(mesh->getName());
01686   ret->setMesh(m2);
01687   ret->incrRef();
01688   return ret;
01689 }
01690 
01694 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFieldFieldGlobsReal *glob,
01695                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
01696                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
01697 {
01698   if(da->isIdentity())
01699     {
01700       int nbOfTuples=da->getNumberOfTuples();
01701       const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
01702       if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,geoTypes2,dads,locs))//No problem for NORM_ERROR because it is in context of node
01703         return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
01704     }
01705   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
01706   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
01707   if(meshu)
01708     {
01709       if(meshu->getNodalConnectivity()==0)
01710         {
01711           MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
01712           int nb=da->getNbOfElems();
01713           const int *ptr=da->getConstPointer();
01714           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
01715           meshuc->allocateCells(nb);
01716           for(int i=0;i<nb;i++)
01717             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
01718           meshuc->finishInsertingCells();
01719           ret->setMesh(meshuc);
01720           ret->checkCoherency();
01721           ret->incrRef();
01722           return ret;
01723         }
01724     }
01725   //
01726   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
01727   isPfl=true;
01728   DataArrayInt *arr2=0;
01729   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
01730   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
01731   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
01732   int nnodes=mesh2->getNumberOfNodes();
01733   if(nnodes==da->getNbOfElems())
01734     {
01735       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->getConstPointer(),arr2->getConstPointer()+arr2->getNbOfElems());
01736       ret->getArray()->renumberInPlace(da3->getConstPointer());
01737       mesh2->setName(mesh->getName());
01738       ret->setMesh(mesh2);
01739       ret->incrRef();
01740       return ret;
01741     }
01742   else
01743     {
01744       std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishField3 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
01745       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
01746       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
01747       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
01748       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
01749       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
01750       throw INTERP_KERNEL::Exception(oss.str().c_str());
01751     }
01752   return 0;
01753 }
01754 
01758 DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
01759 {
01760   if(!pflIn)
01761     {
01762       pflOut=DataArrayInt::New();
01763       pflOut->alloc(nbOfElems,1);
01764       pflOut->iota(0);
01765     }
01766   else
01767     {
01768       pflOut=const_cast<DataArrayInt*>(pflIn);
01769       pflOut->incrRef();
01770     }
01771   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
01772   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
01773   const std::vector<std::string>& infos=getInfo();
01774   int nbOfComp=infos.size();
01775   for(int i=0;i<nbOfComp;i++)
01776     da->setInfoOnComponent(i,infos[i].c_str());
01777   safePfl->incrRef();
01778   da->incrRef();
01779   return da;
01780 }
01781 
01782 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
01783                                                                                                                                                                        _mesh_csit(meshCsit),_father(fath)
01784 {
01785   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01786   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01787   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01788   for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
01789     {
01790       int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
01791       if(nbProfile>0)
01792         {
01793           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
01794           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
01795         }
01796       nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
01797       if(nbProfile>0)
01798         {
01799           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
01800           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
01801         }
01802     }
01803   int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
01804   if(nbProfile>0)
01805     {
01806       _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
01807       _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
01808     }
01809 }
01810 
01811 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh):_father(fath)
01812 {
01813   copyTinyInfoFrom(mesh);
01814 }
01815 
01816 void MEDFieldFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
01817 {
01818   if(id>=(int)_pfls.size())
01819     _pfls.resize(id+1);
01820   _pfls[id]=DataArrayInt::New();
01821   int lgth=MEDprofileSizeByName(fid,pflName);
01822   _pfls[id]->setName(pflName);
01823   _pfls[id]->alloc(lgth,1);
01824   MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
01825   _pfls[id]->applyLin(1,-1,0);//Converting into C format
01826 }
01827 
01828 void MEDFieldFieldGlobs::loadProfileInFile(med_idt fid, int i)
01829 {
01830   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01831   int sz;
01832   MEDprofileInfo(fid,i+1,pflName,&sz);
01833   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
01834   if(i>=(int)_pfls.size())
01835     _pfls.resize(i+1);
01836   _pfls[i]=DataArrayInt::New();
01837   _pfls[i]->alloc(sz,1);
01838   _pfls[i]->setName(pflCpp.c_str());
01839   MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
01840   _pfls[i]->applyLin(1,-1,0);//Converting into C format
01841 }
01842 
01843 void MEDFieldFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
01844 {
01845   int nbOfPfls=_pfls.size();
01846   for(int i=0;i<nbOfPfls;i++)
01847     {
01848       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
01849       cpy->applyLin(1,1,0);
01850       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
01851       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
01852       MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
01853     }
01854   //
01855   int nbOfLocs=_locs.size();
01856   for(int i=0;i<nbOfLocs;i++)
01857     _locs[i]->writeLL(fid);
01858 }
01859 
01860 void MEDFieldFieldGlobs::appendGlobs(const MEDFieldFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
01861 {
01862   std::vector<std::string> pfls=getPfls();
01863   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
01864     {
01865       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
01866       if(it2==pfls.end())
01867         {
01868           _pfls.push_back(*it);
01869         }
01870       else
01871         {
01872           int id=std::distance(pfls.begin(),it2);
01873           if(!(*it)->isEqual(*_pfls[id]))
01874             {
01875               std::ostringstream oss; oss << "MEDFieldFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
01876               throw INTERP_KERNEL::Exception(oss.str().c_str());
01877             }
01878         }
01879     }
01880   std::vector<std::string> locs=getLocs();
01881   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
01882     {
01883       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
01884       if(it2==locs.end())
01885         {
01886           _locs.push_back(*it);
01887         }
01888       else
01889         {
01890           int id=std::distance(locs.begin(),it2);
01891           if(!(*it)->isEqual(*_locs[id],eps))
01892             {
01893               std::ostringstream oss; oss << "MEDFieldFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
01894               throw INTERP_KERNEL::Exception(oss.str().c_str());
01895             }
01896         }
01897     }
01898 }
01899 
01900 void MEDFieldFieldGlobs::loadGlobals(med_idt fid, const MEDFieldFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
01901 {
01902   std::vector<std::string> profiles=real.getPflsReallyUsed();
01903   int sz=profiles.size();
01904   _pfls.resize(sz);
01905   for(int i=0;i<sz;i++)
01906     loadProfileInFile(fid,i,profiles[i].c_str());
01907   //
01908   std::vector<std::string> locs=real.getLocsReallyUsed();
01909   sz=locs.size();
01910   _locs.resize(sz);
01911   for(int i=0;i<sz;i++)
01912     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
01913 }
01914 
01915 void MEDFieldFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
01916 {
01917   int nProfil=MEDnProfile(fid);
01918   for(int i=0;i<nProfil;i++)
01919     loadProfileInFile(fid,i);
01920   int sz=MEDnLocalization(fid);
01921   _locs.resize(sz);
01922   for(int i=0;i<sz;i++)
01923     {
01924       _locs[i]=MEDFileFieldLoc::New(fid,i);
01925     }
01926 }
01927 
01928 MEDFieldFieldGlobs *MEDFieldFieldGlobs::New(const char *fname)
01929 {
01930   return new MEDFieldFieldGlobs(fname);
01931 }
01932 
01933 MEDFieldFieldGlobs *MEDFieldFieldGlobs::New()
01934 {
01935   return new MEDFieldFieldGlobs;
01936 }
01937 
01938 MEDFieldFieldGlobs::MEDFieldFieldGlobs(const char *fname):_file_name(fname)
01939 {
01940 }
01941 
01942 MEDFieldFieldGlobs::MEDFieldFieldGlobs()
01943 {
01944 }
01945 
01946 MEDFieldFieldGlobs::~MEDFieldFieldGlobs()
01947 {
01948 }
01949 
01950 void MEDFieldFieldGlobs::simpleRepr(std::ostream& oss) const
01951 {
01952   oss << "Profiles :\n";
01953   std::size_t n=_pfls.size();
01954   for(std::size_t i=0;i<n;i++)
01955     {
01956       oss << "  - #" << i << " ";
01957       const DataArrayInt *pfl=_pfls[i];
01958       if(pfl)
01959         oss << "\"" << pfl->getName() << "\"\n";
01960       else
01961         oss << "EMPTY !\n";
01962     }
01963   n=_locs.size();
01964   oss << "Localizations :\n";
01965   for(std::size_t i=0;i<n;i++)
01966     {
01967       oss << "  - #" << i << " ";
01968       const MEDFileFieldLoc *loc=_locs[i];
01969       if(loc)
01970         loc->simpleRepr(oss);
01971       else
01972         oss<< "EMPTY !\n";
01973     }
01974 }
01975 
01976 void MEDFieldFieldGlobs::setFileName(const char *fileName)
01977 {
01978   _file_name=fileName;
01979 }
01980 
01981 void MEDFieldFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
01982 {
01983   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
01984     {
01985       DataArrayInt *elt(*it);
01986       if(elt)
01987         {
01988           std::string name(elt->getName());
01989           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
01990             {
01991               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
01992                 {
01993                   elt->setName((*it2).second.c_str());
01994                   return;
01995                 }
01996             }
01997         }
01998     }
01999 }
02000 
02001 void MEDFieldFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02002 {
02003   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
02004     {
02005       MEDFileFieldLoc *elt(*it);
02006       if(elt)
02007         {
02008           std::string name(elt->getName());
02009           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
02010             {
02011               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
02012                 {
02013                   elt->setName((*it2).second.c_str());
02014                   return;
02015                 }
02016             }
02017         }
02018     }
02019 }
02020 
02021 int MEDFieldFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
02022 {
02023   if(locId<0 || locId>=(int)_locs.size())
02024     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
02025   return _locs[locId]->getNbOfGaussPtPerCell();
02026 }
02027 
02028 const MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
02029 {
02030   return getLocalizationFromId(getLocalizationId(locName));
02031 }
02032 
02033 const MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
02034 {
02035   if(locId<0 || locId>=(int)_locs.size())
02036     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getLocalizationFromId : Invalid localization id !");
02037   return *_locs[locId];
02038 }
02039 
02040 namespace ParaMEDMEMImpl
02041 {
02042   class LocFinder
02043   {
02044   public:
02045     LocFinder(const char *loc):_loc(loc) { }
02046     bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
02047   private:
02048     const char *_loc;
02049   };
02050 
02051   class PflFinder
02052   {
02053   public:
02054     PflFinder(const std::string& pfl):_pfl(pfl) { }
02055     bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
02056   private:
02057     const std::string& _pfl;
02058   };
02059 }
02060 
02061 int MEDFieldFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
02062 {
02063   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
02064   if(it==_locs.end())
02065     {
02066       std::ostringstream oss; oss << "MEDFieldFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
02067       for(it=_locs.begin();it!=_locs.end();it++)
02068         oss << "\"" << (*it)->getName() << "\", ";
02069       throw INTERP_KERNEL::Exception(oss.str().c_str());
02070     }
02071   return std::distance(_locs.begin(),it);
02072 }
02073 
02074 const DataArrayInt *MEDFieldFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
02075 {
02076   std::string pflNameCpp(pflName);
02077   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
02078   if(it==_pfls.end())
02079     {
02080       std::ostringstream oss; oss << "MEDFieldFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
02081       for(it=_pfls.begin();it!=_pfls.end();it++)
02082         oss << "\"" << (*it)->getName() << "\", ";
02083       throw INTERP_KERNEL::Exception(oss.str().c_str());
02084     }
02085   return *it;
02086 }
02087 
02088 const DataArrayInt *MEDFieldFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
02089 {
02090   if(pflId<0 || pflId>=(int)_pfls.size())
02091     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getProfileFromId : Invalid profile id !");
02092   return _pfls[pflId];
02093 }
02094 
02095 MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
02096 {
02097   if(locId<0 || locId>=(int)_locs.size())
02098     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getLocalizationFromId : Invalid localization id !");
02099   return *_locs[locId];
02100 }
02101 
02102 MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
02103 {
02104   return getLocalizationFromId(getLocalizationId(locName));
02105 }
02106 
02107 DataArrayInt *MEDFieldFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
02108 {
02109   std::string pflNameCpp(pflName);
02110   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
02111   if(it==_pfls.end())
02112     {
02113       std::ostringstream oss; oss << "MEDFieldFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
02114       for(it=_pfls.begin();it!=_pfls.end();it++)
02115         oss << "\"" << (*it)->getName() << "\", ";
02116       throw INTERP_KERNEL::Exception(oss.str().c_str());
02117     }
02118   return *it;
02119 }
02120 
02121 DataArrayInt *MEDFieldFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
02122 {
02123   if(pflId<0 || pflId>=(int)_pfls.size())
02124     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getProfileFromId : Invalid profile id !");
02125   return _pfls[pflId];
02126 }
02127 
02128 void MEDFieldFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
02129 {
02130   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
02131   int i=0;
02132   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
02133     {
02134       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
02135         newPfls.push_back(*it);
02136     }
02137   _pfls=newPfls;
02138 }
02139 
02140 void MEDFieldFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
02141 {
02142   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
02143   int i=0;
02144   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
02145     {
02146       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
02147         newLocs.push_back(*it);
02148     }
02149   _locs=newLocs;
02150 }
02151 
02152 std::vector<std::string> MEDFieldFieldGlobs::getPfls() const
02153 {
02154   int sz=_pfls.size();
02155   std::vector<std::string> ret(sz);
02156   for(int i=0;i<sz;i++)
02157     ret[i]=_pfls[i]->getName();
02158   return ret;
02159 }
02160 
02161 std::vector<std::string> MEDFieldFieldGlobs::getLocs() const
02162 {
02163   int sz=_locs.size();
02164   std::vector<std::string> ret(sz);
02165   for(int i=0;i<sz;i++)
02166     ret[i]=_locs[i]->getName();
02167   return ret;
02168 }
02169 
02170 bool MEDFieldFieldGlobs::existsPfl(const char *pflName) const
02171 {
02172   std::vector<std::string> v=getPfls();
02173   std::string s(pflName);
02174   return std::find(v.begin(),v.end(),s)!=v.end();
02175 }
02176 
02177 bool MEDFieldFieldGlobs::existsLoc(const char *locName) const
02178 {
02179   std::vector<std::string> v=getLocs();
02180   std::string s(locName);
02181   return std::find(v.begin(),v.end(),s)!=v.end();
02182 }
02183 
02184 std::vector< std::vector<int> > MEDFieldFieldGlobs::whichAreEqualProfiles() const
02185 {
02186   std::map<int,std::vector<int> > m;
02187   int i=0;
02188   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
02189     {
02190       const DataArrayInt *tmp=(*it);
02191       if(tmp)
02192         {
02193           m[tmp->getHashCode()].push_back(i);
02194         }
02195     }
02196   std::vector< std::vector<int> > ret;
02197   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
02198     {
02199       if((*it2).second.size()>1)
02200         {
02201           std::vector<int> ret0;
02202           bool equalityOrNot=false;
02203           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
02204             {
02205               std::vector<int>::const_iterator it4=it3; it4++;
02206               for(;it4!=(*it2).second.end();it4++)
02207                 {
02208                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
02209                     {
02210                       if(!equalityOrNot)
02211                         ret0.push_back(*it3);
02212                       ret0.push_back(*it4);
02213                       equalityOrNot=true;
02214                     }
02215                 }
02216             }
02217           if(!ret0.empty())
02218             ret.push_back(ret0);
02219         }
02220     }
02221   return ret;
02222 }
02223 
02224 std::vector< std::vector<int> > MEDFieldFieldGlobs::whichAreEqualLocs(double eps) const
02225 {
02226   throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
02227 }
02228 
02229 void MEDFieldFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
02230 {
02231   std::string name(pfl->getName());
02232   if(name.empty())
02233     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::appendProfile : unsupported profiles with no name !");
02234   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
02235     if(name==(*it)->getName())
02236       {
02237         if(!pfl->isEqual(*(*it)))
02238           {
02239             std::ostringstream oss; oss << "MEDFieldFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
02240             throw INTERP_KERNEL::Exception(oss.str().c_str());
02241           }
02242       }
02243   pfl->incrRef();
02244   _pfls.push_back(pfl);
02245 }
02246 
02247 void MEDFieldFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
02248 {
02249   std::string name(locName);
02250   if(name.empty())
02251     throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::appendLoc : unsupported localizations with no name !");
02252   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
02253   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
02254     if((*it)->isName(locName))
02255       {
02256         if(!(*it)->isEqual(*obj,1e-12))
02257           {
02258             std::ostringstream oss; oss << "MEDFieldFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
02259             throw INTERP_KERNEL::Exception(oss.str().c_str());
02260           }
02261       }
02262   _locs.push_back(obj);
02263 }
02264 
02265 MEDFieldFieldGlobsReal::MEDFieldFieldGlobsReal(const char *fname):_globals(MEDFieldFieldGlobs::New(fname))
02266 {
02267 }
02268 
02269 MEDFieldFieldGlobsReal::MEDFieldFieldGlobsReal():_globals(MEDFieldFieldGlobs::New())
02270 {
02271 }
02272 
02273 void MEDFieldFieldGlobsReal::simpleRepr(std::ostream& oss) const
02274 {
02275   oss << "Globals information on fields :" << "\n*******************************\n\n";
02276   const MEDFieldFieldGlobs *glob=_globals;
02277   if(glob)
02278     glob->simpleRepr(oss);
02279   else
02280     oss << "NO GLOBAL INFORMATION !\n";
02281 }
02282 
02283 MEDFieldFieldGlobsReal::~MEDFieldFieldGlobsReal()
02284 {
02285 }
02286 
02287 void MEDFieldFieldGlobsReal::shallowCpyGlobs(const MEDFieldFieldGlobsReal& other)
02288 {
02289   _globals=other._globals;
02290 }
02291 
02292 void MEDFieldFieldGlobsReal::appendGlobs(const MEDFieldFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
02293 {
02294   _globals->appendGlobs(*other._globals,eps);
02295 }
02296 
02297 void MEDFieldFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
02298 {
02299   _globals->loadProfileInFile(fid,id,pflName);
02300 }
02301 
02302 void MEDFieldFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
02303 {
02304   _globals->loadProfileInFile(fid,id);
02305 }
02306 
02307 void MEDFieldFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
02308 {
02309   _globals->loadGlobals(fid,*this);
02310 }
02311 
02312 void MEDFieldFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
02313 {
02314   _globals->loadAllGlobals(fid);
02315 }
02316 
02317 void MEDFieldFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
02318 {
02319   _globals->writeGlobals(fid,opt);
02320 }
02321 
02322 std::vector<std::string> MEDFieldFieldGlobsReal::getPfls() const
02323 {
02324   return _globals->getPfls();
02325 }
02326 
02327 std::vector<std::string> MEDFieldFieldGlobsReal::getLocs() const
02328 {
02329   return _globals->getLocs();
02330 }
02331 
02332 bool MEDFieldFieldGlobsReal::existsPfl(const char *pflName) const
02333 {
02334   return _globals->existsPfl(pflName);
02335 }
02336 
02337 bool MEDFieldFieldGlobsReal::existsLoc(const char *locName) const
02338 {
02339   return _globals->existsLoc(locName);
02340 }
02341 
02342 void MEDFieldFieldGlobsReal::setFileName(const char *fileName)
02343 {
02344   _globals->setFileName(fileName);
02345 }
02346 
02347 std::vector< std::vector<int> > MEDFieldFieldGlobsReal::whichAreEqualProfiles() const
02348 {
02349   return _globals->whichAreEqualProfiles();
02350 }
02351 
02352 std::vector< std::vector<int> > MEDFieldFieldGlobsReal::whichAreEqualLocs(double eps) const
02353 {
02354   return _globals->whichAreEqualLocs(eps);
02355 }
02356 
02357 void MEDFieldFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02358 {
02359   _globals->changePflsNamesInStruct(mapOfModif);
02360 }
02361 
02362 void MEDFieldFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02363 {
02364   _globals->changeLocsNamesInStruct(mapOfModif);
02365 }
02366 
02372 void MEDFieldFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02373 {
02374   changePflsRefsNamesGen(mapOfModif);
02375   changePflsNamesInStruct(mapOfModif);
02376 }
02377 
02383 void MEDFieldFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02384 {
02385   changeLocsRefsNamesGen(mapOfModif);
02386   changeLocsNamesInStruct(mapOfModif);
02387 }
02388 
02392 void MEDFieldFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
02393 {
02394   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
02395   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
02396   mapOfModif[0]=p;
02397   changePflsNames(mapOfModif);
02398 }
02399 
02403 void MEDFieldFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
02404 {
02405   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
02406   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
02407   mapOfModif[0]=p;
02408   changeLocsNames(mapOfModif);
02409 }
02410 
02411 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFieldFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
02412 {
02413   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
02414   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
02415   int i=0;
02416   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
02417     {
02418       std::vector< std::string > tmp((*it).size());
02419       int j=0;
02420       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
02421         tmp[j]=std::string(getProfileFromId(*it2)->getName());
02422       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
02423       ret[i]=p;
02424       std::vector<int> tmp2((*it).begin()+1,(*it).end());
02425       killProfileIds(tmp2);
02426     }
02427   changePflsRefsNamesGen(ret);
02428   return ret;
02429 }
02430 
02431 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFieldFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
02432 {
02433   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
02434   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
02435   int i=0;
02436   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
02437     {
02438       std::vector< std::string > tmp((*it).size());
02439       int j=0;
02440       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
02441         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
02442       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
02443       ret[i]=p;
02444       std::vector<int> tmp2((*it).begin()+1,(*it).end());
02445       killLocalizationIds(tmp2);
02446     }
02447   changeLocsRefsNamesGen(ret);
02448   return ret;
02449 }
02450 
02451 int MEDFieldFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
02452 {
02453   return _globals->getNbOfGaussPtPerCell(locId);
02454 }
02455 
02456 int MEDFieldFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
02457 {
02458   return _globals->getLocalizationId(loc);
02459 }
02460 
02461 const char *MEDFieldFieldGlobsReal::getFileName() const
02462 {
02463   return _globals->getFileName();
02464 }
02465 
02466 std::string MEDFieldFieldGlobsReal::getFileName2() const
02467 {
02468   return _globals->getFileName2();
02469 }
02470 
02471 const MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
02472 {
02473   return _globals->getLocalization(locName);
02474 }
02475 
02476 const MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
02477 {
02478   return _globals->getLocalizationFromId(locId);
02479 }
02480 
02481 const DataArrayInt *MEDFieldFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
02482 {
02483   return _globals->getProfile(pflName);
02484 }
02485 
02486 const DataArrayInt *MEDFieldFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
02487 {
02488   return _globals->getProfileFromId(pflId);
02489 }
02490 
02491 MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
02492 {
02493   return _globals->getLocalizationFromId(locId);
02494 }
02495 
02496 MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
02497 {
02498   return _globals->getLocalization(locName);
02499 }
02500 
02501 DataArrayInt *MEDFieldFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
02502 {
02503   return _globals->getProfile(pflName);
02504 }
02505 
02506 DataArrayInt *MEDFieldFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
02507 {
02508   return _globals->getProfileFromId(pflId);
02509 }
02510 
02511 void MEDFieldFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
02512 {
02513   _globals->killProfileIds(pflIds);
02514 }
02515 
02516 void MEDFieldFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
02517 {
02518   _globals->killLocalizationIds(locIds);
02519 }
02520 
02521 void MEDFieldFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
02522 {
02523   _globals->appendProfile(pfl);
02524 }
02525 
02526 void MEDFieldFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
02527 {
02528   _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
02529 }
02530 
02535 int MEDFileField1TSWithoutDAS::getDimension() const
02536 {
02537   int ret=-2;
02538   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02539     (*it)->getDimension(ret);
02540   return ret;
02541 }
02542 
02543 void MEDFileField1TSWithoutDAS::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
02544 {
02545   if(meshDimRelToMax>0)
02546     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
02547 }
02548 
02549 std::vector<int> MEDFileField1TSWithoutDAS::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
02550 {
02551   //
02552   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
02553   int nbOfTypes=geoTypes.size();
02554   std::vector<int> code(3*nbOfTypes);
02555   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
02556   arr1->alloc(nbOfTypes,1);
02557   int *arrPtr=arr1->getPointer();
02558   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
02559   for(int i=0;i<nbOfTypes;i++,it++)
02560     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
02561   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
02562   const int *arrPtr2=arr2->getConstPointer();
02563   int i=0;
02564   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
02565     {
02566       int pos=arrPtr2[i];
02567       int nbCells=mesh->getNumberOfCellsWithType(*it);
02568       code[3*pos]=(int)(*it);
02569       code[3*pos+1]=nbCells;
02570       code[3*pos+2]=-1;//no profiles
02571     }
02572   std::vector<const DataArrayInt *> idsPerType;//no profiles
02573   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
02574   if(da)
02575     {
02576       da->decrRef();
02577       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
02578     }
02579   return code;
02580 }
02581 
02582 MEDFileField1TSWithoutDAS *MEDFileField1TSWithoutDAS::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
02583 {
02584   return new MEDFileField1TSWithoutDAS(fieldName,csit,fieldtype,iteration,order,infos);
02585 }
02586 
02593 int MEDFileField1TSWithoutDAS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
02594 {
02595   std::string name(field->getName());
02596   getOrCreateAndGetArray()->setName(name.c_str());
02597   if(name.empty())
02598     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::copyTinyInfoFrom : unsupported fields with no name in MED file !");
02599   const DataArrayDouble *arr=field->getArray();
02600   if(!arr)
02601     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::copyTinyInfoFrom : no array set !");
02602   _dt=field->getTime(_iteration,_order);
02603   int nbOfComponents=arr->getNumberOfComponents();
02604   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
02605   if(!getOrCreateAndGetArray()->isAllocated())
02606     {
02607       _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
02608       return 0;
02609     }
02610   else
02611     {
02612       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
02613       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
02614       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
02615       tmp->alloc(newNbOfTuples,nbOfComponents);
02616       tmp->copyStringInfoFrom(*_arr);
02617       std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
02618       _arr=tmp;
02619       return oldNbOfTuples;
02620     }
02621 }
02622 
02623 std::string MEDFileField1TSWithoutDAS::getName() const
02624 {
02625   const DataArrayDouble *arr=getOrCreateAndGetArray();
02626   return arr->getName();
02627 }
02628 
02629 void MEDFileField1TSWithoutDAS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
02630 {
02631   std::string startOfLine(bkOffset,' ');
02632   oss << startOfLine << "Field on One time Step ";
02633   if(f1tsId>=0)
02634     oss << "(" << f1tsId << ") ";
02635   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
02636   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
02637   const DataArrayDouble *arr=_arr;
02638   if(arr)
02639     {
02640       const std::vector<std::string> &comps=arr->getInfoOnComponents();
02641       if(f1tsId<0)
02642         {
02643           oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
02644           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
02645           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
02646             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
02647         }
02648       if(arr->isAllocated())
02649         {
02650           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
02651         }
02652       else
02653         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
02654     }
02655   else
02656     {
02657       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
02658     }
02659   oss << startOfLine << "----------------------" << std::endl;
02660   if(!_field_per_mesh.empty())
02661     {
02662       int i=0;
02663       for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
02664         {
02665           const MEDFileFieldPerMesh *cur=(*it2);
02666           if(cur)
02667             cur->simpleRepr(bkOffset,oss,i);
02668           else
02669             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
02670         }
02671     }
02672   else
02673     {
02674       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
02675     }
02676   oss << startOfLine << "----------------------" << std::endl;
02677 }
02678 
02679 std::string MEDFileField1TSWithoutDAS::getMeshName() const throw(INTERP_KERNEL::Exception)
02680 {
02681   if(_field_per_mesh.empty())
02682     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
02683   return _field_per_mesh[0]->getMeshName();
02684 }
02685 
02686 int MEDFileField1TSWithoutDAS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
02687 {
02688   if(_field_per_mesh.empty())
02689     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
02690   return _field_per_mesh[0]->getMeshIteration();
02691 }
02692 
02693 int MEDFileField1TSWithoutDAS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
02694 {
02695   if(_field_per_mesh.empty())
02696     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
02697   return _field_per_mesh[0]->getMeshOrder();
02698 }
02699 
02700 int MEDFileField1TSWithoutDAS::getNumberOfComponents() const
02701 {
02702   return getOrCreateAndGetArray()->getNumberOfComponents();
02703 }
02704 
02705 bool MEDFileField1TSWithoutDAS::isDealingTS(int iteration, int order) const
02706 {
02707   return iteration==_iteration && order==_order;
02708 }
02709 
02710 std::pair<int,int> MEDFileField1TSWithoutDAS::getDtIt() const
02711 {
02712   std::pair<int,int> p;
02713   fillIteration(p);
02714   return p;
02715 }
02716 
02717 void MEDFileField1TSWithoutDAS::fillIteration(std::pair<int,int>& p) const
02718 {
02719   p.first=_iteration;
02720   p.second=_order;
02721 }
02722 
02723 void MEDFileField1TSWithoutDAS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
02724 {
02725   std::set<TypeOfField> types2;
02726   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02727     {
02728       (*it)->fillTypesOfFieldAvailable(types2);
02729     }
02730   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
02731   std::copy(types2.begin(),types2.end(),bi);
02732 }
02733 
02734 const std::vector<std::string>& MEDFileField1TSWithoutDAS::getInfo() const
02735 {
02736   const DataArrayDouble *arr=getOrCreateAndGetArray();
02737   return arr->getInfoOnComponents();
02738 }
02739 
02740 std::vector<std::string>& MEDFileField1TSWithoutDAS::getInfo()
02741 {
02742   DataArrayDouble *arr=getOrCreateAndGetArray();
02743   return arr->getInfoOnComponents();
02744 }
02745 
02777 int MEDFileField1TSWithoutDAS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
02778 {
02779   levs.clear();
02780   int meshId=getMeshIdFromMeshName(mname);
02781   std::vector<INTERP_KERNEL::NormalizedCellType> types;
02782   std::vector< std::vector<TypeOfField> > typesF;
02783   std::vector< std::vector<std::string> > pfls, locs;
02784   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
02785   if(types.empty())
02786     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getNonEmptyLevels : 'this' is empty !");
02787   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
02788   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
02789     return -1;
02790   st.erase(INTERP_KERNEL::NORM_ERROR);
02791   std::set<int> ret1;
02792   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
02793     {
02794       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
02795       ret1.insert((int)cm.getDimension());
02796     }
02797   int ret=*std::max_element(ret1.begin(),ret1.end());
02798   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
02799   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
02800   return ret;
02801 }
02802 
02803 std::vector<TypeOfField> MEDFileField1TSWithoutDAS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
02804 {
02805   std::vector<TypeOfField> ret;
02806   fillTypesOfFieldAvailable(ret);
02807   return ret;
02808 }
02809 
02813 std::vector< std::vector< std::pair<int,int> > > MEDFileField1TSWithoutDAS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
02814 {
02815   int meshId=0;
02816   if(mname)
02817     meshId=getMeshIdFromMeshName(mname);
02818   else
02819     if(_field_per_mesh.empty())
02820       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldSplitedByType : This is empty !");
02821   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
02822 }
02823 
02828 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutDAS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
02829 {
02830   int meshId=0;
02831   if(mname)
02832     meshId=getMeshIdFromMeshName(mname);
02833   else
02834     if(_field_per_mesh.empty())
02835       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldSplitedByType : This is empty !");
02836   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
02837   int nbOfRet=ret0.size();
02838   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
02839   for(int i=0;i<nbOfRet;i++)
02840     {
02841       const std::vector< std::pair<int,int> >& p=ret0[i];
02842       int nbOfRet1=p.size();
02843       ret[i].resize(nbOfRet1);
02844       for(int j=0;j<nbOfRet1;j++)
02845         {
02846           DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
02847           ret[i][j]=tmp;
02848         }
02849     }
02850   return ret;
02851 }
02852 
02853 void MEDFileField1TSWithoutDAS::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
02854 {
02855   med_int numdt,numit;
02856   med_float dt;
02857   med_int nmesh;
02858   med_bool localMesh;
02859   med_int meshnumdt,meshnumit;
02860   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
02861   MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
02862   MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
02863   if(_iteration!=numdt || _order!=numit)
02864     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::finishLoading : unexpected exception internal error !");
02865   _field_per_mesh.resize(nmesh);
02866   for(int i=0;i<nmesh;i++)
02867     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
02868   int start=0;
02869   for(int i=0;i<nmesh;i++)
02870     {
02871       _field_per_mesh[i]->prepareLoading(fid,start);
02872     }
02873   getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
02874   for(int i=0;i<nmesh;i++)
02875     {
02876       _field_per_mesh[i]->finishLoading(fid,_field_type);
02877     }
02878 }
02879 
02880 std::vector<std::string> MEDFileField1TSWithoutDAS::getPflsReallyUsed2() const
02881 {
02882   std::vector<std::string> ret;
02883   std::set<std::string> ret2;
02884   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02885     {
02886       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
02887       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
02888         if(ret2.find(*it2)==ret2.end())
02889           {
02890             ret.push_back(*it2);
02891             ret2.insert(*it2);
02892           }
02893     }
02894   return ret;
02895 }
02896 
02897 std::vector<std::string> MEDFileField1TSWithoutDAS::getLocsReallyUsed2() const
02898 {
02899   std::vector<std::string> ret;
02900   std::set<std::string> ret2;
02901   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02902     {
02903       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
02904       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
02905         if(ret2.find(*it2)==ret2.end())
02906           {
02907             ret.push_back(*it2);
02908             ret2.insert(*it2);
02909           }
02910     }
02911   return ret;
02912 }
02913 
02914 std::vector<std::string> MEDFileField1TSWithoutDAS::getPflsReallyUsedMulti2() const
02915 {
02916   std::vector<std::string> ret;
02917   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02918     {
02919       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
02920       ret.insert(ret.end(),tmp.begin(),tmp.end());
02921     }
02922   return ret;
02923 }
02924 
02925 std::vector<std::string> MEDFileField1TSWithoutDAS::getLocsReallyUsedMulti2() const
02926 {
02927   std::vector<std::string> ret;
02928   std::set<std::string> ret2;
02929   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02930     {
02931       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
02932       ret.insert(ret.end(),tmp.begin(),tmp.end());
02933     }
02934   return ret;
02935 }
02936 
02937 void MEDFileField1TSWithoutDAS::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02938 {
02939   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02940     (*it)->changePflsRefsNamesGen(mapOfModif);
02941 }
02942 
02943 void MEDFileField1TSWithoutDAS::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
02944 {
02945   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
02946     (*it)->changeLocsRefsNamesGen(mapOfModif);
02947 }
02948 
02949 void MEDFileField1TSWithoutDAS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
02950 {
02951   if(_field_per_mesh.empty())
02952     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::writeLL : empty field !");
02953   if(_field_per_mesh.size()>1)
02954     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
02955   _field_per_mesh[0]->copyOptionsFrom(*this);
02956   _field_per_mesh[0]->writeLL(fid);
02957 }
02958 
02963 void MEDFileField1TSWithoutDAS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
02964 {
02965   const MEDCouplingMesh *mesh=field->getMesh();
02966   //
02967   TypeOfField type=field->getTypeOfField();
02968   std::vector<DataArrayInt *> dummy;
02969   int start=copyTinyInfoFrom(field);
02970   if(type!=ON_NODES)
02971     {
02972       std::vector<int> code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh);
02973       //
02974       int pos=addNewEntryIfNecessary(mesh);
02975       _field_per_mesh[pos]->assignFieldProfile(start,0,code,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile.
02976     }
02977   else
02978     {
02979       int pos=addNewEntryIfNecessary(mesh);
02980       _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
02981     }
02982 }
02983 
02987 void MEDFileField1TSWithoutDAS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
02988 {
02989   TypeOfField type=field->getTypeOfField();
02990   int start=copyTinyInfoFrom(field);
02991   std::vector<DataArrayInt *> idsInPflPerType;
02992   std::vector<DataArrayInt *> idsPerType;
02993   std::vector<int> code;
02994   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
02995   if(type!=ON_NODES)
02996     {
02997       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
02998       //
02999       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
03000       for(std::size_t i=0;i<idsInPflPerType.size();i++)
03001         idsInPflPerType2[i]=idsInPflPerType[i];
03002       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
03003       for(std::size_t i=0;i<idsPerType.size();i++)
03004         idsPerType2[i]=idsPerType[i];
03005       //
03006       int pos=addNewEntryIfNecessary(m);
03007       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,idsInPflPerType,idsPerType,field,m,glob);
03008     }
03009   else
03010     {
03011       int pos=addNewEntryIfNecessary(m);
03012       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
03013     }
03014 }
03015 
03016 MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
03017 {
03018   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
03019   if(mName==0)
03020     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
03021   else
03022     mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
03023   return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
03024 }
03025 
03026 MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
03027 {
03028   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
03029   const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
03030   const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
03031   if(meshDimRelToMax==1)
03032     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
03033   return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
03034 }
03035 
03036 MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
03037 {
03038    MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
03039   if(mName==0)
03040     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
03041   else
03042     mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
03043   int absDim=getDimension();
03044   int meshDimRelToMax=absDim-mm->getMeshDimension();
03045   return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
03046 }
03047 
03048 MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
03049 {
03050   static const char msg1[]="MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
03051   int meshId=getMeshIdFromMeshName(mesh->getName());
03052   bool isPfl=false;
03053   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
03054   switch(renumPol)
03055     {
03056     case 0:
03057       {
03058         //no need to test _field_per_mesh.empty() because geMeshName has already done it
03059         ret->incrRef();
03060         return ret;
03061       }
03062     case 3:
03063     case 1:
03064       {
03065         if(isPfl)
03066           throw INTERP_KERNEL::Exception(msg1);
03067         //no need to test _field_per_mesh.empty() because geMeshName has already done it
03068         if(cellRenum)
03069           {
03070             if(cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
03071               {
03072                 std::ostringstream oss; oss << "MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
03073                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
03074                 throw INTERP_KERNEL::Exception(oss.str().c_str());
03075               }
03076             ret->renumberCells(cellRenum->getConstPointer(),true);
03077           }
03078         if(renumPol==1)
03079           {
03080             ret->incrRef();
03081             return ret;
03082           }
03083       }
03084     case 2:
03085       {
03086         //no need to test _field_per_mesh.empty() because geMeshName has already done it
03087         if(isPfl)
03088           throw INTERP_KERNEL::Exception(msg1);
03089         if(nodeRenum)
03090           {
03091             if(nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
03092               {
03093                 std::ostringstream oss; oss << "MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
03094                 oss << "\"" << getName() << "\" not defined on all nodes !";
03095                 throw INTERP_KERNEL::Exception(oss.str().c_str());
03096               }
03097             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
03098             ret->renumberNodes(nodeRenumSafe->getConstPointer());
03099           }
03100         ret->incrRef();
03101         return ret;
03102       }
03103     default:
03104       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
03105     }
03106 }
03107 
03108 DataArrayDouble *MEDFileField1TSWithoutDAS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
03109 {
03110   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
03111   int meshId=getMeshIdFromMeshName(mesh->getName());
03112   return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
03113 }
03114 
03121 DataArrayDouble *MEDFileField1TSWithoutDAS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
03122 {
03123   const DataArrayDouble *ret=_arr;
03124   if(ret)
03125     return const_cast<DataArrayDouble *>(ret);
03126   else
03127     return 0;
03128 }
03129 
03137 DataArrayDouble *MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
03138 {
03139   if(_field_per_mesh.size()!=1)
03140     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
03141   if(_field_per_mesh[0]==0)
03142     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getUndergroundDataArrayExt : no field specified !");
03143   return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
03144 }
03145 
03146 MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int fieldtype, int iteration, int order,
03147                                                      const std::vector<std::string>& infos):_csit(csit),_field_type(fieldtype),_iteration(iteration),_order(order)
03148 {
03149   DataArrayDouble *arr=getOrCreateAndGetArray();
03150   arr->setName(fieldName);
03151   arr->setInfoAndChangeNbOfCompo(infos);
03152 }
03153 
03154 MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS():_csit(-1),_field_type(-1)
03155 {
03156 }
03157 
03158 int MEDFileField1TSWithoutDAS::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
03159 {
03160   std::string tmp(mesh->getName());
03161   if(tmp.empty())
03162     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
03163   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
03164   int i=0;
03165   for(;it!=_field_per_mesh.end();it++,i++)
03166     {
03167       if((*it)->getMeshName()==tmp)
03168         return i;
03169     }
03170   int sz=_field_per_mesh.size();
03171   _field_per_mesh.resize(sz+1);
03172   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
03173   return sz;
03174 }
03175 
03179 int MEDFileField1TSWithoutDAS::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
03180 {
03181   if(_field_per_mesh.empty())
03182     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getMeshIdFromMeshName : No field set !");
03183   if(mName==0)
03184     return 0;
03185   std::string mName2(mName);
03186   int ret=0;
03187   std::vector<std::string> msg;
03188   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
03189     if(mName2==(*it)->getMeshName())
03190       return ret;
03191     else
03192       msg.push_back((*it)->getMeshName());
03193   std::ostringstream oss; oss << "MEDFileField1TSWithoutDAS::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
03194   oss << "Possible meshes are : ";
03195   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
03196     oss << "\"" << (*it2) << "\" ";
03197   throw INTERP_KERNEL::Exception(oss.str().c_str());
03198 }
03199 
03206 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutDAS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
03207 {
03208   int mid=getMeshIdFromMeshName(mName);
03209   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
03210 }
03211 
03218 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutDAS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
03219 {
03220   int mid=getMeshIdFromMeshName(mName);
03221   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
03222 }
03223 
03224 DataArrayDouble *MEDFileField1TSWithoutDAS::getOrCreateAndGetArray()
03225 {
03226   DataArrayDouble *ret=_arr;
03227   if(ret)
03228     return ret;
03229   _arr=DataArrayDouble::New();
03230   return _arr;
03231 }
03232 
03233 const DataArrayDouble *MEDFileField1TSWithoutDAS::getOrCreateAndGetArray() const
03234 {
03235   const DataArrayDouble *ret=_arr;
03236   if(ret)
03237     return ret;
03238   DataArrayDouble *ret2=DataArrayDouble::New();
03239   const_cast<MEDFileField1TSWithoutDAS *>(this)->_arr=DataArrayDouble::New();
03240   return ret2;
03241 }
03242 
03243 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
03244 {
03245   return new MEDFileField1TS(fileName,fieldName,iteration,order);
03246 }
03247 
03248 MEDFileField1TS *MEDFileField1TS::New()
03249 {
03250   return new MEDFileField1TS;
03251 }
03252 
03253 std::string MEDFileField1TS::simpleRepr() const
03254 {
03255   std::ostringstream oss;
03256   MEDFileField1TSWithoutDAS::simpleRepr(0,oss,-1);
03257   MEDFieldFieldGlobsReal::simpleRepr(oss);
03258   return oss.str();
03259 }
03260 
03261 void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
03262 {
03263   int nbComp=getNumberOfComponents();
03264   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
03265   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
03266   for(int i=0;i<nbComp;i++)
03267     {
03268       std::string info=getInfo()[i];
03269       std::string c,u;
03270       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
03271       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
03272       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
03273     }
03274   if(getName().empty())
03275     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
03276   MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
03277   writeGlobals(fid,*this);
03278   MEDFileField1TSWithoutDAS::writeLL(fid);
03279 }
03280 
03281 void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
03282 {
03283   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
03284   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
03285   writeLL(fid);
03286 }
03287 
03288 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
03289 try:MEDFileField1TSWithoutDAS(fieldName,-1,-1,iteration,order,std::vector<std::string>()),MEDFieldFieldGlobsReal(fileName)
03290 {
03291   MEDFileUtilities::CheckFileForRead(fileName);
03292   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
03293   int nbFields=MEDnField(fid);
03294   med_field_type typcha;
03295   bool found=false;
03296   std::vector<std::string> fns(nbFields);
03297   int nbOfStep2=-1;
03298   for(int i=0;i<nbFields && !found;i++)
03299     {
03300       int ncomp=MEDfieldnComponent(fid,i+1);
03301       INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
03302       INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
03303       INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
03304       INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
03305       INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
03306       med_bool localMesh;
03307       int nbOfStep;
03308       MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
03309       std::string tmp(nomcha);
03310       fns[i]=tmp;
03311       found=(tmp==fieldName);
03312       if(found)
03313         {
03314           nbOfStep2=nbOfStep;
03315           std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
03316           std::vector<std::string> infos(ncomp);
03317           for(int j=0;j<ncomp;j++)
03318             infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
03319           getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
03320         }
03321     }
03322   if(!found)
03323     {
03324       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
03325       std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
03326       throw INTERP_KERNEL::Exception(oss.str().c_str());
03327     }
03328   found=false;
03329   std::vector< std::pair<int,int> > dtits(nbOfStep2);
03330   for(int i=0;i<nbOfStep2 && !found;i++)
03331     {
03332       med_int numdt,numit;
03333       med_float dt;
03334       MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
03335       if(numdt==iteration && numit==order)
03336         {
03337           found=true;
03338           _csit=i+1;
03339           _field_type=MEDFileUtilities::TraduceFieldType(typcha);
03340         }
03341       else
03342         dtits[i]=std::pair<int,int>(numdt,numit);
03343     }
03344   if(!found)
03345     {
03346       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
03347       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
03348         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
03349       throw INTERP_KERNEL::Exception(oss.str().c_str());
03350     }
03351   finishLoading(fid);
03352   //
03353   loadGlobals(fid);
03354 }
03355 catch(INTERP_KERNEL::Exception& e)
03356   {
03357     throw e;
03358   }
03359 
03360 MEDFileField1TS::MEDFileField1TS()
03361 {
03362 }
03363 
03369 std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
03370 {
03371   return getPflsReallyUsed2();
03372 }
03373 
03378 std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
03379 {
03380   return getLocsReallyUsed2();
03381 }
03382 
03387 std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
03388 {
03389   return getPflsReallyUsedMulti2();
03390 }
03391 
03396 std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
03397 {
03398   return getLocsReallyUsedMulti2();
03399 }
03400 
03401 void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
03402 {
03403   changePflsRefsNamesGen2(mapOfModif);
03404 }
03405 
03406 void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
03407 {
03408   changeLocsRefsNamesGen2(mapOfModif);
03409 }
03410 
03417 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
03418 {
03419   if(getFileName2().empty())
03420     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
03421   return MEDFileField1TSWithoutDAS::getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
03422 }
03423 
03429 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
03430 {
03431   if(getFileName2().empty())
03432     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
03433   return MEDFileField1TSWithoutDAS::getFieldAtTopLevel(type,0,renumPol,this);
03434 }
03435 
03442 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
03443 {
03444   return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
03445 }
03446 
03452 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
03453 {
03454   return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
03455 }
03456 
03462 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
03463 {
03464   if(getFileName2().empty())
03465     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
03466   return MEDFileField1TSWithoutDAS::getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
03467 }
03468 
03469 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
03470 {
03471   return MEDFileField1TSWithoutDAS::getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
03472 }
03473 
03479 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
03480 {
03481   setFileName("");
03482   MEDFileField1TSWithoutDAS::setFieldNoProfileSBT(field,*this);
03483 }
03484 
03493 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
03494 {
03495   setFileName("");
03496   MEDFileField1TSWithoutDAS::setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
03497 }
03498 
03517 void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
03518 {
03519   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
03520   std::string oldPflName=disc->getProfile();
03521   std::vector<std::string> vv=getPflsReallyUsedMulti();
03522   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
03523   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
03524     {
03525       disc->setProfile(newPflName);
03526       DataArrayInt *pfl=getProfile(oldPflName.c_str());
03527       pfl->setName(newPflName);
03528     }
03529   else
03530     {
03531       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
03532       throw INTERP_KERNEL::Exception(oss.str().c_str());
03533     }
03534 }
03535 
03555 void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
03556 {
03557   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
03558   std::string oldLocName=disc->getLocalization();
03559   std::vector<std::string> vv=getLocsReallyUsedMulti();
03560   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
03561   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
03562     {
03563       disc->setLocalization(newLocName);
03564       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
03565       loc.setName(newLocName);
03566     }
03567   else
03568     {
03569       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
03570       throw INTERP_KERNEL::Exception(oss.str().c_str());
03571     }
03572 }
03573 
03574 MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
03575 {
03576   return new MEDFileFieldMultiTSWithoutDAS(fid,fieldName,id,ft,infos,nbOfStep);
03577 }
03578 
03579 MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS():_field_type(-1)
03580 {
03581 }
03582 
03583 MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(const char *fieldName):_name(fieldName),_field_type(-1)
03584 {
03585 }
03586 
03587 MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
03588 try:_name(fieldName),_infos(infos),_field_type(ft)
03589 {
03590   finishLoading(fid,nbOfStep);
03591 }
03592 catch(INTERP_KERNEL::Exception& e)
03593   {
03594     throw e;
03595   }
03596 
03597 const std::vector<std::string>& MEDFileFieldMultiTSWithoutDAS::getInfo() const throw(INTERP_KERNEL::Exception)
03598 {
03599   if(_time_steps.empty())
03600     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::getInfos : not time steps !");
03601   return _time_steps[0]->getInfo();
03602 }
03603 
03607 DataArrayDouble *MEDFileFieldMultiTSWithoutDAS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
03608 {
03609   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
03610 }
03611 
03615 DataArrayDouble *MEDFileFieldMultiTSWithoutDAS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
03616 {
03617   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
03618 }
03619 
03620 std::string MEDFileFieldMultiTSWithoutDAS::getMeshName() const throw(INTERP_KERNEL::Exception)
03621 {
03622   if(_time_steps.empty())
03623     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::getMeshName : not time steps !");
03624   return _time_steps[0]->getMeshName();
03625 }
03626 
03627 std::string MEDFileFieldMultiTSWithoutDAS::getDtUnit() const throw(INTERP_KERNEL::Exception)
03628 {
03629   if(_time_steps.empty())
03630     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::getMeshName : not time steps !");
03631   return _time_steps[0]->getDtUnit();
03632 }
03633 
03634 std::string MEDFileFieldMultiTSWithoutDAS::getName() const
03635 {
03636   return _name;
03637 }
03638 
03639 void MEDFileFieldMultiTSWithoutDAS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
03640 {
03641   std::string startLine(bkOffset,' ');
03642   oss << startLine << "Field multi time steps";
03643   if(fmtsId>=0)
03644     oss << " (" << fmtsId << ")";
03645   oss << " has the following name: \"" << _name << "\"." << std::endl;
03646   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
03647   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
03648     {
03649       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
03650     }
03651   int i=0;
03652   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
03653     {
03654       std::string chapter(17,'0'+i);
03655       oss << startLine << chapter << std::endl;
03656       const MEDFileField1TSWithoutDAS *cur=(*it);
03657       if(cur)
03658         cur->simpleRepr(bkOffset+2,oss,i);
03659       else
03660         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
03661       oss << startLine << chapter << std::endl;
03662     }
03663 }
03664 
03665 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutDAS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
03666 {
03667   std::size_t sz=_time_steps.size();
03668   std::vector< std::pair<int,int> > ret(sz);
03669   ret1.resize(sz);
03670   for(std::size_t i=0;i<sz;i++)
03671     {
03672       const MEDFileField1TSWithoutDAS *f1ts=_time_steps[i];
03673       if(f1ts)
03674         {
03675           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
03676         }
03677       else
03678         {
03679           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getTimeSteps : At rank #" << i << " time step is not defined !";
03680           throw INTERP_KERNEL::Exception(oss.str().c_str());
03681         }
03682     }
03683   return ret;
03684 }
03685 
03686 void MEDFileFieldMultiTSWithoutDAS::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
03687 {
03688   _time_steps.resize(nbPdt);
03689   for(int i=0;i<nbPdt;i++)
03690     {
03691       std::vector< std::pair<int,int> > ts;
03692       med_int numdt=0,numo=0;
03693       med_int meshIt=0,meshOrder=0;
03694       med_float dt=0.0;
03695       MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
03696       _time_steps[i]=MEDFileField1TSWithoutDAS::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
03697       _time_steps[i]->finishLoading(fid);
03698     }
03699 }
03700 
03701 void MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
03702 {
03703   _name=field->getName();
03704   if(_name.empty())
03705     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom : unsupported fields with no name in MED file !");
03706   const DataArrayDouble *arr=field->getArray();
03707   if(!arr)
03708     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom : no array set !");
03709   _infos=arr->getInfoOnComponents();
03710 }
03711 
03712 void MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
03713 {
03714   static const char MSG[]="MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo : invalid ";
03715   if(_name!=field->getName())
03716     {
03717       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
03718       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
03719       throw INTERP_KERNEL::Exception(oss.str().c_str());
03720     }
03721   const DataArrayDouble *arr=field->getArray();
03722   if(!arr)
03723     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo : no array set !");
03724   if(_infos!=arr->getInfoOnComponents())
03725     {
03726       std::ostringstream oss; oss << MSG << "components ! should be \"";
03727       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
03728       oss << " But compo in input fields are : ";
03729       std::vector<std::string> tmp=arr->getInfoOnComponents();
03730       std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
03731       oss << " !";
03732       throw INTERP_KERNEL::Exception(oss.str().c_str());
03733     }
03734 }
03735 
03736 void MEDFileFieldMultiTSWithoutDAS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
03737 {
03738   if(_time_steps.empty())
03739     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::writeLL : no time steps set !");
03740   std::vector<std::string> infos(getInfo());
03741   int nbComp=infos.size();
03742   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
03743   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
03744   for(int i=0;i<nbComp;i++)
03745     {
03746       std::string info=infos[i];
03747       std::string c,u;
03748       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
03749       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
03750       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
03751     }
03752   if(_name.empty())
03753     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::write : MED file does not accept field with empty name !");
03754   MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
03755   int nbOfTS=_time_steps.size();
03756   for(int i=0;i<nbOfTS;i++)
03757     {
03758       _time_steps[i]->copyOptionsFrom(*this);
03759       _time_steps[i]->writeLL(fid);
03760     }
03761 }
03762 
03763 int MEDFileFieldMultiTSWithoutDAS::getNumberOfTS() const
03764 {
03765   return _time_steps.size();
03766 }
03767 
03768 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutDAS::getIterations() const
03769 {
03770   int lgth=_time_steps.size();
03771   std::vector< std::pair<int,int> > ret(lgth);
03772   for(int i=0;i<lgth;i++)
03773     _time_steps[i]->fillIteration(ret[i]);
03774   return ret;
03775 }
03776 
03808 int MEDFileFieldMultiTSWithoutDAS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
03809 {
03810   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
03811 }
03812 
03813 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutDAS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
03814 {
03815   int lgth=_time_steps.size();
03816   std::vector< std::vector<TypeOfField> > ret(lgth);
03817   for(int i=0;i<lgth;i++)
03818     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
03819   return ret;
03820 }
03821 
03825 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTSWithoutDAS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
03826 {
03827   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
03828 }
03829 
03834 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutDAS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
03835 {
03836   return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
03837 }
03838 
03839 const MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
03840 {
03841   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03842     if((*it)->isDealingTS(iteration,order))
03843       return *(*it);
03844   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
03845   std::vector< std::pair<int,int> > vp=getIterations();
03846   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
03847     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
03848   throw INTERP_KERNEL::Exception(oss.str().c_str());
03849 }
03850 
03851 MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
03852 {
03853   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS>  >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03854     if((*it)->isDealingTS(iteration,order))
03855       return *(*it);
03856   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
03857   std::vector< std::pair<int,int> > vp=getIterations();
03858   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
03859     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
03860   throw INTERP_KERNEL::Exception(oss.str().c_str());
03861 }
03862 
03863 std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getPflsReallyUsed2() const
03864 {
03865   std::vector<std::string> ret;
03866   std::set<std::string> ret2;
03867   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03868     {
03869       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
03870       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
03871         if(ret2.find(*it2)==ret2.end())
03872           {
03873             ret.push_back(*it2);
03874             ret2.insert(*it2);
03875           }
03876     }
03877   return ret;
03878 }
03879 
03880 std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getLocsReallyUsed2() const
03881 {
03882   std::vector<std::string> ret;
03883   std::set<std::string> ret2;
03884   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03885     {
03886       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
03887       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
03888         if(ret2.find(*it2)==ret2.end())
03889           {
03890             ret.push_back(*it2);
03891             ret2.insert(*it2);
03892           }
03893     }
03894   return ret;
03895 }
03896 
03897 std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getPflsReallyUsedMulti2() const
03898 {
03899   std::vector<std::string> ret;
03900   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03901     {
03902       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
03903       ret.insert(ret.end(),tmp.begin(),tmp.end());
03904     }
03905   return ret;
03906 }
03907 
03908 std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getLocsReallyUsedMulti2() const
03909 {
03910   std::vector<std::string> ret;
03911   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03912     {
03913       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
03914       ret.insert(ret.end(),tmp.begin(),tmp.end());
03915     }
03916   return ret;
03917 }
03918 
03919 void MEDFileFieldMultiTSWithoutDAS::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
03920 {
03921   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03922     (*it)->changePflsRefsNamesGen2(mapOfModif);
03923 }
03924 
03925 void MEDFileFieldMultiTSWithoutDAS::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
03926 {
03927   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
03928     (*it)->changeLocsRefsNamesGen2(mapOfModif);
03929 }
03930 
03931 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
03932 {
03933   return new MEDFileFieldMultiTS;
03934 }
03935 
03936 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
03937 {
03938   return new MEDFileFieldMultiTS(fileName,fieldName);
03939 }
03940 
03941 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutDAS& other)
03942 {
03943   return new MEDFileFieldMultiTS(other);
03944 }
03945 
03946 std::string MEDFileFieldMultiTS::simpleRepr() const
03947 {
03948   std::ostringstream oss;
03949   MEDFileFieldMultiTSWithoutDAS::simpleRepr(0,oss,-1);
03950   MEDFieldFieldGlobsReal::simpleRepr(oss);
03951   return oss.str();
03952 }
03953 
03954 void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
03955 {
03956   writeGlobals(fid,*this);
03957   MEDFileFieldMultiTSWithoutDAS::writeLL(fid);
03958 }
03959 
03960 void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
03961 {
03962   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
03963   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
03964   writeLL(fid);
03965 }
03966 
03971 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
03972 {
03973   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
03974   return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
03975 }
03976 
03977 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
03978 {
03979   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
03980   return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
03981 }
03982 
03987 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
03988 {
03989   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
03990   return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
03991 }
03992 
03997 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
03998 {
03999   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
04000   return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
04001 }
04002 
04008 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
04009 {
04010   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
04011   return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
04012 }
04013 
04014 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
04015 {
04016   const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
04017   return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
04018 }
04019 
04020 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
04021 {
04022   if(_time_steps.empty())
04023     {
04024       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
04025       obj->setFieldNoProfileSBT(field,*this);
04026       copyTinyInfoFrom(field);
04027       _time_steps.push_back(obj);
04028     }
04029   else
04030     {
04031       checkCoherencyOfTinyInfo(field);
04032       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
04033       obj->setFieldNoProfileSBT(field,*this);
04034       _time_steps.push_back(obj);
04035     }
04036 }
04037 
04038 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
04039 {
04040   if(_time_steps.empty())
04041     {
04042       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
04043       obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
04044       copyTinyInfoFrom(field);
04045       _time_steps.push_back(obj);
04046     }
04047   else
04048     {
04049       checkCoherencyOfTinyInfo(field);
04050       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
04051       obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
04052       _time_steps.push_back(obj);
04053     }
04054 }
04055 
04056 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
04057 {
04058 }
04059 
04060 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
04061 try:MEDFileFieldMultiTSWithoutDAS(fieldName),MEDFieldFieldGlobsReal(fileName)
04062 {
04063   MEDFileUtilities::CheckFileForRead(fileName);
04064   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
04065   int nbFields=MEDnField(fid);
04066   med_field_type typcha;
04067   bool found=false;
04068   std::vector<std::string> fns(nbFields);
04069   int nbstep2=-1;
04070   for(int i=0;i<nbFields && !found;i++)
04071     {
04072       int ncomp=MEDfieldnComponent(fid,i+1);
04073       INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
04074       INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
04075       INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
04076       INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
04077       INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
04078       med_bool localMesh;
04079       int nbOfStep;
04080       MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
04081       std::string tmp(nomcha);
04082       fns[i]=tmp;
04083       found=(tmp==fieldName);
04084       if(found)
04085         {
04086           nbstep2=nbOfStep;
04087           _field_type=MEDFileUtilities::TraduceFieldType(typcha);
04088           _infos.resize(ncomp);
04089           for(int j=0;j<ncomp;j++)
04090             _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
04091         }
04092     }
04093   if(!found)
04094     {
04095       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
04096       std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
04097       throw INTERP_KERNEL::Exception(oss.str().c_str());
04098     }
04099   finishLoading(fid,nbstep2);
04100   loadGlobals(fid);
04101 }
04102 catch(INTERP_KERNEL::Exception& e)
04103   {
04104     throw e;
04105   }
04106 
04107 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutDAS& other):MEDFileFieldMultiTSWithoutDAS(other)
04108 {
04109 }
04110 
04111 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
04112 {
04113   return getPflsReallyUsed2();
04114 }
04115 
04116 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
04117 {
04118   return getLocsReallyUsed2();
04119 }
04120 
04121 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
04122 {
04123   return getPflsReallyUsedMulti2();
04124 }
04125 
04126 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
04127 {
04128   return getLocsReallyUsedMulti2();
04129 }
04130 
04131 void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
04132 {
04133   changePflsRefsNamesGen2(mapOfModif);
04134 }
04135 
04136 void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
04137 {
04138   changeLocsRefsNamesGen2(mapOfModif);
04139 }
04140 
04141 MEDFileFields *MEDFileFields::New()
04142 {
04143   return new MEDFileFields;
04144 }
04145 
04146 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
04147 {
04148   return new MEDFileFields(fileName);
04149 }
04150 
04151 int MEDFileFields::getNumberOfFields() const
04152 {
04153   return _fields.size();
04154 }
04155 
04156 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
04157 {
04158   std::vector<std::string> ret(_fields.size());
04159   int i=0;
04160   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
04161     {
04162       const MEDFileFieldMultiTSWithoutDAS *f=(*it);
04163       if(f)
04164         {
04165           ret[i]=f->getName();
04166         }
04167       else
04168         {
04169           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
04170           throw INTERP_KERNEL::Exception(oss.str().c_str());
04171         }
04172     }
04173   return ret;
04174 }
04175 
04176 std::string MEDFileFields::simpleRepr() const
04177 {
04178   std::ostringstream oss;
04179   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
04180   simpleRepr(0,oss);
04181   return oss.str();
04182 }
04183 
04184 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
04185 {
04186   int nbOfFields=getNumberOfFields();
04187   std::string startLine(bkOffset,' ');
04188   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
04189   int i=0;
04190   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
04191     {
04192       const MEDFileFieldMultiTSWithoutDAS *cur=(*it);
04193       if(cur)
04194         {
04195           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
04196         }
04197       else
04198         {
04199           oss << startLine << "  - not defined !" << std::endl;
04200         }
04201     }
04202   i=0;
04203   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
04204     {
04205       const MEDFileFieldMultiTSWithoutDAS *cur=(*it);
04206       std::string chapter(17,'0'+i);
04207       oss << startLine << chapter << std::endl;
04208       if(cur)
04209         {
04210           cur->simpleRepr(bkOffset+2,oss,i);
04211         }
04212       else
04213         {
04214           oss << startLine << "  - not defined !" << std::endl;
04215         }
04216       oss << startLine << chapter << std::endl;
04217     }
04218   MEDFieldFieldGlobsReal::simpleRepr(oss);
04219 }
04220 
04221 MEDFileFields::MEDFileFields()
04222 {
04223 }
04224 
04225 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
04226 try:MEDFieldFieldGlobsReal(fileName)
04227   {
04228     MEDFileUtilities::CheckFileForRead(fileName);
04229     MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
04230     int nbFields=MEDnField(fid);
04231     _fields.resize(nbFields);
04232     med_field_type typcha;
04233     for(int i=0;i<nbFields;i++)
04234       {
04235         int ncomp=MEDfieldnComponent(fid,i+1);
04236         INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
04237         INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
04238         INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
04239         INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
04240         INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
04241         med_bool localMesh;
04242         int nbOfStep;
04243         MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
04244         int ft=MEDFileUtilities::TraduceFieldType(typcha);
04245         std::vector<std::string> infos(ncomp);
04246         for(int j=0;j<ncomp;j++)
04247           infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
04248         _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i+1,ft,infos,nbOfStep);
04249       }
04250     loadAllGlobals(fid);
04251   }
04252 catch(INTERP_KERNEL::Exception& e)
04253   {
04254     throw e;
04255   }
04256 
04257 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
04258 {
04259   int i=0;
04260   writeGlobals(fid,*this);
04261   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
04262     {
04263       const MEDFileFieldMultiTSWithoutDAS *elt=*it;
04264       if(!elt)
04265         {
04266           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
04267           throw INTERP_KERNEL::Exception(oss.str().c_str());
04268         }
04269       elt->copyOptionsFrom(*this);
04270       elt->writeLL(fid);
04271     }
04272 }
04273 
04274 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
04275 {
04276   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
04277   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
04278   writeLL(fid);
04279 }
04280 
04281 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
04282 {
04283   std::vector<std::string> ret;
04284   std::set<std::string> ret2;
04285   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
04286     {
04287       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
04288       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
04289         if(ret2.find(*it2)==ret2.end())
04290           {
04291             ret.push_back(*it2);
04292             ret2.insert(*it2);
04293           }
04294     }
04295   return ret;
04296 }
04297 
04298 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
04299 {
04300   std::vector<std::string> ret;
04301   std::set<std::string> ret2;
04302   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
04303     {
04304       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
04305       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
04306         if(ret2.find(*it2)==ret2.end())
04307           {
04308             ret.push_back(*it2);
04309             ret2.insert(*it2);
04310           }
04311     }
04312   return ret;
04313 }
04314 
04315 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
04316 {
04317   std::vector<std::string> ret;
04318   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
04319     {
04320       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
04321       ret.insert(ret.end(),tmp.begin(),tmp.end());
04322     }
04323   return ret;
04324 }
04325 
04326 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
04327 {
04328   std::vector<std::string> ret;
04329   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
04330     {
04331       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
04332       ret.insert(ret.end(),tmp.begin(),tmp.end());
04333     }
04334   return ret;
04335 }
04336 
04337 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
04338 {
04339   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::iterator it=_fields.begin();it!=_fields.end();it++)
04340     (*it)->changePflsRefsNamesGen2(mapOfModif);
04341 }
04342 
04343 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
04344 {
04345   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::iterator it=_fields.begin();it!=_fields.end();it++)
04346     (*it)->changeLocsRefsNamesGen2(mapOfModif);
04347 }
04348 
04349 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
04350 {
04351   _fields.resize(newSize);
04352 }
04353 
04354 void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
04355 {
04356   if(!field)
04357     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
04358   field->incrRef();
04359   _fields.push_back(field);
04360   appendGlobs(*field,1e-12);
04361 }
04362 
04363 void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
04364 {
04365   if(!field)
04366     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
04367   if(i>=(int)_fields.size())
04368     _fields.resize(i+1);
04369   field->incrRef();
04370   _fields[i]=field;
04371   appendGlobs(*field,1e-12);
04372 }
04373 
04374 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
04375 {
04376   if(i<0 || i>=(int)_fields.size())
04377     {
04378       std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
04379       throw INTERP_KERNEL::Exception(oss.str().c_str());
04380     }
04381   _fields.erase(_fields.begin()+i);
04382 }
04383 
04384 MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
04385 {
04386   if(i<0 || i>=(int)_fields.size())
04387     {
04388       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
04389       throw INTERP_KERNEL::Exception(oss.str().c_str());
04390     }
04391   const MEDFileFieldMultiTSWithoutDAS *fmts=_fields[i];
04392   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts);
04393   ret->shallowCpyGlobs(*this);
04394   ret->incrRef();
04395   return ret;
04396 }
04397 
04398 MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
04399 {
04400   return getFieldAtPos(getPosFromFieldName(fieldName));
04401 }
04402 
04403 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
04404 {
04405   std::string tmp(fieldName);
04406   std::vector<std::string> poss;
04407   for(std::size_t i=0;i<_fields.size();i++)
04408     {
04409       const MEDFileFieldMultiTSWithoutDAS *f=_fields[i];
04410       if(f)
04411         {
04412           std::string fname(f->getName());
04413           if(tmp==fname)
04414             return i;
04415           else
04416             poss.push_back(fname);
04417         }
04418     }
04419   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
04420   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
04421   oss << " !";
04422   throw INTERP_KERNEL::Exception(oss.str().c_str());
04423 }