1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
47 return new MEDFileFieldLoc(fid,locName);
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
52 return new MEDFileFieldLoc(fid,id);
55 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)
57 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
62 med_geometry_type geotype;
63 med_geometry_type sectiongeotype;
65 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
68 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70 _nb_node_per_cell=cm.getNumberOfNodes();
71 _ref_coo.resize(_dim*_nb_node_per_cell);
72 _gs_coo.resize(_dim*_nb_gauss_pt);
73 _w.resize(_nb_gauss_pt);
74 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
79 med_geometry_type geotype;
80 med_geometry_type sectiongeotype;
82 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
87 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89 _nb_node_per_cell=cm.getNumberOfNodes();
90 _ref_coo.resize(_dim*_nb_node_per_cell);
91 _gs_coo.resize(_dim*_nb_gauss_pt);
92 _w.resize(_nb_gauss_pt);
93 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97 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),
100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101 _dim=cm.getDimension();
102 _nb_node_per_cell=cm.getNumberOfNodes();
103 _nb_gauss_pt=_w.size();
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
108 return new MEDFileFieldLoc(*this);
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
113 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
118 static const char OFF7[]="\n ";
119 oss << "\"" << _name << "\"" << OFF7;
120 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121 oss << "Dimension=" << _dim << OFF7;
122 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
129 void MEDFileFieldLoc::setName(const char *name)
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
136 if(_name!=other._name)
140 if(_nb_gauss_pt!=other._nb_gauss_pt)
142 if(_nb_node_per_cell!=other._nb_node_per_cell)
144 if(_geo_type!=other._geo_type)
146 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
148 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
150 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
158 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);
161 std::string MEDFileFieldLoc::repr() const
163 std::ostringstream oss; oss.precision(15);
164 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
166 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
167 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
168 oss << "\n - Ref coords are : ";
169 int sz=_ref_coo.size();
172 int nbOfTuples=sz/_dim;
173 for(int i=0;i<nbOfTuples;i++)
176 for(int j=0;j<_dim;j++)
177 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
182 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183 oss << "\n - Gauss coords in reference element : ";
187 int nbOfTuples=sz/_dim;
188 for(int i=0;i<nbOfTuples;i++)
191 for(int j=0;j<_dim;j++)
192 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
197 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
204 _type=field->getTypeOfField();
210 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211 _end=_start+nbOfCells;
217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218 const int *arrPtr=arr->getConstPointer();
219 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
226 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
230 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233 const int *dai2Ptr=dai2->getConstPointer();
234 int nbi=gsLoc.getWeights().size();
235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237 const int *da3Ptr=da3->getConstPointer();
238 if(da3->getNumberOfTuples()!=nbOfCells)
239 {//profile : for gauss even in NoProfile !!!
240 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
242 da3->setName(_profile.c_str());
243 glob.appendProfile(da3);
245 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246 _nval=da3->getNbOfElems();
247 da4->alloc(_nval*nbi,1);
248 int *da4Ptr=da4->getPointer();
249 for(int i=0;i<_nval;i++)
251 int ref=dai2Ptr[offset+da3Ptr[i]];
252 for(int j=0;j<nbi;j++)
255 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256 _localization=oss2.str();
257 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258 _end=_start+_nval*nbi;
259 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
269 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
271 * \param [in] multiTypePfl is the end user profile specified in high level API
272 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
274 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
280 _type=field->getTypeOfField();
281 std::string pflName(multiTypePfl->getName());
282 std::ostringstream oss; oss << pflName;
283 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288 if(_type!=ON_GAUSS_PT)
290 locIds->setName(oss.str().c_str());
291 glob.appendProfile(locIds);
300 _nval=idsInPfl->getNumberOfTuples();
301 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
307 _nval=idsInPfl->getNumberOfTuples();
308 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
314 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317 arr3->computeOffsets2();
318 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319 int trueNval=tmp->getNumberOfTuples();
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322 _end=_start+trueNval;
327 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
329 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
336 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
339 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
341 for(const int *pt=da4->begin();pt!=da4->end();pt++)
342 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343 tmp->alloc(trueNval,1);
344 int *tmpPtr=tmp->getPointer();
345 for(const int *pt=da4->begin();pt!=da4->end();pt++)
346 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
349 _nval=da4->getNumberOfTuples();
350 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351 _end=_start+trueNval;
352 oss << "_loc_" << _loc_id;
355 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356 da5->setName(oss.str().c_str());
357 glob.appendProfile(da5);
362 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
364 da3->setName(oss.str().c_str());
365 glob.appendProfile(da3);
369 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370 _localization=oss2.str();
371 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
383 _nval=arrr->getNumberOfTuples();
384 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
391 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
396 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
401 return new MEDFileFieldPerMeshPerTypePerDisc(other);
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
406 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
411 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
420 catch(INTERP_KERNEL::Exception& e)
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
443 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
445 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447 std::string fieldName=nasc.getName();
448 std::string meshName=getMeshName();
449 int iteration=getIteration();
450 int order=getOrder();
451 TypeOfField type=getType();
452 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
454 med_geometry_type mgeoti;
455 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457 pflname,&profilesize,locname,&nbi);
458 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
461 _end=start+_nval*nbi;
463 if(type==ON_CELLS && !_localization.empty())
465 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466 setType(ON_GAUSS_PT);
469 setType(ON_GAUSS_NE);
470 _localization.clear();
475 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
477 std::string fieldName=nasc.getName();
478 std::string meshName=getMeshName();
479 int iteration=getIteration();
480 int order=getOrder();
481 TypeOfField type=getType();
482 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483 med_geometry_type mgeoti;
484 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
486 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
489 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
490 if(_start<0 || _start>=arr->getNumberOfTuples())
492 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
493 throw INTERP_KERNEL::Exception(oss.str().c_str());
495 if(_end<0 || _end>arr->getNumberOfTuples())
497 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
498 throw INTERP_KERNEL::Exception(oss.str().c_str());
501 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
502 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
503 int nbOfCompo=arr->getNumberOfComponents();
504 if(_end-_start!=nbValsInFile*nbi)
506 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
507 throw INTERP_KERNEL::Exception(oss.str().c_str());
509 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
512 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
513 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
514 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
517 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
520 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
521 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
522 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
525 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
529 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
531 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
533 int delta=_end-_start;
534 _start=newValueOfStart;
538 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
540 return _father->getIteration();
543 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
545 return _father->getOrder();
548 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
550 return _father->getTime();
553 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
555 return _father->getMeshName();
558 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
560 const char startLine[]=" ## ";
561 std::string startLine2(bkOffset,' ');
562 startLine2+=startLine;
563 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
564 oss << startLine2 << "Localization #" << id << "." << std::endl;
565 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
567 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
568 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
569 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
572 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
577 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
582 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
587 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
589 return _father->getGeoType();
592 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
594 return _father->getNumberOfComponents();
597 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
602 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
604 return _father->getOrCreateAndGetArray();
607 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
609 const MEDFileFieldPerMeshPerType *fath=_father;
610 return fath->getOrCreateAndGetArray();
613 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
615 return _father->getInfo();
618 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
623 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
628 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
630 return _localization;
633 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
635 _localization=newLocName;
638 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
640 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
642 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
644 _profile=(*it2).second;
650 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
652 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
654 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
656 _localization=(*it2).second;
662 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
666 dads.push_back(std::pair<int,int>(_start,_end));
667 geoTypes.push_back(getGeoType());
672 pfls.push_back(glob->getProfile(_profile.c_str()));
674 if(_localization.empty())
678 locs.push_back(glob->getLocalizationId(_localization.c_str()));
682 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
684 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));
688 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
690 TypeOfField type=getType();
691 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
692 med_geometry_type mgeoti;
693 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
694 const DataArray *arr=getOrCreateAndGetArray();
696 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
697 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
698 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
699 const unsigned char *locToWrite=0;
701 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
703 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
705 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
706 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
707 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
711 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
716 dad.first=_start; dad.second=_end;
720 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
721 * This code corresponds to the distribution of types in the corresponding mesh.
722 * \param [out] ptToFill memory zone where the output will be stored.
723 * \return the size of data pushed into output param \a ptToFill
725 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
728 std::ostringstream oss;
729 std::size_t nbOfType=codeOfMesh.size()/3;
731 for(std::size_t i=0;i<nbOfType && found==-1;i++)
732 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
736 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
737 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
738 throw INTERP_KERNEL::Exception(oss.str().c_str());
743 if(_nval!=codeOfMesh[3*found+1])
745 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
746 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
747 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
748 throw INTERP_KERNEL::Exception(oss.str().c_str());
750 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
755 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
756 if(pfl->getNumberOfTuples()!=_nval)
758 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
759 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
761 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
762 throw INTERP_KERNEL::Exception(oss.str().c_str());
764 int offset2=codeOfMesh[3*found+2];
765 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
767 if(*pflId<codeOfMesh[3*found+1])
768 *work++=offset2+*pflId;
774 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
776 for(int i=_start;i<_end;i++)
781 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
792 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
796 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
799 std::map<std::pair<std::string,TypeOfField>,int> m;
800 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
801 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
802 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
803 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
805 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
806 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
811 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
813 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
814 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
815 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
816 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
817 * \param [in,out] glob if necessary by the method, new profiles can be added to it
818 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
819 * \param [out] result All new entries will be appended on it.
820 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
822 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
823 const DataArrayInt *explicitIdsInMesh,
824 const std::vector<int>& newCode,
825 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
826 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
828 if(entriesOnSameDisc.empty())
830 TypeOfField type=entriesOnSameDisc[0]->getType();
831 int szEntities=0,szTuples=0;
832 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
833 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
834 int nbi=szTuples/szEntities;
835 if(szTuples%szEntities!=0)
836 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
839 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
840 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
841 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
842 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
843 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
845 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
847 int startOfEltIdOfChunk=(*it)->_start;
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
853 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
855 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
856 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
858 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
859 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
865 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
866 arrPart->renumberInPlace(renumTupleIds->begin());
867 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
869 const int *idIt=diffVals->begin();
870 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
872 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
874 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
875 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
876 int nbEntityElts=subIds->getNumberOfTuples();
878 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
879 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
883 result.push_back(eltToAdd);
884 offset2+=nbEntityElts*nbi;
886 ret=ret || li.empty();
891 * \param [in] typeF type of field of new chunk
892 * \param [in] geoType the geometric type of the chunk
893 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
894 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
895 * \param [in] nbi number of integration points
896 * \param [in] offset The offset in the **global array of data**.
897 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
898 * to the new chunk to create.
899 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
900 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
901 * and corresponding entry erased from \a entriesOnSameDisc.
902 * \return a newly allocated chunk
904 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
905 bool isPfl, int nbi, int offset,
906 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
907 MEDFileFieldGlobsReal& glob,
908 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
910 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
911 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
912 for(;it!=entriesOnSameDisc.end();it++)
914 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
918 if((*it)->_profile.empty())
921 if(!(*it)->_profile.empty())
923 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
924 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
930 if(it==entriesOnSameDisc.end())
933 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
935 ret->_loc_id=(int)geoType;
936 ret->_nval=nbMeshEntities;
938 ret->_end=ret->_start+ret->_nval*nbi;
941 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
942 glob.appendProfile(idsOfMeshElt);
943 ret->_profile=idsOfMeshElt->getName();
945 //tony treatment of localization
951 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
952 ret->_loc_id=(int)geoType;
953 ret->setNewStart(offset);
954 entriesOnSameDisc.erase(it);
960 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
962 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
965 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
967 return new MEDFileFieldPerMeshPerType(fath,geoType);
970 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
972 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
973 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
974 ret+=(*it)->getHeapMemorySize();
978 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
980 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
983 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
985 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
986 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
991 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
993 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
994 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
995 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
999 * This method is the most general one. No optimization is done here.
1000 * \param [in] multiTypePfl is the end user profile specified in high level API
1001 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1002 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1003 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1004 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1005 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1007 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1009 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1010 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1011 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1014 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1016 _field_pm_pt_pd.resize(1);
1017 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1018 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1021 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1023 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1025 _field_pm_pt_pd.resize(1);
1026 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1027 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1030 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1032 TypeOfField type=field->getTypeOfField();
1033 if(type!=ON_GAUSS_PT)
1035 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1036 int sz=_field_pm_pt_pd.size();
1038 for(int j=0;j<sz && !found;j++)
1040 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1042 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1048 _field_pm_pt_pd.resize(sz+1);
1049 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1051 std::vector<int> ret(1,0);
1056 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1057 int sz2=ret2.size();
1058 std::vector<int> ret3(sz2);
1060 for(int i=0;i<sz2;i++)
1062 int sz=_field_pm_pt_pd.size();
1063 int locIdToFind=ret2[i];
1065 for(int j=0;j<sz && !found;j++)
1067 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1069 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1076 _field_pm_pt_pd.resize(sz+1);
1077 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1085 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1087 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1088 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1090 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1091 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1093 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1094 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1095 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1096 if(retTmp->presenceOfValue(-1))
1097 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1098 std::vector<int> ret(retTmp->begin(),retTmp->end());
1102 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1104 TypeOfField type=field->getTypeOfField();
1105 if(type!=ON_GAUSS_PT)
1107 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1108 int sz=_field_pm_pt_pd.size();
1110 for(int j=0;j<sz && !found;j++)
1112 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1114 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1120 _field_pm_pt_pd.resize(sz+1);
1121 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1123 std::vector<int> ret(1,0);
1128 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1129 int sz2=ret2.size();
1130 std::vector<int> ret3(sz2);
1132 for(int i=0;i<sz2;i++)
1134 int sz=_field_pm_pt_pd.size();
1135 int locIdToFind=ret2[i];
1137 for(int j=0;j<sz && !found;j++)
1139 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1141 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1148 _field_pm_pt_pd.resize(sz+1);
1149 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1157 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1159 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1160 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1162 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1163 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1165 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1166 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1167 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1168 if(retTmp->presenceOfValue(-1))
1169 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1170 std::vector<int> ret(retTmp->begin(),retTmp->end());
1174 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1179 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1181 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1182 int curDim=(int)cm.getDimension();
1183 dim=std::max(dim,curDim);
1186 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1188 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1190 (*it)->fillTypesOfFieldAvailable(types);
1194 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)
1196 int sz=_field_pm_pt_pd.size();
1197 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1198 for(int i=0;i<sz;i++)
1200 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1204 int MEDFileFieldPerMeshPerType::getIteration() const
1206 return _father->getIteration();
1209 int MEDFileFieldPerMeshPerType::getOrder() const
1211 return _father->getOrder();
1214 double MEDFileFieldPerMeshPerType::getTime() const
1216 return _father->getTime();
1219 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1221 return _father->getMeshName();
1224 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1226 const char startLine[]=" ## ";
1227 std::string startLine2(bkOffset,' ');
1228 std::string startLine3(startLine2);
1229 startLine3+=startLine;
1230 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1232 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1233 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1236 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1237 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1239 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1241 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1243 cur->simpleRepr(bkOffset,oss,i);
1246 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1251 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1253 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1255 globalSz+=(*it)->getNumberOfTuples();
1257 nbOfEntries+=(int)_field_pm_pt_pd.size();
1260 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1266 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1268 return _father->getNumberOfComponents();
1271 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1273 return _father->getOrCreateAndGetArray();
1276 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1278 const MEDFileFieldPerMesh *fath=_father;
1279 return fath->getOrCreateAndGetArray();
1282 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1284 return _father->getInfo();
1287 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1289 std::vector<std::string> ret;
1290 std::set<std::string> ret2;
1291 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1293 std::string tmp=(*it1)->getProfile();
1295 if(ret2.find(tmp)==ret2.end())
1304 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1306 std::vector<std::string> ret;
1307 std::set<std::string> ret2;
1308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1310 std::string tmp=(*it1)->getLocalization();
1311 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1312 if(ret2.find(tmp)==ret2.end())
1321 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1323 std::vector<std::string> ret;
1324 std::set<std::string> ret2;
1325 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1327 std::string tmp=(*it1)->getProfile();
1334 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1336 std::vector<std::string> ret;
1337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1339 std::string tmp=(*it1)->getLocalization();
1340 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1346 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1349 (*it1)->changePflsRefsNamesGen(mapOfModif);
1352 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1354 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1355 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1358 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1360 if(_field_pm_pt_pd.empty())
1362 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1363 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1364 throw INTERP_KERNEL::Exception(oss.str().c_str());
1366 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1367 return _field_pm_pt_pd[locId];
1368 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1369 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1370 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1371 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1372 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1375 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1377 if(_field_pm_pt_pd.empty())
1379 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1380 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1381 throw INTERP_KERNEL::Exception(oss.str().c_str());
1383 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1384 return _field_pm_pt_pd[locId];
1385 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1386 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1387 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1388 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1389 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1392 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1394 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1396 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1397 if(meshDim!=(int)cm.getDimension())
1400 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1401 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1404 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1407 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1409 (*it)->fillValues(i,startEntryId,entries);
1413 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1415 _field_pm_pt_pd=leaves;
1416 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1417 (*it)->setFather(this);
1420 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1424 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1426 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1427 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1428 med_geometry_type mgeoti;
1429 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1430 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1431 _field_pm_pt_pd.resize(nbProfiles);
1432 for(int i=0;i<nbProfiles;i++)
1434 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1438 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1441 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1443 (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1447 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1450 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1452 (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1456 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1458 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1460 (*it)->copyOptionsFrom(*this);
1461 (*it)->writeLL(fid,nasc);
1465 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1470 medfGeoType=typmai3[(int)ikGeoType];
1473 medfGeoType=MED_NONE;
1476 medfGeoType=typmai3[(int)ikGeoType];
1477 return MED_NODE_ELEMENT;
1479 medfGeoType=typmai3[(int)ikGeoType];
1482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1484 return MED_UNDEF_ENTITY_TYPE;
1487 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1489 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1492 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1494 return new MEDFileFieldPerMesh(fath,mesh);
1497 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1499 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1500 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1501 if((const MEDFileFieldPerMeshPerType *)*it)
1502 ret+=(*it)->getHeapMemorySize();
1506 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1508 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1509 ret->_father=father;
1511 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1513 if((const MEDFileFieldPerMeshPerType *)*it)
1514 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1519 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1521 std::string startLine(bkOffset,' ');
1522 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1523 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1525 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1527 const MEDFileFieldPerMeshPerType *cur=*it;
1529 cur->simpleRepr(bkOffset,oss,i);
1532 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1537 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1539 _mesh_name=mesh->getName();
1540 mesh->getTime(_mesh_iteration,_mesh_order);
1543 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1545 int nbOfTypes=code.size()/3;
1547 for(int i=0;i<nbOfTypes;i++)
1549 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1550 int nbOfCells=code[3*i+1];
1551 int pos=addNewEntryIfNecessary(type);
1552 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1558 * This method is the most general one. No optimization is done here.
1559 * \param [in] multiTypePfl is the end user profile specified in high level API
1560 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1561 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1562 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1563 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1564 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1566 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1568 int nbOfTypes=code.size()/3;
1569 for(int i=0;i<nbOfTypes;i++)
1571 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1572 int pos=addNewEntryIfNecessary(type);
1573 DataArrayInt *pfl=0;
1575 pfl=idsPerType[code[3*i+2]];
1576 int nbOfTupes2=code2.size()/3;
1578 for(;found<nbOfTupes2;found++)
1579 if(code[3*i]==code2[3*found])
1581 if(found==nbOfTupes2)
1582 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1583 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1587 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1589 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1590 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1593 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1595 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1596 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1599 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1601 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1602 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1605 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1607 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1608 (*it)->loadBigArraysRecursively(fid,nasc);
1611 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1613 int nbOfTypes=_field_pm_pt.size();
1614 for(int i=0;i<nbOfTypes;i++)
1616 _field_pm_pt[i]->copyOptionsFrom(*this);
1617 _field_pm_pt[i]->writeLL(fid,nasc);
1621 void MEDFileFieldPerMesh::getDimension(int& dim) const
1623 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1624 (*it)->getDimension(dim);
1627 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1629 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1630 (*it)->fillTypesOfFieldAvailable(types);
1633 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)
1635 int sz=_field_pm_pt.size();
1636 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1637 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1638 for(int i=0;i<sz;i++)
1640 types[i]=_field_pm_pt[i]->getGeoType();
1641 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1646 double MEDFileFieldPerMesh::getTime() const
1649 return _father->getTime(tmp1,tmp2);
1652 int MEDFileFieldPerMesh::getIteration() const
1654 return _father->getIteration();
1657 int MEDFileFieldPerMesh::getOrder() const
1659 return _father->getOrder();
1662 int MEDFileFieldPerMesh::getNumberOfComponents() const
1664 return _father->getNumberOfComponents();
1667 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1670 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1671 return _father->getOrCreateAndGetArray();
1674 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1677 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1678 return _father->getOrCreateAndGetArray();
1681 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1683 return _father->getInfo();
1687 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1688 * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1689 * It returns 2 output vectors :
1690 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1691 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1692 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1694 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *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)
1696 int notNullPflsSz=0;
1697 int nbOfArrs=geoTypes.size();
1698 for(int i=0;i<nbOfArrs;i++)
1701 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1702 int nbOfDiffGeoTypes=geoTypes3.size();
1703 code.resize(3*nbOfDiffGeoTypes);
1704 notNullPfls.resize(notNullPflsSz);
1707 for(int i=0;i<nbOfDiffGeoTypes;i++)
1710 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1711 std::vector<const DataArrayInt *> notNullTmp;
1713 notNullTmp.push_back(pfls[j]);
1715 for(;j<nbOfArrs;j++)
1716 if(geoTypes[j]==refType)
1719 notNullTmp.push_back(pfls[j]);
1723 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1724 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1725 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1726 code[3*i]=(int)refType;
1727 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1728 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1729 if(notNullTmp.empty())
1733 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1734 code[3*i+2]=notNullPflsSz++;
1740 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1742 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *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)
1746 for(int i=0;i<sz;i++)
1750 if(type!=ON_GAUSS_NE)
1751 ret+=dads[i].second-dads[i].first;
1754 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1755 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1760 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1761 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1767 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1769 std::vector<std::string> ret;
1770 std::set<std::string> ret2;
1771 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1773 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1774 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1775 if(ret2.find(*it2)==ret2.end())
1777 ret.push_back(*it2);
1784 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1786 std::vector<std::string> ret;
1787 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1789 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1790 ret.insert(ret.end(),tmp.begin(),tmp.end());
1795 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1797 std::vector<std::string> ret;
1798 std::set<std::string> ret2;
1799 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1801 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1802 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1803 if(ret2.find(*it2)==ret2.end())
1805 ret.push_back(*it2);
1812 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1814 std::vector<std::string> ret;
1815 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1817 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1818 ret.insert(ret.end(),tmp.begin(),tmp.end());
1823 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1825 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1827 if((*it).first==_mesh_name)
1829 _mesh_name=(*it).second;
1836 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1837 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1839 if(_mesh_name!=meshName)
1841 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1842 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1843 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1844 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1845 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1846 getUndergroundDataArrayExt(entries);
1847 DataArray *arr0=getOrCreateAndGetArray();//tony
1849 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1850 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1852 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1855 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1856 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1858 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1860 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1861 sz+=(*it).second.second-(*it).second.first;
1864 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1866 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1867 ////////////////////
1868 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1869 int *workI2=explicitIdsOldInMesh->getPointer();
1870 int sz1=0,sz2=0,sid=1;
1871 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1872 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1873 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1875 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1876 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1877 int *workI=explicitIdsOldInArr->getPointer();
1878 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1880 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1881 (*itL2)->setLocId(sz2);
1882 (*itL2)->_tmp_work1=(*itL2)->getStart();
1883 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1885 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1887 explicitIdsOldInMesh->reAlloc(sz2);
1888 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1889 ////////////////////
1890 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1891 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1892 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1893 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1895 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1896 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1897 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1899 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1900 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1901 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1903 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1904 int newStart=elt->getLocId();
1905 elt->setLocId((*it)->getGeoType());
1906 elt->setNewStart(newStart);
1907 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1908 entriesKeptNew.push_back(elt);
1909 entriesKeptNew2.push_back(elt);
1911 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1912 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1913 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1914 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1916 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1919 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1921 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1922 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1924 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1925 glob,arr2,otherEntriesNew) || ret;
1929 // Assign new dispatching
1930 assignNewLeaves(otherEntriesNew);
1931 arr->cpyFrom(*arr2);
1935 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1937 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1938 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1939 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1941 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1942 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1943 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1944 for(;it1!=types.end();it1++,it2++)
1946 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1947 elt->setLeaves((*it1).second);
1950 _field_pm_pt=fieldPmPt;
1953 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1955 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1956 (*it)->changePflsRefsNamesGen(mapOfModif);
1959 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1961 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1962 (*it)->changeLocsRefsNamesGen(mapOfModif);
1966 * \param [in] mesh is the whole mesh
1968 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1970 if(_field_pm_pt.empty())
1971 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1973 std::vector< std::pair<int,int> > dads;
1974 std::vector<const DataArrayInt *> pfls;
1975 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1976 std::vector<int> locs,code;
1977 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1978 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1979 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1981 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1984 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1985 throw INTERP_KERNEL::Exception(oss.str().c_str());
1988 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1989 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1992 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1994 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1997 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1998 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2004 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2008 if(nb!=mesh->getNumberOfNodes())
2010 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2011 oss << " nodes in mesh !";
2012 throw INTERP_KERNEL::Exception(oss.str().c_str());
2014 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2017 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2021 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2023 if(_field_pm_pt.empty())
2024 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2026 std::vector<std::pair<int,int> > dads;
2027 std::vector<const DataArrayInt *> pfls;
2028 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2029 std::vector<int> locs,code;
2030 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2031 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2032 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2034 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2037 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2038 throw INTERP_KERNEL::Exception(oss.str().c_str());
2040 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2041 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2044 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2045 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2050 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2054 if(nb!=mesh->getNumberOfNodes())
2056 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2057 oss << " nodes in mesh !";
2058 throw INTERP_KERNEL::Exception(oss.str().c_str());
2061 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2067 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2071 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2073 (*it)->getSizes(globalSz,nbOfEntries);
2075 entries.resize(nbOfEntries);
2077 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2079 (*it)->fillValues(nbOfEntries,entries);
2083 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2085 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2087 if((*it)->getGeoType()==typ)
2088 return (*it)->getLeafGivenLocId(locId);
2090 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2091 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2092 oss << "Possiblities are : ";
2093 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2095 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2096 oss << "\"" << cm2.getRepr() << "\", ";
2098 throw INTERP_KERNEL::Exception(oss.str().c_str());
2101 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 if((*it)->getGeoType()==typ)
2106 return (*it)->getLeafGivenLocId(locId);
2108 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2109 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2110 oss << "Possiblities are : ";
2111 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2113 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2114 oss << "\"" << cm2.getRepr() << "\", ";
2116 throw INTERP_KERNEL::Exception(oss.str().c_str());
2119 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2122 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2123 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2124 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2126 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2131 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2136 int ret=std::distance(_field_pm_pt.begin(),it2);
2137 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2142 * 'dads' and 'locs' input parameters have the same number of elements
2143 * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2145 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2146 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2147 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2150 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2151 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2152 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2153 const std::vector<std::string>& infos=getInfo();
2154 da->setInfoOnComponents(infos);
2156 if(type==ON_GAUSS_PT)
2159 int nbOfArrs=dads.size();
2160 for(int i=0;i<nbOfArrs;i++)
2162 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2163 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2164 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2165 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2166 di->alloc(nbOfElems,1);
2168 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2169 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2178 * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2179 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2180 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2181 * The order of cells in the returned field is those imposed by the profile.
2182 * \param [in] mesh is the global mesh.
2184 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2185 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2186 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2187 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2189 if(da->isIdentity())
2191 int nbOfTuples=da->getNumberOfTuples();
2192 if(nbOfTuples==mesh->getNumberOfCells())
2193 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2195 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2196 m2->setName(mesh->getName());
2197 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2203 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2205 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2206 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2207 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2209 if(da->isIdentity())
2211 int nbOfTuples=da->getNumberOfTuples();
2212 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2213 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2215 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2216 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2219 if(meshu->getNodalConnectivity()==0)
2221 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2222 int nb=da->getNbOfElems();
2223 const int *ptr=da->getConstPointer();
2224 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2225 meshuc->allocateCells(nb);
2226 for(int i=0;i<nb;i++)
2227 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2228 meshuc->finishInsertingCells();
2229 ret->setMesh(meshuc);
2230 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2231 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2232 disc->checkCoherencyBetween(meshuc,arrOut);
2237 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2239 DataArrayInt *arr2=0;
2240 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2241 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2243 int nnodes=mesh2->getNumberOfNodes();
2244 if(nnodes==(int)da->getNbOfElems())
2246 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2247 arrOut->renumberInPlace(da3->getConstPointer());
2248 mesh2->setName(mesh->getName());
2249 ret->setMesh(mesh2);
2254 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : 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 !!!";
2255 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2256 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2257 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2258 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2259 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2260 throw INTERP_KERNEL::Exception(oss.str().c_str());
2266 * This method is the most light method of field retrieving.
2268 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2272 pflOut=DataArrayInt::New();
2273 pflOut->alloc(nbOfElems,1);
2278 pflOut=const_cast<DataArrayInt*>(pflIn);
2281 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2282 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2283 const std::vector<std::string>& infos=getInfo();
2284 int nbOfComp=infos.size();
2285 for(int i=0;i<nbOfComp;i++)
2286 da->setInfoOnComponent(i,infos[i].c_str());
2291 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2292 _mesh_csit(meshCsit),_father(fath)
2294 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2295 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2296 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2297 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2299 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2302 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2303 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2305 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2308 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2309 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2312 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2315 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2316 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2320 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2322 copyTinyInfoFrom(mesh);
2325 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2327 if(id>=(int)_pfls.size())
2329 _pfls[id]=DataArrayInt::New();
2330 int lgth=MEDprofileSizeByName(fid,pflName);
2331 _pfls[id]->setName(pflName);
2332 _pfls[id]->alloc(lgth,1);
2333 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2334 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2337 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2339 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2341 MEDprofileInfo(fid,i+1,pflName,&sz);
2342 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2343 if(i>=(int)_pfls.size())
2345 _pfls[i]=DataArrayInt::New();
2346 _pfls[i]->alloc(sz,1);
2347 _pfls[i]->setName(pflCpp.c_str());
2348 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2349 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2352 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2354 int nbOfPfls=_pfls.size();
2355 for(int i=0;i<nbOfPfls;i++)
2357 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2358 cpy->applyLin(1,1,0);
2359 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2360 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2361 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2364 int nbOfLocs=_locs.size();
2365 for(int i=0;i<nbOfLocs;i++)
2366 _locs[i]->writeLL(fid);
2369 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2371 std::vector<std::string> pfls=getPfls();
2372 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2374 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2377 _pfls.push_back(*it);
2381 int id=std::distance(pfls.begin(),it2);
2382 if(!(*it)->isEqual(*_pfls[id]))
2384 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2385 throw INTERP_KERNEL::Exception(oss.str().c_str());
2389 std::vector<std::string> locs=getLocs();
2390 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2392 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2395 _locs.push_back(*it);
2399 int id=std::distance(locs.begin(),it2);
2400 if(!(*it)->isEqual(*_locs[id],eps))
2402 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2403 throw INTERP_KERNEL::Exception(oss.str().c_str());
2409 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2411 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2412 getProfile((*it).c_str());
2415 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2417 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2418 getLocalization((*it).c_str());
2421 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2423 std::vector<std::string> profiles=real.getPflsReallyUsed();
2424 int sz=profiles.size();
2426 for(int i=0;i<sz;i++)
2427 loadProfileInFile(fid,i,profiles[i].c_str());
2429 std::vector<std::string> locs=real.getLocsReallyUsed();
2432 for(int i=0;i<sz;i++)
2433 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2436 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2438 int nProfil=MEDnProfile(fid);
2439 for(int i=0;i<nProfil;i++)
2440 loadProfileInFile(fid,i);
2441 int sz=MEDnLocalization(fid);
2443 for(int i=0;i<sz;i++)
2445 _locs[i]=MEDFileFieldLoc::New(fid,i);
2449 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2451 return new MEDFileFieldGlobs(fname);
2454 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2456 return new MEDFileFieldGlobs;
2459 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2461 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2462 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2463 ret+=(*it)->getHeapMemorySize();
2464 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2465 ret+=(*it)->getHeapMemorySize();
2469 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2471 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2473 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2475 if((const DataArrayInt *)*it)
2476 ret->_pfls[i]=(*it)->deepCpy();
2479 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2481 if((const MEDFileFieldLoc*)*it)
2482 ret->_locs[i]=(*it)->deepCpy();
2488 * \throw if a profile in \a pfls in not in \a this.
2489 * \throw if a localization in \a locs in not in \a this.
2490 * \sa MEDFileFieldGlobs::deepCpyPart
2492 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2494 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2495 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2497 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2499 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2501 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2502 ret->_pfls.push_back(pfl2);
2504 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2506 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2508 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2510 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2511 ret->_locs.push_back(loc2);
2513 ret->setFileName(getFileName());
2518 * \throw if a profile in \a pfls in not in \a this.
2519 * \throw if a localization in \a locs in not in \a this.
2520 * \sa MEDFileFieldGlobs::shallowCpyPart
2522 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2524 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2525 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2527 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2529 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2530 ret->_pfls.push_back(pfl->deepCpy());
2532 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2534 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2536 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2537 ret->_locs.push_back(loc->deepCpy());
2539 ret->setFileName(getFileName());
2543 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2547 MEDFileFieldGlobs::MEDFileFieldGlobs()
2551 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2555 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2557 oss << "Profiles :\n";
2558 std::size_t n=_pfls.size();
2559 for(std::size_t i=0;i<n;i++)
2561 oss << " - #" << i << " ";
2562 const DataArrayInt *pfl=_pfls[i];
2564 oss << "\"" << pfl->getName() << "\"\n";
2569 oss << "Localizations :\n";
2570 for(std::size_t i=0;i<n;i++)
2572 oss << " - #" << i << " ";
2573 const MEDFileFieldLoc *loc=_locs[i];
2575 loc->simpleRepr(oss);
2581 void MEDFileFieldGlobs::setFileName(const char *fileName)
2583 _file_name=fileName;
2586 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2588 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2590 DataArrayInt *elt(*it);
2593 std::string name(elt->getName());
2594 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2596 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2598 elt->setName((*it2).second.c_str());
2606 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2608 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2610 MEDFileFieldLoc *elt(*it);
2613 std::string name(elt->getName());
2614 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2616 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2618 elt->setName((*it2).second.c_str());
2626 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2628 if(locId<0 || locId>=(int)_locs.size())
2629 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2630 return _locs[locId]->getNbOfGaussPtPerCell();
2633 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2635 return getLocalizationFromId(getLocalizationId(locName));
2638 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2640 if(locId<0 || locId>=(int)_locs.size())
2641 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2642 return *_locs[locId];
2645 namespace ParaMEDMEMImpl
2650 LocFinder(const char *loc):_loc(loc) { }
2651 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2659 PflFinder(const std::string& pfl):_pfl(pfl) { }
2660 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2662 const std::string& _pfl;
2666 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2668 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2671 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2672 for(it=_locs.begin();it!=_locs.end();it++)
2673 oss << "\"" << (*it)->getName() << "\", ";
2674 throw INTERP_KERNEL::Exception(oss.str().c_str());
2676 return std::distance(_locs.begin(),it);
2680 * The returned value is never null.
2682 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2684 std::string pflNameCpp(pflName);
2685 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2688 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2689 for(it=_pfls.begin();it!=_pfls.end();it++)
2690 oss << "\"" << (*it)->getName() << "\", ";
2691 throw INTERP_KERNEL::Exception(oss.str().c_str());
2696 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2698 if(pflId<0 || pflId>=(int)_pfls.size())
2699 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2700 return _pfls[pflId];
2703 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2705 if(locId<0 || locId>=(int)_locs.size())
2706 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2707 return *_locs[locId];
2710 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2712 return getLocalizationFromId(getLocalizationId(locName));
2716 * The returned value is never null.
2718 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2720 std::string pflNameCpp(pflName);
2721 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2724 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2725 for(it=_pfls.begin();it!=_pfls.end();it++)
2726 oss << "\"" << (*it)->getName() << "\", ";
2727 throw INTERP_KERNEL::Exception(oss.str().c_str());
2732 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2734 if(pflId<0 || pflId>=(int)_pfls.size())
2735 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2736 return _pfls[pflId];
2739 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2741 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2743 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2745 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2746 newPfls.push_back(*it);
2751 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2753 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2755 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2757 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2758 newLocs.push_back(*it);
2763 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2765 int sz=_pfls.size();
2766 std::vector<std::string> ret(sz);
2767 for(int i=0;i<sz;i++)
2768 ret[i]=_pfls[i]->getName();
2772 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2774 int sz=_locs.size();
2775 std::vector<std::string> ret(sz);
2776 for(int i=0;i<sz;i++)
2777 ret[i]=_locs[i]->getName();
2781 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2783 std::vector<std::string> v=getPfls();
2784 std::string s(pflName);
2785 return std::find(v.begin(),v.end(),s)!=v.end();
2788 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2790 std::vector<std::string> v=getLocs();
2791 std::string s(locName);
2792 return std::find(v.begin(),v.end(),s)!=v.end();
2795 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2797 std::map<int,std::vector<int> > m;
2799 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2801 const DataArrayInt *tmp=(*it);
2804 m[tmp->getHashCode()].push_back(i);
2807 std::vector< std::vector<int> > ret;
2808 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2810 if((*it2).second.size()>1)
2812 std::vector<int> ret0;
2813 bool equalityOrNot=false;
2814 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2816 std::vector<int>::const_iterator it4=it3; it4++;
2817 for(;it4!=(*it2).second.end();it4++)
2819 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2822 ret0.push_back(*it3);
2823 ret0.push_back(*it4);
2829 ret.push_back(ret0);
2835 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2837 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2840 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2842 std::string name(pfl->getName());
2844 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2845 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2846 if(name==(*it)->getName())
2848 if(!pfl->isEqual(*(*it)))
2850 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2851 throw INTERP_KERNEL::Exception(oss.str().c_str());
2855 _pfls.push_back(pfl);
2858 void MEDFileFieldGlobs::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)
2860 std::string name(locName);
2862 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2863 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2864 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2865 if((*it)->isName(locName))
2867 if(!(*it)->isEqual(*obj,1e-12))
2869 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2870 throw INTERP_KERNEL::Exception(oss.str().c_str());
2873 _locs.push_back(obj);
2876 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2878 std::vector<std::string> names=getPfls();
2879 return CreateNewNameNotIn("NewPfl_",names);
2882 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2884 std::vector<std::string> names=getLocs();
2885 return CreateNewNameNotIn("NewLoc_",names);
2888 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2890 for(std::size_t sz=0;sz<100000;sz++)
2892 std::ostringstream tryName;
2893 tryName << prefix << sz;
2894 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2895 return tryName.str();
2897 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2901 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2902 * \param [in] fname - the file name.
2904 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2909 * Creates an empty MEDFileFieldGlobsReal.
2911 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2915 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2918 if((const MEDFileFieldGlobs *)_globals)
2919 ret+=_globals->getHeapMemorySize();
2924 * Returns a string describing profiles and Gauss points held in \a this.
2925 * \return std::string - the description string.
2927 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2929 const MEDFileFieldGlobs *glob=_globals;
2930 std::ostringstream oss2; oss2 << glob;
2931 std::string stars(oss2.str().length(),'*');
2932 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2934 glob->simpleRepr(oss);
2936 oss << "NO GLOBAL INFORMATION !\n";
2939 void MEDFileFieldGlobsReal::resetContent()
2941 _globals=MEDFileFieldGlobs::New();
2944 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2949 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2950 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2952 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2954 _globals=other._globals;
2958 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2959 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2961 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2963 const MEDFileFieldGlobs *otherg(other._globals);
2966 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2970 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2971 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2973 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2975 const MEDFileFieldGlobs *otherg(other._globals);
2978 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2981 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2983 _globals=other._globals;
2984 if((const MEDFileFieldGlobs *)_globals)
2985 _globals=other._globals->deepCpy();
2989 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
2990 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
2991 * \param [in] eps - a precision used to compare Gauss points with same name held by
2992 * \a this and \a other MEDFileFieldGlobsReal.
2993 * \throw If \a this and \a other hold profiles with equal names but different ids.
2994 * \throw If \a this and \a other hold different Gauss points with equal names.
2996 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2998 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
2999 if(thisGlobals==otherGlobals)
3003 _globals=other._globals;
3006 _globals->appendGlobs(*other._globals,eps);
3009 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3011 checkGlobsPflsPartCoherency();
3012 checkGlobsLocsPartCoherency();
3015 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3017 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3020 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3022 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3025 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3027 contentNotNull()->loadProfileInFile(fid,id,pflName);
3030 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3032 contentNotNull()->loadProfileInFile(fid,id);
3035 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3037 contentNotNull()->loadGlobals(fid,*this);
3040 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3042 contentNotNull()->loadAllGlobals(fid);
3045 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3047 contentNotNull()->writeGlobals(fid,opt);
3051 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3052 * or getPflsReallyUsedMulti().
3053 * \return std::vector<std::string> - a sequence of names of all profiles.
3055 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3057 return contentNotNull()->getPfls();
3061 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3062 * or getLocsReallyUsedMulti().
3063 * \return std::vector<std::string> - a sequence of names of all localizations.
3065 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3067 return contentNotNull()->getLocs();
3071 * Checks if the profile with a given name exists.
3072 * \param [in] pflName - the profile name of interest.
3073 * \return bool - \c true if the profile named \a pflName exists.
3075 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3077 return contentNotNull()->existsPfl(pflName);
3081 * Checks if the localization with a given name exists.
3082 * \param [in] locName - the localization name of interest.
3083 * \return bool - \c true if the localization named \a locName exists.
3085 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3087 return contentNotNull()->existsLoc(locName);
3090 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3092 return contentNotNull()->createNewNameOfPfl();
3095 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3097 return contentNotNull()->createNewNameOfLoc();
3101 * Sets the name of a MED file.
3102 * \param [inout] fileName - the file name.
3104 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3106 contentNotNull()->setFileName(fileName);
3110 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3111 * in the same order.
3112 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3113 * Each item of this sequence is a vector containing ids of equal profiles.
3115 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3117 return contentNotNull()->whichAreEqualProfiles();
3121 * Finds equal localizations.
3122 * \param [in] eps - a precision used to compare real values of the localizations.
3123 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3124 * Each item of this sequence is a vector containing ids of equal localizations.
3126 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3128 return contentNotNull()->whichAreEqualLocs(eps);
3132 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3133 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3134 * this sequence is a pair whose
3135 * - the first item is a vector of profile names to replace by the second item,
3136 * - the second item is a profile name to replace every profile name of the first item.
3138 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3140 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3144 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3145 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3146 * this sequence is a pair whose
3147 * - the first item is a vector of localization names to replace by the second item,
3148 * - the second item is a localization name to replace every localization name of the first item.
3150 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3152 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3156 * Replaces references to some profiles (a reference is a profile name) by references
3157 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3158 * them-selves accordingly. <br>
3159 * This method is a generalization of changePflName().
3160 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3161 * this sequence is a pair whose
3162 * - the first item is a vector of profile names to replace by the second item,
3163 * - the second item is a profile name to replace every profile of the first item.
3164 * \sa changePflsRefsNamesGen()
3165 * \sa changePflName()
3167 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3169 changePflsRefsNamesGen(mapOfModif);
3170 changePflsNamesInStruct(mapOfModif);
3174 * Replaces references to some localizations (a reference is a localization name) by references
3175 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3176 * them-selves accordingly. <br>
3177 * This method is a generalization of changeLocName().
3178 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3179 * this sequence is a pair whose
3180 * - the first item is a vector of localization names to replace by the second item,
3181 * - the second item is a localization name to replace every localization of the first item.
3182 * \sa changeLocsRefsNamesGen()
3183 * \sa changeLocName()
3185 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3187 changeLocsRefsNamesGen(mapOfModif);
3188 changeLocsNamesInStruct(mapOfModif);
3192 * Renames the profile having a given name and updates references to this profile.
3193 * \param [in] oldName - the name of the profile to rename.
3194 * \param [in] newName - a new name of the profile.
3195 * \sa changePflsNames().
3197 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3199 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3200 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3202 changePflsNames(mapOfModif);
3206 * Renames the localization having a given name and updates references to this localization.
3207 * \param [in] oldName - the name of the localization to rename.
3208 * \param [in] newName - a new name of the localization.
3209 * \sa changeLocsNames().
3211 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3213 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3214 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3216 changeLocsNames(mapOfModif);
3220 * Removes duplicated profiles. Returns a map used to update references to removed
3221 * profiles via changePflsRefsNamesGen().
3222 * Equal profiles are found using whichAreEqualProfiles().
3223 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3224 * a sequence describing the performed replacements of profiles. Each element of
3225 * this sequence is a pair whose
3226 * - the first item is a vector of profile names replaced by the second item,
3227 * - the second item is a profile name replacing every profile of the first item.
3229 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3231 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3232 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3234 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3236 std::vector< std::string > tmp((*it).size());
3238 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3239 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3240 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3242 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3243 killProfileIds(tmp2);
3245 changePflsRefsNamesGen(ret);
3250 * Removes duplicated localizations. Returns a map used to update references to removed
3251 * localizations via changeLocsRefsNamesGen().
3252 * Equal localizations are found using whichAreEqualLocs().
3253 * \param [in] eps - a precision used to compare real values of the localizations.
3254 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3255 * a sequence describing the performed replacements of localizations. Each element of
3256 * this sequence is a pair whose
3257 * - the first item is a vector of localization names replaced by the second item,
3258 * - the second item is a localization name replacing every localization of the first item.
3260 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3262 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3263 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3265 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3267 std::vector< std::string > tmp((*it).size());
3269 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3270 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3271 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3273 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3274 killLocalizationIds(tmp2);
3276 changeLocsRefsNamesGen(ret);
3281 * Returns number of Gauss points per cell in a given localization.
3282 * \param [in] locId - an id of the localization of interest.
3283 * \return int - the number of the Gauss points per cell.
3285 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3287 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3291 * Returns an id of a localization by its name.
3292 * \param [in] loc - the localization name of interest.
3293 * \return int - the id of the localization.
3294 * \throw If there is no a localization named \a loc.
3296 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3298 return contentNotNull()->getLocalizationId(loc);
3302 * Returns the name of the MED file.
3303 * \return const char * - the MED file name.
3305 const char *MEDFileFieldGlobsReal::getFileName() const
3307 return contentNotNull()->getFileName();
3310 std::string MEDFileFieldGlobsReal::getFileName2() const
3312 return contentNotNull()->getFileName2();
3316 * Returns a localization object by its name.
3317 * \param [in] locName - the name of the localization of interest.
3318 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3319 * \throw If there is no a localization named \a locName.
3321 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3323 return contentNotNull()->getLocalization(locName);
3327 * Returns a localization object by its id.
3328 * \param [in] locId - the id of the localization of interest.
3329 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3330 * \throw If there is no a localization with id \a locId.
3332 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3334 return contentNotNull()->getLocalizationFromId(locId);
3338 * Returns a profile array by its name.
3339 * \param [in] pflName - the name of the profile of interest.
3340 * \return const DataArrayInt * - the profile array having the name \a pflName.
3341 * \throw If there is no a profile named \a pflName.
3343 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3345 return contentNotNull()->getProfile(pflName);
3349 * Returns a profile array by its id.
3350 * \param [in] pflId - the id of the profile of interest.
3351 * \return const DataArrayInt * - the profile array having the id \a pflId.
3352 * \throw If there is no a profile with id \a pflId.
3354 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3356 return contentNotNull()->getProfileFromId(pflId);
3360 * Returns a localization object, apt for modification, by its id.
3361 * \param [in] locId - the id of the localization of interest.
3362 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3363 * having the id \a locId.
3364 * \throw If there is no a localization with id \a locId.
3366 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3368 return contentNotNull()->getLocalizationFromId(locId);
3372 * Returns a localization object, apt for modification, by its name.
3373 * \param [in] locName - the name of the localization of interest.
3374 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3375 * having the name \a locName.
3376 * \throw If there is no a localization named \a locName.
3378 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3380 return contentNotNull()->getLocalization(locName);
3384 * Returns a profile array, apt for modification, by its name.
3385 * \param [in] pflName - the name of the profile of interest.
3386 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3387 * \throw If there is no a profile named \a pflName.
3389 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3391 return contentNotNull()->getProfile(pflName);
3395 * Returns a profile array, apt for modification, by its id.
3396 * \param [in] pflId - the id of the profile of interest.
3397 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3398 * \throw If there is no a profile with id \a pflId.
3400 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3402 return contentNotNull()->getProfileFromId(pflId);
3406 * Removes profiles given by their ids. No data is updated to track this removal.
3407 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3409 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3411 contentNotNull()->killProfileIds(pflIds);
3415 * Removes localizations given by their ids. No data is updated to track this removal.
3416 * \param [in] locIds - a sequence of ids of the localizations to remove.
3418 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3420 contentNotNull()->killLocalizationIds(locIds);
3424 * Stores a profile array.
3425 * \param [in] pfl - the profile array to store.
3426 * \throw If the name of \a pfl is empty.
3427 * \throw If a profile with the same name as that of \a pfl already exists but contains
3430 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3432 contentNotNull()->appendProfile(pfl);
3436 * Adds a new localization of Gauss points.
3437 * \param [in] locName - the name of the new localization.
3438 * \param [in] geoType - a geometrical type of the reference cell.
3439 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3440 * must be \c nbOfNodesPerCell * \c dimOfType.
3441 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3442 * must be _wg_.size() * \c dimOfType.
3443 * \param [in] w - the weights of Gauss points.
3444 * \throw If \a locName is empty.
3445 * \throw If a localization with the name \a locName already exists but is
3446 * different form the new one.
3448 void MEDFileFieldGlobsReal::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)
3450 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3453 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3455 MEDFileFieldGlobs *g(_globals);
3457 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3461 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3463 const MEDFileFieldGlobs *g(_globals);
3465 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3469 //= MEDFileFieldNameScope
3471 MEDFileFieldNameScope::MEDFileFieldNameScope()
3475 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3480 * Returns the name of \a this field.
3481 * \return std::string - a string containing the field name.
3483 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3489 * Sets name of \a this field
3490 * \param [in] name - the new field name.
3492 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3497 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3502 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3507 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3510 _dt_unit=other._dt_unit;
3513 //= MEDFileAnyTypeField1TSWithoutSDA
3515 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3517 _field_per_mesh.resize(other._field_per_mesh.size());
3519 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3521 if((const MEDFileFieldPerMesh *)*it)
3522 _field_per_mesh[i]=(*it)->deepCpy(this);
3527 * Prints a string describing \a this field into a stream. This string is outputted
3528 * by \c print Python command.
3529 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3530 * \param [in,out] oss - the out stream.
3531 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3532 * info id printed, else, not.
3534 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3536 std::string startOfLine(bkOffset,' ');
3537 oss << startOfLine << "Field ";
3539 oss << "[Type=" << getTypeStr() << "] ";
3540 oss << "on One time Step ";
3542 oss << "(" << f1tsId << ") ";
3543 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3544 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3545 const DataArray *arr=getUndergroundDataArray();
3548 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3551 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3552 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3553 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3554 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3556 if(arr->isAllocated())
3558 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3561 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3565 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3567 oss << startOfLine << "----------------------" << std::endl;
3568 if(!_field_per_mesh.empty())
3571 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3573 const MEDFileFieldPerMesh *cur=(*it2);
3575 cur->simpleRepr(bkOffset,oss,i);
3577 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3582 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3584 oss << startOfLine << "----------------------" << std::endl;
3587 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3589 const DataArray *arr(getUndergroundDataArray());
3591 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3592 int nbOfCompo=arr->getNumberOfComponents();
3593 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3594 for(int i=0;i<nbOfCompo;i++)
3597 std::vector<int> v(1,i);
3598 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3599 ret[i]->setArray(arr2);
3604 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3608 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3613 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3614 * empty. Returns -1 if this in on nodes.
3615 * \return int - the dimension of \a this.
3617 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3620 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3621 (*it)->getDimension(ret);
3626 * Returns the mesh name.
3627 * \return std::string - a string holding the mesh name.
3628 * \throw If \c _field_per_mesh.empty()
3630 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3632 if(_field_per_mesh.empty())
3633 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3634 return _field_per_mesh[0]->getMeshName();
3637 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3639 std::string oldName(getMeshName());
3640 std::vector< std::pair<std::string,std::string> > v(1);
3641 v[0].first=oldName; v[0].second=newMeshName;
3645 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3648 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3650 MEDFileFieldPerMesh *cur(*it);
3652 ret=cur->changeMeshNames(modifTab) || ret;
3658 * Returns the number of iteration of the state of underlying mesh.
3659 * \return int - the iteration number.
3660 * \throw If \c _field_per_mesh.empty()
3662 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3664 if(_field_per_mesh.empty())
3665 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3666 return _field_per_mesh[0]->getMeshIteration();
3670 * Returns the order number of iteration of the state of underlying mesh.
3671 * \return int - the order number.
3672 * \throw If \c _field_per_mesh.empty()
3674 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3676 if(_field_per_mesh.empty())
3677 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3678 return _field_per_mesh[0]->getMeshOrder();
3682 * Checks if \a this field is tagged by a given iteration number and a given
3683 * iteration order number.
3684 * \param [in] iteration - the iteration number of interest.
3685 * \param [in] order - the iteration order number of interest.
3686 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3687 * \a this->getOrder() == \a order.
3689 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3691 return iteration==_iteration && order==_order;
3695 * Returns number of iteration and order number of iteration when
3696 * \a this field has been calculated.
3697 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3700 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3702 std::pair<int,int> p;
3708 * Returns number of iteration and order number of iteration when
3709 * \a this field has been calculated.
3710 * \param [in,out] p - a pair returning the iteration number and the iteration
3713 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3720 * Returns all types of spatial discretization of \a this field.
3721 * \param [in,out] types - a sequence of types of \a this field.
3723 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3725 std::set<TypeOfField> types2;
3726 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3728 (*it)->fillTypesOfFieldAvailable(types2);
3730 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3731 std::copy(types2.begin(),types2.end(),bi);
3735 * Returns all types of spatial discretization of \a this field.
3736 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3739 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3741 std::vector<TypeOfField> ret;
3742 fillTypesOfFieldAvailable(ret);
3746 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3748 std::vector<std::string> ret;
3749 std::set<std::string> ret2;
3750 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3752 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3753 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3754 if(ret2.find(*it2)==ret2.end())
3756 ret.push_back(*it2);
3763 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3765 std::vector<std::string> ret;
3766 std::set<std::string> ret2;
3767 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3769 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3770 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3771 if(ret2.find(*it2)==ret2.end())
3773 ret.push_back(*it2);
3780 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3782 std::vector<std::string> ret;
3783 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3785 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3786 ret.insert(ret.end(),tmp.begin(),tmp.end());
3791 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3793 std::vector<std::string> ret;
3794 std::set<std::string> ret2;
3795 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3797 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3798 ret.insert(ret.end(),tmp.begin(),tmp.end());
3803 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3805 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3806 (*it)->changePflsRefsNamesGen(mapOfModif);
3809 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3811 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3812 (*it)->changeLocsRefsNamesGen(mapOfModif);
3816 * Returns all attributes of parts of \a this field lying on a given mesh.
3817 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3818 * item of every of returned sequences refers to the _i_-th part of \a this field.
3819 * Thus all sequences returned by this method are of the same length equal to number
3820 * of different types of supporting entities.<br>
3821 * A field part can include sub-parts with several different spatial discretizations,
3822 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3823 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3824 * of a nested sequence corresponds to a type of spatial discretization.<br>
3825 * This method allows for iteration over MEDFile DataStructure without any overhead.
3826 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3827 * for the case with only one underlying mesh. (Actually, the number of meshes is
3828 * not checked if \a mname == \c NULL).
3829 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3830 * a field part is returned.
3831 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3832 * This sequence is of the same length as \a types.
3833 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3834 * discretization. A profile name can be empty.
3835 * Length of this and of nested sequences is the same as that of \a typesF.
3836 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3837 * discretization. A localization name can be empty.
3838 * Length of this and of nested sequences is the same as that of \a typesF.
3839 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3840 * of ids of tuples within the data array, per each type of spatial
3841 * discretization within one mesh entity type.
3842 * Length of this and of nested sequences is the same as that of \a typesF.
3843 * \throw If no field is lying on \a mname.
3845 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::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)
3849 meshId=getMeshIdFromMeshName(mname);
3851 if(_field_per_mesh.empty())
3852 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3853 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3857 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3858 * maximal absolute dimension and values returned via the out parameter \a levs are
3859 * dimensions relative to the maximal absolute dimension. <br>
3860 * This method is designed for MEDFileField1TS instances that have a discretization
3861 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3862 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3863 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3864 * Only these 3 discretizations will be taken into account here. If \a this is
3865 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3866 * This method is useful to make the link between the dimension of the underlying mesh
3867 * and the levels of \a this, because it is possible that the highest dimension of \a this
3868 * field is not equal to the dimension of the underlying mesh.
3870 * Let's consider the following case:
3871 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3872 * TETRA4, HEXA8, TRI3 and SEG2.
3873 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3874 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3876 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3877 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3878 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3879 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3880 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3881 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3883 * to retrieve the highest level of
3884 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3885 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3886 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3887 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3888 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3889 * for the case with only one underlying mesh. (Actually, the number of meshes is
3890 * not checked if \a mname == \c NULL).
3891 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3892 * absolute one. They are in decreasing order. This sequence is cleared before
3894 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3895 * \throw If no field is lying on \a mname.
3897 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3900 int meshId=getMeshIdFromMeshName(mname);
3901 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3902 std::vector< std::vector<TypeOfField> > typesF;
3903 std::vector< std::vector<std::string> > pfls, locs;
3904 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3906 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3907 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3908 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3910 st.erase(INTERP_KERNEL::NORM_ERROR);
3912 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3914 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3915 ret1.insert((int)cm.getDimension());
3917 int ret=*std::max_element(ret1.begin(),ret1.end());
3918 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3919 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3924 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3925 * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
3926 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3927 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3929 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3931 int mid=getMeshIdFromMeshName(mName);
3932 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3936 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3937 * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
3938 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3939 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3941 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3943 int mid=getMeshIdFromMeshName(mName);
3944 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3948 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3950 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3952 if(_field_per_mesh.empty())
3953 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3956 std::string mName2(mName);
3958 std::vector<std::string> msg;
3959 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3960 if(mName2==(*it)->getMeshName())
3963 msg.push_back((*it)->getMeshName());
3964 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3965 oss << "Possible meshes are : ";
3966 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3967 oss << "\"" << (*it2) << "\" ";
3968 throw INTERP_KERNEL::Exception(oss.str().c_str());
3971 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3974 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3975 std::string tmp(mesh->getName());
3977 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3978 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3980 for(;it!=_field_per_mesh.end();it++,i++)
3982 if((*it)->getMeshName()==tmp)
3985 int sz=_field_per_mesh.size();
3986 _field_per_mesh.resize(sz+1);
3987 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3991 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3992 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3995 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3997 MEDFileFieldPerMesh *fpm(*it);
3999 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4004 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4006 if(_field_per_mesh.empty())
4007 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4008 if(_field_per_mesh.size()>1)
4009 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4010 _field_per_mesh[0]->copyOptionsFrom(opts);
4011 _field_per_mesh[0]->writeLL(fid,nasc);
4015 * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated.
4016 * If false is returned the memory allocation is not required.
4018 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4020 if(_nb_of_tuples_to_be_allocated>=0)
4022 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4023 _nb_of_tuples_to_be_allocated=-2;
4026 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4028 if(_nb_of_tuples_to_be_allocated==-1)
4029 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4030 if(_nb_of_tuples_to_be_allocated<-3)
4031 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4035 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4037 med_int numdt,numit;
4041 med_int meshnumdt,meshnumit;
4042 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4043 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4044 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4045 if(_iteration!=numdt || _order!=numit)
4046 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4047 _field_per_mesh.resize(nmesh);
4048 for(int i=0;i<nmesh;i++)
4049 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4050 _nb_of_tuples_to_be_allocated=0;
4051 for(int i=0;i<nmesh;i++)
4052 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4055 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4057 allocIfNecessaryTheArrayToReceiveDataFromFile();
4058 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4059 (*it)->loadBigArraysRecursively(fid,nasc);
4062 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4064 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4065 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4066 (*it)->loadBigArraysRecursively(fid,nasc);
4069 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4071 loadOnlyStructureOfDataRecursively(fid,nasc);
4072 loadBigArraysRecursively(fid,nasc);
4075 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4077 DataArray *thisArr(getUndergroundDataArray());
4078 if(thisArr && thisArr->isAllocated())
4080 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4081 thisArr->desallocate();
4085 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4087 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4088 if(getUndergroundDataArray())
4089 ret+=getUndergroundDataArray()->getHeapMemorySize();
4090 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4091 ret+=(*it)->getHeapMemorySize();
4096 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4097 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4098 * "Sort By Type"), if not, an exception is thrown.
4099 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4100 * \param [in] arr - the array of values.
4101 * \param [in,out] glob - the global data where profiles and localization present in
4102 * \a field, if any, are added.
4103 * \throw If the name of \a field is empty.
4104 * \throw If the data array of \a field is not set.
4105 * \throw If \a this->_arr is already allocated but has different number of components
4107 * \throw If the underlying mesh of \a field has no name.
4108 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4110 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4112 const MEDCouplingMesh *mesh=field->getMesh();
4114 TypeOfField type=field->getTypeOfField();
4115 std::vector<DataArrayInt *> dummy;
4116 int start=copyTinyInfoFrom(field,arr);
4117 int pos=addNewEntryIfNecessary(mesh);
4120 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4121 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4124 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4128 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4129 * of a given mesh are used as the support of the given field (a real support is not used).
4130 * Elements of the given mesh must be sorted suitable for writing to MED file.
4131 * Order of underlying mesh entities of the given field specified by \a profile parameter
4132 * is not prescribed; this method permutes field values to have them sorted by element
4133 * type as required for writing to MED file. A new profile is added only if no equal
4134 * profile is missing.
4135 * \param [in] field - the field to add to \a this. The field double values are ignored.
4136 * \param [in] arrOfVals - the values of the field \a field used.
4137 * \param [in] mesh - the supporting mesh of \a field.
4138 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4139 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4140 * \param [in,out] glob - the global data where profiles and localization present in
4141 * \a field, if any, are added.
4142 * \throw If either \a field or \a mesh or \a profile has an empty name.
4143 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4144 * \throw If the data array of \a field is not set.
4145 * \throw If \a this->_arr is already allocated but has different number of components
4147 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4148 * \sa setFieldNoProfileSBT()
4150 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4152 TypeOfField type=field->getTypeOfField();
4153 int start=copyTinyInfoFrom(field,arrOfVals);
4154 std::vector<DataArrayInt *> idsInPflPerType;
4155 std::vector<DataArrayInt *> idsPerType;
4156 std::vector<int> code,code2;
4157 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4160 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4161 code2=m->getDistributionOfTypes();
4163 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4164 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4165 idsInPflPerType2[i]=idsInPflPerType[i];
4166 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4167 for(std::size_t i=0;i<idsPerType.size();i++)
4168 idsPerType2[i]=idsPerType[i];
4170 int pos=addNewEntryIfNecessary(m);
4171 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4175 int pos=addNewEntryIfNecessary(m);
4176 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4181 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4183 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4185 if(_nb_of_tuples_to_be_allocated>=0)
4186 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile : the object is expected to be appended to a data coming from a file but not loaded ! Load before appending data !");
4187 DataArray *arr(getOrCreateAndGetArray());
4188 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4189 _nb_of_tuples_to_be_allocated=-3;
4193 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4194 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4195 * larger by the size of \a field. Returns an id of the first not filled
4196 * tuple of \a this->_arr.
4197 * \param [in] field - the field to copy the info on components and the name from.
4198 * \return int - the id of first not initialized tuple of \a this->_arr.
4199 * \throw If the name of \a field is empty.
4200 * \throw If the data array of \a field is not set.
4201 * \throw If \a this->_arr is already allocated but has different number of components
4204 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4207 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4208 std::string name(field->getName());
4209 setName(name.c_str());
4210 setDtUnit(field->getTimeUnit());
4212 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4214 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4215 if(!arr->isAllocated())
4216 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4217 _dt=field->getTime(_iteration,_order);
4218 int nbOfComponents=arr->getNumberOfComponents();
4219 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4220 if(!getOrCreateAndGetArray()->isAllocated())
4222 allocNotFromFile(arr->getNumberOfTuples());
4227 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4228 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4229 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4230 _nb_of_tuples_to_be_allocated=-3;
4231 return oldNbOfTuples;
4236 * Returns number of components in \a this field
4237 * \return int - the number of components.
4239 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4241 return getOrCreateAndGetArray()->getNumberOfComponents();
4245 * Change info on components in \a this.
4246 * \throw If size of \a infos is not equal to the number of components already in \a this.
4248 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4250 DataArray *arr=getOrCreateAndGetArray();
4251 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4255 * Returns info on components of \a this field.
4256 * \return const std::vector<std::string>& - a sequence of strings each being an
4257 * information on _i_-th component.
4259 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4261 const DataArray *arr=getOrCreateAndGetArray();
4262 return arr->getInfoOnComponents();
4266 * Returns a mutable info on components of \a this field.
4267 * \return std::vector<std::string>& - a sequence of strings each being an
4268 * information on _i_-th component.
4270 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4272 DataArray *arr=getOrCreateAndGetArray();
4273 return arr->getInfoOnComponents();
4277 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4278 * \param [in] type - a spatial discretization of the new field.
4279 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4280 * \param [in] mName - a name of the supporting mesh.
4281 * \param [in] renumPol - specifies how to permute values of the result field according to
4282 * the optional numbers of cells and nodes, if any. The valid values are
4283 * - 0 - do not permute.
4284 * - 1 - permute cells.
4285 * - 2 - permute nodes.
4286 * - 3 - permute cells and nodes.
4288 * \param [in] glob - the global data storing profiles and localization.
4289 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4290 * caller is to delete this field using decrRef() as it is no more needed.
4291 * \throw If the MED file is not readable.
4292 * \throw If there is no mesh named \a mName in the MED file.
4293 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4294 * \throw If no field of \a this is lying on the mesh \a mName.
4295 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4297 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4299 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4301 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4303 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4304 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4308 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4309 * \param [in] type - a spatial discretization of the new field.
4310 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4311 * \param [in] renumPol - specifies how to permute values of the result field according to
4312 * the optional numbers of cells and nodes, if any. The valid values are
4313 * - 0 - do not permute.
4314 * - 1 - permute cells.
4315 * - 2 - permute nodes.
4316 * - 3 - permute cells and nodes.
4318 * \param [in] glob - the global data storing profiles and localization.
4319 * \param [in] mesh - the supporting mesh.
4320 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4321 * caller is to delete this field using decrRef() as it is no more needed.
4322 * \throw If the MED file is not readable.
4323 * \throw If no field of \a this is lying on \a mesh.
4324 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4325 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4327 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4329 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4330 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4331 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4332 if(meshDimRelToMax==1)
4333 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4334 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4338 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4340 * \param [in] type - a spatial discretization of the new field.
4341 * \param [in] mName - a name of the supporting mesh.
4342 * \param [in] renumPol - specifies how to permute values of the result field according to
4343 * the optional numbers of cells and nodes, if any. The valid values are
4344 * - 0 - do not permute.
4345 * - 1 - permute cells.
4346 * - 2 - permute nodes.
4347 * - 3 - permute cells and nodes.
4349 * \param [in] glob - the global data storing profiles and localization.
4350 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4351 * caller is to delete this field using decrRef() as it is no more needed.
4352 * \throw If the MED file is not readable.
4353 * \throw If there is no mesh named \a mName in the MED file.
4354 * \throw If there are no mesh entities in the mesh.
4355 * \throw If no field values of the given \a type are available.
4357 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4359 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4361 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4363 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4364 int absDim=getDimension();
4365 int meshDimRelToMax=absDim-mm->getMeshDimension();
4366 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4370 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4371 * \param [in] type - a spatial discretization of the new field.
4372 * \param [in] renumPol - specifies how to permute values of the result field according to
4373 * the optional numbers of cells and nodes, if any. The valid values are
4374 * - 0 - do not permute.
4375 * - 1 - permute cells.
4376 * - 2 - permute nodes.
4377 * - 3 - permute cells and nodes.
4379 * \param [in] glob - the global data storing profiles and localization.
4380 * \param [in] mesh - the supporting mesh.
4381 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4382 * field according to \a renumPol.
4383 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4384 * field according to \a renumPol.
4385 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4386 * caller is to delete this field using decrRef() as it is no more needed.
4387 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4388 * \throw If no field of \a this is lying on \a mesh.
4389 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4391 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4393 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4394 int meshId=getMeshIdFromMeshName(mesh->getName());
4396 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4401 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4408 throw INTERP_KERNEL::Exception(msg1);
4409 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4412 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4414 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4415 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4416 throw INTERP_KERNEL::Exception(oss.str().c_str());
4418 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4419 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4420 std::vector<DataArray *> arrOut2(1,arrOut);
4421 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4422 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4423 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4430 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4432 throw INTERP_KERNEL::Exception(msg1);
4435 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4437 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4438 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4439 throw INTERP_KERNEL::Exception(oss.str().c_str());
4441 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4442 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4443 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4444 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4449 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4454 * Returns values and a profile of the field of a given type lying on a given support.
4455 * \param [in] type - a spatial discretization of the field.
4456 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4457 * \param [in] mesh - the supporting mesh.
4458 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4459 * field of interest lies on. If the field lies on all entities of the given
4460 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4461 * using decrRef() as it is no more needed.
4462 * \param [in] glob - the global data storing profiles and localization.
4463 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4464 * field. The caller is to delete this array using decrRef() as it is no more needed.
4465 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4466 * \throw If no field of \a this is lying on \a mesh.
4467 * \throw If no field values of the given \a type are available.
4469 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4471 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4472 int meshId=getMeshIdFromMeshName(mesh->getName());
4473 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4474 ret->setName(nasc.getName().c_str());
4478 //= MEDFileField1TSWithoutSDA
4481 * Throws if a given value is not a valid (non-extended) relative dimension.
4482 * \param [in] meshDimRelToMax - the relative dimension value.
4483 * \throw If \a meshDimRelToMax > 0.
4485 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4487 if(meshDimRelToMax>0)
4488 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4492 * Checks if elements of a given mesh are in the order suitable for writing
4493 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4494 * vector describing types of elements and their number.
4495 * \param [in] mesh - the mesh to check.
4496 * \return std::vector<int> - a vector holding for each element type (1) item of
4497 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4498 * These values are in full-interlace mode.
4499 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4501 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4504 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4505 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4506 int nbOfTypes=geoTypes.size();
4507 std::vector<int> code(3*nbOfTypes);
4508 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4509 arr1->alloc(nbOfTypes,1);
4510 int *arrPtr=arr1->getPointer();
4511 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4512 for(int i=0;i<nbOfTypes;i++,it++)
4513 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4514 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4515 const int *arrPtr2=arr2->getConstPointer();
4517 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4520 int nbCells=mesh->getNumberOfCellsWithType(*it);
4521 code[3*pos]=(int)(*it);
4522 code[3*pos+1]=nbCells;
4523 code[3*pos+2]=-1;//no profiles
4525 std::vector<const DataArrayInt *> idsPerType;//no profiles
4526 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4530 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4535 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4537 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4541 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4542 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4543 * item of every of returned sequences refers to the _i_-th part of \a this field.
4544 * Thus all sequences returned by this method are of the same length equal to number
4545 * of different types of supporting entities.<br>
4546 * A field part can include sub-parts with several different spatial discretizations,
4547 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4548 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4549 * of a nested sequence corresponds to a type of spatial discretization.<br>
4550 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4551 * The overhead is due to selecting values into new instances of DataArrayDouble.
4552 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4553 * for the case with only one underlying mesh. (Actually, the number of meshes is
4554 * not checked if \a mname == \c NULL).
4555 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4556 * a field part is returned.
4557 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4558 * A field part can include sub-parts with several different spatial discretizations,
4559 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4560 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4561 * This sequence is of the same length as \a types.
4562 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4563 * discretization. A profile name can be empty.
4564 * Length of this and of nested sequences is the same as that of \a typesF.
4565 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4566 * discretization. A localization name can be empty.
4567 * Length of this and of nested sequences is the same as that of \a typesF.
4568 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4569 * per each type of spatial discretization within one mesh entity type.
4570 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4571 * Length of this and of nested sequences is the same as that of \a typesF.
4572 * \throw If no field is lying on \a mname.
4574 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::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)
4578 meshId=getMeshIdFromMeshName(mname);
4580 if(_field_per_mesh.empty())
4581 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4582 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4583 int nbOfRet=ret0.size();
4584 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4585 for(int i=0;i<nbOfRet;i++)
4587 const std::vector< std::pair<int,int> >& p=ret0[i];
4588 int nbOfRet1=p.size();
4589 ret[i].resize(nbOfRet1);
4590 for(int j=0;j<nbOfRet1;j++)
4592 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4600 * Returns a pointer to the underground DataArrayDouble instance. So the
4601 * caller should not decrRef() it. This method allows for a direct access to the field
4602 * values. This method is quite unusable if there is more than a nodal field or a cell
4603 * field on single geometric cell type.
4604 * \return DataArrayDouble * - the pointer to the field values array.
4606 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4608 const DataArrayDouble *ret=_arr;
4610 return const_cast<DataArrayDouble *>(ret);
4615 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4620 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4622 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4623 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4624 ret->deepCpyLeavesFrom(*this);
4625 const DataArrayDouble *arr(_arr);
4628 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4629 ret->setArray(arr2);
4635 * Returns a pointer to the underground DataArrayDouble instance. So the
4636 * caller should not decrRef() it. This method allows for a direct access to the field
4637 * values. This method is quite unusable if there is more than a nodal field or a cell
4638 * field on single geometric cell type.
4639 * \return DataArrayDouble * - the pointer to the field values array.
4641 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4643 return getUndergroundDataArrayDouble();
4647 * Returns a pointer to the underground DataArrayDouble instance and a
4648 * sequence describing parameters of a support of each part of \a this field. The
4649 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4650 * direct access to the field values. This method is intended for the field lying on one
4652 * \param [in,out] entries - the sequence describing parameters of a support of each
4653 * part of \a this field. Each item of this sequence consists of two parts. The
4654 * first part describes a type of mesh entity and an id of discretization of a
4655 * current field part. The second part describes a range of values [begin,end)
4656 * within the returned array relating to the current field part.
4657 * \return DataArrayDouble * - the pointer to the field values array.
4658 * \throw If the number of underlying meshes is not equal to 1.
4659 * \throw If no field values are available.
4660 * \sa getUndergroundDataArray()
4662 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4664 if(_field_per_mesh.size()!=1)
4665 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4666 if(_field_per_mesh[0]==0)
4667 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4668 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4669 return getUndergroundDataArrayDouble();
4673 * Returns a pointer to the underground DataArrayDouble instance and a
4674 * sequence describing parameters of a support of each part of \a this field. The
4675 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4676 * direct access to the field values. This method is intended for the field lying on one
4678 * \param [in,out] entries - the sequence describing parameters of a support of each
4679 * part of \a this field. Each item of this sequence consists of two parts. The
4680 * first part describes a type of mesh entity and an id of discretization of a
4681 * current field part. The second part describes a range of values [begin,end)
4682 * within the returned array relating to the current field part.
4683 * \return DataArrayDouble * - the pointer to the field values array.
4684 * \throw If the number of underlying meshes is not equal to 1.
4685 * \throw If no field values are available.
4686 * \sa getUndergroundDataArray()
4688 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4690 return getUndergroundDataArrayDoubleExt(entries);
4693 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4694 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4696 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4697 arr->setInfoAndChangeNbOfCompo(infos);
4700 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4704 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4706 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4707 ret->deepCpyLeavesFrom(*this);
4711 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4713 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4714 if((const DataArrayDouble *)_arr)
4715 ret->_arr=_arr->deepCpy();
4719 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4723 _nb_of_tuples_to_be_allocated=-1;
4727 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4729 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4731 _nb_of_tuples_to_be_allocated=-3;
4736 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4738 return DataArrayDouble::New();
4741 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4743 DataArrayDouble *ret=_arr;
4746 _arr=DataArrayDouble::New();
4750 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4752 return getOrCreateAndGetArrayDouble();
4755 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4757 const DataArrayDouble *ret=_arr;
4760 DataArrayDouble *ret2=DataArrayDouble::New();
4761 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4765 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4767 return getOrCreateAndGetArrayDouble();
4770 //= MEDFileIntField1TSWithoutSDA
4772 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4773 const std::vector<std::string>& infos)
4775 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4778 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4782 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4783 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4785 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4786 arr->setInfoAndChangeNbOfCompo(infos);
4789 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4794 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4796 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4797 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4798 ret->deepCpyLeavesFrom(*this);
4799 const DataArrayInt *arr(_arr);
4802 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4803 ret->setArray(arr2);
4809 * Returns a pointer to the underground DataArrayInt instance. So the
4810 * caller should not decrRef() it. This method allows for a direct access to the field
4811 * values. This method is quite unusable if there is more than a nodal field or a cell
4812 * field on single geometric cell type.
4813 * \return DataArrayInt * - the pointer to the field values array.
4815 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4817 return getUndergroundDataArrayInt();
4821 * Returns a pointer to the underground DataArrayInt instance. So the
4822 * caller should not decrRef() it. This method allows for a direct access to the field
4823 * values. This method is quite unusable if there is more than a nodal field or a cell
4824 * field on single geometric cell type.
4825 * \return DataArrayInt * - the pointer to the field values array.
4827 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4829 const DataArrayInt *ret=_arr;
4831 return const_cast<DataArrayInt *>(ret);
4837 * Returns a pointer to the underground DataArrayInt instance and a
4838 * sequence describing parameters of a support of each part of \a this field. The
4839 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4840 * direct access to the field values. This method is intended for the field lying on one
4842 * \param [in,out] entries - the sequence describing parameters of a support of each
4843 * part of \a this field. Each item of this sequence consists of two parts. The
4844 * first part describes a type of mesh entity and an id of discretization of a
4845 * current field part. The second part describes a range of values [begin,end)
4846 * within the returned array relating to the current field part.
4847 * \return DataArrayInt * - the pointer to the field values array.
4848 * \throw If the number of underlying meshes is not equal to 1.
4849 * \throw If no field values are available.
4850 * \sa getUndergroundDataArray()
4852 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4854 return getUndergroundDataArrayIntExt(entries);
4858 * Returns a pointer to the underground DataArrayInt instance and a
4859 * sequence describing parameters of a support of each part of \a this field. The
4860 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4861 * direct access to the field values. This method is intended for the field lying on one
4863 * \param [in,out] entries - the sequence describing parameters of a support of each
4864 * part of \a this field. Each item of this sequence consists of two parts. The
4865 * first part describes a type of mesh entity and an id of discretization of a
4866 * current field part. The second part describes a range of values [begin,end)
4867 * within the returned array relating to the current field part.
4868 * \return DataArrayInt * - the pointer to the field values array.
4869 * \throw If the number of underlying meshes is not equal to 1.
4870 * \throw If no field values are available.
4871 * \sa getUndergroundDataArray()
4873 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4875 if(_field_per_mesh.size()!=1)
4876 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4877 if(_field_per_mesh[0]==0)
4878 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4879 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4880 return getUndergroundDataArrayInt();
4883 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4885 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4886 ret->deepCpyLeavesFrom(*this);
4890 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4892 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4893 if((const DataArrayInt *)_arr)
4894 ret->_arr=_arr->deepCpy();
4898 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4902 _nb_of_tuples_to_be_allocated=-1;
4906 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4908 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4910 _nb_of_tuples_to_be_allocated=-3;
4915 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4917 return DataArrayInt::New();
4920 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4922 DataArrayInt *ret=_arr;
4925 _arr=DataArrayInt::New();
4929 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4931 return getOrCreateAndGetArrayInt();
4934 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4936 const DataArrayInt *ret=_arr;
4939 DataArrayInt *ret2=DataArrayInt::New();
4940 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4944 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4946 return getOrCreateAndGetArrayInt();
4949 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4953 //= MEDFileAnyTypeField1TS
4955 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
4957 med_field_type typcha;
4959 std::vector<std::string> infos;
4960 std::string dtunit,fieldName;
4961 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4962 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4967 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4972 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4977 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
4978 throw INTERP_KERNEL::Exception(oss.str().c_str());
4981 ret->setDtUnit(dtunit.c_str());
4982 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4984 med_int numdt,numit;
4986 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4987 ret->setTime(numdt,numit,dt);
4990 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4992 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4996 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
4997 try:MEDFileFieldGlobsReal(fileName)
4999 MEDFileUtilities::CheckFileForRead(fileName);
5000 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5001 _content=BuildContentFrom(fid,fileName,loadAll);
5004 catch(INTERP_KERNEL::Exception& e)
5009 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5011 med_field_type typcha;
5012 std::vector<std::string> infos;
5015 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5016 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5021 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5026 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5031 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5032 throw INTERP_KERNEL::Exception(oss.str().c_str());
5035 ret->setDtUnit(dtunit.c_str());
5036 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5040 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5041 throw INTERP_KERNEL::Exception(oss.str().c_str());
5044 med_int numdt,numit;
5046 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5047 ret->setTime(numdt,numit,dt);
5050 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5052 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5056 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5057 try:MEDFileFieldGlobsReal(fileName)
5059 MEDFileUtilities::CheckFileForRead(fileName);
5060 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5061 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5064 catch(INTERP_KERNEL::Exception& e)
5069 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5072 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5073 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5075 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5076 ret->setFileName(fileName);
5077 ret->_content=c; c->incrRef();
5080 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5082 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5083 ret->setFileName(fileName);
5084 ret->_content=c; c->incrRef();
5087 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5090 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5092 MEDFileUtilities::CheckFileForRead(fileName);
5093 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5094 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5095 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5096 ret->loadGlobals(fid);
5100 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5102 MEDFileUtilities::CheckFileForRead(fileName);
5103 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5104 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5105 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5106 ret->loadGlobals(fid);
5110 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5112 MEDFileUtilities::CheckFileForRead(fileName);
5113 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5114 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5115 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5116 ret->loadGlobals(fid);
5120 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5122 med_field_type typcha;
5123 std::vector<std::string> infos;
5126 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5127 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5132 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5137 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5142 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5143 throw INTERP_KERNEL::Exception(oss.str().c_str());
5146 ret->setDtUnit(dtunit.c_str());
5147 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5150 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5151 for(int i=0;i<nbOfStep2 && !found;i++)
5153 med_int numdt,numit;
5155 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5156 if(numdt==iteration && numit==order)
5162 dtits[i]=std::pair<int,int>(numdt,numit);
5166 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5167 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5168 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5169 throw INTERP_KERNEL::Exception(oss.str().c_str());
5172 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5174 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5178 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5179 try:MEDFileFieldGlobsReal(fileName)
5181 MEDFileUtilities::CheckFileForRead(fileName);
5182 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5183 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5186 catch(INTERP_KERNEL::Exception& e)
5192 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5193 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5195 * \warning this is a shallow copy constructor
5197 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5199 if(!shallowCopyOfContent)
5201 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5202 otherPtr->incrRef();
5203 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5207 _content=other.shallowCpy();
5211 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5215 int nbFields=MEDnField(fid);
5216 if(fieldIdCFormat>=nbFields)
5218 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5219 throw INTERP_KERNEL::Exception(oss.str().c_str());
5222 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5223 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5224 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5225 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5226 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5227 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5230 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5231 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5232 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5233 infos.clear(); infos.resize(ncomp);
5234 for(int j=0;j<ncomp;j++)
5235 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5240 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5243 * \return in case of success the number of time steps available for the field with name \a fieldName.
5245 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5247 int nbFields=MEDnField(fid);
5249 std::vector<std::string> fns(nbFields);
5251 for(int i=0;i<nbFields && !found;i++)
5254 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5256 found=(tmp==fieldName);
5262 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5263 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5264 oss << "\"" << *it << "\" ";
5265 throw INTERP_KERNEL::Exception(oss.str().c_str());
5271 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5272 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5273 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5274 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5275 * to keep a valid instance.
5276 * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5277 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5278 * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
5280 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5281 * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5282 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5283 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5284 * \param [in] newLocName is the new localization name.
5285 * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
5286 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5288 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5290 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5291 std::string oldPflName=disc->getProfile();
5292 std::vector<std::string> vv=getPflsReallyUsedMulti();
5293 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5294 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5296 disc->setProfile(newPflName);
5297 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5298 pfl->setName(newPflName);
5302 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5303 throw INTERP_KERNEL::Exception(oss.str().c_str());
5308 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5309 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5310 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5311 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5312 * to keep a valid instance.
5313 * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5314 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5315 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5316 * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
5318 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5319 * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5320 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5321 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5322 * \param [in] newLocName is the new localization name.
5323 * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
5324 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5326 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5328 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5329 std::string oldLocName=disc->getLocalization();
5330 std::vector<std::string> vv=getLocsReallyUsedMulti();
5331 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5332 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5334 disc->setLocalization(newLocName);
5335 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5336 loc.setName(newLocName);
5340 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5341 throw INTERP_KERNEL::Exception(oss.str().c_str());
5345 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5347 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5349 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5353 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5355 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5357 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5362 * Writes \a this field into a MED file specified by its name.
5363 * \param [in] fileName - the MED file name.
5364 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5365 * - 2 - erase; an existing file is removed.
5366 * - 1 - append; same data should not be present in an existing file.
5367 * - 0 - overwrite; same data present in an existing file is overwritten.
5368 * \throw If the field name is not set.
5369 * \throw If no field data is set.
5370 * \throw If \a mode == 1 and the same data is present in an existing file.
5372 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5374 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5375 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5380 * This method alloc the arrays and load potentially huge arrays contained in this field.
5381 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5382 * This method can be also called to refresh or reinit values from a file.
5384 * \throw If the fileName is not set or points to a non readable MED file.
5385 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5387 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5389 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5390 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5394 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5395 * But once data loaded once, this method does nothing.
5397 * \throw If the fileName is not set or points to a non readable MED file.
5398 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5400 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5402 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5403 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5407 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5408 * This method does not release arrays set outside the context of a MED file.
5410 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5412 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5414 contentNotNullBase()->releaseArrays();
5417 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5419 int nbComp=getNumberOfComponents();
5420 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5421 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5422 for(int i=0;i<nbComp;i++)
5424 std::string info=getInfo()[i];
5426 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5427 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5428 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5430 if(getName().empty())
5431 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5432 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5433 writeGlobals(fid,*this);
5434 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5437 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5440 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5441 ret+=_content->getHeapMemorySize();
5442 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5446 * Returns a string describing \a this field. This string is outputted
5447 * by \c print Python command.
5449 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5451 std::ostringstream oss;
5452 contentNotNullBase()->simpleRepr(0,oss,-1);
5453 simpleReprGlobs(oss);
5458 * This method returns all profiles whose name is non empty used.
5459 * \b WARNING If profile is used several times it will be reported \b only \b once.
5460 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5462 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5464 return contentNotNullBase()->getPflsReallyUsed2();
5468 * This method returns all localizations whose name is non empty used.
5469 * \b WARNING If localization is used several times it will be reported \b only \b once.
5471 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5473 return contentNotNullBase()->getLocsReallyUsed2();
5477 * This method returns all profiles whose name is non empty used.
5478 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5480 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5482 return contentNotNullBase()->getPflsReallyUsedMulti2();
5486 * This method returns all localizations whose name is non empty used.
5487 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5489 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5491 return contentNotNullBase()->getLocsReallyUsedMulti2();
5494 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5496 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5499 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5501 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5504 int MEDFileAnyTypeField1TS::getDimension() const
5506 return contentNotNullBase()->getDimension();
5509 int MEDFileAnyTypeField1TS::getIteration() const
5511 return contentNotNullBase()->getIteration();
5514 int MEDFileAnyTypeField1TS::getOrder() const
5516 return contentNotNullBase()->getOrder();
5519 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5521 return contentNotNullBase()->getTime(iteration,order);
5524 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5526 contentNotNullBase()->setTime(iteration,order,val);
5529 std::string MEDFileAnyTypeField1TS::getName() const
5531 return contentNotNullBase()->getName();
5534 void MEDFileAnyTypeField1TS::setName(const char *name)
5536 contentNotNullBase()->setName(name);
5539 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5541 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5544 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5546 return contentNotNullBase()->getDtUnit();
5549 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5551 contentNotNullBase()->setDtUnit(dtUnit);
5554 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5556 return contentNotNullBase()->getMeshName();
5559 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5561 contentNotNullBase()->setMeshName(newMeshName);
5564 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5566 return contentNotNullBase()->changeMeshNames(modifTab);
5569 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5571 return contentNotNullBase()->getMeshIteration();
5574 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5576 return contentNotNullBase()->getMeshOrder();
5579 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5581 return contentNotNullBase()->getNumberOfComponents();
5584 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5586 return contentNotNullBase()->isDealingTS(iteration,order);
5589 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5591 return contentNotNullBase()->getDtIt();
5594 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5596 contentNotNullBase()->fillIteration(p);
5599 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5601 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5604 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5606 contentNotNullBase()->setInfo(infos);
5609 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5611 return contentNotNullBase()->getInfo();
5613 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5615 return contentNotNullBase()->getInfo();
5618 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5620 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5623 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5625 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5628 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5630 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5633 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5635 return contentNotNullBase()->getTypesOfFieldAvailable();
5638 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5639 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5641 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5645 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5646 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5647 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5649 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5651 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5653 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5654 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5655 std::size_t sz(contentsSplit.size());
5656 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5657 for(std::size_t i=0;i<sz;i++)
5659 ret[i]=shallowCpy();
5660 ret[i]->_content=contentsSplit[i];
5665 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5667 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5668 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5669 ret->_content=_content->deepCpy();
5670 ret->deepCpyGlobs(*this);
5674 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5676 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5682 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5683 * the first field that has been read from a specified MED file.
5684 * \param [in] fileName - the name of the MED file to read.
5685 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5686 * is to delete this field using decrRef() as it is no more needed.
5687 * \throw If reading the file fails.
5689 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5691 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5692 ret->contentNotNull();
5697 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5698 * a given field that has been read from a specified MED file.
5699 * \param [in] fileName - the name of the MED file to read.
5700 * \param [in] fieldName - the name of the field to read.
5701 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5702 * is to delete this field using decrRef() as it is no more needed.
5703 * \throw If reading the file fails.
5704 * \throw If there is no field named \a fieldName in the file.
5706 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5708 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5709 ret->contentNotNull();
5714 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5715 * a given field that has been read from a specified MED file.
5716 * \param [in] fileName - the name of the MED file to read.
5717 * \param [in] fieldName - the name of the field to read.
5718 * \param [in] iteration - the iteration number of a required time step.
5719 * \param [in] order - the iteration order number of required time step.
5720 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5721 * is to delete this field using decrRef() as it is no more needed.
5722 * \throw If reading the file fails.
5723 * \throw If there is no field named \a fieldName in the file.
5724 * \throw If the required time step is missing from the file.
5726 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5728 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5729 ret->contentNotNull();
5734 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5735 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5737 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5738 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5739 * \warning this is a shallow copy constructor
5740 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5741 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5742 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5743 * is to delete this field using decrRef() as it is no more needed.
5745 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5747 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5748 ret->contentNotNull();
5753 * Returns a new empty instance of MEDFileField1TS.
5754 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5755 * is to delete this field using decrRef() as it is no more needed.
5757 MEDFileField1TS *MEDFileField1TS::New()
5759 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5760 ret->contentNotNull();
5765 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5766 * following the given input policy.
5768 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5769 * By default (true) the globals are deeply copied.
5770 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5772 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5774 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5775 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5778 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5780 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5781 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5782 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5785 ret=MEDFileIntField1TS::New();
5787 ret->deepCpyGlobs(*this);
5789 ret->shallowCpyGlobs(*this);
5793 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5795 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5797 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5798 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5800 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5804 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5806 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5808 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5809 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5811 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5815 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5818 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5819 if(!((DataArray*)arr))
5820 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5821 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5823 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5824 f->setArray(arrOutC);
5827 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5829 if(!((DataArray*)arr))
5830 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5831 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5833 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5838 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5839 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5842 catch(INTERP_KERNEL::Exception& e)
5845 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5846 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5849 catch(INTERP_KERNEL::Exception& e)
5852 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5853 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
5856 catch(INTERP_KERNEL::Exception& e)
5860 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5861 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5863 * \warning this is a shallow copy constructor
5865 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5866 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5869 catch(INTERP_KERNEL::Exception& e)
5872 MEDFileField1TS::MEDFileField1TS()
5874 _content=new MEDFileField1TSWithoutSDA;
5878 * Returns a new MEDCouplingFieldDouble of a given type lying on
5879 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
5880 * has not been constructed via file reading, an exception is thrown.
5881 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5882 * \param [in] type - a spatial discretization of interest.
5883 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5884 * \param [in] renumPol - specifies how to permute values of the result field according to
5885 * the optional numbers of cells and nodes, if any. The valid values are
5886 * - 0 - do not permute.
5887 * - 1 - permute cells.
5888 * - 2 - permute nodes.
5889 * - 3 - permute cells and nodes.
5891 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5892 * caller is to delete this field using decrRef() as it is no more needed.
5893 * \throw If \a this field has not been constructed via file reading.
5894 * \throw If the MED file is not readable.
5895 * \throw If there is no mesh in the MED file.
5896 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5897 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5898 * \sa getFieldOnMeshAtLevel()
5900 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5902 if(getFileName2().empty())
5903 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5904 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5905 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5906 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5911 * Returns a new MEDCouplingFieldDouble of a given type lying on
5912 * the top level cells of the first mesh in MED file. If \a this field
5913 * has not been constructed via file reading, an exception is thrown.
5914 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5915 * \param [in] type - a spatial discretization of interest.
5916 * \param [in] renumPol - specifies how to permute values of the result field according to
5917 * the optional numbers of cells and nodes, if any. The valid values are
5918 * - 0 - do not permute.
5919 * - 1 - permute cells.
5920 * - 2 - permute nodes.
5921 * - 3 - permute cells and nodes.
5923 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5924 * caller is to delete this field using decrRef() as it is no more needed.
5925 * \throw If \a this field has not been constructed via file reading.
5926 * \throw If the MED file is not readable.
5927 * \throw If there is no mesh in the MED file.
5928 * \throw If no field values of the given \a type.
5929 * \throw If no field values lying on the top level support.
5930 * \sa getFieldAtLevel()
5932 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5934 if(getFileName2().empty())
5935 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5936 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5937 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5938 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5943 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5944 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5945 * \param [in] type - a spatial discretization of the new field.
5946 * \param [in] mesh - the supporting mesh.
5947 * \param [in] renumPol - specifies how to permute values of the result field according to
5948 * the optional numbers of cells and nodes, if any. The valid values are
5949 * - 0 - do not permute.
5950 * - 1 - permute cells.
5951 * - 2 - permute nodes.
5952 * - 3 - permute cells and nodes.
5954 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5955 * caller is to delete this field using decrRef() as it is no more needed.
5956 * \throw If no field of \a this is lying on \a mesh.
5957 * \throw If the mesh is empty.
5958 * \throw If no field values of the given \a type are available.
5959 * \sa getFieldAtLevel()
5960 * \sa getFieldOnMeshAtLevel()
5962 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5964 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5965 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5966 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5971 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5972 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5973 * \param [in] type - a spatial discretization of interest.
5974 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5975 * \param [in] mesh - the supporting mesh.
5976 * \param [in] renumPol - specifies how to permute values of the result field according to
5977 * the optional numbers of cells and nodes, if any. The valid values are
5978 * - 0 - do not permute.
5979 * - 1 - permute cells.
5980 * - 2 - permute nodes.
5981 * - 3 - permute cells and nodes.
5983 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5984 * caller is to delete this field using decrRef() as it is no more needed.
5985 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5986 * \throw If no field of \a this is lying on \a mesh.
5987 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5988 * \sa getFieldAtLevel()
5989 * \sa getFieldOnMeshAtLevel()
5991 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5993 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5994 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5995 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6000 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6001 * This method is called "Old" because in MED3 norm a field has only one meshName
6002 * attached, so this method is for readers of MED2 files. If \a this field
6003 * has not been constructed via file reading, an exception is thrown.
6004 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6005 * \param [in] type - a spatial discretization of interest.
6006 * \param [in] mName - a name of the supporting mesh.
6007 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6008 * \param [in] renumPol - specifies how to permute values of the result field according to
6009 * the optional numbers of cells and nodes, if any. The valid values are
6010 * - 0 - do not permute.
6011 * - 1 - permute cells.
6012 * - 2 - permute nodes.
6013 * - 3 - permute cells and nodes.
6015 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6016 * caller is to delete this field using decrRef() as it is no more needed.
6017 * \throw If the MED file is not readable.
6018 * \throw If there is no mesh named \a mName in the MED file.
6019 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6020 * \throw If \a this field has not been constructed via file reading.
6021 * \throw If no field of \a this is lying on the mesh named \a mName.
6022 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6023 * \sa getFieldAtLevel()
6025 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6027 if(getFileName2().empty())
6028 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6029 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6030 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6031 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6036 * Returns values and a profile of the field of a given type lying on a given support.
6037 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6038 * \param [in] type - a spatial discretization of the field.
6039 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6040 * \param [in] mesh - the supporting mesh.
6041 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6042 * field of interest lies on. If the field lies on all entities of the given
6043 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6044 * using decrRef() as it is no more needed.
6045 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6046 * field. The caller is to delete this array using decrRef() as it is no more needed.
6047 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6048 * \throw If no field of \a this is lying on \a mesh.
6049 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6051 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6053 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6054 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6058 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6059 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6060 * "Sort By Type"), if not, an exception is thrown.
6061 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6062 * \param [in] field - the field to add to \a this.
6063 * \throw If the name of \a field is empty.
6064 * \throw If the data array of \a field is not set.
6065 * \throw If the data array is already allocated but has different number of components
6067 * \throw If the underlying mesh of \a field has no name.
6068 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6070 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6073 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6077 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6078 * of a given mesh are used as the support of the given field (a real support is not used).
6079 * Elements of the given mesh must be sorted suitable for writing to MED file.
6080 * Order of underlying mesh entities of the given field specified by \a profile parameter
6081 * is not prescribed; this method permutes field values to have them sorted by element
6082 * type as required for writing to MED file. A new profile is added only if no equal
6083 * profile is missing.
6084 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6085 * \param [in] field - the field to add to \a this.
6086 * \param [in] mesh - the supporting mesh of \a field.
6087 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6088 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6089 * \throw If either \a field or \a mesh or \a profile has an empty name.
6090 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6091 * \throw If the data array of \a field is not set.
6092 * \throw If the data array of \a this is already allocated but has different number of
6093 * components than \a field.
6094 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6095 * \sa setFieldNoProfileSBT()
6097 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6100 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6103 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6105 return new MEDFileField1TS(*this);
6108 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6110 return contentNotNull()->getUndergroundDataArrayDouble();
6113 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6115 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6118 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6119 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6121 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6124 //= MEDFileIntField1TS
6126 MEDFileIntField1TS *MEDFileIntField1TS::New()
6128 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6129 ret->contentNotNull();
6133 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6135 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6136 ret->contentNotNull();
6140 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6142 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6143 ret->contentNotNull();
6147 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6149 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6150 ret->contentNotNull();
6154 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6156 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6157 ret->contentNotNull();
6161 MEDFileIntField1TS::MEDFileIntField1TS()
6163 _content=new MEDFileIntField1TSWithoutSDA;
6166 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6167 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6170 catch(INTERP_KERNEL::Exception& e)
6173 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6174 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6177 catch(INTERP_KERNEL::Exception& e)
6180 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6181 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6184 catch(INTERP_KERNEL::Exception& e)
6188 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6189 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6191 * \warning this is a shallow copy constructor
6193 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6197 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6199 return new MEDFileIntField1TS(*this);
6203 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6204 * following the given input policy.
6206 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6207 * By default (true) the globals are deeply copied.
6208 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6210 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6212 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6213 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6216 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6218 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6219 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6220 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6223 ret=MEDFileField1TS::New();
6225 ret->deepCpyGlobs(*this);
6227 ret->shallowCpyGlobs(*this);
6232 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6233 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6234 * "Sort By Type"), if not, an exception is thrown.
6235 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6236 * \param [in] field - the field to add to \a this. The field double values are ignored.
6237 * \param [in] arrOfVals - the values of the field \a field used.
6238 * \throw If the name of \a field is empty.
6239 * \throw If the data array of \a field is not set.
6240 * \throw If the data array is already allocated but has different number of components
6242 * \throw If the underlying mesh of \a field has no name.
6243 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6245 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6248 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6252 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6253 * of a given mesh are used as the support of the given field (a real support is not used).
6254 * Elements of the given mesh must be sorted suitable for writing to MED file.
6255 * Order of underlying mesh entities of the given field specified by \a profile parameter
6256 * is not prescribed; this method permutes field values to have them sorted by element
6257 * type as required for writing to MED file. A new profile is added only if no equal
6258 * profile is missing.
6259 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6260 * \param [in] field - the field to add to \a this. The field double values are ignored.
6261 * \param [in] arrOfVals - the values of the field \a field used.
6262 * \param [in] mesh - the supporting mesh of \a field.
6263 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6264 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6265 * \throw If either \a field or \a mesh or \a profile has an empty name.
6266 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6267 * \throw If the data array of \a field is not set.
6268 * \throw If the data array of \a this is already allocated but has different number of
6269 * components than \a field.
6270 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6271 * \sa setFieldNoProfileSBT()
6273 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6276 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6279 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6281 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6283 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6284 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6286 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6290 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6292 if(getFileName2().empty())
6293 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6294 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6295 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6296 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6298 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6303 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6305 if(!((DataArray *)arr))
6306 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6307 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6309 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6315 * Returns a new MEDCouplingFieldDouble of a given type lying on
6316 * the top level cells of the first mesh in MED file. If \a this field
6317 * has not been constructed via file reading, an exception is thrown.
6318 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6319 * \param [in] type - a spatial discretization of interest.
6320 * \param [out] arrOut - the DataArrayInt containing values of field.
6321 * \param [in] renumPol - specifies how to permute values of the result field according to
6322 * the optional numbers of cells and nodes, if any. The valid values are
6323 * - 0 - do not permute.
6324 * - 1 - permute cells.
6325 * - 2 - permute nodes.
6326 * - 3 - permute cells and nodes.
6328 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6329 * caller is to delete this field using decrRef() as it is no more needed.
6330 * \throw If \a this field has not been constructed via file reading.
6331 * \throw If the MED file is not readable.
6332 * \throw If there is no mesh in the MED file.
6333 * \throw If no field values of the given \a type.
6334 * \throw If no field values lying on the top level support.
6335 * \sa getFieldAtLevel()
6337 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6339 if(getFileName2().empty())
6340 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6341 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6342 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6343 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6348 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6349 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6350 * \param [in] type - a spatial discretization of the new field.
6351 * \param [in] mesh - the supporting mesh.
6352 * \param [out] arrOut - the DataArrayInt containing values of field.
6353 * \param [in] renumPol - specifies how to permute values of the result field according to
6354 * the optional numbers of cells and nodes, if any. The valid values are
6355 * - 0 - do not permute.
6356 * - 1 - permute cells.
6357 * - 2 - permute nodes.
6358 * - 3 - permute cells and nodes.
6360 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6361 * caller is to delete this field using decrRef() as it is no more needed.
6362 * \throw If no field of \a this is lying on \a mesh.
6363 * \throw If the mesh is empty.
6364 * \throw If no field values of the given \a type are available.
6365 * \sa getFieldAtLevel()
6366 * \sa getFieldOnMeshAtLevel()
6368 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6370 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6371 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6372 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6377 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6378 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6379 * \param [in] type - a spatial discretization of interest.
6380 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6381 * \param [out] arrOut - the DataArrayInt containing values of field.
6382 * \param [in] mesh - the supporting mesh.
6383 * \param [in] renumPol - specifies how to permute values of the result field according to
6384 * the optional numbers of cells and nodes, if any. The valid values are
6385 * - 0 - do not permute.
6386 * - 1 - permute cells.
6387 * - 2 - permute nodes.
6388 * - 3 - permute cells and nodes.
6390 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6391 * caller is to delete this field using decrRef() as it is no more needed.
6392 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6393 * \throw If no field of \a this is lying on \a mesh.
6394 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6395 * \sa getFieldAtLevel()
6396 * \sa getFieldOnMeshAtLevel()
6398 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6400 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6401 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6402 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6407 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6408 * This method is called "Old" because in MED3 norm a field has only one meshName
6409 * attached, so this method is for readers of MED2 files. If \a this field
6410 * has not been constructed via file reading, an exception is thrown.
6411 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6412 * \param [in] type - a spatial discretization of interest.
6413 * \param [in] mName - a name of the supporting mesh.
6414 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6415 * \param [out] arrOut - the DataArrayInt containing values of field.
6416 * \param [in] renumPol - specifies how to permute values of the result field according to
6417 * the optional numbers of cells and nodes, if any. The valid values are
6418 * - 0 - do not permute.
6419 * - 1 - permute cells.
6420 * - 2 - permute nodes.
6421 * - 3 - permute cells and nodes.
6423 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6424 * caller is to delete this field using decrRef() as it is no more needed.
6425 * \throw If the MED file is not readable.
6426 * \throw If there is no mesh named \a mName in the MED file.
6427 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6428 * \throw If \a this field has not been constructed via file reading.
6429 * \throw If no field of \a this is lying on the mesh named \a mName.
6430 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6431 * \sa getFieldAtLevel()
6433 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6435 if(getFileName2().empty())
6436 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6437 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6438 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6439 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6444 * Returns values and a profile of the field of a given type lying on a given support.
6445 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6446 * \param [in] type - a spatial discretization of the field.
6447 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6448 * \param [in] mesh - the supporting mesh.
6449 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6450 * field of interest lies on. If the field lies on all entities of the given
6451 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6452 * using decrRef() as it is no more needed.
6453 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6454 * field. The caller is to delete this array using decrRef() as it is no more needed.
6455 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6456 * \throw If no field of \a this is lying on \a mesh.
6457 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6459 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6461 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6462 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6465 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6467 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6469 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6470 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6472 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6476 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6478 return contentNotNull()->getUndergroundDataArrayInt();
6481 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6483 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6487 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6492 * \param [in] fieldId field id in C mode
6494 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6496 med_field_type typcha;
6497 std::string dtunitOut;
6498 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6499 setDtUnit(dtunitOut.c_str());
6500 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6503 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
6504 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6506 setDtUnit(dtunit.c_str());
6507 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6509 catch(INTERP_KERNEL::Exception& e)
6514 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6516 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6517 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6518 ret+=(*it).capacity();
6519 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6520 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6521 ret+=(*it)->getHeapMemorySize();
6526 * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
6529 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6531 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6532 ret->setInfo(_infos);
6533 int sz=(int)_time_steps.size();
6534 for(const int *id=startIds;id!=endIds;id++)
6536 if(*id>=0 && *id<sz)
6538 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6539 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6543 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6545 ret->pushBackTimeStep(tse2);
6549 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6550 oss << " ! Should be in [0," << sz << ") !";
6551 throw INTERP_KERNEL::Exception(oss.str().c_str());
6554 if(ret->getNumberOfTS()>0)
6555 ret->synchronizeNameScope();
6556 ret->copyNameScope(*this);
6561 * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
6564 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6566 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6567 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6568 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6569 ret->setInfo(_infos);
6570 int sz=(int)_time_steps.size();
6572 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6576 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6577 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6581 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6583 ret->pushBackTimeStep(tse2);
6587 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6588 oss << " ! Should be in [0," << sz << ") !";
6589 throw INTERP_KERNEL::Exception(oss.str().c_str());
6592 if(ret->getNumberOfTS()>0)
6593 ret->synchronizeNameScope();
6594 ret->copyNameScope(*this);
6598 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6601 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6602 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6604 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6607 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6608 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6609 ids->pushBackSilent(id);
6611 return buildFromTimeStepIds(ids->begin(),ids->end());
6614 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6617 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6618 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6620 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6623 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6624 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6625 ids->pushBackSilent(id);
6627 return buildFromTimeStepIds(ids->begin(),ids->end());
6630 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6635 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6640 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6643 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6645 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6646 if(pt->isDealingTS(iteration,order))
6649 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6650 std::vector< std::pair<int,int> > vp=getIterations();
6651 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6652 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6653 throw INTERP_KERNEL::Exception(oss.str().c_str());
6656 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6658 return *_time_steps[getTimeStepPos(iteration,order)];
6661 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6663 return *_time_steps[getTimeStepPos(iteration,order)];
6666 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6668 if(_time_steps.empty())
6669 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6670 return _time_steps[0]->getMeshName();
6673 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6675 std::string oldName(getMeshName());
6676 std::vector< std::pair<std::string,std::string> > v(1);
6677 v[0].first=oldName; v[0].second=newMeshName;
6681 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6684 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6686 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6688 ret=cur->changeMeshNames(modifTab) || ret;
6694 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6696 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6698 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6702 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6704 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::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)
6706 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6709 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6710 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6713 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6715 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6717 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6722 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6724 std::string startLine(bkOffset,' ');
6725 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6727 oss << " (" << fmtsId << ")";
6728 oss << " has the following name: \"" << _name << "\"." << std::endl;
6729 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6730 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6732 oss << startLine << " - \"" << *it << "\"" << std::endl;
6735 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6737 std::string chapter(17,'0'+i);
6738 oss << startLine << chapter << std::endl;
6739 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6741 cur->simpleRepr(bkOffset+2,oss,i);
6743 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6744 oss << startLine << chapter << std::endl;
6748 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6750 std::size_t sz=_time_steps.size();
6751 std::vector< std::pair<int,int> > ret(sz);
6753 for(std::size_t i=0;i<sz;i++)
6755 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6758 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6762 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6763 throw INTERP_KERNEL::Exception(oss.str().c_str());
6769 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6771 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6773 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6774 checkCoherencyOfType(tse2);
6775 if(_time_steps.empty())
6777 setName(tse2->getName().c_str());
6778 setInfo(tse2->getInfo());
6780 checkThatComponentsMatch(tse2->getInfo());
6781 _time_steps.push_back(tse);
6784 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6786 std::size_t nbOfCompo=_infos.size();
6787 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6789 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6792 if((cur->getInfo()).size()!=nbOfCompo)
6794 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6795 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6796 throw INTERP_KERNEL::Exception(oss.str().c_str());
6798 cur->copyNameScope(*this);
6803 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6805 _time_steps.resize(nbPdt);
6806 for(int i=0;i<nbPdt;i++)
6808 std::vector< std::pair<int,int> > ts;
6809 med_int numdt=0,numo=0;
6810 med_int meshIt=0,meshOrder=0;
6812 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6817 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6822 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6826 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6829 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6831 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6835 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6837 if(_time_steps.empty())
6838 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6839 checkThatNbOfCompoOfTSMatchThis();
6840 std::vector<std::string> infos(getInfo());
6841 int nbComp=infos.size();
6842 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6843 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6844 for(int i=0;i<nbComp;i++)
6846 std::string info=infos[i];
6848 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6849 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6850 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6853 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6854 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6855 int nbOfTS=_time_steps.size();
6856 for(int i=0;i<nbOfTS;i++)
6857 _time_steps[i]->writeLL(fid,opts,*this);
6860 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6862 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6864 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6866 elt->loadBigArraysRecursively(fid,nasc);
6870 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6872 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6874 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6876 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
6880 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
6882 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6884 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6886 elt->releaseArrays();
6890 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6892 return _time_steps.size();
6895 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6897 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6898 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6900 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6902 newTS.push_back(*it);
6907 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6909 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6910 int maxId=(int)_time_steps.size();
6912 std::set<int> idsToDel;
6913 for(const int *id=startIds;id!=endIds;id++,ii++)
6915 if(*id>=0 && *id<maxId)
6917 idsToDel.insert(*id);
6921 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6922 throw INTERP_KERNEL::Exception(oss.str().c_str());
6925 for(int iii=0;iii<maxId;iii++)
6926 if(idsToDel.find(iii)==idsToDel.end())
6927 newTS.push_back(_time_steps[iii]);
6931 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6933 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6934 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6935 if(nbOfEntriesToKill==0)
6937 std::size_t sz=_time_steps.size();
6938 std::vector<bool> b(sz,true);
6940 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6942 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6943 for(std::size_t i=0;i<sz;i++)
6945 newTS.push_back(_time_steps[i]);
6949 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6952 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
6953 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6955 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6959 tmp->getTime(it2,ord);
6960 if(it2==iteration && order==ord)
6963 oss << "(" << it2 << "," << ord << "), ";
6966 throw INTERP_KERNEL::Exception(oss.str().c_str());
6969 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6972 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6974 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6976 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6980 double ti=tmp->getTime(it2,ord);
6981 if(fabs(time-ti)<eps)
6987 throw INTERP_KERNEL::Exception(oss.str().c_str());
6990 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6992 int lgth=_time_steps.size();
6993 std::vector< std::pair<int,int> > ret(lgth);
6994 for(int i=0;i<lgth;i++)
6995 _time_steps[i]->fillIteration(ret[i]);
7000 * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
7001 * This method returns two things.
7002 * - The absolute dimension of 'this' in first parameter.
7003 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7004 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7006 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7007 * Only these 3 discretizations will be taken into account here.
7009 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7010 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7011 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7013 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7014 * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
7016 * Let's consider the typical following case :
7017 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7018 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7019 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7021 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7023 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7025 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7026 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7027 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7028 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7030 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7032 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7035 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7037 if(pos<0 || pos>=(int)_time_steps.size())
7039 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7040 throw INTERP_KERNEL::Exception(oss.str().c_str());
7042 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7045 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7046 oss << "\nTry to use following method eraseEmptyTS !";
7047 throw INTERP_KERNEL::Exception(oss.str().c_str());
7052 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7054 if(pos<0 || pos>=(int)_time_steps.size())
7056 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7057 throw INTERP_KERNEL::Exception(oss.str().c_str());
7059 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7062 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7063 oss << "\nTry to use following method eraseEmptyTS !";
7064 throw INTERP_KERNEL::Exception(oss.str().c_str());
7069 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7071 std::vector<std::string> ret;
7072 std::set<std::string> ret2;
7073 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7075 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7076 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7077 if(ret2.find(*it2)==ret2.end())
7079 ret.push_back(*it2);
7086 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7088 std::vector<std::string> ret;
7089 std::set<std::string> ret2;
7090 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7092 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7093 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7094 if(ret2.find(*it2)==ret2.end())
7096 ret.push_back(*it2);
7103 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7105 std::vector<std::string> ret;
7106 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7108 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7109 ret.insert(ret.end(),tmp.begin(),tmp.end());
7114 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7116 std::vector<std::string> ret;
7117 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7119 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7120 ret.insert(ret.end(),tmp.begin(),tmp.end());
7125 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7127 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7128 (*it)->changePflsRefsNamesGen2(mapOfModif);
7131 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7133 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7134 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7137 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7139 int lgth=_time_steps.size();
7140 std::vector< std::vector<TypeOfField> > ret(lgth);
7141 for(int i=0;i<lgth;i++)
7142 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7147 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7149 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::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)
7151 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7154 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7156 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7158 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7160 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7161 ret->_time_steps[i]=(*it)->deepCpy();
7166 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7168 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7169 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7170 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7171 for(std::size_t i=0;i<sz;i++)
7173 ret[i]=shallowCpy();
7174 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7176 for(std::size_t i=0;i<sz2;i++)
7178 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7181 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7182 throw INTERP_KERNEL::Exception(oss.str().c_str());
7186 for(std::size_t i=0;i<sz;i++)
7187 for(std::size_t j=0;j<sz2;j++)
7188 ret[i]->_time_steps[j]=ts[j][i];
7192 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7194 _name=field->getName();
7196 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7198 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7199 _infos=arr->getInfoOnComponents();
7202 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7204 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7205 if(_name!=field->getName())
7207 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7208 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7209 throw INTERP_KERNEL::Exception(oss.str().c_str());
7212 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7213 checkThatComponentsMatch(arr->getInfoOnComponents());
7216 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7218 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7219 if(getInfo().size()!=compos.size())
7221 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7222 oss << " number of components of element to append (" << compos.size() << ") !";
7223 throw INTERP_KERNEL::Exception(oss.str().c_str());
7227 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7228 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7229 oss << " But compo in input fields are : ";
7230 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7232 throw INTERP_KERNEL::Exception(oss.str().c_str());
7236 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7238 std::size_t sz=_infos.size();
7240 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7242 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7244 if(elt->getInfo().size()!=sz)
7246 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7247 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7248 throw INTERP_KERNEL::Exception(oss.str().c_str());
7253 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7256 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7257 if(!_time_steps.empty())
7258 checkCoherencyOfTinyInfo(field,arr);
7259 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7260 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7261 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7262 copyTinyInfoFrom(field,arr);
7263 _time_steps.push_back(obj);
7266 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7269 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7270 if(!_time_steps.empty())
7271 checkCoherencyOfTinyInfo(field,arr);
7272 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7273 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7274 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7275 copyTinyInfoFrom(field,arr);
7276 _time_steps.push_back(obj);
7279 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7281 int sz=(int)_time_steps.size();
7284 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7285 throw INTERP_KERNEL::Exception(oss.str().c_str());
7287 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7290 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7292 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7293 throw INTERP_KERNEL::Exception(oss.str().c_str());
7299 //= MEDFileFieldMultiTSWithoutSDA
7301 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7303 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7306 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7310 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7315 * \param [in] fieldId field id in C mode
7317 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7318 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7321 catch(INTERP_KERNEL::Exception& e)
7324 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7325 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7328 catch(INTERP_KERNEL::Exception& e)
7331 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7333 return new MEDFileField1TSWithoutSDA;
7336 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7339 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7340 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7342 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7345 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7347 return MEDFileField1TSWithoutSDA::TYPE_STR;
7350 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7352 return new MEDFileFieldMultiTSWithoutSDA(*this);
7355 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7357 return new MEDFileFieldMultiTSWithoutSDA;
7361 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7362 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7364 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::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)
7366 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7367 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7369 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7370 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7373 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7375 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7376 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7378 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7380 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7383 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7385 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7386 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7387 ret->setIteration(i,elt);
7393 //= MEDFileAnyTypeFieldMultiTS
7395 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7399 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7400 try:MEDFileFieldGlobsReal(fileName)
7402 MEDFileUtilities::CheckFileForRead(fileName);
7403 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7404 _content=BuildContentFrom(fid,fileName,loadAll);
7407 catch(INTERP_KERNEL::Exception& e)
7412 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7414 med_field_type typcha;
7415 std::vector<std::string> infos;
7418 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7419 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7424 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7429 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7434 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
7435 throw INTERP_KERNEL::Exception(oss.str().c_str());
7438 ret->setDtUnit(dtunit.c_str());
7442 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7444 med_field_type typcha;
7446 std::vector<std::string> infos;
7447 std::string dtunit,fieldName;
7448 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7449 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7454 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7459 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7464 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
7465 throw INTERP_KERNEL::Exception(oss.str().c_str());
7468 ret->setDtUnit(dtunit.c_str());
7472 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7475 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7476 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7478 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7479 ret->setFileName(fileName);
7480 ret->_content=c; c->incrRef();
7483 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7485 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7486 ret->setFileName(fileName);
7487 ret->_content=c; c->incrRef();
7490 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7493 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7494 try:MEDFileFieldGlobsReal(fileName)
7496 MEDFileUtilities::CheckFileForRead(fileName);
7497 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7498 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7501 catch(INTERP_KERNEL::Exception& e)
7506 //= MEDFileIntFieldMultiTSWithoutSDA
7508 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7510 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7513 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7517 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7521 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7522 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7525 catch(INTERP_KERNEL::Exception& e)
7529 * \param [in] fieldId field id in C mode
7531 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7532 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7535 catch(INTERP_KERNEL::Exception& e)
7538 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7540 return new MEDFileIntField1TSWithoutSDA;
7543 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7546 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7547 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7549 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7552 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7554 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7557 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7559 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7562 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7564 return new MEDFileIntFieldMultiTSWithoutSDA;
7567 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7569 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7570 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7572 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7574 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7577 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7579 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7581 ret->setIteration(i,elt);
7587 //= MEDFileAnyTypeFieldMultiTS
7590 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7591 * that has been read from a specified MED file.
7592 * \param [in] fileName - the name of the MED file to read.
7593 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7594 * is to delete this field using decrRef() as it is no more needed.
7595 * \throw If reading the file fails.
7597 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7599 MEDFileUtilities::CheckFileForRead(fileName);
7600 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7601 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7602 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7603 ret->loadGlobals(fid);
7608 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7609 * that has been read from a specified MED file.
7610 * \param [in] fileName - the name of the MED file to read.
7611 * \param [in] fieldName - the name of the field to read.
7612 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7613 * is to delete this field using decrRef() as it is no more needed.
7614 * \throw If reading the file fails.
7615 * \throw If there is no field named \a fieldName in the file.
7617 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7619 MEDFileUtilities::CheckFileForRead(fileName);
7620 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7621 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7622 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7623 ret->loadGlobals(fid);
7628 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7629 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7631 * \warning this is a shallow copy constructor
7633 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7635 if(!shallowCopyOfContent)
7637 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7638 otherPtr->incrRef();
7639 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7643 _content=other.shallowCpy();
7647 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7649 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7651 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7655 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7657 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7659 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7663 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7665 return contentNotNullBase()->getPflsReallyUsed2();
7668 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7670 return contentNotNullBase()->getLocsReallyUsed2();
7673 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7675 return contentNotNullBase()->getPflsReallyUsedMulti2();
7678 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7680 return contentNotNullBase()->getLocsReallyUsedMulti2();
7683 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7685 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7688 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7690 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7693 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7695 return contentNotNullBase()->getNumberOfTS();
7698 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7700 contentNotNullBase()->eraseEmptyTS();
7703 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7705 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7708 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7710 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7713 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7715 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7716 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7721 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7723 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7724 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7729 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7731 return contentNotNullBase()->getIterations();
7734 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7736 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7737 pushBackTimeStep(*it);
7740 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7743 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7744 checkCoherencyOfType(f1ts);
7746 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7747 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7749 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7750 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7751 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7752 _content->pushBackTimeStep(cSafe);
7753 appendGlobs(*f1ts,1e-12);
7756 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7758 contentNotNullBase()->synchronizeNameScope();
7761 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7763 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7766 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7768 return contentNotNullBase()->getPosGivenTime(time,eps);
7771 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7773 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7776 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7778 return contentNotNullBase()->getTypesOfFieldAvailable();
7781 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::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)
7783 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7786 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7788 return contentNotNullBase()->getName();
7791 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7793 contentNotNullBase()->setName(name);
7796 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7798 return contentNotNullBase()->getDtUnit();
7801 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7803 contentNotNullBase()->setDtUnit(dtUnit);
7806 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7808 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7811 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7813 return contentNotNullBase()->getTimeSteps(ret1);
7816 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7818 return contentNotNullBase()->getMeshName();
7821 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7823 contentNotNullBase()->setMeshName(newMeshName);
7826 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7828 return contentNotNullBase()->changeMeshNames(modifTab);
7831 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7833 return contentNotNullBase()->getInfo();
7836 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7838 return contentNotNullBase()->setInfo(info);
7841 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7843 const std::vector<std::string> ret=getInfo();
7844 return (int)ret.size();
7847 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7849 writeGlobals(fid,*this);
7850 contentNotNullBase()->writeLL(fid,*this);
7854 * Writes \a this field into a MED file specified by its name.
7855 * \param [in] fileName - the MED file name.
7856 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7857 * - 2 - erase; an existing file is removed.
7858 * - 1 - append; same data should not be present in an existing file.
7859 * - 0 - overwrite; same data present in an existing file is overwritten.
7860 * \throw If the field name is not set.
7861 * \throw If no field data is set.
7862 * \throw If \a mode == 1 and the same data is present in an existing file.
7864 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7866 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7867 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7872 * This method alloc the arrays and load potentially huge arrays contained in this field.
7873 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
7874 * This method can be also called to refresh or reinit values from a file.
7876 * \throw If the fileName is not set or points to a non readable MED file.
7878 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
7880 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
7881 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
7885 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
7886 * But once data loaded once, this method does nothing.
7888 * \throw If the fileName is not set or points to a non readable MED file.
7889 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
7891 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
7893 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
7894 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
7898 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
7899 * This method does not release arrays set outside the context of a MED file.
7901 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
7903 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
7905 contentNotNullBase()->releaseArrays();
7908 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7910 std::ostringstream oss;
7911 contentNotNullBase()->simpleRepr(0,oss,-1);
7912 simpleReprGlobs(oss);
7916 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7919 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7920 ret+=_content->getHeapMemorySize();
7921 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7925 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
7926 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7927 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7929 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7931 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7933 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7934 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7935 std::size_t sz(contentsSplit.size());
7936 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7937 for(std::size_t i=0;i<sz;i++)
7939 ret[i]=shallowCpy();
7940 ret[i]->_content=contentsSplit[i];
7945 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7947 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7948 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7949 ret->_content=_content->deepCpy();
7950 ret->deepCpyGlobs(*this);
7954 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7960 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7961 * \param [in] iteration - the iteration number of a required time step.
7962 * \param [in] order - the iteration order number of required time step.
7963 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7964 * delete this field using decrRef() as it is no more needed.
7965 * \throw If there is no required time step in \a this field.
7967 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7969 int pos=getPosOfTimeStep(iteration,order);
7970 return getTimeStepAtPos(pos);
7974 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7975 * \param [in] time - the time of the time step of interest.
7976 * \param [in] eps - a precision used to compare time values.
7977 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7978 * delete this field using decrRef() as it is no more needed.
7979 * \throw If there is no required time step in \a this field.
7981 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7983 int pos=getPosGivenTime(time,eps);
7984 return getTimeStepAtPos(pos);
7987 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7989 return new MEDFileAnyTypeFieldMultiTSIterator(this);
7992 //= MEDFileFieldMultiTS
7995 * Returns a new empty instance of MEDFileFieldMultiTS.
7996 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7997 * is to delete this field using decrRef() as it is no more needed.
7999 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8001 return new MEDFileFieldMultiTS;
8005 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8006 * that has been read from a specified MED file.
8007 * \param [in] fileName - the name of the MED file to read.
8008 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8009 * is to delete this field using decrRef() as it is no more needed.
8010 * \throw If reading the file fails.
8012 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8014 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8015 ret->contentNotNull();//to check that content type matches with \a this type.
8020 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8021 * that has been read from a specified MED file.
8022 * \param [in] fileName - the name of the MED file to read.
8023 * \param [in] fieldName - the name of the field to read.
8024 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8025 * is to delete this field using decrRef() as it is no more needed.
8026 * \throw If reading the file fails.
8027 * \throw If there is no field named \a fieldName in the file.
8029 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8031 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8032 ret->contentNotNull();//to check that content type matches with \a this type.
8037 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8038 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8040 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8041 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8042 * \warning this is a shallow copy constructor
8043 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8044 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8045 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8046 * is to delete this field using decrRef() as it is no more needed.
8048 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8050 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8053 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8055 return new MEDFileFieldMultiTS(*this);
8058 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8061 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8062 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8064 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8068 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8069 * following the given input policy.
8071 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8072 * By default (true) the globals are deeply copied.
8073 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8075 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8077 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8078 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8081 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8083 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8084 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8085 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8088 ret=MEDFileIntFieldMultiTS::New();
8090 ret->deepCpyGlobs(*this);
8092 ret->shallowCpyGlobs(*this);
8097 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8098 * \param [in] pos - a time step id.
8099 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8100 * delete this field using decrRef() as it is no more needed.
8101 * \throw If \a pos is not a valid time step id.
8103 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8105 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8108 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8109 throw INTERP_KERNEL::Exception(oss.str().c_str());
8111 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8114 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8115 ret->shallowCpyGlobs(*this);
8118 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8119 throw INTERP_KERNEL::Exception(oss.str().c_str());
8123 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8124 * mesh entities of a given dimension of the first mesh in MED file.
8125 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8126 * \param [in] type - a spatial discretization of interest.
8127 * \param [in] iteration - the iteration number of a required time step.
8128 * \param [in] order - the iteration order number of required time step.
8129 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8130 * \param [in] renumPol - specifies how to permute values of the result field according to
8131 * the optional numbers of cells and nodes, if any. The valid values are
8132 * - 0 - do not permute.
8133 * - 1 - permute cells.
8134 * - 2 - permute nodes.
8135 * - 3 - permute cells and nodes.
8137 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8138 * caller is to delete this field using decrRef() as it is no more needed.
8139 * \throw If the MED file is not readable.
8140 * \throw If there is no mesh in the MED file.
8141 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8142 * \throw If no field values of the required parameters are available.
8144 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8146 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8147 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8149 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8150 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8151 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8152 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8157 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8158 * the top level cells of the first mesh in MED file.
8159 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8160 * \param [in] type - a spatial discretization of interest.
8161 * \param [in] iteration - the iteration number of a required time step.
8162 * \param [in] order - the iteration order number of required time step.
8163 * \param [in] renumPol - specifies how to permute values of the result field according to
8164 * the optional numbers of cells and nodes, if any. The valid values are
8165 * - 0 - do not permute.
8166 * - 1 - permute cells.
8167 * - 2 - permute nodes.
8168 * - 3 - permute cells and nodes.
8170 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8171 * caller is to delete this field using decrRef() as it is no more needed.
8172 * \throw If the MED file is not readable.
8173 * \throw If there is no mesh in the MED file.
8174 * \throw If no field values of the required parameters are available.
8176 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8178 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8179 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8181 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8182 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8183 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8184 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8189 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8191 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8192 * \param [in] type - a spatial discretization of interest.
8193 * \param [in] iteration - the iteration number of a required time step.
8194 * \param [in] order - the iteration order number of required time step.
8195 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8196 * \param [in] mesh - the supporting mesh.
8197 * \param [in] renumPol - specifies how to permute values of the result field according to
8198 * the optional numbers of cells and nodes, if any. The valid values are
8199 * - 0 - do not permute.
8200 * - 1 - permute cells.
8201 * - 2 - permute nodes.
8202 * - 3 - permute cells and nodes.
8204 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8205 * caller is to delete this field using decrRef() as it is no more needed.
8206 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8207 * \throw If no field of \a this is lying on \a mesh.
8208 * \throw If no field values of the required parameters are available.
8210 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8212 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8213 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8215 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8216 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8217 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8218 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8223 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8225 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8226 * \param [in] type - a spatial discretization of the new field.
8227 * \param [in] iteration - the iteration number of a required time step.
8228 * \param [in] order - the iteration order number of required time step.
8229 * \param [in] mesh - the supporting mesh.
8230 * \param [in] renumPol - specifies how to permute values of the result field according to
8231 * the optional numbers of cells and nodes, if any. The valid values are
8232 * - 0 - do not permute.
8233 * - 1 - permute cells.
8234 * - 2 - permute nodes.
8235 * - 3 - permute cells and nodes.
8237 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8238 * caller is to delete this field using decrRef() as it is no more needed.
8239 * \throw If no field of \a this is lying on \a mesh.
8240 * \throw If no field values of the required parameters are available.
8242 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8244 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8245 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8247 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8248 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8249 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8250 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8255 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8256 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8257 * This method is useful for MED2 file format when field on different mesh was autorized.
8259 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8261 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8262 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8264 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8265 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8266 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8267 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8272 * Returns values and a profile of the field of a given type, of a given time step,
8273 * lying on a given support.
8274 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8275 * \param [in] type - a spatial discretization of the field.
8276 * \param [in] iteration - the iteration number of a required time step.
8277 * \param [in] order - the iteration order number of required time step.
8278 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8279 * \param [in] mesh - the supporting mesh.
8280 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8281 * field of interest lies on. If the field lies on all entities of the given
8282 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8283 * using decrRef() as it is no more needed.
8284 * \param [in] glob - the global data storing profiles and localization.
8285 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8286 * field. The caller is to delete this array using decrRef() as it is no more needed.
8287 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8288 * \throw If no field of \a this is lying on \a mesh.
8289 * \throw If no field values of the required parameters are available.
8291 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8293 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8294 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8296 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8297 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8298 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8301 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8303 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8305 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8306 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8308 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
8312 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8314 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8316 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8317 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8319 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
8324 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8325 * the given field is checked if its elements are sorted suitable for writing to MED file
8326 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8327 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8328 * \param [in] field - the field to add to \a this.
8329 * \throw If the name of \a field is empty.
8330 * \throw If the data array of \a field is not set.
8331 * \throw If existing time steps have different name or number of components than \a field.
8332 * \throw If the underlying mesh of \a field has no name.
8333 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8335 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8337 const DataArrayDouble *arr=0;
8339 arr=field->getArray();
8340 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8344 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8345 * a given dimension of a given mesh are used as the support of the given field.
8346 * Elements of the given mesh must be sorted suitable for writing to MED file.
8347 * Order of underlying mesh entities of the given field specified by \a profile parameter
8348 * is not prescribed; this method permutes field values to have them sorted by element
8349 * type as required for writing to MED file.
8350 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8351 * \param [in] field - the field to add to \a this.
8352 * \param [in] mesh - the supporting mesh of \a field.
8353 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8354 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8355 * \throw If either \a field or \a mesh or \a profile has an empty name.
8356 * \throw If existing time steps have different name or number of components than \a field.
8357 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8358 * \throw If the data array of \a field is not set.
8359 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8361 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8363 const DataArrayDouble *arr=0;
8365 arr=field->getArray();
8366 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8369 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8371 _content=new MEDFileFieldMultiTSWithoutSDA;
8374 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8375 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8378 catch(INTERP_KERNEL::Exception& e)
8381 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8382 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8385 catch(INTERP_KERNEL::Exception& e)
8388 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8392 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::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)
8394 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8397 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8399 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8402 DataArrayDouble *MEDFileFieldMultiTS::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)
8404 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8407 //= MEDFileAnyTypeFieldMultiTSIterator
8409 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8414 _nb_iter=fmts->getNumberOfTS();
8418 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8422 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8424 if(_iter_id<_nb_iter)
8426 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8428 return fmts->getTimeStepAtPos(_iter_id++);
8436 //= MEDFileIntFieldMultiTS
8439 * Returns a new empty instance of MEDFileFieldMultiTS.
8440 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8441 * is to delete this field using decrRef() as it is no more needed.
8443 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8445 return new MEDFileIntFieldMultiTS;
8449 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8450 * that has been read from a specified MED file.
8451 * \param [in] fileName - the name of the MED file to read.
8452 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8453 * is to delete this field using decrRef() as it is no more needed.
8454 * \throw If reading the file fails.
8456 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8458 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8459 ret->contentNotNull();//to check that content type matches with \a this type.
8464 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8465 * that has been read from a specified MED file.
8466 * \param [in] fileName - the name of the MED file to read.
8467 * \param [in] fieldName - the name of the field to read.
8468 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8469 * is to delete this field using decrRef() as it is no more needed.
8470 * \throw If reading the file fails.
8471 * \throw If there is no field named \a fieldName in the file.
8473 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8475 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8476 ret->contentNotNull();//to check that content type matches with \a this type.
8481 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8482 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8484 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8485 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8486 * \warning this is a shallow copy constructor
8487 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8488 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8489 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8490 * is to delete this field using decrRef() as it is no more needed.
8492 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8494 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8498 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8499 * following the given input policy.
8501 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8502 * By default (true) the globals are deeply copied.
8503 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8505 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8507 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8508 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8511 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8513 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8514 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8515 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8518 ret=MEDFileFieldMultiTS::New();
8520 ret->deepCpyGlobs(*this);
8522 ret->shallowCpyGlobs(*this);
8526 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8528 return new MEDFileIntFieldMultiTS(*this);
8531 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8534 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8535 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8537 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8541 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8542 * mesh entities of a given dimension of the first mesh in MED file.
8543 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8544 * \param [in] type - a spatial discretization of interest.
8545 * \param [in] iteration - the iteration number of a required time step.
8546 * \param [in] order - the iteration order number of required time step.
8547 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8548 * \param [out] arrOut - the DataArrayInt containing values of field.
8549 * \param [in] renumPol - specifies how to permute values of the result field according to
8550 * the optional numbers of cells and nodes, if any. The valid values are
8551 * - 0 - do not permute.
8552 * - 1 - permute cells.
8553 * - 2 - permute nodes.
8554 * - 3 - permute cells and nodes.
8556 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8557 * caller is to delete this field using decrRef() as it is no more needed.
8558 * \throw If the MED file is not readable.
8559 * \throw If there is no mesh in the MED file.
8560 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8561 * \throw If no field values of the required parameters are available.
8563 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8565 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8566 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8568 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8569 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8570 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8571 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8576 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8577 * the top level cells of the first mesh in MED file.
8578 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8579 * \param [in] type - a spatial discretization of interest.
8580 * \param [in] iteration - the iteration number of a required time step.
8581 * \param [in] order - the iteration order number of required time step.
8582 * \param [out] arrOut - the DataArrayInt containing values of field.
8583 * \param [in] renumPol - specifies how to permute values of the result field according to
8584 * the optional numbers of cells and nodes, if any. The valid values are
8585 * - 0 - do not permute.
8586 * - 1 - permute cells.
8587 * - 2 - permute nodes.
8588 * - 3 - permute cells and nodes.
8590 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8591 * caller is to delete this field using decrRef() as it is no more needed.
8592 * \throw If the MED file is not readable.
8593 * \throw If there is no mesh in the MED file.
8594 * \throw If no field values of the required parameters are available.
8596 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8598 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8599 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8601 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8602 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8603 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8604 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8609 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8611 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8612 * \param [in] type - a spatial discretization of interest.
8613 * \param [in] iteration - the iteration number of a required time step.
8614 * \param [in] order - the iteration order number of required time step.
8615 * \param [out] arrOut - the DataArrayInt containing values of field.
8616 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8617 * \param [in] mesh - the supporting mesh.
8618 * \param [in] renumPol - specifies how to permute values of the result field according to
8619 * the optional numbers of cells and nodes, if any. The valid values are
8620 * - 0 - do not permute.
8621 * - 1 - permute cells.
8622 * - 2 - permute nodes.
8623 * - 3 - permute cells and nodes.
8625 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8626 * caller is to delete this field using decrRef() as it is no more needed.
8627 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8628 * \throw If no field of \a this is lying on \a mesh.
8629 * \throw If no field values of the required parameters are available.
8631 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8633 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8634 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8636 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8637 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8638 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8639 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8644 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8646 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8647 * \param [in] type - a spatial discretization of the new field.
8648 * \param [in] iteration - the iteration number of a required time step.
8649 * \param [in] order - the iteration order number of required time step.
8650 * \param [in] mesh - the supporting mesh.
8651 * \param [out] arrOut - the DataArrayInt containing values of field.
8652 * \param [in] renumPol - specifies how to permute values of the result field according to
8653 * the optional numbers of cells and nodes, if any. The valid values are
8654 * - 0 - do not permute.
8655 * - 1 - permute cells.
8656 * - 2 - permute nodes.
8657 * - 3 - permute cells and nodes.
8659 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8660 * caller is to delete this field using decrRef() as it is no more needed.
8661 * \throw If no field of \a this is lying on \a mesh.
8662 * \throw If no field values of the required parameters are available.
8664 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8666 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8667 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8669 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8670 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8671 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8672 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8677 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8678 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8679 * This method is useful for MED2 file format when field on different mesh was autorized.
8681 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8683 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8684 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8686 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8687 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8688 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8689 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8694 * Returns values and a profile of the field of a given type, of a given time step,
8695 * lying on a given support.
8696 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8697 * \param [in] type - a spatial discretization of the field.
8698 * \param [in] iteration - the iteration number of a required time step.
8699 * \param [in] order - the iteration order number of required time step.
8700 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8701 * \param [in] mesh - the supporting mesh.
8702 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8703 * field of interest lies on. If the field lies on all entities of the given
8704 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8705 * using decrRef() as it is no more needed.
8706 * \param [in] glob - the global data storing profiles and localization.
8707 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8708 * field. The caller is to delete this array using decrRef() as it is no more needed.
8709 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8710 * \throw If no field of \a this is lying on \a mesh.
8711 * \throw If no field values of the required parameters are available.
8713 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8715 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8716 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8718 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8719 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8720 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8724 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8725 * \param [in] pos - a time step id.
8726 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8727 * delete this field using decrRef() as it is no more needed.
8728 * \throw If \a pos is not a valid time step id.
8730 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8732 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8735 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8736 throw INTERP_KERNEL::Exception(oss.str().c_str());
8738 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8741 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8742 ret->shallowCpyGlobs(*this);
8745 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8746 throw INTERP_KERNEL::Exception(oss.str().c_str());
8750 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8751 * the given field is checked if its elements are sorted suitable for writing to MED file
8752 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8753 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8754 * \param [in] field - the field to add to \a this.
8755 * \throw If the name of \a field is empty.
8756 * \throw If the data array of \a field is not set.
8757 * \throw If existing time steps have different name or number of components than \a field.
8758 * \throw If the underlying mesh of \a field has no name.
8759 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8761 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8763 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8767 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8768 * a given dimension of a given mesh are used as the support of the given field.
8769 * Elements of the given mesh must be sorted suitable for writing to MED file.
8770 * Order of underlying mesh entities of the given field specified by \a profile parameter
8771 * is not prescribed; this method permutes field values to have them sorted by element
8772 * type as required for writing to MED file.
8773 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8774 * \param [in] field - the field to add to \a this.
8775 * \param [in] mesh - the supporting mesh of \a field.
8776 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8777 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8778 * \throw If either \a field or \a mesh or \a profile has an empty name.
8779 * \throw If existing time steps have different name or number of components than \a field.
8780 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8781 * \throw If the data array of \a field is not set.
8782 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8784 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8786 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8789 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8791 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8793 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8794 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8796 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8800 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8802 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8804 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8805 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8807 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8811 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8813 _content=new MEDFileIntFieldMultiTSWithoutSDA;
8816 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8820 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8821 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8824 catch(INTERP_KERNEL::Exception& e)
8827 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8828 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8831 catch(INTERP_KERNEL::Exception& e)
8834 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8836 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8841 MEDFileFields *MEDFileFields::New()
8843 return new MEDFileFields;
8846 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8848 return new MEDFileFields(fileName,loadAll);
8851 std::size_t MEDFileFields::getHeapMemorySize() const
8853 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8854 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8855 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8856 ret+=(*it)->getHeapMemorySize();
8857 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8860 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8862 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8864 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8866 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8867 ret->_fields[i]=(*it)->deepCpy();
8869 ret->deepCpyGlobs(*this);
8873 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8875 return new MEDFileFields(*this);
8879 * This method scans for all fields in \a this which time steps ids are common. Time step are discriminated by the pair of integer (iteration,order) whatever
8880 * the double time value. If all returned time steps are \b exactly those for all fields in \a this output parameter \a areThereSomeForgottenTS will be set to false.
8881 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8883 * \param [out] areThereSomeForgottenTS - indicates to the caller if there is some time steps in \a this that are not present for all fields in \a this.
8884 * \return the sorted list of time steps (specified with a pair of integer iteration first and order second) present for all fields in \a this.
8886 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8888 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8890 std::set< std::pair<int,int> > s;
8891 bool firstShot=true;
8892 areThereSomeForgottenTS=false;
8893 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8895 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8897 std::vector< std::pair<int,int> > v=(*it)->getIterations();
8898 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8900 { s=s1; firstShot=false; }
8903 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8905 areThereSomeForgottenTS=true;
8909 std::vector< std::pair<int,int> > ret;
8910 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8914 int MEDFileFields::getNumberOfFields() const
8916 return _fields.size();
8919 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8921 std::vector<std::string> ret(_fields.size());
8923 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8925 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8928 ret[i]=f->getName();
8932 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8933 throw INTERP_KERNEL::Exception(oss.str().c_str());
8939 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8941 std::vector<std::string> ret;
8942 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8944 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8946 ret.push_back(cur->getMeshName());
8951 std::string MEDFileFields::simpleRepr() const
8953 std::ostringstream oss;
8954 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8959 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8961 int nbOfFields=getNumberOfFields();
8962 std::string startLine(bkOffset,' ');
8963 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8965 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8967 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8970 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8974 oss << startLine << " - not defined !" << std::endl;
8978 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8980 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8981 std::string chapter(17,'0'+i);
8982 oss << startLine << chapter << std::endl;
8985 cur->simpleRepr(bkOffset+2,oss,i);
8989 oss << startLine << " - not defined !" << std::endl;
8991 oss << startLine << chapter << std::endl;
8993 simpleReprGlobs(oss);
8996 MEDFileFields::MEDFileFields()
9000 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9001 try:MEDFileFieldGlobsReal(fileName)
9003 MEDFileUtilities::CheckFileForRead(fileName);
9004 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9005 int nbFields=MEDnField(fid);
9006 _fields.resize(nbFields);
9007 med_field_type typcha;
9008 for(int i=0;i<nbFields;i++)
9010 std::vector<std::string> infos;
9011 std::string fieldName,dtunit;
9012 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9017 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9022 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9027 std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
9028 throw INTERP_KERNEL::Exception(oss.str().c_str());
9032 loadAllGlobals(fid);
9034 catch(INTERP_KERNEL::Exception& e)
9039 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9042 writeGlobals(fid,*this);
9043 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9045 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9048 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9049 throw INTERP_KERNEL::Exception(oss.str().c_str());
9051 elt->writeLL(fid,*this);
9055 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9057 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9058 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9063 * This method alloc the arrays and load potentially huge arrays contained in this field.
9064 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9065 * This method can be also called to refresh or reinit values from a file.
9067 * \throw If the fileName is not set or points to a non readable MED file.
9069 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9071 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9072 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9074 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9076 elt->loadBigArraysRecursively(fid,*elt);
9081 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9082 * But once data loaded once, this method does nothing.
9084 * \throw If the fileName is not set or points to a non readable MED file.
9085 * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9087 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9089 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9090 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9092 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9094 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9099 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9100 * This method does not release arrays set outside the context of a MED file.
9102 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9104 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9106 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9107 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9109 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9111 elt->releaseArrays();
9115 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9117 std::vector<std::string> ret;
9118 std::set<std::string> ret2;
9119 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9121 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9122 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9123 if(ret2.find(*it2)==ret2.end())
9125 ret.push_back(*it2);
9132 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9134 std::vector<std::string> ret;
9135 std::set<std::string> ret2;
9136 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9138 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9139 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9140 if(ret2.find(*it2)==ret2.end())
9142 ret.push_back(*it2);
9149 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9151 std::vector<std::string> ret;
9152 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9154 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9155 ret.insert(ret.end(),tmp.begin(),tmp.end());
9160 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9162 std::vector<std::string> ret;
9163 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9165 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9166 ret.insert(ret.end(),tmp.begin(),tmp.end());
9171 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9173 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9174 (*it)->changePflsRefsNamesGen2(mapOfModif);
9177 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9179 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9180 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9183 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9185 _fields.resize(newSize);
9188 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9190 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9194 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9197 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9198 _fields.push_back(field->getContent());
9199 appendGlobs(*field,1e-12);
9202 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9205 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9206 if(i>=(int)_fields.size())
9207 _fields.resize(i+1);
9208 _fields[i]=field->getContent();
9209 appendGlobs(*field,1e-12);
9212 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9214 destroyFieldsAtPos(&i,&i+1);
9217 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9219 std::vector<bool> b(_fields.size(),true);
9220 for(const int *i=startIds;i!=endIds;i++)
9222 if(*i<0 || *i>=(int)_fields.size())
9224 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9225 throw INTERP_KERNEL::Exception(oss.str().c_str());
9229 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9231 for(std::size_t i=0;i<_fields.size();i++)
9233 fields[j++]=_fields[i];
9237 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9239 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9240 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9241 std::vector<bool> b(_fields.size(),true);
9243 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9245 if(k<0 || k>=(int)_fields.size())
9247 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9248 throw INTERP_KERNEL::Exception(oss.str().c_str());
9252 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9254 for(std::size_t i=0;i<_fields.size();i++)
9256 fields[j++]=_fields[i];
9260 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9263 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9265 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9267 ret=cur->changeMeshNames(modifTab) || ret;
9273 * \param [in] meshName the name of the mesh that will be renumbered.
9274 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9275 * This code corresponds to the distribution of types in the corresponding mesh.
9276 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9277 * \param [in] renumO2N the old to new renumber array.
9278 * \return If true a renumbering has been performed. The structure in \a this has been modified. If false, nothing has been done: it is typically the case if \a meshName is not refered by any
9281 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9284 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9286 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9289 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9295 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9297 if(i<0 || i>=(int)_fields.size())
9299 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9300 throw INTERP_KERNEL::Exception(oss.str().c_str());
9302 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9305 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9306 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9307 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9309 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9311 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9314 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9315 throw INTERP_KERNEL::Exception(oss.str().c_str());
9317 ret->shallowCpyGlobs(*this);
9322 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9323 * This method is accessible in python using __getitem__ with a list in input.
9324 * \return a new object that the caller should deal with.
9326 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9328 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9329 std::size_t sz=std::distance(startIds,endIds);
9330 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9332 for(const int *i=startIds;i!=endIds;i++,j++)
9334 if(*i<0 || *i>=(int)_fields.size())
9336 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9337 throw INTERP_KERNEL::Exception(oss.str().c_str());
9339 fields[j]=_fields[*i];
9341 ret->_fields=fields;
9345 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9347 return getFieldAtPos(getPosFromFieldName(fieldName));
9351 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9352 * This method can be seen as a filter applied on \a this, that returns an object containing
9353 * reduced the list of fields compared to those in \a this. The returned object is a new object but the object on which it lies are only
9354 * shallow copied from \a this.
9356 * \param [in] meshName - the name of the mesh on w
9357 * \return a new object that the caller should deal with.
9359 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9361 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9362 ret->shallowCpyOnlyUsedGlobs(*this);
9363 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9365 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9368 if(cur->getMeshName()==meshName)
9371 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9372 ret->_fields.push_back(cur2);
9379 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9380 * Input time steps are specified using a pair of integer (iteration, order).
9381 * This method can be seen as a filter applied on \a this, that returns an object containing the same number of fields than those in \a this,
9382 * but for each multitimestep only the time steps in \a timeSteps are kept.
9383 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9385 * The returned object points to shallow copy of elements in \a this.
9387 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9388 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9389 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9391 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9393 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9394 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9396 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9399 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9400 ret->_fields.push_back(elt);
9402 ret->shallowCpyOnlyUsedGlobs(*this);
9407 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9409 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9411 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9412 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9414 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9417 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9418 if(elt->getNumberOfTS()!=0)
9419 ret->_fields.push_back(elt);
9421 ret->shallowCpyOnlyUsedGlobs(*this);
9425 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9427 return new MEDFileFieldsIterator(this);
9430 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9432 std::string tmp(fieldName);
9433 std::vector<std::string> poss;
9434 for(std::size_t i=0;i<_fields.size();i++)
9436 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9439 std::string fname(f->getName());
9443 poss.push_back(fname);
9446 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9447 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9449 throw INTERP_KERNEL::Exception(oss.str().c_str());
9452 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9457 _nb_iter=fs->getNumberOfFields();
9461 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9465 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9467 if(_iter_id<_nb_iter)
9469 MEDFileFields *fs(_fs);
9471 return fs->getFieldAtPos(_iter_id++);