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"
25 #include "MEDFileFieldOverView.hxx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[32];
41 using namespace ParaMEDMEM;
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
48 return new MEDFileFieldLoc(fid,locName);
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 return new MEDFileFieldLoc(fid,id);
56 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)
58 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
63 med_geometry_type geotype;
64 med_geometry_type sectiongeotype;
66 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
70 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71 _nb_node_per_cell=cm.getNumberOfNodes();
72 _ref_coo.resize(_dim*_nb_node_per_cell);
73 _gs_coo.resize(_dim*_nb_gauss_pt);
74 _w.resize(_nb_gauss_pt);
75 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 med_geometry_type geotype;
81 med_geometry_type sectiongeotype;
83 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
88 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
89 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90 _nb_node_per_cell=cm.getNumberOfNodes();
91 _ref_coo.resize(_dim*_nb_node_per_cell);
92 _gs_coo.resize(_dim*_nb_gauss_pt);
93 _w.resize(_nb_gauss_pt);
94 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
98 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),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
119 static const char OFF7[]="\n ";
120 oss << "\"" << _name << "\"" << OFF7;
121 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
122 oss << "Dimension=" << _dim << OFF7;
123 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
124 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
125 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
127 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
130 void MEDFileFieldLoc::setName(const char *name)
135 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
137 if(_name!=other._name)
141 if(_nb_gauss_pt!=other._nb_gauss_pt)
143 if(_nb_node_per_cell!=other._nb_node_per_cell)
145 if(_geo_type!=other._geo_type)
147 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
149 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
151 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
157 void MEDFileFieldLoc::writeLL(med_idt fid) const
159 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);
162 std::string MEDFileFieldLoc::repr() const
164 std::ostringstream oss; oss.precision(15);
165 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
166 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
167 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
168 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
169 oss << "\n - Ref coords are : ";
170 int sz=_ref_coo.size();
173 int nbOfTuples=sz/_dim;
174 for(int i=0;i<nbOfTuples;i++)
177 for(int j=0;j<_dim;j++)
178 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
183 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
184 oss << "\n - Gauss coords in reference element : ";
188 int nbOfTuples=sz/_dim;
189 for(int i=0;i<nbOfTuples;i++)
192 for(int j=0;j<_dim;j++)
193 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
198 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
199 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
203 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
205 _type=field->getTypeOfField();
211 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
212 _end=_start+nbOfCells;
218 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
219 const int *arrPtr=arr->getConstPointer();
220 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
221 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
227 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
228 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
229 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
231 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
232 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
233 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
234 const int *dai2Ptr=dai2->getConstPointer();
235 int nbi=gsLoc.getWeights().size();
236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
237 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
238 const int *da3Ptr=da3->getConstPointer();
239 if(da3->getNumberOfTuples()!=nbOfCells)
240 {//profile : for gauss even in NoProfile !!!
241 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
243 da3->setName(_profile.c_str());
244 glob.appendProfile(da3);
246 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
247 _nval=da3->getNbOfElems();
248 da4->alloc(_nval*nbi,1);
249 int *da4Ptr=da4->getPointer();
250 for(int i=0;i<_nval;i++)
252 int ref=dai2Ptr[offset+da3Ptr[i]];
253 for(int j=0;j<nbi;j++)
256 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
257 _localization=oss2.str();
258 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
259 _end=_start+_nval*nbi;
260 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
264 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
270 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
271 * \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).
272 * \param [in] multiTypePfl is the end user profile specified in high level API
273 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
274 * \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.
275 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
276 * \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.
278 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)
281 _type=field->getTypeOfField();
282 std::string pflName(multiTypePfl->getName());
283 std::ostringstream oss; oss << pflName;
284 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
288 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
289 if(_type!=ON_GAUSS_PT)
291 locIds->setName(oss.str().c_str());
292 glob.appendProfile(locIds);
301 _nval=idsInPfl->getNumberOfTuples();
302 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
308 _nval=idsInPfl->getNumberOfTuples();
309 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
316 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
317 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
318 arr3->computeOffsets2();
319 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
320 int trueNval=tmp->getNumberOfTuples();
321 _nval=idsInPfl->getNumberOfTuples();
322 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
323 _end=_start+trueNval;
328 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
330 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
331 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
332 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
335 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
337 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
338 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
340 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
342 for(const int *pt=da4->begin();pt!=da4->end();pt++)
343 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
344 tmp->alloc(trueNval,1);
345 int *tmpPtr=tmp->getPointer();
346 for(const int *pt=da4->begin();pt!=da4->end();pt++)
347 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
350 _nval=da4->getNumberOfTuples();
351 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
352 _end=_start+trueNval;
353 oss << "_loc_" << _loc_id;
356 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
357 da5->setName(oss.str().c_str());
358 glob.appendProfile(da5);
363 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
365 da3->setName(oss.str().c_str());
366 glob.appendProfile(da3);
370 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
371 _localization=oss2.str();
372 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
376 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
381 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
384 _nval=arrr->getNumberOfTuples();
385 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
390 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
392 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
395 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
397 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
400 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
402 return new MEDFileFieldPerMeshPerTypePerDisc(other);
405 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
407 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
410 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
412 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
417 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
418 try:_type(atype),_father(fath)
421 catch(INTERP_KERNEL::Exception& e)
426 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
430 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)
434 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
435 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
439 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
444 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
446 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
448 std::string fieldName=nasc.getName();
449 std::string meshName=getMeshName();
450 int iteration=getIteration();
451 int order=getOrder();
452 TypeOfField type=getType();
453 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
455 med_geometry_type mgeoti;
456 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
457 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
458 pflname,&profilesize,locname,&nbi);
459 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
460 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
462 _end=start+_nval*nbi;
464 if(type==ON_CELLS && !_localization.empty())
466 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
467 setType(ON_GAUSS_PT);
470 setType(ON_GAUSS_NE);
471 _localization.clear();
476 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
478 std::string fieldName=nasc.getName();
479 std::string meshName=getMeshName();
480 int iteration=getIteration();
481 int order=getOrder();
482 TypeOfField type=getType();
483 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
484 med_geometry_type mgeoti;
485 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
487 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
490 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
491 if(_start<0 || _start>=arr->getNumberOfTuples())
493 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
494 throw INTERP_KERNEL::Exception(oss.str().c_str());
496 if(_end<0 || _end>arr->getNumberOfTuples())
498 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
499 throw INTERP_KERNEL::Exception(oss.str().c_str());
502 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
503 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
504 int nbOfCompo=arr->getNumberOfComponents();
505 if(_end-_start!=nbValsInFile*nbi)
507 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 !";
508 throw INTERP_KERNEL::Exception(oss.str().c_str());
510 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
513 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
514 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
515 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
518 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
521 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
522 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
523 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
526 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
530 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
532 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
534 int delta=_end-_start;
535 _start=newValueOfStart;
539 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
541 return _father->getIteration();
544 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
546 return _father->getOrder();
549 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
551 return _father->getTime();
554 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
556 return _father->getMeshName();
559 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
561 const char startLine[]=" ## ";
562 std::string startLine2(bkOffset,' ');
563 startLine2+=startLine;
564 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
565 oss << startLine2 << "Localization #" << id << "." << std::endl;
566 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
568 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
569 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
570 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
573 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
578 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
583 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
588 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
590 return _father->getGeoType();
593 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
595 return _father->getNumberOfComponents();
598 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
603 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
605 return _father->getOrCreateAndGetArray();
608 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
610 const MEDFileFieldPerMeshPerType *fath=_father;
611 return fath->getOrCreateAndGetArray();
614 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
616 return _father->getInfo();
619 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
624 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
629 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
631 return _localization;
634 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
636 _localization=newLocName;
639 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
641 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
643 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
645 _profile=(*it2).second;
651 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
653 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
655 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
657 _localization=(*it2).second;
663 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
667 dads.push_back(std::pair<int,int>(_start,_end));
668 geoTypes.push_back(getGeoType());
673 pfls.push_back(glob->getProfile(_profile.c_str()));
675 if(_localization.empty())
679 locs.push_back(glob->getLocalizationId(_localization.c_str()));
683 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
685 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));
689 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
691 TypeOfField type=getType();
692 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
693 med_geometry_type mgeoti;
694 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
695 const DataArray *arr=getOrCreateAndGetArray();
697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
698 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
699 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
700 const unsigned char *locToWrite=0;
702 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
704 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
706 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
707 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
708 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
712 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
717 dad.first=_start; dad.second=_end;
721 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
722 * This code corresponds to the distribution of types in the corresponding mesh.
723 * \param [out] ptToFill memory zone where the output will be stored.
724 * \return the size of data pushed into output param \a ptToFill
726 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
729 std::ostringstream oss;
730 std::size_t nbOfType=codeOfMesh.size()/3;
732 for(std::size_t i=0;i<nbOfType && found==-1;i++)
733 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
737 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
738 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
739 throw INTERP_KERNEL::Exception(oss.str().c_str());
744 if(_nval!=codeOfMesh[3*found+1])
746 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
747 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
748 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
749 throw INTERP_KERNEL::Exception(oss.str().c_str());
751 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
756 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
757 if(pfl->getNumberOfTuples()!=_nval)
759 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
760 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
762 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
763 throw INTERP_KERNEL::Exception(oss.str().c_str());
765 int offset2=codeOfMesh[3*found+2];
766 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
768 if(*pflId<codeOfMesh[3*found+1])
769 *work++=offset2+*pflId;
775 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
777 for(int i=_start;i<_end;i++)
782 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
793 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
797 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
800 std::map<std::pair<std::string,TypeOfField>,int> m;
801 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
802 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
803 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
804 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
806 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
807 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
812 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
814 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
815 * \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.
816 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
817 * \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)
818 * \param [in,out] glob if necessary by the method, new profiles can be added to it
819 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
820 * \param [out] result All new entries will be appended on it.
821 * \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 !)
823 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
824 const DataArrayInt *explicitIdsInMesh,
825 const std::vector<int>& newCode,
826 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
827 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
829 if(entriesOnSameDisc.empty())
831 TypeOfField type=entriesOnSameDisc[0]->getType();
832 int szEntities=0,szTuples=0;
833 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
834 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
835 int nbi=szTuples/szEntities;
836 if(szTuples%szEntities!=0)
837 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
839 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
840 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
841 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
842 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
843 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
844 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
846 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
848 int startOfEltIdOfChunk=(*it)->_start;
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
851 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
853 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
854 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
856 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
857 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
859 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
862 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
864 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
866 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
867 arrPart->renumberInPlace(renumTupleIds->begin());
868 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
870 const int *idIt=diffVals->begin();
871 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
873 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
875 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
876 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
877 int nbEntityElts=subIds->getNumberOfTuples();
879 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
880 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
884 result.push_back(eltToAdd);
885 offset2+=nbEntityElts*nbi;
887 ret=ret || li.empty();
892 * \param [in] typeF type of field of new chunk
893 * \param [in] geoType the geometric type of the chunk
894 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
895 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
896 * \param [in] nbi number of integration points
897 * \param [in] offset The offset in the **global array of data**.
898 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
899 * to the new chunk to create.
900 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
901 * \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
902 * and corresponding entry erased from \a entriesOnSameDisc.
903 * \return a newly allocated chunk
905 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
906 bool isPfl, int nbi, int offset,
907 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
908 MEDFileFieldGlobsReal& glob,
909 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
911 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
912 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
913 for(;it!=entriesOnSameDisc.end();it++)
915 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
919 if((*it)->_profile.empty())
922 if(!(*it)->_profile.empty())
924 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
925 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
931 if(it==entriesOnSameDisc.end())
934 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
936 ret->_loc_id=(int)geoType;
937 ret->_nval=nbMeshEntities;
939 ret->_end=ret->_start+ret->_nval*nbi;
942 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
943 glob.appendProfile(idsOfMeshElt);
944 ret->_profile=idsOfMeshElt->getName();
946 //tony treatment of localization
952 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
953 ret->_loc_id=(int)geoType;
954 ret->setNewStart(offset);
955 entriesOnSameDisc.erase(it);
961 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
963 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
966 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
968 return new MEDFileFieldPerMeshPerType(fath,geoType);
971 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
973 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
974 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
975 ret+=(*it)->getHeapMemorySize();
979 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
981 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
984 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
986 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
987 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
992 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
994 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
995 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
996 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1000 * This method is the most general one. No optimization is done here.
1001 * \param [in] multiTypePfl is the end user profile specified in high level API
1002 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1003 * \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.
1004 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1005 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1006 * \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.
1008 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)
1010 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1011 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1012 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1015 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1017 _field_pm_pt_pd.resize(1);
1018 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1019 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1022 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1024 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1025 if(!arr || !arr->isAllocated())
1026 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1027 _field_pm_pt_pd.resize(1);
1028 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1029 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1032 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1034 TypeOfField type=field->getTypeOfField();
1035 if(type!=ON_GAUSS_PT)
1037 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1038 int sz=_field_pm_pt_pd.size();
1040 for(int j=0;j<sz && !found;j++)
1042 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1044 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1050 _field_pm_pt_pd.resize(sz+1);
1051 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1053 std::vector<int> ret(1,(int)sz);
1058 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1059 int sz2=ret2.size();
1060 std::vector<int> ret3(sz2);
1062 for(int i=0;i<sz2;i++)
1064 int sz=_field_pm_pt_pd.size();
1065 int locIdToFind=ret2[i];
1067 for(int j=0;j<sz && !found;j++)
1069 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1071 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1078 _field_pm_pt_pd.resize(sz+1);
1079 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1087 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1089 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1090 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1092 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1093 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1095 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1096 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1097 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1098 if(retTmp->presenceOfValue(-1))
1099 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1100 std::vector<int> ret(retTmp->begin(),retTmp->end());
1104 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1106 TypeOfField type=field->getTypeOfField();
1107 if(type!=ON_GAUSS_PT)
1109 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1110 int sz=_field_pm_pt_pd.size();
1112 for(int j=0;j<sz && !found;j++)
1114 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1116 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1122 _field_pm_pt_pd.resize(sz+1);
1123 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1125 std::vector<int> ret(1,0);
1130 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1131 int sz2=ret2.size();
1132 std::vector<int> ret3(sz2);
1134 for(int i=0;i<sz2;i++)
1136 int sz=_field_pm_pt_pd.size();
1137 int locIdToFind=ret2[i];
1139 for(int j=0;j<sz && !found;j++)
1141 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1143 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1150 _field_pm_pt_pd.resize(sz+1);
1151 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1159 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1161 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1162 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1164 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1165 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1167 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1168 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1169 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1170 if(retTmp->presenceOfValue(-1))
1171 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1172 std::vector<int> ret(retTmp->begin(),retTmp->end());
1176 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1181 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1183 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1184 int curDim=(int)cm.getDimension();
1185 dim=std::max(dim,curDim);
1188 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1190 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1192 (*it)->fillTypesOfFieldAvailable(types);
1196 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)
1198 int sz=_field_pm_pt_pd.size();
1199 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1200 for(int i=0;i<sz;i++)
1202 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1206 int MEDFileFieldPerMeshPerType::getIteration() const
1208 return _father->getIteration();
1211 int MEDFileFieldPerMeshPerType::getOrder() const
1213 return _father->getOrder();
1216 double MEDFileFieldPerMeshPerType::getTime() const
1218 return _father->getTime();
1221 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1223 return _father->getMeshName();
1226 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1228 const char startLine[]=" ## ";
1229 std::string startLine2(bkOffset,' ');
1230 std::string startLine3(startLine2);
1231 startLine3+=startLine;
1232 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1234 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1235 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1238 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1239 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1241 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1243 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1245 cur->simpleRepr(bkOffset,oss,i);
1248 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1253 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1255 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1257 globalSz+=(*it)->getNumberOfTuples();
1259 nbOfEntries+=(int)_field_pm_pt_pd.size();
1262 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1268 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1270 return _father->getNumberOfComponents();
1273 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1275 return _father->getOrCreateAndGetArray();
1278 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1280 const MEDFileFieldPerMesh *fath=_father;
1281 return fath->getOrCreateAndGetArray();
1284 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1286 return _father->getInfo();
1289 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1291 std::vector<std::string> ret;
1292 std::set<std::string> ret2;
1293 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1295 std::string tmp=(*it1)->getProfile();
1297 if(ret2.find(tmp)==ret2.end())
1306 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1308 std::vector<std::string> ret;
1309 std::set<std::string> ret2;
1310 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1312 std::string tmp=(*it1)->getLocalization();
1313 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1314 if(ret2.find(tmp)==ret2.end())
1323 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1325 std::vector<std::string> ret;
1326 std::set<std::string> ret2;
1327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1329 std::string tmp=(*it1)->getProfile();
1336 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1338 std::vector<std::string> ret;
1339 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1341 std::string tmp=(*it1)->getLocalization();
1342 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1348 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1350 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1351 (*it1)->changePflsRefsNamesGen(mapOfModif);
1354 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1356 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1357 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1360 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1362 if(_field_pm_pt_pd.empty())
1364 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1365 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1366 throw INTERP_KERNEL::Exception(oss.str().c_str());
1368 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1369 return _field_pm_pt_pd[locId];
1370 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1371 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1372 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1373 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1374 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1377 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1379 if(_field_pm_pt_pd.empty())
1381 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1382 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1383 throw INTERP_KERNEL::Exception(oss.str().c_str());
1385 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1386 return _field_pm_pt_pd[locId];
1387 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1388 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1389 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1390 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1391 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1394 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
1396 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1398 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1399 if(meshDim!=(int)cm.getDimension())
1402 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1403 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1406 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1409 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1411 (*it)->fillValues(i,startEntryId,entries);
1415 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1417 _field_pm_pt_pd=leaves;
1418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1419 (*it)->setFather(this);
1423 * \param [in,out] globalNum a global numbering counter for the renumbering.
1424 * \param [out] its - list of pair (start,stop) kept
1425 * \return bool - false if the type of field \a tof is not contained in \a this.
1427 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1430 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1431 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1432 if((*it)->getType()==tof)
1434 newPmPtPd.push_back(*it);
1435 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1436 (*it)->setNewStart(globalNum);
1437 globalNum=(*it)->getEnd();
1438 its.push_back(bgEnd);
1442 _field_pm_pt_pd=newPmPtPd;
1446 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1450 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)
1452 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1453 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1454 med_geometry_type mgeoti;
1455 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1456 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1457 _field_pm_pt_pd.resize(nbProfiles);
1458 for(int i=0;i<nbProfiles;i++)
1460 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1464 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1467 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1469 (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1473 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1476 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1478 (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1482 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1484 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1486 (*it)->copyOptionsFrom(*this);
1487 (*it)->writeLL(fid,nasc);
1491 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1496 medfGeoType=typmai3[(int)ikGeoType];
1499 medfGeoType=MED_NONE;
1502 medfGeoType=typmai3[(int)ikGeoType];
1503 return MED_NODE_ELEMENT;
1505 medfGeoType=typmai3[(int)ikGeoType];
1508 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1510 return MED_UNDEF_ENTITY_TYPE;
1513 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1515 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1518 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1520 return new MEDFileFieldPerMesh(fath,mesh);
1523 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1525 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1526 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1527 if((const MEDFileFieldPerMeshPerType *)*it)
1528 ret+=(*it)->getHeapMemorySize();
1532 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1534 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1535 ret->_father=father;
1537 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1539 if((const MEDFileFieldPerMeshPerType *)*it)
1540 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1545 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1547 std::string startLine(bkOffset,' ');
1548 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1549 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1551 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1553 const MEDFileFieldPerMeshPerType *cur=*it;
1555 cur->simpleRepr(bkOffset,oss,i);
1558 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1563 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1565 _mesh_name=mesh->getName();
1566 mesh->getTime(_mesh_iteration,_mesh_order);
1569 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)
1571 int nbOfTypes=code.size()/3;
1573 for(int i=0;i<nbOfTypes;i++)
1575 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1576 int nbOfCells=code[3*i+1];
1577 int pos=addNewEntryIfNecessary(type);
1578 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1584 * This method is the most general one. No optimization is done here.
1585 * \param [in] multiTypePfl is the end user profile specified in high level API
1586 * \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].
1587 * \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.
1588 * \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.
1589 * \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.
1590 * \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.
1592 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)
1594 int nbOfTypes=code.size()/3;
1595 for(int i=0;i<nbOfTypes;i++)
1597 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1598 int pos=addNewEntryIfNecessary(type);
1599 DataArrayInt *pfl=0;
1601 pfl=idsPerType[code[3*i+2]];
1602 int nbOfTupes2=code2.size()/3;
1604 for(;found<nbOfTupes2;found++)
1605 if(code[3*i]==code2[3*found])
1607 if(found==nbOfTupes2)
1608 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1609 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1613 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1615 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1616 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1619 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1621 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1622 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1625 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1627 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1628 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1631 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1633 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1634 (*it)->loadBigArraysRecursively(fid,nasc);
1637 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1639 int nbOfTypes=_field_pm_pt.size();
1640 for(int i=0;i<nbOfTypes;i++)
1642 _field_pm_pt[i]->copyOptionsFrom(*this);
1643 _field_pm_pt[i]->writeLL(fid,nasc);
1647 void MEDFileFieldPerMesh::getDimension(int& dim) const
1649 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1650 (*it)->getDimension(dim);
1653 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1655 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1656 (*it)->fillTypesOfFieldAvailable(types);
1659 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)
1661 int sz=_field_pm_pt.size();
1662 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1663 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1664 for(int i=0;i<sz;i++)
1666 types[i]=_field_pm_pt[i]->getGeoType();
1667 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1672 double MEDFileFieldPerMesh::getTime() const
1675 return _father->getTime(tmp1,tmp2);
1678 int MEDFileFieldPerMesh::getIteration() const
1680 return _father->getIteration();
1683 int MEDFileFieldPerMesh::getOrder() const
1685 return _father->getOrder();
1688 int MEDFileFieldPerMesh::getNumberOfComponents() const
1690 return _father->getNumberOfComponents();
1693 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1696 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1697 return _father->getOrCreateAndGetArray();
1700 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1703 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1704 return _father->getOrCreateAndGetArray();
1707 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1709 return _father->getInfo();
1713 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1714 * 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.
1715 * It returns 2 output vectors :
1716 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1717 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1718 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1720 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)
1722 int notNullPflsSz=0;
1723 int nbOfArrs=geoTypes.size();
1724 for(int i=0;i<nbOfArrs;i++)
1727 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1728 int nbOfDiffGeoTypes=geoTypes3.size();
1729 code.resize(3*nbOfDiffGeoTypes);
1730 notNullPfls.resize(notNullPflsSz);
1733 for(int i=0;i<nbOfDiffGeoTypes;i++)
1736 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1737 std::vector<const DataArrayInt *> notNullTmp;
1739 notNullTmp.push_back(pfls[j]);
1741 for(;j<nbOfArrs;j++)
1742 if(geoTypes[j]==refType)
1745 notNullTmp.push_back(pfls[j]);
1749 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1750 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1751 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1752 code[3*i]=(int)refType;
1753 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1754 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1755 if(notNullTmp.empty())
1759 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1760 code[3*i+2]=notNullPflsSz++;
1766 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1768 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)
1772 for(int i=0;i<sz;i++)
1776 if(type!=ON_GAUSS_NE)
1777 ret+=dads[i].second-dads[i].first;
1780 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1781 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1786 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1787 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1793 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1795 std::vector<std::string> ret;
1796 std::set<std::string> ret2;
1797 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1799 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1800 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1801 if(ret2.find(*it2)==ret2.end())
1803 ret.push_back(*it2);
1810 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1812 std::vector<std::string> ret;
1813 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1815 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1816 ret.insert(ret.end(),tmp.begin(),tmp.end());
1821 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1823 std::vector<std::string> ret;
1824 std::set<std::string> ret2;
1825 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1827 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1828 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1829 if(ret2.find(*it2)==ret2.end())
1831 ret.push_back(*it2);
1838 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1840 std::vector<std::string> ret;
1841 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1843 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1844 ret.insert(ret.end(),tmp.begin(),tmp.end());
1849 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1851 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1853 if((*it).first==_mesh_name)
1855 _mesh_name=(*it).second;
1862 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1863 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1865 if(_mesh_name!=meshName)
1867 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1868 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1869 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1870 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1871 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1872 getUndergroundDataArrayExt(entries);
1873 DataArray *arr0=getOrCreateAndGetArray();//tony
1875 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1876 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1878 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1882 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1884 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1886 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1887 sz+=(*it).second.second-(*it).second.first;
1890 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1892 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1893 ////////////////////
1894 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1895 int *workI2=explicitIdsOldInMesh->getPointer();
1896 int sz1=0,sz2=0,sid=1;
1897 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1898 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1899 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1901 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1902 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1903 int *workI=explicitIdsOldInArr->getPointer();
1904 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1906 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1907 (*itL2)->setLocId(sz2);
1908 (*itL2)->_tmp_work1=(*itL2)->getStart();
1909 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1911 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1913 explicitIdsOldInMesh->reAlloc(sz2);
1914 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1915 ////////////////////
1916 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1917 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1918 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1919 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1921 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1922 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1923 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1925 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1926 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1927 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1929 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1930 int newStart=elt->getLocId();
1931 elt->setLocId((*it)->getGeoType());
1932 elt->setNewStart(newStart);
1933 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1934 entriesKeptNew.push_back(elt);
1935 entriesKeptNew2.push_back(elt);
1937 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1938 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1939 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1940 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1942 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1945 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1947 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1948 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1950 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1951 glob,arr2,otherEntriesNew) || ret;
1955 // Assign new dispatching
1956 assignNewLeaves(otherEntriesNew);
1957 arr->cpyFrom(*arr2);
1962 * \param [in,out] globalNum a global numbering counter for the renumbering.
1963 * \param [out] its - list of pair (start,stop) kept
1965 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1967 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1968 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1970 std::vector< std::pair<int,int> > its2;
1971 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1974 its.insert(its.end(),its2.begin(),its2.end());
1980 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1982 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1983 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1984 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1986 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1987 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1988 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1989 for(;it1!=types.end();it1++,it2++)
1991 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1992 elt->setLeaves((*it1).second);
1995 _field_pm_pt=fieldPmPt;
1998 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2000 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2001 (*it)->changePflsRefsNamesGen(mapOfModif);
2004 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2006 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2007 (*it)->changeLocsRefsNamesGen(mapOfModif);
2011 * \param [in] mesh is the whole mesh
2013 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2015 if(_field_pm_pt.empty())
2016 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2018 std::vector< std::pair<int,int> > dads;
2019 std::vector<const DataArrayInt *> pfls;
2020 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2021 std::vector<int> locs,code;
2022 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2023 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2024 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2026 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2029 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2030 throw INTERP_KERNEL::Exception(oss.str().c_str());
2033 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2034 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2037 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2039 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2042 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2043 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2049 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2053 if(nb!=mesh->getNumberOfNodes())
2055 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2056 oss << " nodes in mesh !";
2057 throw INTERP_KERNEL::Exception(oss.str().c_str());
2059 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2062 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2066 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2068 if(_field_pm_pt.empty())
2069 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2071 std::vector<std::pair<int,int> > dads;
2072 std::vector<const DataArrayInt *> pfls;
2073 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2074 std::vector<int> locs,code;
2075 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2076 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2077 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2079 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2082 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2083 throw INTERP_KERNEL::Exception(oss.str().c_str());
2085 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2086 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2089 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2090 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2095 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2099 if(nb!=mesh->getNumberOfNodes())
2101 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2102 oss << " nodes in mesh !";
2103 throw INTERP_KERNEL::Exception(oss.str().c_str());
2106 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2112 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2116 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2118 (*it)->getSizes(globalSz,nbOfEntries);
2120 entries.resize(nbOfEntries);
2122 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124 (*it)->fillValues(nbOfEntries,entries);
2128 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2130 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2132 if((*it)->getGeoType()==typ)
2133 return (*it)->getLeafGivenLocId(locId);
2135 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2136 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2137 oss << "Possiblities are : ";
2138 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2140 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2141 oss << "\"" << cm2.getRepr() << "\", ";
2143 throw INTERP_KERNEL::Exception(oss.str().c_str());
2146 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2148 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2150 if((*it)->getGeoType()==typ)
2151 return (*it)->getLeafGivenLocId(locId);
2153 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2154 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2155 oss << "Possiblities are : ";
2156 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2159 oss << "\"" << cm2.getRepr() << "\", ";
2161 throw INTERP_KERNEL::Exception(oss.str().c_str());
2164 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2167 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2168 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2169 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2171 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2176 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2181 int ret=std::distance(_field_pm_pt.begin(),it2);
2182 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2187 * 'dads' and 'locs' input parameters have the same number of elements
2188 * \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
2190 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2191 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2192 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2195 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2196 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2197 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2198 const std::vector<std::string>& infos=getInfo();
2199 da->setInfoOnComponents(infos);
2201 if(type==ON_GAUSS_PT)
2204 int nbOfArrs=dads.size();
2205 for(int i=0;i<nbOfArrs;i++)
2207 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2208 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2209 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2210 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2211 di->alloc(nbOfElems,1);
2213 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2214 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2223 * 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.
2224 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2225 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2226 * The order of cells in the returned field is those imposed by the profile.
2227 * \param [in] mesh is the global mesh.
2229 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2230 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2231 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2232 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2234 if(da->isIdentity())
2236 int nbOfTuples=da->getNumberOfTuples();
2237 if(nbOfTuples==mesh->getNumberOfCells())
2238 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2240 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2241 m2->setName(mesh->getName());
2242 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2248 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2250 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2251 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2252 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2254 if(da->isIdentity())
2256 int nbOfTuples=da->getNumberOfTuples();
2257 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2258 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2260 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2261 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2264 if(meshu->getNodalConnectivity()==0)
2266 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2267 int nb=da->getNbOfElems();
2268 const int *ptr=da->getConstPointer();
2269 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2270 meshuc->allocateCells(nb);
2271 for(int i=0;i<nb;i++)
2272 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2273 meshuc->finishInsertingCells();
2274 ret->setMesh(meshuc);
2275 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2276 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2277 disc->checkCoherencyBetween(meshuc,arrOut);
2282 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2284 DataArrayInt *arr2=0;
2285 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2286 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2287 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2288 int nnodes=mesh2->getNumberOfNodes();
2289 if(nnodes==(int)da->getNbOfElems())
2291 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2292 arrOut->renumberInPlace(da3->getConstPointer());
2293 mesh2->setName(mesh->getName());
2294 ret->setMesh(mesh2);
2299 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 !!!";
2300 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2301 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2302 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2303 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2304 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2305 throw INTERP_KERNEL::Exception(oss.str().c_str());
2311 * This method is the most light method of field retrieving.
2313 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2317 pflOut=DataArrayInt::New();
2318 pflOut->alloc(nbOfElems,1);
2323 pflOut=const_cast<DataArrayInt*>(pflIn);
2326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2327 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2328 const std::vector<std::string>& infos=getInfo();
2329 int nbOfComp=infos.size();
2330 for(int i=0;i<nbOfComp;i++)
2331 da->setInfoOnComponent(i,infos[i].c_str());
2336 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),
2337 _mesh_csit(meshCsit),_father(fath)
2339 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2340 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2341 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2342 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2344 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2347 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2348 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2350 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2353 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2354 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2357 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2360 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2361 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2365 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2367 copyTinyInfoFrom(mesh);
2370 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2372 if(id>=(int)_pfls.size())
2374 _pfls[id]=DataArrayInt::New();
2375 int lgth=MEDprofileSizeByName(fid,pflName);
2376 _pfls[id]->setName(pflName);
2377 _pfls[id]->alloc(lgth,1);
2378 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2379 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2382 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2384 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2386 MEDprofileInfo(fid,i+1,pflName,&sz);
2387 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2388 if(i>=(int)_pfls.size())
2390 _pfls[i]=DataArrayInt::New();
2391 _pfls[i]->alloc(sz,1);
2392 _pfls[i]->setName(pflCpp.c_str());
2393 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2394 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2397 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2399 int nbOfPfls=_pfls.size();
2400 for(int i=0;i<nbOfPfls;i++)
2402 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2403 cpy->applyLin(1,1,0);
2404 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2405 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2406 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2409 int nbOfLocs=_locs.size();
2410 for(int i=0;i<nbOfLocs;i++)
2411 _locs[i]->writeLL(fid);
2414 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2416 std::vector<std::string> pfls=getPfls();
2417 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2419 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2422 _pfls.push_back(*it);
2426 int id=std::distance(pfls.begin(),it2);
2427 if(!(*it)->isEqual(*_pfls[id]))
2429 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2430 throw INTERP_KERNEL::Exception(oss.str().c_str());
2434 std::vector<std::string> locs=getLocs();
2435 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2437 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2440 _locs.push_back(*it);
2444 int id=std::distance(locs.begin(),it2);
2445 if(!(*it)->isEqual(*_locs[id],eps))
2447 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2448 throw INTERP_KERNEL::Exception(oss.str().c_str());
2454 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2456 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2457 getProfile((*it).c_str());
2460 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2462 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2463 getLocalization((*it).c_str());
2466 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2468 std::vector<std::string> profiles=real.getPflsReallyUsed();
2469 int sz=profiles.size();
2471 for(int i=0;i<sz;i++)
2472 loadProfileInFile(fid,i,profiles[i].c_str());
2474 std::vector<std::string> locs=real.getLocsReallyUsed();
2477 for(int i=0;i<sz;i++)
2478 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2481 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2483 int nProfil=MEDnProfile(fid);
2484 for(int i=0;i<nProfil;i++)
2485 loadProfileInFile(fid,i);
2486 int sz=MEDnLocalization(fid);
2488 for(int i=0;i<sz;i++)
2490 _locs[i]=MEDFileFieldLoc::New(fid,i);
2494 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2496 return new MEDFileFieldGlobs(fname);
2499 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2501 return new MEDFileFieldGlobs;
2504 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2506 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2508 ret+=(*it)->getHeapMemorySize();
2509 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2510 ret+=(*it)->getHeapMemorySize();
2514 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2516 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2518 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2520 if((const DataArrayInt *)*it)
2521 ret->_pfls[i]=(*it)->deepCpy();
2524 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2526 if((const MEDFileFieldLoc*)*it)
2527 ret->_locs[i]=(*it)->deepCpy();
2533 * \throw if a profile in \a pfls in not in \a this.
2534 * \throw if a localization in \a locs in not in \a this.
2535 * \sa MEDFileFieldGlobs::deepCpyPart
2537 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2539 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2540 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2542 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2544 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2546 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2547 ret->_pfls.push_back(pfl2);
2549 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2551 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2553 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2555 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2556 ret->_locs.push_back(loc2);
2558 ret->setFileName(getFileName());
2563 * \throw if a profile in \a pfls in not in \a this.
2564 * \throw if a localization in \a locs in not in \a this.
2565 * \sa MEDFileFieldGlobs::shallowCpyPart
2567 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2569 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2570 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2572 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2574 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2575 ret->_pfls.push_back(pfl->deepCpy());
2577 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2579 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2581 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2582 ret->_locs.push_back(loc->deepCpy());
2584 ret->setFileName(getFileName());
2588 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2592 MEDFileFieldGlobs::MEDFileFieldGlobs()
2596 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2600 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2602 oss << "Profiles :\n";
2603 std::size_t n=_pfls.size();
2604 for(std::size_t i=0;i<n;i++)
2606 oss << " - #" << i << " ";
2607 const DataArrayInt *pfl=_pfls[i];
2609 oss << "\"" << pfl->getName() << "\"\n";
2614 oss << "Localizations :\n";
2615 for(std::size_t i=0;i<n;i++)
2617 oss << " - #" << i << " ";
2618 const MEDFileFieldLoc *loc=_locs[i];
2620 loc->simpleRepr(oss);
2626 void MEDFileFieldGlobs::setFileName(const char *fileName)
2628 _file_name=fileName;
2631 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2633 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2635 DataArrayInt *elt(*it);
2638 std::string name(elt->getName());
2639 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2641 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2643 elt->setName((*it2).second.c_str());
2651 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2653 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2655 MEDFileFieldLoc *elt(*it);
2658 std::string name(elt->getName());
2659 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2661 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2663 elt->setName((*it2).second.c_str());
2671 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2673 if(locId<0 || locId>=(int)_locs.size())
2674 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2675 return _locs[locId]->getNbOfGaussPtPerCell();
2678 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2680 return getLocalizationFromId(getLocalizationId(locName));
2683 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2685 if(locId<0 || locId>=(int)_locs.size())
2686 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2687 return *_locs[locId];
2690 namespace ParaMEDMEMImpl
2695 LocFinder(const char *loc):_loc(loc) { }
2696 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2704 PflFinder(const std::string& pfl):_pfl(pfl) { }
2705 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2707 const std::string& _pfl;
2711 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2713 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2716 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2717 for(it=_locs.begin();it!=_locs.end();it++)
2718 oss << "\"" << (*it)->getName() << "\", ";
2719 throw INTERP_KERNEL::Exception(oss.str().c_str());
2721 return std::distance(_locs.begin(),it);
2725 * The returned value is never null.
2727 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2729 std::string pflNameCpp(pflName);
2730 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2733 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2734 for(it=_pfls.begin();it!=_pfls.end();it++)
2735 oss << "\"" << (*it)->getName() << "\", ";
2736 throw INTERP_KERNEL::Exception(oss.str().c_str());
2741 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2743 if(pflId<0 || pflId>=(int)_pfls.size())
2744 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2745 return _pfls[pflId];
2748 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2750 if(locId<0 || locId>=(int)_locs.size())
2751 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2752 return *_locs[locId];
2755 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2757 return getLocalizationFromId(getLocalizationId(locName));
2761 * The returned value is never null.
2763 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2765 std::string pflNameCpp(pflName);
2766 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2769 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2770 for(it=_pfls.begin();it!=_pfls.end();it++)
2771 oss << "\"" << (*it)->getName() << "\", ";
2772 throw INTERP_KERNEL::Exception(oss.str().c_str());
2777 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2779 if(pflId<0 || pflId>=(int)_pfls.size())
2780 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2781 return _pfls[pflId];
2784 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2786 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2788 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2790 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2791 newPfls.push_back(*it);
2796 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2798 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2800 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2802 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2803 newLocs.push_back(*it);
2808 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2810 int sz=_pfls.size();
2811 std::vector<std::string> ret(sz);
2812 for(int i=0;i<sz;i++)
2813 ret[i]=_pfls[i]->getName();
2817 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2819 int sz=_locs.size();
2820 std::vector<std::string> ret(sz);
2821 for(int i=0;i<sz;i++)
2822 ret[i]=_locs[i]->getName();
2826 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2828 std::vector<std::string> v=getPfls();
2829 std::string s(pflName);
2830 return std::find(v.begin(),v.end(),s)!=v.end();
2833 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2835 std::vector<std::string> v=getLocs();
2836 std::string s(locName);
2837 return std::find(v.begin(),v.end(),s)!=v.end();
2840 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2842 std::map<int,std::vector<int> > m;
2844 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2846 const DataArrayInt *tmp=(*it);
2849 m[tmp->getHashCode()].push_back(i);
2852 std::vector< std::vector<int> > ret;
2853 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2855 if((*it2).second.size()>1)
2857 std::vector<int> ret0;
2858 bool equalityOrNot=false;
2859 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2861 std::vector<int>::const_iterator it4=it3; it4++;
2862 for(;it4!=(*it2).second.end();it4++)
2864 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2867 ret0.push_back(*it3);
2868 ret0.push_back(*it4);
2874 ret.push_back(ret0);
2880 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2882 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2885 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2887 std::string name(pfl->getName());
2889 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2890 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2891 if(name==(*it)->getName())
2893 if(!pfl->isEqual(*(*it)))
2895 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2896 throw INTERP_KERNEL::Exception(oss.str().c_str());
2900 _pfls.push_back(pfl);
2903 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)
2905 std::string name(locName);
2907 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2908 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2909 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2910 if((*it)->isName(locName))
2912 if(!(*it)->isEqual(*obj,1e-12))
2914 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2915 throw INTERP_KERNEL::Exception(oss.str().c_str());
2918 _locs.push_back(obj);
2921 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2923 std::vector<std::string> names=getPfls();
2924 return CreateNewNameNotIn("NewPfl_",names);
2927 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2929 std::vector<std::string> names=getLocs();
2930 return CreateNewNameNotIn("NewLoc_",names);
2933 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2935 for(std::size_t sz=0;sz<100000;sz++)
2937 std::ostringstream tryName;
2938 tryName << prefix << sz;
2939 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2940 return tryName.str();
2942 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2946 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2947 * \param [in] fname - the file name.
2949 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2954 * Creates an empty MEDFileFieldGlobsReal.
2956 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2960 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2963 if((const MEDFileFieldGlobs *)_globals)
2964 ret+=_globals->getHeapMemorySize();
2969 * Returns a string describing profiles and Gauss points held in \a this.
2970 * \return std::string - the description string.
2972 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2974 const MEDFileFieldGlobs *glob=_globals;
2975 std::ostringstream oss2; oss2 << glob;
2976 std::string stars(oss2.str().length(),'*');
2977 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2979 glob->simpleRepr(oss);
2981 oss << "NO GLOBAL INFORMATION !\n";
2984 void MEDFileFieldGlobsReal::resetContent()
2986 _globals=MEDFileFieldGlobs::New();
2989 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2994 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2995 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2997 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2999 _globals=other._globals;
3003 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3004 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3006 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3008 const MEDFileFieldGlobs *otherg(other._globals);
3011 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3015 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3016 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3018 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3020 const MEDFileFieldGlobs *otherg(other._globals);
3023 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3026 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3028 _globals=other._globals;
3029 if((const MEDFileFieldGlobs *)_globals)
3030 _globals=other._globals->deepCpy();
3034 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3035 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3036 * \param [in] eps - a precision used to compare Gauss points with same name held by
3037 * \a this and \a other MEDFileFieldGlobsReal.
3038 * \throw If \a this and \a other hold profiles with equal names but different ids.
3039 * \throw If \a this and \a other hold different Gauss points with equal names.
3041 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3043 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3044 if(thisGlobals==otherGlobals)
3048 _globals=other._globals;
3051 _globals->appendGlobs(*other._globals,eps);
3054 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3056 checkGlobsPflsPartCoherency();
3057 checkGlobsLocsPartCoherency();
3060 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3062 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3065 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3067 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3070 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3072 contentNotNull()->loadProfileInFile(fid,id,pflName);
3075 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3077 contentNotNull()->loadProfileInFile(fid,id);
3080 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3082 contentNotNull()->loadGlobals(fid,*this);
3085 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3087 contentNotNull()->loadAllGlobals(fid);
3090 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3092 contentNotNull()->writeGlobals(fid,opt);
3096 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3097 * or getPflsReallyUsedMulti().
3098 * \return std::vector<std::string> - a sequence of names of all profiles.
3100 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3102 return contentNotNull()->getPfls();
3106 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3107 * or getLocsReallyUsedMulti().
3108 * \return std::vector<std::string> - a sequence of names of all localizations.
3110 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3112 return contentNotNull()->getLocs();
3116 * Checks if the profile with a given name exists.
3117 * \param [in] pflName - the profile name of interest.
3118 * \return bool - \c true if the profile named \a pflName exists.
3120 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3122 return contentNotNull()->existsPfl(pflName);
3126 * Checks if the localization with a given name exists.
3127 * \param [in] locName - the localization name of interest.
3128 * \return bool - \c true if the localization named \a locName exists.
3130 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3132 return contentNotNull()->existsLoc(locName);
3135 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3137 return contentNotNull()->createNewNameOfPfl();
3140 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3142 return contentNotNull()->createNewNameOfLoc();
3146 * Sets the name of a MED file.
3147 * \param [inout] fileName - the file name.
3149 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3151 contentNotNull()->setFileName(fileName);
3155 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3156 * in the same order.
3157 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3158 * Each item of this sequence is a vector containing ids of equal profiles.
3160 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3162 return contentNotNull()->whichAreEqualProfiles();
3166 * Finds equal localizations.
3167 * \param [in] eps - a precision used to compare real values of the localizations.
3168 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3169 * Each item of this sequence is a vector containing ids of equal localizations.
3171 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3173 return contentNotNull()->whichAreEqualLocs(eps);
3177 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3178 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3179 * this sequence is a pair whose
3180 * - the first item is a vector of profile names to replace by the second item,
3181 * - the second item is a profile name to replace every profile name of the first item.
3183 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3185 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3189 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3190 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3191 * this sequence is a pair whose
3192 * - the first item is a vector of localization names to replace by the second item,
3193 * - the second item is a localization name to replace every localization name of the first item.
3195 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3197 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3201 * Replaces references to some profiles (a reference is a profile name) by references
3202 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3203 * them-selves accordingly. <br>
3204 * This method is a generalization of changePflName().
3205 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3206 * this sequence is a pair whose
3207 * - the first item is a vector of profile names to replace by the second item,
3208 * - the second item is a profile name to replace every profile of the first item.
3209 * \sa changePflsRefsNamesGen()
3210 * \sa changePflName()
3212 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3214 changePflsRefsNamesGen(mapOfModif);
3215 changePflsNamesInStruct(mapOfModif);
3219 * Replaces references to some localizations (a reference is a localization name) by references
3220 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3221 * them-selves accordingly. <br>
3222 * This method is a generalization of changeLocName().
3223 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3224 * this sequence is a pair whose
3225 * - the first item is a vector of localization names to replace by the second item,
3226 * - the second item is a localization name to replace every localization of the first item.
3227 * \sa changeLocsRefsNamesGen()
3228 * \sa changeLocName()
3230 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3232 changeLocsRefsNamesGen(mapOfModif);
3233 changeLocsNamesInStruct(mapOfModif);
3237 * Renames the profile having a given name and updates references to this profile.
3238 * \param [in] oldName - the name of the profile to rename.
3239 * \param [in] newName - a new name of the profile.
3240 * \sa changePflsNames().
3242 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3244 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3245 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3247 changePflsNames(mapOfModif);
3251 * Renames the localization having a given name and updates references to this localization.
3252 * \param [in] oldName - the name of the localization to rename.
3253 * \param [in] newName - a new name of the localization.
3254 * \sa changeLocsNames().
3256 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3258 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3259 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3261 changeLocsNames(mapOfModif);
3265 * Removes duplicated profiles. Returns a map used to update references to removed
3266 * profiles via changePflsRefsNamesGen().
3267 * Equal profiles are found using whichAreEqualProfiles().
3268 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3269 * a sequence describing the performed replacements of profiles. Each element of
3270 * this sequence is a pair whose
3271 * - the first item is a vector of profile names replaced by the second item,
3272 * - the second item is a profile name replacing every profile of the first item.
3274 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3276 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3277 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3279 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3281 std::vector< std::string > tmp((*it).size());
3283 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3284 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3285 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3287 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3288 killProfileIds(tmp2);
3290 changePflsRefsNamesGen(ret);
3295 * Removes duplicated localizations. Returns a map used to update references to removed
3296 * localizations via changeLocsRefsNamesGen().
3297 * Equal localizations are found using whichAreEqualLocs().
3298 * \param [in] eps - a precision used to compare real values of the localizations.
3299 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3300 * a sequence describing the performed replacements of localizations. Each element of
3301 * this sequence is a pair whose
3302 * - the first item is a vector of localization names replaced by the second item,
3303 * - the second item is a localization name replacing every localization of the first item.
3305 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3307 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3308 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3310 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3312 std::vector< std::string > tmp((*it).size());
3314 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3315 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3316 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3318 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3319 killLocalizationIds(tmp2);
3321 changeLocsRefsNamesGen(ret);
3326 * Returns number of Gauss points per cell in a given localization.
3327 * \param [in] locId - an id of the localization of interest.
3328 * \return int - the number of the Gauss points per cell.
3330 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3332 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3336 * Returns an id of a localization by its name.
3337 * \param [in] loc - the localization name of interest.
3338 * \return int - the id of the localization.
3339 * \throw If there is no a localization named \a loc.
3341 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3343 return contentNotNull()->getLocalizationId(loc);
3347 * Returns the name of the MED file.
3348 * \return const char * - the MED file name.
3350 const char *MEDFileFieldGlobsReal::getFileName() const
3352 return contentNotNull()->getFileName();
3355 std::string MEDFileFieldGlobsReal::getFileName2() const
3357 return contentNotNull()->getFileName2();
3361 * Returns a localization object by its name.
3362 * \param [in] locName - the name of the localization of interest.
3363 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3364 * \throw If there is no a localization named \a locName.
3366 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3368 return contentNotNull()->getLocalization(locName);
3372 * Returns a localization object by its id.
3373 * \param [in] locId - the id of the localization of interest.
3374 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3375 * \throw If there is no a localization with id \a locId.
3377 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3379 return contentNotNull()->getLocalizationFromId(locId);
3383 * Returns a profile array by its name.
3384 * \param [in] pflName - the name of the profile of interest.
3385 * \return const DataArrayInt * - the profile array having the name \a pflName.
3386 * \throw If there is no a profile named \a pflName.
3388 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3390 return contentNotNull()->getProfile(pflName);
3394 * Returns a profile array by its id.
3395 * \param [in] pflId - the id of the profile of interest.
3396 * \return const DataArrayInt * - the profile array having the id \a pflId.
3397 * \throw If there is no a profile with id \a pflId.
3399 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3401 return contentNotNull()->getProfileFromId(pflId);
3405 * Returns a localization object, apt for modification, by its id.
3406 * \param [in] locId - the id of the localization of interest.
3407 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3408 * having the id \a locId.
3409 * \throw If there is no a localization with id \a locId.
3411 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3413 return contentNotNull()->getLocalizationFromId(locId);
3417 * Returns a localization object, apt for modification, by its name.
3418 * \param [in] locName - the name of the localization of interest.
3419 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3420 * having the name \a locName.
3421 * \throw If there is no a localization named \a locName.
3423 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3425 return contentNotNull()->getLocalization(locName);
3429 * Returns a profile array, apt for modification, by its name.
3430 * \param [in] pflName - the name of the profile of interest.
3431 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3432 * \throw If there is no a profile named \a pflName.
3434 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3436 return contentNotNull()->getProfile(pflName);
3440 * Returns a profile array, apt for modification, by its id.
3441 * \param [in] pflId - the id of the profile of interest.
3442 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3443 * \throw If there is no a profile with id \a pflId.
3445 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3447 return contentNotNull()->getProfileFromId(pflId);
3451 * Removes profiles given by their ids. No data is updated to track this removal.
3452 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3454 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3456 contentNotNull()->killProfileIds(pflIds);
3460 * Removes localizations given by their ids. No data is updated to track this removal.
3461 * \param [in] locIds - a sequence of ids of the localizations to remove.
3463 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3465 contentNotNull()->killLocalizationIds(locIds);
3469 * Stores a profile array.
3470 * \param [in] pfl - the profile array to store.
3471 * \throw If the name of \a pfl is empty.
3472 * \throw If a profile with the same name as that of \a pfl already exists but contains
3475 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3477 contentNotNull()->appendProfile(pfl);
3481 * Adds a new localization of Gauss points.
3482 * \param [in] locName - the name of the new localization.
3483 * \param [in] geoType - a geometrical type of the reference cell.
3484 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3485 * must be \c nbOfNodesPerCell * \c dimOfType.
3486 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3487 * must be _wg_.size() * \c dimOfType.
3488 * \param [in] w - the weights of Gauss points.
3489 * \throw If \a locName is empty.
3490 * \throw If a localization with the name \a locName already exists but is
3491 * different form the new one.
3493 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)
3495 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3498 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3500 MEDFileFieldGlobs *g(_globals);
3502 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3506 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3508 const MEDFileFieldGlobs *g(_globals);
3510 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3514 //= MEDFileFieldNameScope
3516 MEDFileFieldNameScope::MEDFileFieldNameScope()
3520 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3525 * Returns the name of \a this field.
3526 * \return std::string - a string containing the field name.
3528 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3534 * Sets name of \a this field
3535 * \param [in] name - the new field name.
3537 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3542 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3547 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3552 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3555 _dt_unit=other._dt_unit;
3558 //= MEDFileAnyTypeField1TSWithoutSDA
3560 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3562 _field_per_mesh.resize(other._field_per_mesh.size());
3564 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3566 if((const MEDFileFieldPerMesh *)*it)
3567 _field_per_mesh[i]=(*it)->deepCpy(this);
3572 * Prints a string describing \a this field into a stream. This string is outputted
3573 * by \c print Python command.
3574 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3575 * \param [in,out] oss - the out stream.
3576 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3577 * info id printed, else, not.
3579 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3581 std::string startOfLine(bkOffset,' ');
3582 oss << startOfLine << "Field ";
3584 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3585 oss << "on one time Step ";
3587 oss << "(" << f1tsId << ") ";
3588 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3589 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3590 const DataArray *arr=getUndergroundDataArray();
3593 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3596 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3597 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3598 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3600 if(arr->isAllocated())
3602 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3605 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3609 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3611 oss << startOfLine << "----------------------" << std::endl;
3612 if(!_field_per_mesh.empty())
3615 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3617 const MEDFileFieldPerMesh *cur=(*it2);
3619 cur->simpleRepr(bkOffset,oss,i);
3621 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3626 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3628 oss << startOfLine << "----------------------" << std::endl;
3631 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3633 const DataArray *arr(getUndergroundDataArray());
3635 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3636 int nbOfCompo=arr->getNumberOfComponents();
3637 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3638 for(int i=0;i<nbOfCompo;i++)
3641 std::vector<int> v(1,i);
3642 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3643 ret[i]->setArray(arr2);
3648 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)
3652 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3657 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3658 * empty. Returns -1 if this in on nodes.
3659 * \return int - the dimension of \a this.
3661 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3664 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3665 (*it)->getDimension(ret);
3670 * Returns the mesh name.
3671 * \return std::string - a string holding the mesh name.
3672 * \throw If \c _field_per_mesh.empty()
3674 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3676 if(_field_per_mesh.empty())
3677 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3678 return _field_per_mesh[0]->getMeshName();
3681 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3683 std::string oldName(getMeshName());
3684 std::vector< std::pair<std::string,std::string> > v(1);
3685 v[0].first=oldName; v[0].second=newMeshName;
3689 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3692 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3694 MEDFileFieldPerMesh *cur(*it);
3696 ret=cur->changeMeshNames(modifTab) || ret;
3702 * Returns the number of iteration of the state of underlying mesh.
3703 * \return int - the iteration number.
3704 * \throw If \c _field_per_mesh.empty()
3706 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3708 if(_field_per_mesh.empty())
3709 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3710 return _field_per_mesh[0]->getMeshIteration();
3714 * Returns the order number of iteration of the state of underlying mesh.
3715 * \return int - the order number.
3716 * \throw If \c _field_per_mesh.empty()
3718 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3720 if(_field_per_mesh.empty())
3721 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3722 return _field_per_mesh[0]->getMeshOrder();
3726 * Checks if \a this field is tagged by a given iteration number and a given
3727 * iteration order number.
3728 * \param [in] iteration - the iteration number of interest.
3729 * \param [in] order - the iteration order number of interest.
3730 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3731 * \a this->getOrder() == \a order.
3733 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3735 return iteration==_iteration && order==_order;
3739 * Returns number of iteration and order number of iteration when
3740 * \a this field has been calculated.
3741 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3744 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3746 std::pair<int,int> p;
3752 * Returns number of iteration and order number of iteration when
3753 * \a this field has been calculated.
3754 * \param [in,out] p - a pair returning the iteration number and the iteration
3757 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3764 * Returns all types of spatial discretization of \a this field.
3765 * \param [in,out] types - a sequence of types of \a this field.
3767 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3769 std::set<TypeOfField> types2;
3770 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3772 (*it)->fillTypesOfFieldAvailable(types2);
3774 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3775 std::copy(types2.begin(),types2.end(),bi);
3779 * Returns all types of spatial discretization of \a this field.
3780 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3783 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3785 std::vector<TypeOfField> ret;
3786 fillTypesOfFieldAvailable(ret);
3790 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3792 std::vector<std::string> ret;
3793 std::set<std::string> ret2;
3794 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3796 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3797 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3798 if(ret2.find(*it2)==ret2.end())
3800 ret.push_back(*it2);
3807 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3809 std::vector<std::string> ret;
3810 std::set<std::string> ret2;
3811 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3813 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3814 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3815 if(ret2.find(*it2)==ret2.end())
3817 ret.push_back(*it2);
3824 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3826 std::vector<std::string> ret;
3827 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3829 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3830 ret.insert(ret.end(),tmp.begin(),tmp.end());
3835 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3837 std::vector<std::string> ret;
3838 std::set<std::string> ret2;
3839 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3841 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3842 ret.insert(ret.end(),tmp.begin(),tmp.end());
3847 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3849 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3850 (*it)->changePflsRefsNamesGen(mapOfModif);
3853 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3855 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3856 (*it)->changeLocsRefsNamesGen(mapOfModif);
3860 * Returns all attributes of parts of \a this field lying on a given mesh.
3861 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3862 * item of every of returned sequences refers to the _i_-th part of \a this field.
3863 * Thus all sequences returned by this method are of the same length equal to number
3864 * of different types of supporting entities.<br>
3865 * A field part can include sub-parts with several different spatial discretizations,
3866 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3867 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3868 * of a nested sequence corresponds to a type of spatial discretization.<br>
3869 * This method allows for iteration over MEDFile DataStructure without any overhead.
3870 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3871 * for the case with only one underlying mesh. (Actually, the number of meshes is
3872 * not checked if \a mname == \c NULL).
3873 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3874 * a field part is returned.
3875 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3876 * This sequence is of the same length as \a types.
3877 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3878 * discretization. A profile name can be empty.
3879 * Length of this and of nested sequences is the same as that of \a typesF.
3880 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3881 * discretization. A localization name can be empty.
3882 * Length of this and of nested sequences is the same as that of \a typesF.
3883 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3884 * of ids of tuples within the data array, per each type of spatial
3885 * discretization within one mesh entity type.
3886 * Length of this and of nested sequences is the same as that of \a typesF.
3887 * \throw If no field is lying on \a mname.
3889 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)
3893 meshId=getMeshIdFromMeshName(mname);
3895 if(_field_per_mesh.empty())
3896 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3897 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3901 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3902 * maximal absolute dimension and values returned via the out parameter \a levs are
3903 * dimensions relative to the maximal absolute dimension. <br>
3904 * This method is designed for MEDFileField1TS instances that have a discretization
3905 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3906 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3907 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3908 * Only these 3 discretizations will be taken into account here. If \a this is
3909 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3910 * This method is useful to make the link between the dimension of the underlying mesh
3911 * and the levels of \a this, because it is possible that the highest dimension of \a this
3912 * field is not equal to the dimension of the underlying mesh.
3914 * Let's consider the following case:
3915 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3916 * TETRA4, HEXA8, TRI3 and SEG2.
3917 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3918 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3920 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3921 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3922 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3923 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3924 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3925 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3927 * to retrieve the highest level of
3928 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3929 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3930 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3931 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3932 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3933 * for the case with only one underlying mesh. (Actually, the number of meshes is
3934 * not checked if \a mname == \c NULL).
3935 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3936 * absolute one. They are in decreasing order. This sequence is cleared before
3938 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3939 * \throw If no field is lying on \a mname.
3941 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3944 int meshId=getMeshIdFromMeshName(mname);
3945 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3946 std::vector< std::vector<TypeOfField> > typesF;
3947 std::vector< std::vector<std::string> > pfls, locs;
3948 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3950 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3951 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3952 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3954 st.erase(INTERP_KERNEL::NORM_ERROR);
3956 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3958 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3959 ret1.insert((int)cm.getDimension());
3961 int ret=*std::max_element(ret1.begin(),ret1.end());
3962 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3963 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3968 * \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.
3969 * \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.
3970 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3971 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3973 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3975 int mid=getMeshIdFromMeshName(mName);
3976 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3980 * \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.
3981 * \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.
3982 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3983 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3985 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3987 int mid=getMeshIdFromMeshName(mName);
3988 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3992 * \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.
3994 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3996 if(_field_per_mesh.empty())
3997 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4000 std::string mName2(mName);
4002 std::vector<std::string> msg;
4003 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4004 if(mName2==(*it)->getMeshName())
4007 msg.push_back((*it)->getMeshName());
4008 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4009 oss << "Possible meshes are : ";
4010 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4011 oss << "\"" << (*it2) << "\" ";
4012 throw INTERP_KERNEL::Exception(oss.str().c_str());
4015 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4018 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4019 std::string tmp(mesh->getName());
4021 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4022 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4024 for(;it!=_field_per_mesh.end();it++,i++)
4026 if((*it)->getMeshName()==tmp)
4029 int sz=_field_per_mesh.size();
4030 _field_per_mesh.resize(sz+1);
4031 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4035 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4036 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4039 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4041 MEDFileFieldPerMesh *fpm(*it);
4043 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4048 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4050 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4051 std::vector< std::vector<TypeOfField> > typesF;
4052 std::vector< std::vector<std::string> > pfls,locs;
4053 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4054 std::set<TypeOfField> allEnt;
4055 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4056 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4057 allEnt.insert(*it2);
4058 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4059 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4060 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4062 std::vector< std::pair<int,int> > its;
4063 ret[i]=shallowCpy();
4064 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4065 ret[i]->updateData(newLgth,its);
4070 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4072 int globalCounter=0;
4073 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4074 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4075 return globalCounter;
4078 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4080 if(_nb_of_tuples_to_be_allocated>=0)
4082 _nb_of_tuples_to_be_allocated=newLgth;
4085 if(_nb_of_tuples_to_be_allocated==-1)
4087 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4089 const DataArray *oldArr=getUndergroundDataArray();
4090 if(!oldArr || !oldArr->isAllocated())
4091 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4092 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4093 newArr->alloc(newLgth,getNumberOfComponents());
4095 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4097 if((*it).second<(*it).first)
4098 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4099 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4100 pos+=(*it).second-(*it).first;
4105 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4108 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4110 if(_field_per_mesh.empty())
4111 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4112 if(_field_per_mesh.size()>1)
4113 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4114 _field_per_mesh[0]->copyOptionsFrom(opts);
4115 _field_per_mesh[0]->writeLL(fid,nasc);
4119 * 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.
4120 * If false is returned the memory allocation is not required.
4122 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4124 if(_nb_of_tuples_to_be_allocated>=0)
4126 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4127 _nb_of_tuples_to_be_allocated=-2;
4130 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4132 if(_nb_of_tuples_to_be_allocated==-1)
4133 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4134 if(_nb_of_tuples_to_be_allocated<-3)
4135 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4139 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4141 med_int numdt,numit;
4145 med_int meshnumdt,meshnumit;
4146 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4147 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4148 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4149 if(_iteration!=numdt || _order!=numit)
4150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4151 _field_per_mesh.resize(nmesh);
4152 for(int i=0;i<nmesh;i++)
4153 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4154 _nb_of_tuples_to_be_allocated=0;
4155 for(int i=0;i<nmesh;i++)
4156 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4159 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4161 allocIfNecessaryTheArrayToReceiveDataFromFile();
4162 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4163 (*it)->loadBigArraysRecursively(fid,nasc);
4166 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4168 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4169 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4170 (*it)->loadBigArraysRecursively(fid,nasc);
4173 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4175 loadOnlyStructureOfDataRecursively(fid,nasc);
4176 loadBigArraysRecursively(fid,nasc);
4179 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4181 DataArray *thisArr(getUndergroundDataArray());
4182 if(thisArr && thisArr->isAllocated())
4184 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4185 thisArr->desallocate();
4189 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4191 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4192 if(getUndergroundDataArray())
4193 ret+=getUndergroundDataArray()->getHeapMemorySize();
4194 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4195 ret+=(*it)->getHeapMemorySize();
4200 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4201 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4202 * "Sort By Type"), if not, an exception is thrown.
4203 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4204 * \param [in] arr - the array of values.
4205 * \param [in,out] glob - the global data where profiles and localization present in
4206 * \a field, if any, are added.
4207 * \throw If the name of \a field is empty.
4208 * \throw If the data array of \a field is not set.
4209 * \throw If \a this->_arr is already allocated but has different number of components
4211 * \throw If the underlying mesh of \a field has no name.
4212 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4214 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4216 const MEDCouplingMesh *mesh=field->getMesh();
4218 TypeOfField type=field->getTypeOfField();
4219 std::vector<DataArrayInt *> dummy;
4220 int start=copyTinyInfoFrom(field,arr);
4221 int pos=addNewEntryIfNecessary(mesh);
4224 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4225 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4228 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4232 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4233 * of a given mesh are used as the support of the given field (a real support is not used).
4234 * Elements of the given mesh must be sorted suitable for writing to MED file.
4235 * Order of underlying mesh entities of the given field specified by \a profile parameter
4236 * is not prescribed; this method permutes field values to have them sorted by element
4237 * type as required for writing to MED file. A new profile is added only if no equal
4238 * profile is missing.
4239 * \param [in] field - the field to add to \a this. The field double values are ignored.
4240 * \param [in] arrOfVals - the values of the field \a field used.
4241 * \param [in] mesh - the supporting mesh of \a field.
4242 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4243 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4244 * \param [in,out] glob - the global data where profiles and localization present in
4245 * \a field, if any, are added.
4246 * \throw If either \a field or \a mesh or \a profile has an empty name.
4247 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4248 * \throw If the data array of \a field is not set.
4249 * \throw If \a this->_arr is already allocated but has different number of components
4251 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4252 * \sa setFieldNoProfileSBT()
4254 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)
4257 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4258 if(!arrOfVals || !arrOfVals->isAllocated())
4259 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4260 TypeOfField type=field->getTypeOfField();
4261 std::vector<DataArrayInt *> idsInPflPerType;
4262 std::vector<DataArrayInt *> idsPerType;
4263 std::vector<int> code,code2;
4264 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4267 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4268 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4269 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4270 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4272 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4273 if(type==ON_GAUSS_NE)
4275 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4276 field2->setMesh(mPart);
4278 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4279 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4281 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4282 throw INTERP_KERNEL::Exception(oss.str().c_str());
4285 int start=copyTinyInfoFrom(field,arrOfVals);
4286 code2=m->getDistributionOfTypes();
4288 int pos=addNewEntryIfNecessary(m);
4289 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4293 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4294 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4295 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4296 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4297 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4298 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4300 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4301 throw INTERP_KERNEL::Exception(oss.str().c_str());
4303 int start=copyTinyInfoFrom(field,arrOfVals);
4304 int pos=addNewEntryIfNecessary(m);
4305 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4310 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4312 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4314 if(_nb_of_tuples_to_be_allocated>=0)
4315 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 !");
4316 DataArray *arr(getOrCreateAndGetArray());
4317 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4318 _nb_of_tuples_to_be_allocated=-3;
4322 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4323 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4324 * larger by the size of \a field. Returns an id of the first not filled
4325 * tuple of \a this->_arr.
4326 * \param [in] field - the field to copy the info on components and the name from.
4327 * \return int - the id of first not initialized tuple of \a this->_arr.
4328 * \throw If the name of \a field is empty.
4329 * \throw If the data array of \a field is not set.
4330 * \throw If \a this->_arr is already allocated but has different number of components
4333 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4336 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4337 std::string name(field->getName());
4338 setName(name.c_str());
4339 setDtUnit(field->getTimeUnit());
4341 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4343 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4344 if(!arr->isAllocated())
4345 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4346 _dt=field->getTime(_iteration,_order);
4347 int nbOfComponents=arr->getNumberOfComponents();
4348 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4349 if(!getOrCreateAndGetArray()->isAllocated())
4351 allocNotFromFile(arr->getNumberOfTuples());
4356 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4357 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4358 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4359 _nb_of_tuples_to_be_allocated=-3;
4360 return oldNbOfTuples;
4365 * Returns number of components in \a this field
4366 * \return int - the number of components.
4368 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4370 return getOrCreateAndGetArray()->getNumberOfComponents();
4374 * Change info on components in \a this.
4375 * \throw If size of \a infos is not equal to the number of components already in \a this.
4377 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4379 DataArray *arr=getOrCreateAndGetArray();
4380 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4384 * Returns info on components of \a this field.
4385 * \return const std::vector<std::string>& - a sequence of strings each being an
4386 * information on _i_-th component.
4388 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4390 const DataArray *arr=getOrCreateAndGetArray();
4391 return arr->getInfoOnComponents();
4395 * Returns a mutable info on components of \a this field.
4396 * \return std::vector<std::string>& - a sequence of strings each being an
4397 * information on _i_-th component.
4399 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4401 DataArray *arr=getOrCreateAndGetArray();
4402 return arr->getInfoOnComponents();
4406 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4407 * \param [in] type - a spatial discretization of the new field.
4408 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4409 * \param [in] mName - a name of the supporting mesh.
4410 * \param [in] renumPol - specifies how to permute values of the result field according to
4411 * the optional numbers of cells and nodes, if any. The valid values are
4412 * - 0 - do not permute.
4413 * - 1 - permute cells.
4414 * - 2 - permute nodes.
4415 * - 3 - permute cells and nodes.
4417 * \param [in] glob - the global data storing profiles and localization.
4418 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4419 * caller is to delete this field using decrRef() as it is no more needed.
4420 * \throw If the MED file is not readable.
4421 * \throw If there is no mesh named \a mName in the MED file.
4422 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4423 * \throw If no field of \a this is lying on the mesh \a mName.
4424 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4426 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)
4428 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4430 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4432 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4433 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4437 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4438 * \param [in] type - a spatial discretization of the new field.
4439 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4440 * \param [in] renumPol - specifies how to permute values of the result field according to
4441 * the optional numbers of cells and nodes, if any. The valid values are
4442 * - 0 - do not permute.
4443 * - 1 - permute cells.
4444 * - 2 - permute nodes.
4445 * - 3 - permute cells and nodes.
4447 * \param [in] glob - the global data storing profiles and localization.
4448 * \param [in] mesh - the supporting mesh.
4449 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4450 * caller is to delete this field using decrRef() as it is no more needed.
4451 * \throw If the MED file is not readable.
4452 * \throw If no field of \a this is lying on \a mesh.
4453 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4454 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4456 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)
4458 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4459 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4460 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4461 if(meshDimRelToMax==1)
4462 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4463 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4467 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4469 * \param [in] type - a spatial discretization of the new field.
4470 * \param [in] mName - a name of the supporting mesh.
4471 * \param [in] renumPol - specifies how to permute values of the result field according to
4472 * the optional numbers of cells and nodes, if any. The valid values are
4473 * - 0 - do not permute.
4474 * - 1 - permute cells.
4475 * - 2 - permute nodes.
4476 * - 3 - permute cells and nodes.
4478 * \param [in] glob - the global data storing profiles and localization.
4479 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4480 * caller is to delete this field using decrRef() as it is no more needed.
4481 * \throw If the MED file is not readable.
4482 * \throw If there is no mesh named \a mName in the MED file.
4483 * \throw If there are no mesh entities in the mesh.
4484 * \throw If no field values of the given \a type are available.
4486 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4488 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4490 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4492 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4493 int absDim=getDimension();
4494 int meshDimRelToMax=absDim-mm->getMeshDimension();
4495 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4499 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4500 * \param [in] type - a spatial discretization of the new field.
4501 * \param [in] renumPol - specifies how to permute values of the result field according to
4502 * the optional numbers of cells and nodes, if any. The valid values are
4503 * - 0 - do not permute.
4504 * - 1 - permute cells.
4505 * - 2 - permute nodes.
4506 * - 3 - permute cells and nodes.
4508 * \param [in] glob - the global data storing profiles and localization.
4509 * \param [in] mesh - the supporting mesh.
4510 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4511 * field according to \a renumPol.
4512 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4513 * field according to \a renumPol.
4514 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4515 * caller is to delete this field using decrRef() as it is no more needed.
4516 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4517 * \throw If no field of \a this is lying on \a mesh.
4518 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4520 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)
4522 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4523 int meshId=getMeshIdFromMeshName(mesh->getName());
4525 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4530 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4537 throw INTERP_KERNEL::Exception(msg1);
4538 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4541 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4543 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4544 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4545 throw INTERP_KERNEL::Exception(oss.str().c_str());
4547 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4548 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4549 std::vector<DataArray *> arrOut2(1,arrOut);
4550 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4551 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4552 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4559 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4561 throw INTERP_KERNEL::Exception(msg1);
4564 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4566 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4567 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4568 throw INTERP_KERNEL::Exception(oss.str().c_str());
4570 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4571 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4572 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4573 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4578 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4583 * Returns values and a profile of the field of a given type lying on a given support.
4584 * \param [in] type - a spatial discretization of the field.
4585 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4586 * \param [in] mesh - the supporting mesh.
4587 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4588 * field of interest lies on. If the field lies on all entities of the given
4589 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4590 * using decrRef() as it is no more needed.
4591 * \param [in] glob - the global data storing profiles and localization.
4592 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4593 * field. The caller is to delete this array using decrRef() as it is no more needed.
4594 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4595 * \throw If no field of \a this is lying on \a mesh.
4596 * \throw If no field values of the given \a type are available.
4598 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4600 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4601 int meshId=getMeshIdFromMeshName(mesh->getName());
4602 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4603 ret->setName(nasc.getName().c_str());
4607 //= MEDFileField1TSWithoutSDA
4610 * Throws if a given value is not a valid (non-extended) relative dimension.
4611 * \param [in] meshDimRelToMax - the relative dimension value.
4612 * \throw If \a meshDimRelToMax > 0.
4614 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4616 if(meshDimRelToMax>0)
4617 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4621 * Checks if elements of a given mesh are in the order suitable for writing
4622 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4623 * vector describing types of elements and their number.
4624 * \param [in] mesh - the mesh to check.
4625 * \return std::vector<int> - a vector holding for each element type (1) item of
4626 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4627 * These values are in full-interlace mode.
4628 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4630 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4633 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4634 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4635 int nbOfTypes=geoTypes.size();
4636 std::vector<int> code(3*nbOfTypes);
4637 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4638 arr1->alloc(nbOfTypes,1);
4639 int *arrPtr=arr1->getPointer();
4640 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4641 for(int i=0;i<nbOfTypes;i++,it++)
4642 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4643 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4644 const int *arrPtr2=arr2->getConstPointer();
4646 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4649 int nbCells=mesh->getNumberOfCellsWithType(*it);
4650 code[3*pos]=(int)(*it);
4651 code[3*pos+1]=nbCells;
4652 code[3*pos+2]=-1;//no profiles
4654 std::vector<const DataArrayInt *> idsPerType;//no profiles
4655 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4659 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4664 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4666 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4670 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4671 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4672 * item of every of returned sequences refers to the _i_-th part of \a this field.
4673 * Thus all sequences returned by this method are of the same length equal to number
4674 * of different types of supporting entities.<br>
4675 * A field part can include sub-parts with several different spatial discretizations,
4676 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4677 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4678 * of a nested sequence corresponds to a type of spatial discretization.<br>
4679 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4680 * The overhead is due to selecting values into new instances of DataArrayDouble.
4681 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4682 * for the case with only one underlying mesh. (Actually, the number of meshes is
4683 * not checked if \a mname == \c NULL).
4684 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4685 * a field part is returned.
4686 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4687 * A field part can include sub-parts with several different spatial discretizations,
4688 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4689 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4690 * This sequence is of the same length as \a types.
4691 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4692 * discretization. A profile name can be empty.
4693 * Length of this and of nested sequences is the same as that of \a typesF.
4694 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4695 * discretization. A localization name can be empty.
4696 * Length of this and of nested sequences is the same as that of \a typesF.
4697 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4698 * per each type of spatial discretization within one mesh entity type.
4699 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4700 * Length of this and of nested sequences is the same as that of \a typesF.
4701 * \throw If no field is lying on \a mname.
4703 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)
4707 meshId=getMeshIdFromMeshName(mname);
4709 if(_field_per_mesh.empty())
4710 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4711 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4712 int nbOfRet=ret0.size();
4713 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4714 for(int i=0;i<nbOfRet;i++)
4716 const std::vector< std::pair<int,int> >& p=ret0[i];
4717 int nbOfRet1=p.size();
4718 ret[i].resize(nbOfRet1);
4719 for(int j=0;j<nbOfRet1;j++)
4721 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4729 * Returns a pointer to the underground DataArrayDouble instance. So the
4730 * caller should not decrRef() it. This method allows for a direct access to the field
4731 * values. This method is quite unusable if there is more than a nodal field or a cell
4732 * field on single geometric cell type.
4733 * \return DataArrayDouble * - the pointer to the field values array.
4735 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4737 const DataArrayDouble *ret=_arr;
4739 return const_cast<DataArrayDouble *>(ret);
4744 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4749 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4751 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4752 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4753 ret->deepCpyLeavesFrom(*this);
4754 const DataArrayDouble *arr(_arr);
4757 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4758 ret->setArray(arr2);
4764 * Returns a pointer to the underground DataArrayDouble instance. So the
4765 * caller should not decrRef() it. This method allows for a direct access to the field
4766 * values. This method is quite unusable if there is more than a nodal field or a cell
4767 * field on single geometric cell type.
4768 * \return DataArrayDouble * - the pointer to the field values array.
4770 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4772 return getUndergroundDataArrayDouble();
4776 * Returns a pointer to the underground DataArrayDouble instance and a
4777 * sequence describing parameters of a support of each part of \a this field. The
4778 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4779 * direct access to the field values. This method is intended for the field lying on one
4781 * \param [in,out] entries - the sequence describing parameters of a support of each
4782 * part of \a this field. Each item of this sequence consists of two parts. The
4783 * first part describes a type of mesh entity and an id of discretization of a
4784 * current field part. The second part describes a range of values [begin,end)
4785 * within the returned array relating to the current field part.
4786 * \return DataArrayDouble * - the pointer to the field values array.
4787 * \throw If the number of underlying meshes is not equal to 1.
4788 * \throw If no field values are available.
4789 * \sa getUndergroundDataArray()
4791 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4793 if(_field_per_mesh.size()!=1)
4794 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4795 if(_field_per_mesh[0]==0)
4796 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4797 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4798 return getUndergroundDataArrayDouble();
4802 * Returns a pointer to the underground DataArrayDouble instance and a
4803 * sequence describing parameters of a support of each part of \a this field. The
4804 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4805 * direct access to the field values. This method is intended for the field lying on one
4807 * \param [in,out] entries - the sequence describing parameters of a support of each
4808 * part of \a this field. Each item of this sequence consists of two parts. The
4809 * first part describes a type of mesh entity and an id of discretization of a
4810 * current field part. The second part describes a range of values [begin,end)
4811 * within the returned array relating to the current field part.
4812 * \return DataArrayDouble * - the pointer to the field values array.
4813 * \throw If the number of underlying meshes is not equal to 1.
4814 * \throw If no field values are available.
4815 * \sa getUndergroundDataArray()
4817 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4819 return getUndergroundDataArrayDoubleExt(entries);
4822 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4823 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4825 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4826 arr->setInfoAndChangeNbOfCompo(infos);
4829 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4833 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4835 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4836 ret->deepCpyLeavesFrom(*this);
4840 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4842 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4843 if((const DataArrayDouble *)_arr)
4844 ret->_arr=_arr->deepCpy();
4848 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4852 _nb_of_tuples_to_be_allocated=-1;
4856 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4858 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4860 _nb_of_tuples_to_be_allocated=-3;
4865 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4867 return DataArrayDouble::New();
4870 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4872 DataArrayDouble *ret=_arr;
4875 _arr=DataArrayDouble::New();
4879 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4881 return getOrCreateAndGetArrayDouble();
4884 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4886 const DataArrayDouble *ret=_arr;
4889 DataArrayDouble *ret2=DataArrayDouble::New();
4890 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4894 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4896 return getOrCreateAndGetArrayDouble();
4899 //= MEDFileIntField1TSWithoutSDA
4901 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4902 const std::vector<std::string>& infos)
4904 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4907 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4911 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4912 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4914 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4915 arr->setInfoAndChangeNbOfCompo(infos);
4918 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4923 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4925 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4926 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4927 ret->deepCpyLeavesFrom(*this);
4928 const DataArrayInt *arr(_arr);
4931 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4932 ret->setArray(arr2);
4938 * Returns a pointer to the underground DataArrayInt instance. So the
4939 * caller should not decrRef() it. This method allows for a direct access to the field
4940 * values. This method is quite unusable if there is more than a nodal field or a cell
4941 * field on single geometric cell type.
4942 * \return DataArrayInt * - the pointer to the field values array.
4944 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4946 return getUndergroundDataArrayInt();
4950 * Returns a pointer to the underground DataArrayInt instance. So the
4951 * caller should not decrRef() it. This method allows for a direct access to the field
4952 * values. This method is quite unusable if there is more than a nodal field or a cell
4953 * field on single geometric cell type.
4954 * \return DataArrayInt * - the pointer to the field values array.
4956 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4958 const DataArrayInt *ret=_arr;
4960 return const_cast<DataArrayInt *>(ret);
4966 * Returns a pointer to the underground DataArrayInt instance and a
4967 * sequence describing parameters of a support of each part of \a this field. The
4968 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4969 * direct access to the field values. This method is intended for the field lying on one
4971 * \param [in,out] entries - the sequence describing parameters of a support of each
4972 * part of \a this field. Each item of this sequence consists of two parts. The
4973 * first part describes a type of mesh entity and an id of discretization of a
4974 * current field part. The second part describes a range of values [begin,end)
4975 * within the returned array relating to the current field part.
4976 * \return DataArrayInt * - the pointer to the field values array.
4977 * \throw If the number of underlying meshes is not equal to 1.
4978 * \throw If no field values are available.
4979 * \sa getUndergroundDataArray()
4981 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4983 return getUndergroundDataArrayIntExt(entries);
4987 * Returns a pointer to the underground DataArrayInt instance and a
4988 * sequence describing parameters of a support of each part of \a this field. The
4989 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4990 * direct access to the field values. This method is intended for the field lying on one
4992 * \param [in,out] entries - the sequence describing parameters of a support of each
4993 * part of \a this field. Each item of this sequence consists of two parts. The
4994 * first part describes a type of mesh entity and an id of discretization of a
4995 * current field part. The second part describes a range of values [begin,end)
4996 * within the returned array relating to the current field part.
4997 * \return DataArrayInt * - the pointer to the field values array.
4998 * \throw If the number of underlying meshes is not equal to 1.
4999 * \throw If no field values are available.
5000 * \sa getUndergroundDataArray()
5002 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5004 if(_field_per_mesh.size()!=1)
5005 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5006 if(_field_per_mesh[0]==0)
5007 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5008 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5009 return getUndergroundDataArrayInt();
5012 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
5014 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5015 ret->deepCpyLeavesFrom(*this);
5019 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
5021 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5022 if((const DataArrayInt *)_arr)
5023 ret->_arr=_arr->deepCpy();
5027 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5031 _nb_of_tuples_to_be_allocated=-1;
5035 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5037 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5039 _nb_of_tuples_to_be_allocated=-3;
5044 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5046 return DataArrayInt::New();
5049 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5051 DataArrayInt *ret=_arr;
5054 _arr=DataArrayInt::New();
5058 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5060 return getOrCreateAndGetArrayInt();
5063 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5065 const DataArrayInt *ret=_arr;
5068 DataArrayInt *ret2=DataArrayInt::New();
5069 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5073 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5075 return getOrCreateAndGetArrayInt();
5078 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5082 //= MEDFileAnyTypeField1TS
5084 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5086 med_field_type typcha;
5088 std::vector<std::string> infos;
5089 std::string dtunit,fieldName;
5090 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5091 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5096 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5101 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5106 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] !";
5107 throw INTERP_KERNEL::Exception(oss.str().c_str());
5110 ret->setDtUnit(dtunit.c_str());
5111 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5113 med_int numdt,numit;
5115 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5116 ret->setTime(numdt,numit,dt);
5119 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5121 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5125 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5126 try:MEDFileFieldGlobsReal(fileName)
5128 MEDFileUtilities::CheckFileForRead(fileName);
5129 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5130 _content=BuildContentFrom(fid,fileName,loadAll);
5133 catch(INTERP_KERNEL::Exception& e)
5138 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5140 med_field_type typcha;
5141 std::vector<std::string> infos;
5144 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5145 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5150 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5155 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5160 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] !";
5161 throw INTERP_KERNEL::Exception(oss.str().c_str());
5164 ret->setDtUnit(dtunit.c_str());
5165 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5169 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5170 throw INTERP_KERNEL::Exception(oss.str().c_str());
5173 med_int numdt,numit;
5175 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5176 ret->setTime(numdt,numit,dt);
5179 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5181 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5185 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5186 try:MEDFileFieldGlobsReal(fileName)
5188 MEDFileUtilities::CheckFileForRead(fileName);
5189 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5190 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5193 catch(INTERP_KERNEL::Exception& e)
5198 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5201 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5202 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5204 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5205 ret->setFileName(fileName);
5206 ret->_content=c; c->incrRef();
5209 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5211 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5212 ret->setFileName(fileName);
5213 ret->_content=c; c->incrRef();
5216 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5219 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5221 MEDFileUtilities::CheckFileForRead(fileName);
5222 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5223 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5224 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5225 ret->loadGlobals(fid);
5229 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5231 MEDFileUtilities::CheckFileForRead(fileName);
5232 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5233 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5234 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5235 ret->loadGlobals(fid);
5239 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5241 MEDFileUtilities::CheckFileForRead(fileName);
5242 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5243 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5244 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5245 ret->loadGlobals(fid);
5249 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5251 med_field_type typcha;
5252 std::vector<std::string> infos;
5255 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5256 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5261 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5266 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5271 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] !";
5272 throw INTERP_KERNEL::Exception(oss.str().c_str());
5275 ret->setDtUnit(dtunit.c_str());
5276 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5279 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5280 for(int i=0;i<nbOfStep2 && !found;i++)
5282 med_int numdt,numit;
5284 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5285 if(numdt==iteration && numit==order)
5291 dtits[i]=std::pair<int,int>(numdt,numit);
5295 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5296 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5297 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5298 throw INTERP_KERNEL::Exception(oss.str().c_str());
5301 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5303 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5307 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5308 try:MEDFileFieldGlobsReal(fileName)
5310 MEDFileUtilities::CheckFileForRead(fileName);
5311 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5312 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5315 catch(INTERP_KERNEL::Exception& e)
5321 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5322 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5324 * \warning this is a shallow copy constructor
5326 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5328 if(!shallowCopyOfContent)
5330 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5331 otherPtr->incrRef();
5332 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5336 _content=other.shallowCpy();
5340 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)
5344 int nbFields=MEDnField(fid);
5345 if(fieldIdCFormat>=nbFields)
5347 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5348 throw INTERP_KERNEL::Exception(oss.str().c_str());
5351 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5352 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5353 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5354 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5355 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5356 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5359 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5360 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5361 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5362 infos.clear(); infos.resize(ncomp);
5363 for(int j=0;j<ncomp;j++)
5364 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5369 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5372 * \return in case of success the number of time steps available for the field with name \a fieldName.
5374 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)
5376 int nbFields=MEDnField(fid);
5378 std::vector<std::string> fns(nbFields);
5380 for(int i=0;i<nbFields && !found;i++)
5383 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5385 found=(tmp==fieldName);
5391 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5392 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5393 oss << "\"" << *it << "\" ";
5394 throw INTERP_KERNEL::Exception(oss.str().c_str());
5400 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5401 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5402 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5403 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5404 * to keep a valid instance.
5405 * 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.
5406 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5407 * 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.
5409 * \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.
5410 * \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.
5411 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5412 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5413 * \param [in] newLocName is the new localization name.
5414 * \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.
5415 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5417 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5419 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5420 std::string oldPflName=disc->getProfile();
5421 std::vector<std::string> vv=getPflsReallyUsedMulti();
5422 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5423 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5425 disc->setProfile(newPflName);
5426 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5427 pfl->setName(newPflName);
5431 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5432 throw INTERP_KERNEL::Exception(oss.str().c_str());
5437 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5438 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5439 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5440 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5441 * to keep a valid instance.
5442 * 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.
5443 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5444 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5445 * 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.
5447 * \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.
5448 * \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.
5449 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5450 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5451 * \param [in] newLocName is the new localization name.
5452 * \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.
5453 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5455 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5457 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5458 std::string oldLocName=disc->getLocalization();
5459 std::vector<std::string> vv=getLocsReallyUsedMulti();
5460 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5461 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5463 disc->setLocalization(newLocName);
5464 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5465 loc.setName(newLocName);
5469 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5470 throw INTERP_KERNEL::Exception(oss.str().c_str());
5474 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5476 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5478 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5482 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5484 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5486 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5491 * Writes \a this field into a MED file specified by its name.
5492 * \param [in] fileName - the MED file name.
5493 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5494 * - 2 - erase; an existing file is removed.
5495 * - 1 - append; same data should not be present in an existing file.
5496 * - 0 - overwrite; same data present in an existing file is overwritten.
5497 * \throw If the field name is not set.
5498 * \throw If no field data is set.
5499 * \throw If \a mode == 1 and the same data is present in an existing file.
5501 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5503 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5504 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5509 * This method alloc the arrays and load potentially huge arrays contained in this field.
5510 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5511 * This method can be also called to refresh or reinit values from a file.
5513 * \throw If the fileName is not set or points to a non readable MED file.
5514 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5516 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5518 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5519 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5523 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5524 * But once data loaded once, this method does nothing.
5526 * \throw If the fileName is not set or points to a non readable MED file.
5527 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5529 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5531 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5532 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5536 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5537 * This method does not release arrays set outside the context of a MED file.
5539 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5541 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5543 contentNotNullBase()->releaseArrays();
5546 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5548 int nbComp=getNumberOfComponents();
5549 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5550 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5551 for(int i=0;i<nbComp;i++)
5553 std::string info=getInfo()[i];
5555 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5556 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5557 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5559 if(getName().empty())
5560 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5561 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5562 writeGlobals(fid,*this);
5563 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5566 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5569 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5570 ret+=_content->getHeapMemorySize();
5571 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5575 * Returns a string describing \a this field. This string is outputted
5576 * by \c print Python command.
5578 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5580 std::ostringstream oss;
5581 contentNotNullBase()->simpleRepr(0,oss,-1);
5582 simpleReprGlobs(oss);
5587 * This method returns all profiles whose name is non empty used.
5588 * \b WARNING If profile is used several times it will be reported \b only \b once.
5589 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5591 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5593 return contentNotNullBase()->getPflsReallyUsed2();
5597 * This method returns all localizations whose name is non empty used.
5598 * \b WARNING If localization is used several times it will be reported \b only \b once.
5600 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5602 return contentNotNullBase()->getLocsReallyUsed2();
5606 * This method returns all profiles whose name is non empty used.
5607 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5609 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5611 return contentNotNullBase()->getPflsReallyUsedMulti2();
5615 * This method returns all localizations whose name is non empty used.
5616 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5618 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5620 return contentNotNullBase()->getLocsReallyUsedMulti2();
5623 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5625 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5628 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5630 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5633 int MEDFileAnyTypeField1TS::getDimension() const
5635 return contentNotNullBase()->getDimension();
5638 int MEDFileAnyTypeField1TS::getIteration() const
5640 return contentNotNullBase()->getIteration();
5643 int MEDFileAnyTypeField1TS::getOrder() const
5645 return contentNotNullBase()->getOrder();
5648 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5650 return contentNotNullBase()->getTime(iteration,order);
5653 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5655 contentNotNullBase()->setTime(iteration,order,val);
5658 std::string MEDFileAnyTypeField1TS::getName() const
5660 return contentNotNullBase()->getName();
5663 void MEDFileAnyTypeField1TS::setName(const char *name)
5665 contentNotNullBase()->setName(name);
5668 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5670 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5673 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5675 return contentNotNullBase()->getDtUnit();
5678 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5680 contentNotNullBase()->setDtUnit(dtUnit);
5683 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5685 return contentNotNullBase()->getMeshName();
5688 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5690 contentNotNullBase()->setMeshName(newMeshName);
5693 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5695 return contentNotNullBase()->changeMeshNames(modifTab);
5698 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5700 return contentNotNullBase()->getMeshIteration();
5703 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5705 return contentNotNullBase()->getMeshOrder();
5708 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5710 return contentNotNullBase()->getNumberOfComponents();
5713 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5715 return contentNotNullBase()->isDealingTS(iteration,order);
5718 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5720 return contentNotNullBase()->getDtIt();
5723 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5725 contentNotNullBase()->fillIteration(p);
5728 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5730 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5733 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5735 contentNotNullBase()->setInfo(infos);
5738 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5740 return contentNotNullBase()->getInfo();
5742 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5744 return contentNotNullBase()->getInfo();
5747 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5749 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5752 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5754 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5757 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5759 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5762 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5764 return contentNotNullBase()->getTypesOfFieldAvailable();
5767 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,
5768 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5770 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5774 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5775 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5776 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5778 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5780 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5782 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5783 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5784 std::size_t sz(contentsSplit.size());
5785 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5786 for(std::size_t i=0;i<sz;i++)
5788 ret[i]=shallowCpy();
5789 ret[i]->_content=contentsSplit[i];
5795 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5796 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5798 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5800 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5802 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5803 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5804 std::size_t sz(contentsSplit.size());
5805 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5806 for(std::size_t i=0;i<sz;i++)
5808 ret[i]=shallowCpy();
5809 ret[i]->_content=contentsSplit[i];
5814 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5816 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5817 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5818 ret->_content=_content->deepCpy();
5819 ret->deepCpyGlobs(*this);
5823 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5825 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5831 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5832 * the first field that has been read from a specified MED file.
5833 * \param [in] fileName - the name of the MED file to read.
5834 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5835 * is to delete this field using decrRef() as it is no more needed.
5836 * \throw If reading the file fails.
5838 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5840 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5841 ret->contentNotNull();
5846 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5847 * a given field that has been read from a specified MED file.
5848 * \param [in] fileName - the name of the MED file to read.
5849 * \param [in] fieldName - the name of the field to read.
5850 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5851 * is to delete this field using decrRef() as it is no more needed.
5852 * \throw If reading the file fails.
5853 * \throw If there is no field named \a fieldName in the file.
5855 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5857 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5858 ret->contentNotNull();
5863 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5864 * a given field that has been read from a specified MED file.
5865 * \param [in] fileName - the name of the MED file to read.
5866 * \param [in] fieldName - the name of the field to read.
5867 * \param [in] iteration - the iteration number of a required time step.
5868 * \param [in] order - the iteration order number of required time step.
5869 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5870 * is to delete this field using decrRef() as it is no more needed.
5871 * \throw If reading the file fails.
5872 * \throw If there is no field named \a fieldName in the file.
5873 * \throw If the required time step is missing from the file.
5875 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5877 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5878 ret->contentNotNull();
5883 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5884 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5886 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5887 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5888 * \warning this is a shallow copy constructor
5889 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5890 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5891 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5892 * is to delete this field using decrRef() as it is no more needed.
5894 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5896 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5897 ret->contentNotNull();
5902 * Returns a new empty instance of MEDFileField1TS.
5903 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5904 * is to delete this field using decrRef() as it is no more needed.
5906 MEDFileField1TS *MEDFileField1TS::New()
5908 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5909 ret->contentNotNull();
5914 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5915 * following the given input policy.
5917 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5918 * By default (true) the globals are deeply copied.
5919 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5921 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5923 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5924 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5927 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5929 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5930 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5931 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5934 ret=MEDFileIntField1TS::New();
5936 ret->deepCpyGlobs(*this);
5938 ret->shallowCpyGlobs(*this);
5942 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5944 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5946 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5947 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5949 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 !");
5953 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5955 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5957 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5958 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5960 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 !");
5964 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5967 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5968 if(!((DataArray*)arr))
5969 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5970 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5972 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5973 f->setArray(arrOutC);
5976 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5978 if(!((DataArray*)arr))
5979 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5980 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5982 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5987 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5988 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5991 catch(INTERP_KERNEL::Exception& e)
5994 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5995 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5998 catch(INTERP_KERNEL::Exception& e)
6001 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6002 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6005 catch(INTERP_KERNEL::Exception& e)
6009 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6010 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6012 * \warning this is a shallow copy constructor
6014 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6015 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6018 catch(INTERP_KERNEL::Exception& e)
6021 MEDFileField1TS::MEDFileField1TS()
6023 _content=new MEDFileField1TSWithoutSDA;
6027 * Returns a new MEDCouplingFieldDouble of a given type lying on
6028 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6029 * has not been constructed via file reading, an exception is thrown.
6030 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6031 * \param [in] type - a spatial discretization of interest.
6032 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6033 * \param [in] renumPol - specifies how to permute values of the result field according to
6034 * the optional numbers of cells and nodes, if any. The valid values are
6035 * - 0 - do not permute.
6036 * - 1 - permute cells.
6037 * - 2 - permute nodes.
6038 * - 3 - permute cells and nodes.
6040 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6041 * caller is to delete this field using decrRef() as it is no more needed.
6042 * \throw If \a this field has not been constructed via file reading.
6043 * \throw If the MED file is not readable.
6044 * \throw If there is no mesh in the MED file.
6045 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6046 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6047 * \sa getFieldOnMeshAtLevel()
6049 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6051 if(getFileName2().empty())
6052 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6053 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6054 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6055 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6060 * Returns a new MEDCouplingFieldDouble of a given type lying on
6061 * the top level cells of the first mesh in MED file. If \a this field
6062 * has not been constructed via file reading, an exception is thrown.
6063 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6064 * \param [in] type - a spatial discretization of interest.
6065 * \param [in] renumPol - specifies how to permute values of the result field according to
6066 * the optional numbers of cells and nodes, if any. The valid values are
6067 * - 0 - do not permute.
6068 * - 1 - permute cells.
6069 * - 2 - permute nodes.
6070 * - 3 - permute cells and nodes.
6072 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6073 * caller is to delete this field using decrRef() as it is no more needed.
6074 * \throw If \a this field has not been constructed via file reading.
6075 * \throw If the MED file is not readable.
6076 * \throw If there is no mesh in the MED file.
6077 * \throw If no field values of the given \a type.
6078 * \throw If no field values lying on the top level support.
6079 * \sa getFieldAtLevel()
6081 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6083 if(getFileName2().empty())
6084 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6085 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6086 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6087 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6092 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6093 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6094 * \param [in] type - a spatial discretization of the new field.
6095 * \param [in] mesh - the supporting mesh.
6096 * \param [in] renumPol - specifies how to permute values of the result field according to
6097 * the optional numbers of cells and nodes, if any. The valid values are
6098 * - 0 - do not permute.
6099 * - 1 - permute cells.
6100 * - 2 - permute nodes.
6101 * - 3 - permute cells and nodes.
6103 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6104 * caller is to delete this field using decrRef() as it is no more needed.
6105 * \throw If no field of \a this is lying on \a mesh.
6106 * \throw If the mesh is empty.
6107 * \throw If no field values of the given \a type are available.
6108 * \sa getFieldAtLevel()
6109 * \sa getFieldOnMeshAtLevel()
6111 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6113 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6114 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6115 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6120 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6121 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6122 * \param [in] type - a spatial discretization of interest.
6123 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6124 * \param [in] mesh - the supporting mesh.
6125 * \param [in] renumPol - specifies how to permute values of the result field according to
6126 * the optional numbers of cells and nodes, if any. The valid values are
6127 * - 0 - do not permute.
6128 * - 1 - permute cells.
6129 * - 2 - permute nodes.
6130 * - 3 - permute cells and nodes.
6132 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6133 * caller is to delete this field using decrRef() as it is no more needed.
6134 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6135 * \throw If no field of \a this is lying on \a mesh.
6136 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6137 * \sa getFieldAtLevel()
6138 * \sa getFieldOnMeshAtLevel()
6140 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6142 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6143 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6144 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6149 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6150 * This method is called "Old" because in MED3 norm a field has only one meshName
6151 * attached, so this method is for readers of MED2 files. If \a this field
6152 * has not been constructed via file reading, an exception is thrown.
6153 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6154 * \param [in] type - a spatial discretization of interest.
6155 * \param [in] mName - a name of the supporting mesh.
6156 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6157 * \param [in] renumPol - specifies how to permute values of the result field according to
6158 * the optional numbers of cells and nodes, if any. The valid values are
6159 * - 0 - do not permute.
6160 * - 1 - permute cells.
6161 * - 2 - permute nodes.
6162 * - 3 - permute cells and nodes.
6164 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6165 * caller is to delete this field using decrRef() as it is no more needed.
6166 * \throw If the MED file is not readable.
6167 * \throw If there is no mesh named \a mName in the MED file.
6168 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6169 * \throw If \a this field has not been constructed via file reading.
6170 * \throw If no field of \a this is lying on the mesh named \a mName.
6171 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6172 * \sa getFieldAtLevel()
6174 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6176 if(getFileName2().empty())
6177 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6178 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6179 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6180 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6185 * Returns values and a profile of the field of a given type lying on a given support.
6186 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6187 * \param [in] type - a spatial discretization of the field.
6188 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6189 * \param [in] mesh - the supporting mesh.
6190 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6191 * field of interest lies on. If the field lies on all entities of the given
6192 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6193 * using decrRef() as it is no more needed.
6194 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6195 * field. The caller is to delete this array using decrRef() as it is no more needed.
6196 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6197 * \throw If no field of \a this is lying on \a mesh.
6198 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6200 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6202 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6203 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6207 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6208 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6209 * "Sort By Type"), if not, an exception is thrown.
6210 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6211 * \param [in] field - the field to add to \a this.
6212 * \throw If the name of \a field is empty.
6213 * \throw If the data array of \a field is not set.
6214 * \throw If the data array is already allocated but has different number of components
6216 * \throw If the underlying mesh of \a field has no name.
6217 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6219 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6222 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6226 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6227 * can be an aggregation of several MEDCouplingFieldDouble instances.
6228 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6229 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6232 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6233 * A new profile is added only if no equal profile is missing.
6234 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6235 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6236 * \param [in] mesh - the supporting mesh of \a field.
6237 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6238 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6239 * \throw If either \a field or \a mesh or \a profile has an empty name.
6240 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6241 * \throw If the data array of \a field is not set.
6242 * \throw If the data array of \a this is already allocated but has different number of
6243 * components than \a field.
6244 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6245 * \sa setFieldNoProfileSBT()
6247 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6250 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6253 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6255 return new MEDFileField1TS(*this);
6258 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6260 return contentNotNull()->getUndergroundDataArrayDouble();
6263 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6265 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6268 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6269 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6271 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6274 //= MEDFileIntField1TS
6276 MEDFileIntField1TS *MEDFileIntField1TS::New()
6278 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6279 ret->contentNotNull();
6283 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6285 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6286 ret->contentNotNull();
6290 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6292 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6293 ret->contentNotNull();
6297 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6299 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6300 ret->contentNotNull();
6304 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6306 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6307 ret->contentNotNull();
6311 MEDFileIntField1TS::MEDFileIntField1TS()
6313 _content=new MEDFileIntField1TSWithoutSDA;
6316 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6317 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6320 catch(INTERP_KERNEL::Exception& e)
6323 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6324 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6327 catch(INTERP_KERNEL::Exception& e)
6330 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6331 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6334 catch(INTERP_KERNEL::Exception& e)
6338 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6339 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6341 * \warning this is a shallow copy constructor
6343 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6347 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6349 return new MEDFileIntField1TS(*this);
6353 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6354 * following the given input policy.
6356 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6357 * By default (true) the globals are deeply copied.
6358 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6360 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6362 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6363 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6366 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6368 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6369 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6370 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6373 ret=MEDFileField1TS::New();
6375 ret->deepCpyGlobs(*this);
6377 ret->shallowCpyGlobs(*this);
6382 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6383 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6384 * "Sort By Type"), if not, an exception is thrown.
6385 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6386 * \param [in] field - the field to add to \a this. The field double values are ignored.
6387 * \param [in] arrOfVals - the values of the field \a field used.
6388 * \throw If the name of \a field is empty.
6389 * \throw If the data array of \a field is not set.
6390 * \throw If the data array is already allocated but has different number of components
6392 * \throw If the underlying mesh of \a field has no name.
6393 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6395 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6398 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6402 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6403 * can be an aggregation of several MEDCouplingFieldDouble instances.
6404 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6405 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6408 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6409 * A new profile is added only if no equal profile is missing.
6410 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6411 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6412 * \param [in] arrOfVals - the values of the field \a field used.
6413 * \param [in] mesh - the supporting mesh of \a field.
6414 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6415 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6416 * \throw If either \a field or \a mesh or \a profile has an empty name.
6417 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6418 * \throw If the data array of \a field is not set.
6419 * \throw If the data array of \a this is already allocated but has different number of
6420 * components than \a field.
6421 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6422 * \sa setFieldNoProfileSBT()
6424 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6427 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6430 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6432 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6434 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6435 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6437 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 !");
6441 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6443 if(getFileName2().empty())
6444 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6445 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6446 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6447 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6449 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6454 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6456 if(!((DataArray *)arr))
6457 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6458 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6460 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6466 * Returns a new MEDCouplingFieldDouble of a given type lying on
6467 * the top level cells of the first mesh in MED file. If \a this field
6468 * has not been constructed via file reading, an exception is thrown.
6469 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6470 * \param [in] type - a spatial discretization of interest.
6471 * \param [out] arrOut - the DataArrayInt containing values of field.
6472 * \param [in] renumPol - specifies how to permute values of the result field according to
6473 * the optional numbers of cells and nodes, if any. The valid values are
6474 * - 0 - do not permute.
6475 * - 1 - permute cells.
6476 * - 2 - permute nodes.
6477 * - 3 - permute cells and nodes.
6479 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6480 * caller is to delete this field using decrRef() as it is no more needed.
6481 * \throw If \a this field has not been constructed via file reading.
6482 * \throw If the MED file is not readable.
6483 * \throw If there is no mesh in the MED file.
6484 * \throw If no field values of the given \a type.
6485 * \throw If no field values lying on the top level support.
6486 * \sa getFieldAtLevel()
6488 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6490 if(getFileName2().empty())
6491 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6492 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6493 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6494 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6499 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6500 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6501 * \param [in] type - a spatial discretization of the new field.
6502 * \param [in] mesh - the supporting mesh.
6503 * \param [out] arrOut - the DataArrayInt containing values of field.
6504 * \param [in] renumPol - specifies how to permute values of the result field according to
6505 * the optional numbers of cells and nodes, if any. The valid values are
6506 * - 0 - do not permute.
6507 * - 1 - permute cells.
6508 * - 2 - permute nodes.
6509 * - 3 - permute cells and nodes.
6511 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6512 * caller is to delete this field using decrRef() as it is no more needed.
6513 * \throw If no field of \a this is lying on \a mesh.
6514 * \throw If the mesh is empty.
6515 * \throw If no field values of the given \a type are available.
6516 * \sa getFieldAtLevel()
6517 * \sa getFieldOnMeshAtLevel()
6519 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6521 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6522 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6523 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6528 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6529 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530 * \param [in] type - a spatial discretization of interest.
6531 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6532 * \param [out] arrOut - the DataArrayInt containing values of field.
6533 * \param [in] mesh - the supporting mesh.
6534 * \param [in] renumPol - specifies how to permute values of the result field according to
6535 * the optional numbers of cells and nodes, if any. The valid values are
6536 * - 0 - do not permute.
6537 * - 1 - permute cells.
6538 * - 2 - permute nodes.
6539 * - 3 - permute cells and nodes.
6541 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6542 * caller is to delete this field using decrRef() as it is no more needed.
6543 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6544 * \throw If no field of \a this is lying on \a mesh.
6545 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6546 * \sa getFieldAtLevel()
6547 * \sa getFieldOnMeshAtLevel()
6549 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6551 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6552 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6553 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6558 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6559 * This method is called "Old" because in MED3 norm a field has only one meshName
6560 * attached, so this method is for readers of MED2 files. If \a this field
6561 * has not been constructed via file reading, an exception is thrown.
6562 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6563 * \param [in] type - a spatial discretization of interest.
6564 * \param [in] mName - a name of the supporting mesh.
6565 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6566 * \param [out] arrOut - the DataArrayInt containing values of field.
6567 * \param [in] renumPol - specifies how to permute values of the result field according to
6568 * the optional numbers of cells and nodes, if any. The valid values are
6569 * - 0 - do not permute.
6570 * - 1 - permute cells.
6571 * - 2 - permute nodes.
6572 * - 3 - permute cells and nodes.
6574 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6575 * caller is to delete this field using decrRef() as it is no more needed.
6576 * \throw If the MED file is not readable.
6577 * \throw If there is no mesh named \a mName in the MED file.
6578 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6579 * \throw If \a this field has not been constructed via file reading.
6580 * \throw If no field of \a this is lying on the mesh named \a mName.
6581 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6582 * \sa getFieldAtLevel()
6584 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6586 if(getFileName2().empty())
6587 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6588 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6589 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6590 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6595 * Returns values and a profile of the field of a given type lying on a given support.
6596 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6597 * \param [in] type - a spatial discretization of the field.
6598 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6599 * \param [in] mesh - the supporting mesh.
6600 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6601 * field of interest lies on. If the field lies on all entities of the given
6602 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6603 * using decrRef() as it is no more needed.
6604 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6605 * field. The caller is to delete this array using decrRef() as it is no more needed.
6606 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6607 * \throw If no field of \a this is lying on \a mesh.
6608 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6610 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6612 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6613 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6616 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6618 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6620 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6621 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6623 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 !");
6627 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6629 return contentNotNull()->getUndergroundDataArrayInt();
6632 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6634 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6638 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6643 * \param [in] fieldId field id in C mode
6645 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6647 med_field_type typcha;
6648 std::string dtunitOut;
6649 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6650 setDtUnit(dtunitOut.c_str());
6651 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6654 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)
6655 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6657 setDtUnit(dtunit.c_str());
6658 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6660 catch(INTERP_KERNEL::Exception& e)
6665 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6667 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6668 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6669 ret+=(*it).capacity();
6670 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6671 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6672 ret+=(*it)->getHeapMemorySize();
6677 * 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
6680 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6682 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6683 ret->setInfo(_infos);
6684 int sz=(int)_time_steps.size();
6685 for(const int *id=startIds;id!=endIds;id++)
6687 if(*id>=0 && *id<sz)
6689 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6690 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6694 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6696 ret->pushBackTimeStep(tse2);
6700 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6701 oss << " ! Should be in [0," << sz << ") !";
6702 throw INTERP_KERNEL::Exception(oss.str().c_str());
6705 if(ret->getNumberOfTS()>0)
6706 ret->synchronizeNameScope();
6707 ret->copyNameScope(*this);
6712 * 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
6715 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6717 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6718 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6719 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6720 ret->setInfo(_infos);
6721 int sz=(int)_time_steps.size();
6723 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6727 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6728 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6732 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6734 ret->pushBackTimeStep(tse2);
6738 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6739 oss << " ! Should be in [0," << sz << ") !";
6740 throw INTERP_KERNEL::Exception(oss.str().c_str());
6743 if(ret->getNumberOfTS()>0)
6744 ret->synchronizeNameScope();
6745 ret->copyNameScope(*this);
6749 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6752 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6753 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6755 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6758 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6759 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6760 ids->pushBackSilent(id);
6762 return buildFromTimeStepIds(ids->begin(),ids->end());
6765 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6768 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6769 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6771 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6774 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6775 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6776 ids->pushBackSilent(id);
6778 return buildFromTimeStepIds(ids->begin(),ids->end());
6781 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6786 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6791 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6794 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6796 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6797 if(pt->isDealingTS(iteration,order))
6800 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6801 std::vector< std::pair<int,int> > vp=getIterations();
6802 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6803 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6804 throw INTERP_KERNEL::Exception(oss.str().c_str());
6807 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6809 return *_time_steps[getTimeStepPos(iteration,order)];
6812 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6814 return *_time_steps[getTimeStepPos(iteration,order)];
6817 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6819 if(_time_steps.empty())
6820 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6821 return _time_steps[0]->getMeshName();
6824 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6826 std::string oldName(getMeshName());
6827 std::vector< std::pair<std::string,std::string> > v(1);
6828 v[0].first=oldName; v[0].second=newMeshName;
6832 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6835 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6837 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6839 ret=cur->changeMeshNames(modifTab) || ret;
6845 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6847 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6849 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6853 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6855 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)
6857 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6860 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6861 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6864 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6866 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6868 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6873 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6875 std::string startLine(bkOffset,' ');
6876 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6878 oss << " (" << fmtsId << ")";
6879 oss << " has the following name: \"" << _name << "\"." << std::endl;
6880 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6881 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6883 oss << startLine << " - \"" << *it << "\"" << std::endl;
6886 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6888 std::string chapter(17,'0'+i);
6889 oss << startLine << chapter << std::endl;
6890 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6892 cur->simpleRepr(bkOffset+2,oss,i);
6894 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6895 oss << startLine << chapter << std::endl;
6899 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6901 std::size_t sz=_time_steps.size();
6902 std::vector< std::pair<int,int> > ret(sz);
6904 for(std::size_t i=0;i<sz;i++)
6906 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6909 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6913 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6914 throw INTERP_KERNEL::Exception(oss.str().c_str());
6920 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6922 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6924 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6925 checkCoherencyOfType(tse2);
6926 if(_time_steps.empty())
6928 setName(tse2->getName().c_str());
6929 setInfo(tse2->getInfo());
6931 checkThatComponentsMatch(tse2->getInfo());
6932 _time_steps.push_back(tse);
6935 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6937 std::size_t nbOfCompo=_infos.size();
6938 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6940 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6943 if((cur->getInfo()).size()!=nbOfCompo)
6945 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6946 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6947 throw INTERP_KERNEL::Exception(oss.str().c_str());
6949 cur->copyNameScope(*this);
6954 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6956 _time_steps.resize(nbPdt);
6957 for(int i=0;i<nbPdt;i++)
6959 std::vector< std::pair<int,int> > ts;
6960 med_int numdt=0,numo=0;
6961 med_int meshIt=0,meshOrder=0;
6963 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6968 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6973 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6977 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6980 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6982 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6988 if(_time_steps.empty())
6989 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6990 checkThatNbOfCompoOfTSMatchThis();
6991 std::vector<std::string> infos(getInfo());
6992 int nbComp=infos.size();
6993 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6994 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6995 for(int i=0;i<nbComp;i++)
6997 std::string info=infos[i];
6999 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7000 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7001 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7004 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7005 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7006 int nbOfTS=_time_steps.size();
7007 for(int i=0;i<nbOfTS;i++)
7008 _time_steps[i]->writeLL(fid,opts,*this);
7011 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7013 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7015 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7017 elt->loadBigArraysRecursively(fid,nasc);
7021 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7023 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7025 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7027 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7031 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
7033 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7035 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7037 elt->releaseArrays();
7041 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7043 return _time_steps.size();
7046 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7048 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7049 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7051 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7053 newTS.push_back(*it);
7058 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7060 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7061 int maxId=(int)_time_steps.size();
7063 std::set<int> idsToDel;
7064 for(const int *id=startIds;id!=endIds;id++,ii++)
7066 if(*id>=0 && *id<maxId)
7068 idsToDel.insert(*id);
7072 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7073 throw INTERP_KERNEL::Exception(oss.str().c_str());
7076 for(int iii=0;iii<maxId;iii++)
7077 if(idsToDel.find(iii)==idsToDel.end())
7078 newTS.push_back(_time_steps[iii]);
7082 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7084 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7085 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7086 if(nbOfEntriesToKill==0)
7088 std::size_t sz=_time_steps.size();
7089 std::vector<bool> b(sz,true);
7091 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7093 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7094 for(std::size_t i=0;i<sz;i++)
7096 newTS.push_back(_time_steps[i]);
7100 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7103 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7104 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7106 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7110 tmp->getTime(it2,ord);
7111 if(it2==iteration && order==ord)
7114 oss << "(" << it2 << "," << ord << "), ";
7117 throw INTERP_KERNEL::Exception(oss.str().c_str());
7120 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7123 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7125 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7127 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7131 double ti=tmp->getTime(it2,ord);
7132 if(fabs(time-ti)<eps)
7138 throw INTERP_KERNEL::Exception(oss.str().c_str());
7141 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7143 int lgth=_time_steps.size();
7144 std::vector< std::pair<int,int> > ret(lgth);
7145 for(int i=0;i<lgth;i++)
7146 _time_steps[i]->fillIteration(ret[i]);
7151 * 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'
7152 * This method returns two things.
7153 * - The absolute dimension of 'this' in first parameter.
7154 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7155 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7157 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7158 * Only these 3 discretizations will be taken into account here.
7160 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7161 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7162 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7164 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7165 * 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'.
7167 * Let's consider the typical following case :
7168 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7169 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7170 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7172 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7174 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7176 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7177 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7178 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7179 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7181 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7183 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7186 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7188 if(pos<0 || pos>=(int)_time_steps.size())
7190 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7191 throw INTERP_KERNEL::Exception(oss.str().c_str());
7193 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7196 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7197 oss << "\nTry to use following method eraseEmptyTS !";
7198 throw INTERP_KERNEL::Exception(oss.str().c_str());
7203 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7205 if(pos<0 || pos>=(int)_time_steps.size())
7207 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7208 throw INTERP_KERNEL::Exception(oss.str().c_str());
7210 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7213 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7214 oss << "\nTry to use following method eraseEmptyTS !";
7215 throw INTERP_KERNEL::Exception(oss.str().c_str());
7220 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7222 std::vector<std::string> ret;
7223 std::set<std::string> ret2;
7224 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7226 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7227 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7228 if(ret2.find(*it2)==ret2.end())
7230 ret.push_back(*it2);
7237 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7239 std::vector<std::string> ret;
7240 std::set<std::string> ret2;
7241 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7243 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7244 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7245 if(ret2.find(*it2)==ret2.end())
7247 ret.push_back(*it2);
7254 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7256 std::vector<std::string> ret;
7257 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7259 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7260 ret.insert(ret.end(),tmp.begin(),tmp.end());
7265 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7267 std::vector<std::string> ret;
7268 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7270 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7271 ret.insert(ret.end(),tmp.begin(),tmp.end());
7276 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7278 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7279 (*it)->changePflsRefsNamesGen2(mapOfModif);
7282 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7284 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7285 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7288 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7290 int lgth=_time_steps.size();
7291 std::vector< std::vector<TypeOfField> > ret(lgth);
7292 for(int i=0;i<lgth;i++)
7293 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7298 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7300 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)
7302 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7305 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7307 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7309 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7311 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7312 ret->_time_steps[i]=(*it)->deepCpy();
7317 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7319 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7320 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7321 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7322 for(std::size_t i=0;i<sz;i++)
7324 ret[i]=shallowCpy();
7325 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7327 for(std::size_t i=0;i<sz2;i++)
7329 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7332 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7333 throw INTERP_KERNEL::Exception(oss.str().c_str());
7337 for(std::size_t i=0;i<sz;i++)
7338 for(std::size_t j=0;j<sz2;j++)
7339 ret[i]->_time_steps[j]=ts[j][i];
7344 * This method splits into discretization each time steps in \a this.
7345 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7347 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7349 std::size_t sz(_time_steps.size());
7350 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7351 for(std::size_t i=0;i<sz;i++)
7353 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7356 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7357 throw INTERP_KERNEL::Exception(oss.str().c_str());
7359 items[i]=timeStep->splitDiscretizations();
7362 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7363 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7364 std::vector< TypeOfField > types;
7365 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7366 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7368 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7370 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7371 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7372 if(it2==types.end())
7373 types.push_back(ts[0]);
7375 ret.resize(types.size()); ret2.resize(types.size());
7376 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7379 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7380 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7381 ret2[pos].push_back(*it1);
7383 for(std::size_t i=0;i<types.size();i++)
7385 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7386 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7387 elt->pushBackTimeStep(*it1);//also updates infos in elt
7389 elt->MEDFileFieldNameScope::operator=(*this);
7394 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7396 _name=field->getName();
7398 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7400 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7401 _infos=arr->getInfoOnComponents();
7404 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7406 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7407 if(_name!=field->getName())
7409 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7410 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7411 throw INTERP_KERNEL::Exception(oss.str().c_str());
7414 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7415 checkThatComponentsMatch(arr->getInfoOnComponents());
7418 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7420 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7421 if(getInfo().size()!=compos.size())
7423 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7424 oss << " number of components of element to append (" << compos.size() << ") !";
7425 throw INTERP_KERNEL::Exception(oss.str().c_str());
7429 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7430 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7431 oss << " But compo in input fields are : ";
7432 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7434 throw INTERP_KERNEL::Exception(oss.str().c_str());
7438 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7440 std::size_t sz=_infos.size();
7442 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7444 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7446 if(elt->getInfo().size()!=sz)
7448 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7449 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7450 throw INTERP_KERNEL::Exception(oss.str().c_str());
7455 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7458 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7459 if(!_time_steps.empty())
7460 checkCoherencyOfTinyInfo(field,arr);
7461 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7462 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7463 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7464 copyTinyInfoFrom(field,arr);
7465 _time_steps.push_back(obj);
7468 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7471 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7472 if(!_time_steps.empty())
7473 checkCoherencyOfTinyInfo(field,arr);
7474 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7475 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7476 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7477 copyTinyInfoFrom(field,arr);
7478 _time_steps.push_back(obj);
7481 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7483 int sz=(int)_time_steps.size();
7486 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7487 throw INTERP_KERNEL::Exception(oss.str().c_str());
7489 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7492 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7494 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7495 throw INTERP_KERNEL::Exception(oss.str().c_str());
7501 //= MEDFileFieldMultiTSWithoutSDA
7503 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)
7505 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7508 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7512 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7517 * \param [in] fieldId field id in C mode
7519 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7520 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7523 catch(INTERP_KERNEL::Exception& e)
7526 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)
7527 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7530 catch(INTERP_KERNEL::Exception& e)
7533 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7535 return new MEDFileField1TSWithoutSDA;
7538 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7541 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7542 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7544 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7547 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7549 return MEDFileField1TSWithoutSDA::TYPE_STR;
7552 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7554 return new MEDFileFieldMultiTSWithoutSDA(*this);
7557 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7559 return new MEDFileFieldMultiTSWithoutSDA;
7563 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7564 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7566 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)
7568 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7569 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7571 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7572 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7575 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7577 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7578 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7580 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7582 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7585 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7587 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7588 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7589 ret->setIteration(i,elt);
7595 //= MEDFileAnyTypeFieldMultiTS
7597 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7601 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7602 try:MEDFileFieldGlobsReal(fileName)
7604 MEDFileUtilities::CheckFileForRead(fileName);
7605 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7606 _content=BuildContentFrom(fid,fileName,loadAll);
7609 catch(INTERP_KERNEL::Exception& e)
7614 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7616 med_field_type typcha;
7617 std::vector<std::string> infos;
7620 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7621 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7626 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7631 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7636 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] !";
7637 throw INTERP_KERNEL::Exception(oss.str().c_str());
7640 ret->setDtUnit(dtunit.c_str());
7644 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7646 med_field_type typcha;
7648 std::vector<std::string> infos;
7649 std::string dtunit,fieldName;
7650 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7651 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7656 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7661 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7666 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] !";
7667 throw INTERP_KERNEL::Exception(oss.str().c_str());
7670 ret->setDtUnit(dtunit.c_str());
7674 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7677 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7678 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7680 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7681 ret->setFileName(fileName);
7682 ret->_content=c; c->incrRef();
7685 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7687 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7688 ret->setFileName(fileName);
7689 ret->_content=c; c->incrRef();
7692 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7695 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7696 try:MEDFileFieldGlobsReal(fileName)
7698 MEDFileUtilities::CheckFileForRead(fileName);
7699 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7700 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7703 catch(INTERP_KERNEL::Exception& e)
7708 //= MEDFileIntFieldMultiTSWithoutSDA
7710 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)
7712 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7715 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7719 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7723 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)
7724 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7727 catch(INTERP_KERNEL::Exception& e)
7731 * \param [in] fieldId field id in C mode
7733 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7734 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7737 catch(INTERP_KERNEL::Exception& e)
7740 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7742 return new MEDFileIntField1TSWithoutSDA;
7745 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7748 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7749 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7751 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7754 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7756 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7759 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7761 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7764 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7766 return new MEDFileIntFieldMultiTSWithoutSDA;
7769 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7771 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7772 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7774 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7776 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7779 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7781 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7782 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7783 ret->setIteration(i,elt);
7789 //= MEDFileAnyTypeFieldMultiTS
7792 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7793 * that has been read from a specified MED file.
7794 * \param [in] fileName - the name of the MED file to read.
7795 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7796 * is to delete this field using decrRef() as it is no more needed.
7797 * \throw If reading the file fails.
7799 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7801 MEDFileUtilities::CheckFileForRead(fileName);
7802 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7803 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7804 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7805 ret->loadGlobals(fid);
7810 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7811 * that has been read from a specified MED file.
7812 * \param [in] fileName - the name of the MED file to read.
7813 * \param [in] fieldName - the name of the field to read.
7814 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7815 * is to delete this field using decrRef() as it is no more needed.
7816 * \throw If reading the file fails.
7817 * \throw If there is no field named \a fieldName in the file.
7819 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7821 MEDFileUtilities::CheckFileForRead(fileName);
7822 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7823 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7824 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7825 ret->loadGlobals(fid);
7830 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7831 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7833 * \warning this is a shallow copy constructor
7835 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7837 if(!shallowCopyOfContent)
7839 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7840 otherPtr->incrRef();
7841 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7845 _content=other.shallowCpy();
7849 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7851 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7853 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7857 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7859 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7861 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7865 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7867 return contentNotNullBase()->getPflsReallyUsed2();
7870 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7872 return contentNotNullBase()->getLocsReallyUsed2();
7875 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7877 return contentNotNullBase()->getPflsReallyUsedMulti2();
7880 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7882 return contentNotNullBase()->getLocsReallyUsedMulti2();
7885 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7887 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7890 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7892 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7895 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7897 return contentNotNullBase()->getNumberOfTS();
7900 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7902 contentNotNullBase()->eraseEmptyTS();
7905 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7907 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7910 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7912 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7915 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7917 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7918 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7923 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7925 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7926 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7931 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7933 return contentNotNullBase()->getIterations();
7936 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7938 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7939 pushBackTimeStep(*it);
7942 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7945 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7946 checkCoherencyOfType(f1ts);
7948 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7949 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7951 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7952 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7953 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7954 _content->pushBackTimeStep(cSafe);
7955 appendGlobs(*f1ts,1e-12);
7958 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7960 contentNotNullBase()->synchronizeNameScope();
7963 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7965 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7968 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7970 return contentNotNullBase()->getPosGivenTime(time,eps);
7973 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7975 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7978 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7980 return contentNotNullBase()->getTypesOfFieldAvailable();
7983 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)
7985 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7988 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7990 return contentNotNullBase()->getName();
7993 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7995 contentNotNullBase()->setName(name);
7998 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
8000 return contentNotNullBase()->getDtUnit();
8003 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
8005 contentNotNullBase()->setDtUnit(dtUnit);
8008 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8010 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8013 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
8015 return contentNotNullBase()->getTimeSteps(ret1);
8018 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
8020 return contentNotNullBase()->getMeshName();
8023 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
8025 contentNotNullBase()->setMeshName(newMeshName);
8028 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8030 return contentNotNullBase()->changeMeshNames(modifTab);
8033 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8035 return contentNotNullBase()->getInfo();
8038 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8040 return contentNotNullBase()->setInfo(info);
8043 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8045 const std::vector<std::string> ret=getInfo();
8046 return (int)ret.size();
8049 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8051 writeGlobals(fid,*this);
8052 contentNotNullBase()->writeLL(fid,*this);
8056 * Writes \a this field into a MED file specified by its name.
8057 * \param [in] fileName - the MED file name.
8058 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8059 * - 2 - erase; an existing file is removed.
8060 * - 1 - append; same data should not be present in an existing file.
8061 * - 0 - overwrite; same data present in an existing file is overwritten.
8062 * \throw If the field name is not set.
8063 * \throw If no field data is set.
8064 * \throw If \a mode == 1 and the same data is present in an existing file.
8066 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8068 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8069 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8074 * This method alloc the arrays and load potentially huge arrays contained in this field.
8075 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8076 * This method can be also called to refresh or reinit values from a file.
8078 * \throw If the fileName is not set or points to a non readable MED file.
8080 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8082 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8083 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8087 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8088 * But once data loaded once, this method does nothing.
8090 * \throw If the fileName is not set or points to a non readable MED file.
8091 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
8093 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8095 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8096 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8100 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8101 * This method does not release arrays set outside the context of a MED file.
8103 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8105 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
8107 contentNotNullBase()->releaseArrays();
8110 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8112 std::ostringstream oss;
8113 contentNotNullBase()->simpleRepr(0,oss,-1);
8114 simpleReprGlobs(oss);
8118 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8121 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8122 ret+=_content->getHeapMemorySize();
8123 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8127 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8128 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8129 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8131 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8133 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8135 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8136 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8137 std::size_t sz(contentsSplit.size());
8138 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8139 for(std::size_t i=0;i<sz;i++)
8141 ret[i]=shallowCpy();
8142 ret[i]->_content=contentsSplit[i];
8148 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8149 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8151 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8153 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8155 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8156 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8157 std::size_t sz(contentsSplit.size());
8158 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8159 for(std::size_t i=0;i<sz;i++)
8161 ret[i]=shallowCpy();
8162 ret[i]->_content=contentsSplit[i];
8167 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8169 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8170 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8171 ret->_content=_content->deepCpy();
8172 ret->deepCpyGlobs(*this);
8176 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8182 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8183 * \param [in] iteration - the iteration number of a required time step.
8184 * \param [in] order - the iteration order number of required time step.
8185 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8186 * delete this field using decrRef() as it is no more needed.
8187 * \throw If there is no required time step in \a this field.
8189 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8191 int pos=getPosOfTimeStep(iteration,order);
8192 return getTimeStepAtPos(pos);
8196 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8197 * \param [in] time - the time of the time step of interest.
8198 * \param [in] eps - a precision used to compare time values.
8199 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8200 * delete this field using decrRef() as it is no more needed.
8201 * \throw If there is no required time step in \a this field.
8203 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8205 int pos=getPosGivenTime(time,eps);
8206 return getTimeStepAtPos(pos);
8210 * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
8211 * The float64 value of time attached to the pair of integers are not considered here.
8213 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8214 * \throw If there is a null pointer in \a vectFMTS.
8216 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8218 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8219 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8220 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8221 while(!lstFMTS.empty())
8223 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8224 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8226 throw INTERP_KERNEL::Exception(msg);
8227 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8228 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8229 elt.push_back(curIt); it=lstFMTS.erase(it);
8230 while(it!=lstFMTS.end())
8234 throw INTERP_KERNEL::Exception(msg);
8235 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8237 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8247 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8248 * All returned instances in a subvector can be safely loaded, rendered along time
8249 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8250 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8251 * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
8252 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8253 * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
8255 * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
8256 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8258 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8259 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8260 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8261 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8262 * \throw If mesh is null.
8263 * \throw If an element in \a vectFMTS is null.
8264 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8266 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
8268 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8270 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8271 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8272 if(vectFMTS.empty())
8274 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8275 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8277 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8278 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8279 for(;it!=vectFMTS.end();it++,i++)
8281 TypeOfField tof0,tof1;
8282 int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
8286 vectFMTSNotNodes.push_back(*it);
8288 vectFMTSNodes.push_back(*it);
8291 vectFMTSNotNodes.push_back(*it);
8293 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8294 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8297 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8299 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8302 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8304 std::vector<MEDFileAnyTypeFieldMultiTS *> elt(1,*it2);
8312 * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
8314 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception)
8316 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8317 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8318 while(!lstFMTS.empty())
8320 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8321 MEDFileAnyTypeFieldMultiTS *ref(*it);
8322 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8323 elt.push_back(ref); it=lstFMTS.erase(it);
8324 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mesh,ref));
8325 while(it!=lstFMTS.end())
8327 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8328 if(cmp->isEqual(ref))
8329 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8333 ret.push_back(elt); cmps.push_back(cmp);
8339 * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
8340 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8342 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8343 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8344 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8345 * \thorw If \a f0 and \a f1 do not have the same times steps.
8346 * \throw If mesh is null.
8347 * \throw If \a f0 or \a f1 is null.
8348 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8350 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception)
8353 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8356 if(f0->getMeshName()!=mesh->getName())
8358 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8359 throw INTERP_KERNEL::Exception(oss.str().c_str());
8361 if(f1->getMeshName()!=mesh->getName())
8363 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8364 throw INTERP_KERNEL::Exception(oss.str().c_str());
8366 int nts=f0->getNumberOfTS();
8367 if(nts!=f1->getNumberOfTS())
8368 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8371 for(int i=0;i<nts;i++)
8373 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8374 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8375 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8376 if(tofs0.size()!=1 || tofs1.size()!=1)
8377 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8380 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8381 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8384 { tof0=tofs0[0]; tof1=tofs1[0]; }
8385 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8387 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8388 throw INTERP_KERNEL::Exception(oss.str().c_str());
8390 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8392 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8393 throw INTERP_KERNEL::Exception(oss.str().c_str());
8395 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8397 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
8398 throw INTERP_KERNEL::Exception(oss.str().c_str());
8404 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8406 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8409 //= MEDFileFieldMultiTS
8412 * Returns a new empty instance of MEDFileFieldMultiTS.
8413 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8414 * is to delete this field using decrRef() as it is no more needed.
8416 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8418 return new MEDFileFieldMultiTS;
8422 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8423 * that has been read from a specified MED file.
8424 * \param [in] fileName - the name of the MED file to read.
8425 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8426 * is to delete this field using decrRef() as it is no more needed.
8427 * \throw If reading the file fails.
8429 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8431 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8432 ret->contentNotNull();//to check that content type matches with \a this type.
8437 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8438 * that has been read from a specified MED file.
8439 * \param [in] fileName - the name of the MED file to read.
8440 * \param [in] fieldName - the name of the field to read.
8441 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8442 * is to delete this field using decrRef() as it is no more needed.
8443 * \throw If reading the file fails.
8444 * \throw If there is no field named \a fieldName in the file.
8446 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8448 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8449 ret->contentNotNull();//to check that content type matches with \a this type.
8454 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8455 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8457 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8458 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8459 * \warning this is a shallow copy constructor
8460 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8461 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8462 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8463 * is to delete this field using decrRef() as it is no more needed.
8465 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8467 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8470 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8472 return new MEDFileFieldMultiTS(*this);
8475 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8478 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8479 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8481 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8485 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8486 * following the given input policy.
8488 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8489 * By default (true) the globals are deeply copied.
8490 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8492 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8494 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8495 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8498 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8500 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8501 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8502 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8505 ret=MEDFileIntFieldMultiTS::New();
8507 ret->deepCpyGlobs(*this);
8509 ret->shallowCpyGlobs(*this);
8514 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8515 * \param [in] pos - a time step id.
8516 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8517 * delete this field using decrRef() as it is no more needed.
8518 * \throw If \a pos is not a valid time step id.
8520 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8522 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8525 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8526 throw INTERP_KERNEL::Exception(oss.str().c_str());
8528 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8531 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8532 ret->shallowCpyGlobs(*this);
8535 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8536 throw INTERP_KERNEL::Exception(oss.str().c_str());
8540 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8541 * mesh entities of a given dimension of the first mesh in MED file.
8542 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8543 * \param [in] type - a spatial discretization of interest.
8544 * \param [in] iteration - the iteration number of a required time step.
8545 * \param [in] order - the iteration order number of required time step.
8546 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8547 * \param [in] renumPol - specifies how to permute values of the result field according to
8548 * the optional numbers of cells and nodes, if any. The valid values are
8549 * - 0 - do not permute.
8550 * - 1 - permute cells.
8551 * - 2 - permute nodes.
8552 * - 3 - permute cells and nodes.
8554 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8555 * caller is to delete this field using decrRef() as it is no more needed.
8556 * \throw If the MED file is not readable.
8557 * \throw If there is no mesh in the MED file.
8558 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8559 * \throw If no field values of the required parameters are available.
8561 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8563 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8564 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8566 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8567 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8568 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8569 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8574 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8575 * the top level cells of the first mesh in MED file.
8576 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8577 * \param [in] type - a spatial discretization of interest.
8578 * \param [in] iteration - the iteration number of a required time step.
8579 * \param [in] order - the iteration order number of required time step.
8580 * \param [in] renumPol - specifies how to permute values of the result field according to
8581 * the optional numbers of cells and nodes, if any. The valid values are
8582 * - 0 - do not permute.
8583 * - 1 - permute cells.
8584 * - 2 - permute nodes.
8585 * - 3 - permute cells and nodes.
8587 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8588 * caller is to delete this field using decrRef() as it is no more needed.
8589 * \throw If the MED file is not readable.
8590 * \throw If there is no mesh in the MED file.
8591 * \throw If no field values of the required parameters are available.
8593 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8595 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8596 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8598 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8599 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8600 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8601 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8606 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8608 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8609 * \param [in] type - a spatial discretization of interest.
8610 * \param [in] iteration - the iteration number of a required time step.
8611 * \param [in] order - the iteration order number of required time step.
8612 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8613 * \param [in] mesh - the supporting mesh.
8614 * \param [in] renumPol - specifies how to permute values of the result field according to
8615 * the optional numbers of cells and nodes, if any. The valid values are
8616 * - 0 - do not permute.
8617 * - 1 - permute cells.
8618 * - 2 - permute nodes.
8619 * - 3 - permute cells and nodes.
8621 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8622 * caller is to delete this field using decrRef() as it is no more needed.
8623 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8624 * \throw If no field of \a this is lying on \a mesh.
8625 * \throw If no field values of the required parameters are available.
8627 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8629 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8630 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8632 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8633 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8634 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8635 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8640 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8642 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8643 * \param [in] type - a spatial discretization of the new field.
8644 * \param [in] iteration - the iteration number of a required time step.
8645 * \param [in] order - the iteration order number of required time step.
8646 * \param [in] mesh - the supporting mesh.
8647 * \param [in] renumPol - specifies how to permute values of the result field according to
8648 * the optional numbers of cells and nodes, if any. The valid values are
8649 * - 0 - do not permute.
8650 * - 1 - permute cells.
8651 * - 2 - permute nodes.
8652 * - 3 - permute cells and nodes.
8654 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8655 * caller is to delete this field using decrRef() as it is no more needed.
8656 * \throw If no field of \a this is lying on \a mesh.
8657 * \throw If no field values of the required parameters are available.
8659 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8661 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8662 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8664 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8665 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8666 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8667 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8672 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8673 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8674 * This method is useful for MED2 file format when field on different mesh was autorized.
8676 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8678 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8679 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8681 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8682 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8683 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8684 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8689 * Returns values and a profile of the field of a given type, of a given time step,
8690 * lying on a given support.
8691 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8692 * \param [in] type - a spatial discretization of the field.
8693 * \param [in] iteration - the iteration number of a required time step.
8694 * \param [in] order - the iteration order number of required time step.
8695 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8696 * \param [in] mesh - the supporting mesh.
8697 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8698 * field of interest lies on. If the field lies on all entities of the given
8699 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8700 * using decrRef() as it is no more needed.
8701 * \param [in] glob - the global data storing profiles and localization.
8702 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8703 * field. The caller is to delete this array using decrRef() as it is no more needed.
8704 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8705 * \throw If no field of \a this is lying on \a mesh.
8706 * \throw If no field values of the required parameters are available.
8708 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8710 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8711 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8713 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8714 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8715 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8718 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8720 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8722 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8723 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8725 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 !");
8729 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8731 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8733 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8734 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8736 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 !");
8741 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8742 * the given field is checked if its elements are sorted suitable for writing to MED file
8743 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8744 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8745 * \param [in] field - the field to add to \a this.
8746 * \throw If the name of \a field is empty.
8747 * \throw If the data array of \a field is not set.
8748 * \throw If existing time steps have different name or number of components than \a field.
8749 * \throw If the underlying mesh of \a field has no name.
8750 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8752 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8754 const DataArrayDouble *arr=0;
8756 arr=field->getArray();
8757 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8761 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8762 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8763 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8766 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8767 * A new profile is added only if no equal profile is missing.
8768 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8769 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8770 * \param [in] mesh - the supporting mesh of \a field.
8771 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8772 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8773 * \throw If either \a field or \a mesh or \a profile has an empty name.
8774 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8775 * \throw If the data array of \a field is not set.
8776 * \throw If the data array of \a this is already allocated but has different number of
8777 * components than \a field.
8778 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8779 * \sa setFieldNoProfileSBT()
8781 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8783 const DataArrayDouble *arr=0;
8785 arr=field->getArray();
8786 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8789 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8791 _content=new MEDFileFieldMultiTSWithoutSDA;
8794 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8795 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8798 catch(INTERP_KERNEL::Exception& e)
8801 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8802 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8805 catch(INTERP_KERNEL::Exception& e)
8808 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8812 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)
8814 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8817 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8819 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8822 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)
8824 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8827 //= MEDFileAnyTypeFieldMultiTSIterator
8829 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8834 _nb_iter=fmts->getNumberOfTS();
8838 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8842 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8844 if(_iter_id<_nb_iter)
8846 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8848 return fmts->getTimeStepAtPos(_iter_id++);
8856 //= MEDFileIntFieldMultiTS
8859 * Returns a new empty instance of MEDFileFieldMultiTS.
8860 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8861 * is to delete this field using decrRef() as it is no more needed.
8863 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8865 return new MEDFileIntFieldMultiTS;
8869 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8870 * that has been read from a specified MED file.
8871 * \param [in] fileName - the name of the MED file to read.
8872 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8873 * is to delete this field using decrRef() as it is no more needed.
8874 * \throw If reading the file fails.
8876 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8878 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8879 ret->contentNotNull();//to check that content type matches with \a this type.
8884 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8885 * that has been read from a specified MED file.
8886 * \param [in] fileName - the name of the MED file to read.
8887 * \param [in] fieldName - the name of the field to read.
8888 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8889 * is to delete this field using decrRef() as it is no more needed.
8890 * \throw If reading the file fails.
8891 * \throw If there is no field named \a fieldName in the file.
8893 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8895 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8896 ret->contentNotNull();//to check that content type matches with \a this type.
8901 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8902 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8904 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8905 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8906 * \warning this is a shallow copy constructor
8907 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8908 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8909 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8910 * is to delete this field using decrRef() as it is no more needed.
8912 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8914 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8918 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8919 * following the given input policy.
8921 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8922 * By default (true) the globals are deeply copied.
8923 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8925 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8927 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8928 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8931 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8933 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8934 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8935 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8938 ret=MEDFileFieldMultiTS::New();
8940 ret->deepCpyGlobs(*this);
8942 ret->shallowCpyGlobs(*this);
8946 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8948 return new MEDFileIntFieldMultiTS(*this);
8951 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8954 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8955 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8957 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8961 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8962 * mesh entities of a given dimension of the first mesh in MED file.
8963 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8964 * \param [in] type - a spatial discretization of interest.
8965 * \param [in] iteration - the iteration number of a required time step.
8966 * \param [in] order - the iteration order number of required time step.
8967 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8968 * \param [out] arrOut - the DataArrayInt containing values of field.
8969 * \param [in] renumPol - specifies how to permute values of the result field according to
8970 * the optional numbers of cells and nodes, if any. The valid values are
8971 * - 0 - do not permute.
8972 * - 1 - permute cells.
8973 * - 2 - permute nodes.
8974 * - 3 - permute cells and nodes.
8976 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8977 * caller is to delete this field using decrRef() as it is no more needed.
8978 * \throw If the MED file is not readable.
8979 * \throw If there is no mesh in the MED file.
8980 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8981 * \throw If no field values of the required parameters are available.
8983 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8985 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8986 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8988 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8989 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8990 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8991 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8996 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8997 * the top level cells of the first mesh in MED file.
8998 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8999 * \param [in] type - a spatial discretization of interest.
9000 * \param [in] iteration - the iteration number of a required time step.
9001 * \param [in] order - the iteration order number of required time step.
9002 * \param [out] arrOut - the DataArrayInt containing values of field.
9003 * \param [in] renumPol - specifies how to permute values of the result field according to
9004 * the optional numbers of cells and nodes, if any. The valid values are
9005 * - 0 - do not permute.
9006 * - 1 - permute cells.
9007 * - 2 - permute nodes.
9008 * - 3 - permute cells and nodes.
9010 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9011 * caller is to delete this field using decrRef() as it is no more needed.
9012 * \throw If the MED file is not readable.
9013 * \throw If there is no mesh in the MED file.
9014 * \throw If no field values of the required parameters are available.
9016 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9018 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9019 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9021 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9022 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9023 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
9024 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9029 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9031 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9032 * \param [in] type - a spatial discretization of interest.
9033 * \param [in] iteration - the iteration number of a required time step.
9034 * \param [in] order - the iteration order number of required time step.
9035 * \param [out] arrOut - the DataArrayInt containing values of field.
9036 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9037 * \param [in] mesh - the supporting mesh.
9038 * \param [in] renumPol - specifies how to permute values of the result field according to
9039 * the optional numbers of cells and nodes, if any. The valid values are
9040 * - 0 - do not permute.
9041 * - 1 - permute cells.
9042 * - 2 - permute nodes.
9043 * - 3 - permute cells and nodes.
9045 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9046 * caller is to delete this field using decrRef() as it is no more needed.
9047 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9048 * \throw If no field of \a this is lying on \a mesh.
9049 * \throw If no field values of the required parameters are available.
9051 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9053 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9054 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9056 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9057 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9058 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9059 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9064 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9066 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9067 * \param [in] type - a spatial discretization of the new field.
9068 * \param [in] iteration - the iteration number of a required time step.
9069 * \param [in] order - the iteration order number of required time step.
9070 * \param [in] mesh - the supporting mesh.
9071 * \param [out] arrOut - the DataArrayInt containing values of field.
9072 * \param [in] renumPol - specifies how to permute values of the result field according to
9073 * the optional numbers of cells and nodes, if any. The valid values are
9074 * - 0 - do not permute.
9075 * - 1 - permute cells.
9076 * - 2 - permute nodes.
9077 * - 3 - permute cells and nodes.
9079 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9080 * caller is to delete this field using decrRef() as it is no more needed.
9081 * \throw If no field of \a this is lying on \a mesh.
9082 * \throw If no field values of the required parameters are available.
9084 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9086 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9087 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9089 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9090 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9091 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9092 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9097 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9098 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9099 * This method is useful for MED2 file format when field on different mesh was autorized.
9101 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9103 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9104 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9106 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9107 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9108 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9109 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9114 * Returns values and a profile of the field of a given type, of a given time step,
9115 * lying on a given support.
9116 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9117 * \param [in] type - a spatial discretization of the field.
9118 * \param [in] iteration - the iteration number of a required time step.
9119 * \param [in] order - the iteration order number of required time step.
9120 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9121 * \param [in] mesh - the supporting mesh.
9122 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9123 * field of interest lies on. If the field lies on all entities of the given
9124 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9125 * using decrRef() as it is no more needed.
9126 * \param [in] glob - the global data storing profiles and localization.
9127 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9128 * field. The caller is to delete this array using decrRef() as it is no more needed.
9129 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9130 * \throw If no field of \a this is lying on \a mesh.
9131 * \throw If no field values of the required parameters are available.
9133 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
9135 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9136 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9138 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9139 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9140 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9144 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9145 * \param [in] pos - a time step id.
9146 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9147 * delete this field using decrRef() as it is no more needed.
9148 * \throw If \a pos is not a valid time step id.
9150 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
9152 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9155 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9156 throw INTERP_KERNEL::Exception(oss.str().c_str());
9158 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9161 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9162 ret->shallowCpyGlobs(*this);
9165 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9166 throw INTERP_KERNEL::Exception(oss.str().c_str());
9170 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9171 * the given field is checked if its elements are sorted suitable for writing to MED file
9172 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9173 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9174 * \param [in] field - the field to add to \a this.
9175 * \throw If the name of \a field is empty.
9176 * \throw If the data array of \a field is not set.
9177 * \throw If existing time steps have different name or number of components than \a field.
9178 * \throw If the underlying mesh of \a field has no name.
9179 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9181 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
9183 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9187 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9188 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9189 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9192 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9193 * A new profile is added only if no equal profile is missing.
9194 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9195 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9196 * \param [in] arrOfVals - the values of the field \a field used.
9197 * \param [in] mesh - the supporting mesh of \a field.
9198 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9199 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9200 * \throw If either \a field or \a mesh or \a profile has an empty name.
9201 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9202 * \throw If the data array of \a field is not set.
9203 * \throw If the data array of \a this is already allocated but has different number of
9204 * components than \a field.
9205 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9206 * \sa setFieldNoProfileSBT()
9208 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9210 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9213 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9215 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9217 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9218 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9220 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 !");
9224 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9226 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9228 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9229 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9231 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 !");
9235 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9237 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9240 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9244 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9245 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9248 catch(INTERP_KERNEL::Exception& e)
9251 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9252 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9255 catch(INTERP_KERNEL::Exception& e)
9258 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9260 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9265 MEDFileFields *MEDFileFields::New()
9267 return new MEDFileFields;
9270 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9272 return new MEDFileFields(fileName,loadAll);
9275 std::size_t MEDFileFields::getHeapMemorySize() const
9277 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9278 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9279 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9280 ret+=(*it)->getHeapMemorySize();
9281 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9284 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9286 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9288 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9290 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9291 ret->_fields[i]=(*it)->deepCpy();
9293 ret->deepCpyGlobs(*this);
9297 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9299 return new MEDFileFields(*this);
9303 * 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
9304 * 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.
9305 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9307 * \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.
9308 * \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.
9310 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9312 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9314 std::set< std::pair<int,int> > s;
9315 bool firstShot=true;
9316 areThereSomeForgottenTS=false;
9317 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9319 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9321 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9322 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9324 { s=s1; firstShot=false; }
9327 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9329 areThereSomeForgottenTS=true;
9333 std::vector< std::pair<int,int> > ret;
9334 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9338 int MEDFileFields::getNumberOfFields() const
9340 return _fields.size();
9343 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9345 std::vector<std::string> ret(_fields.size());
9347 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9349 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9352 ret[i]=f->getName();
9356 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9357 throw INTERP_KERNEL::Exception(oss.str().c_str());
9363 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9365 std::vector<std::string> ret;
9366 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9368 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9370 ret.push_back(cur->getMeshName());
9375 std::string MEDFileFields::simpleRepr() const
9377 std::ostringstream oss;
9378 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9383 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9385 int nbOfFields=getNumberOfFields();
9386 std::string startLine(bkOffset,' ');
9387 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9389 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9391 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9394 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9398 oss << startLine << " - not defined !" << std::endl;
9402 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9404 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9405 std::string chapter(17,'0'+i);
9406 oss << startLine << chapter << std::endl;
9409 cur->simpleRepr(bkOffset+2,oss,i);
9413 oss << startLine << " - not defined !" << std::endl;
9415 oss << startLine << chapter << std::endl;
9417 simpleReprGlobs(oss);
9420 MEDFileFields::MEDFileFields()
9424 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9425 try:MEDFileFieldGlobsReal(fileName)
9427 MEDFileUtilities::CheckFileForRead(fileName);
9428 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9429 int nbFields=MEDnField(fid);
9430 _fields.resize(nbFields);
9431 med_field_type typcha;
9432 for(int i=0;i<nbFields;i++)
9434 std::vector<std::string> infos;
9435 std::string fieldName,dtunit;
9436 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9441 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9446 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9451 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] !";
9452 throw INTERP_KERNEL::Exception(oss.str().c_str());
9456 loadAllGlobals(fid);
9458 catch(INTERP_KERNEL::Exception& e)
9463 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9466 writeGlobals(fid,*this);
9467 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9469 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9472 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9473 throw INTERP_KERNEL::Exception(oss.str().c_str());
9475 elt->writeLL(fid,*this);
9479 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9481 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9482 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9487 * This method alloc the arrays and load potentially huge arrays contained in this field.
9488 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9489 * This method can be also called to refresh or reinit values from a file.
9491 * \throw If the fileName is not set or points to a non readable MED file.
9493 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9495 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9496 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9498 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9500 elt->loadBigArraysRecursively(fid,*elt);
9505 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9506 * But once data loaded once, this method does nothing.
9508 * \throw If the fileName is not set or points to a non readable MED file.
9509 * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9511 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9513 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9514 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9516 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9518 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9523 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9524 * This method does not release arrays set outside the context of a MED file.
9526 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9528 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9530 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9531 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9533 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9535 elt->releaseArrays();
9539 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9541 std::vector<std::string> ret;
9542 std::set<std::string> ret2;
9543 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9545 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9546 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9547 if(ret2.find(*it2)==ret2.end())
9549 ret.push_back(*it2);
9556 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9558 std::vector<std::string> ret;
9559 std::set<std::string> ret2;
9560 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9562 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9563 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9564 if(ret2.find(*it2)==ret2.end())
9566 ret.push_back(*it2);
9573 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9575 std::vector<std::string> ret;
9576 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9578 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9579 ret.insert(ret.end(),tmp.begin(),tmp.end());
9584 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9586 std::vector<std::string> ret;
9587 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9589 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9590 ret.insert(ret.end(),tmp.begin(),tmp.end());
9595 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9597 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9598 (*it)->changePflsRefsNamesGen2(mapOfModif);
9601 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9603 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9604 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9607 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9609 _fields.resize(newSize);
9612 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9614 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9618 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9621 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9622 _fields.push_back(field->getContent());
9623 appendGlobs(*field,1e-12);
9626 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9629 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9630 if(i>=(int)_fields.size())
9631 _fields.resize(i+1);
9632 _fields[i]=field->getContent();
9633 appendGlobs(*field,1e-12);
9636 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9638 destroyFieldsAtPos(&i,&i+1);
9641 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9643 std::vector<bool> b(_fields.size(),true);
9644 for(const int *i=startIds;i!=endIds;i++)
9646 if(*i<0 || *i>=(int)_fields.size())
9648 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9649 throw INTERP_KERNEL::Exception(oss.str().c_str());
9653 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9655 for(std::size_t i=0;i<_fields.size();i++)
9657 fields[j++]=_fields[i];
9661 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9663 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9664 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9665 std::vector<bool> b(_fields.size(),true);
9667 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9669 if(k<0 || k>=(int)_fields.size())
9671 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9672 throw INTERP_KERNEL::Exception(oss.str().c_str());
9676 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9678 for(std::size_t i=0;i<_fields.size();i++)
9680 fields[j++]=_fields[i];
9684 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9687 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9689 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9691 ret=cur->changeMeshNames(modifTab) || ret;
9697 * \param [in] meshName the name of the mesh that will be renumbered.
9698 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9699 * This code corresponds to the distribution of types in the corresponding mesh.
9700 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9701 * \param [in] renumO2N the old to new renumber array.
9702 * \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
9705 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9708 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9710 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9713 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9719 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9721 if(i<0 || i>=(int)_fields.size())
9723 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9724 throw INTERP_KERNEL::Exception(oss.str().c_str());
9726 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9729 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9730 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9731 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9733 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9735 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9738 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9739 throw INTERP_KERNEL::Exception(oss.str().c_str());
9741 ret->shallowCpyGlobs(*this);
9746 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9747 * This method is accessible in python using __getitem__ with a list in input.
9748 * \return a new object that the caller should deal with.
9750 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9752 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9753 std::size_t sz=std::distance(startIds,endIds);
9754 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9756 for(const int *i=startIds;i!=endIds;i++,j++)
9758 if(*i<0 || *i>=(int)_fields.size())
9760 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9761 throw INTERP_KERNEL::Exception(oss.str().c_str());
9763 fields[j]=_fields[*i];
9765 ret->_fields=fields;
9769 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9771 return getFieldAtPos(getPosFromFieldName(fieldName));
9775 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9776 * This method can be seen as a filter applied on \a this, that returns an object containing
9777 * 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
9778 * shallow copied from \a this.
9780 * \param [in] meshName - the name of the mesh on w
9781 * \return a new object that the caller should deal with.
9783 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9785 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9786 ret->shallowCpyOnlyUsedGlobs(*this);
9787 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9789 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9792 if(cur->getMeshName()==meshName)
9795 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9796 ret->_fields.push_back(cur2);
9803 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9804 * Input time steps are specified using a pair of integer (iteration, order).
9805 * 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,
9806 * but for each multitimestep only the time steps in \a timeSteps are kept.
9807 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9809 * The returned object points to shallow copy of elements in \a this.
9811 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9812 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9813 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9815 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9817 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9818 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9820 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9823 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9824 ret->_fields.push_back(elt);
9826 ret->shallowCpyOnlyUsedGlobs(*this);
9831 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9833 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9835 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9836 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9838 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9841 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9842 if(elt->getNumberOfTS()!=0)
9843 ret->_fields.push_back(elt);
9845 ret->shallowCpyOnlyUsedGlobs(*this);
9849 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9851 return new MEDFileFieldsIterator(this);
9854 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9856 std::string tmp(fieldName);
9857 std::vector<std::string> poss;
9858 for(std::size_t i=0;i<_fields.size();i++)
9860 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9863 std::string fname(f->getName());
9867 poss.push_back(fname);
9870 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9871 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9873 throw INTERP_KERNEL::Exception(oss.str().c_str());
9876 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9881 _nb_iter=fs->getNumberOfFields();
9885 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9889 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9891 if(_iter_id<_nb_iter)
9893 MEDFileFields *fs(_fs);
9895 return fs->getFieldAtPos(_iter_id++);