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),_profile_it(profileIt)
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& 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,_profile_it,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, 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;
1456 menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1457 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1458 _field_pm_pt_pd.resize(nbProfiles);
1459 for(int i=0;i<nbProfiles;i++)
1461 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1465 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1466 for(int i=0;i<nbProfiles2;i++)
1467 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i+1));
1471 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1473 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1474 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1477 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1479 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1480 (*it)->loadBigArray(fid,nasc);
1483 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1485 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1487 (*it)->copyOptionsFrom(*this);
1488 (*it)->writeLL(fid,nasc);
1492 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1497 medfGeoType=typmai3[(int)ikGeoType];
1500 medfGeoType=MED_NONE;
1503 medfGeoType=typmai3[(int)ikGeoType];
1504 return MED_NODE_ELEMENT;
1506 medfGeoType=typmai3[(int)ikGeoType];
1509 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1511 return MED_UNDEF_ENTITY_TYPE;
1514 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1516 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1519 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1521 return new MEDFileFieldPerMesh(fath,mesh);
1524 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1526 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1527 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1528 if((const MEDFileFieldPerMeshPerType *)*it)
1529 ret+=(*it)->getHeapMemorySize();
1533 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1535 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1536 ret->_father=father;
1538 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1540 if((const MEDFileFieldPerMeshPerType *)*it)
1541 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1546 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1548 std::string startLine(bkOffset,' ');
1549 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1550 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1552 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1554 const MEDFileFieldPerMeshPerType *cur=*it;
1556 cur->simpleRepr(bkOffset,oss,i);
1559 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1564 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1566 _mesh_name=mesh->getName();
1567 mesh->getTime(_mesh_iteration,_mesh_order);
1570 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)
1572 int nbOfTypes=code.size()/3;
1574 for(int i=0;i<nbOfTypes;i++)
1576 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1577 int nbOfCells=code[3*i+1];
1578 int pos=addNewEntryIfNecessary(type);
1579 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1585 * This method is the most general one. No optimization is done here.
1586 * \param [in] multiTypePfl is the end user profile specified in high level API
1587 * \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].
1588 * \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.
1589 * \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.
1590 * \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.
1591 * \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.
1593 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)
1595 int nbOfTypes=code.size()/3;
1596 for(int i=0;i<nbOfTypes;i++)
1598 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1599 int pos=addNewEntryIfNecessary(type);
1600 DataArrayInt *pfl=0;
1602 pfl=idsPerType[code[3*i+2]];
1603 int nbOfTupes2=code2.size()/3;
1605 for(;found<nbOfTupes2;found++)
1606 if(code[3*i]==code2[3*found])
1608 if(found==nbOfTupes2)
1609 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1610 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1614 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1616 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1617 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1620 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1622 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1623 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1626 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1628 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1629 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1632 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1634 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1635 (*it)->loadBigArraysRecursively(fid,nasc);
1638 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1640 int nbOfTypes=_field_pm_pt.size();
1641 for(int i=0;i<nbOfTypes;i++)
1643 _field_pm_pt[i]->copyOptionsFrom(*this);
1644 _field_pm_pt[i]->writeLL(fid,nasc);
1648 void MEDFileFieldPerMesh::getDimension(int& dim) const
1650 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1651 (*it)->getDimension(dim);
1654 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1656 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1657 (*it)->fillTypesOfFieldAvailable(types);
1660 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)
1662 int sz=_field_pm_pt.size();
1663 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1664 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1665 for(int i=0;i<sz;i++)
1667 types[i]=_field_pm_pt[i]->getGeoType();
1668 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1673 double MEDFileFieldPerMesh::getTime() const
1676 return _father->getTime(tmp1,tmp2);
1679 int MEDFileFieldPerMesh::getIteration() const
1681 return _father->getIteration();
1684 int MEDFileFieldPerMesh::getOrder() const
1686 return _father->getOrder();
1689 int MEDFileFieldPerMesh::getNumberOfComponents() const
1691 return _father->getNumberOfComponents();
1694 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1697 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1698 return _father->getOrCreateAndGetArray();
1701 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1704 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1705 return _father->getOrCreateAndGetArray();
1708 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1710 return _father->getInfo();
1714 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1715 * 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.
1716 * It returns 2 output vectors :
1717 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1718 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1719 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1721 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)
1723 int notNullPflsSz=0;
1724 int nbOfArrs=geoTypes.size();
1725 for(int i=0;i<nbOfArrs;i++)
1728 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1729 int nbOfDiffGeoTypes=geoTypes3.size();
1730 code.resize(3*nbOfDiffGeoTypes);
1731 notNullPfls.resize(notNullPflsSz);
1734 for(int i=0;i<nbOfDiffGeoTypes;i++)
1737 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1738 std::vector<const DataArrayInt *> notNullTmp;
1740 notNullTmp.push_back(pfls[j]);
1742 for(;j<nbOfArrs;j++)
1743 if(geoTypes[j]==refType)
1746 notNullTmp.push_back(pfls[j]);
1750 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1751 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1752 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1753 code[3*i]=(int)refType;
1754 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1755 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1756 if(notNullTmp.empty())
1760 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1761 code[3*i+2]=notNullPflsSz++;
1767 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1769 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)
1773 for(int i=0;i<sz;i++)
1777 if(type!=ON_GAUSS_NE)
1778 ret+=dads[i].second-dads[i].first;
1781 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1782 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1787 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1788 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1794 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1796 std::vector<std::string> ret;
1797 std::set<std::string> ret2;
1798 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1800 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1801 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1802 if(ret2.find(*it2)==ret2.end())
1804 ret.push_back(*it2);
1811 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1813 std::vector<std::string> ret;
1814 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1816 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1817 ret.insert(ret.end(),tmp.begin(),tmp.end());
1822 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1824 std::vector<std::string> ret;
1825 std::set<std::string> ret2;
1826 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1828 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1829 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1830 if(ret2.find(*it2)==ret2.end())
1832 ret.push_back(*it2);
1839 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1841 std::vector<std::string> ret;
1842 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1845 ret.insert(ret.end(),tmp.begin(),tmp.end());
1850 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1852 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1854 if((*it).first==_mesh_name)
1856 _mesh_name=(*it).second;
1863 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1864 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1866 if(_mesh_name!=meshName)
1868 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1869 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1870 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1871 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1872 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1873 getUndergroundDataArrayExt(entries);
1874 DataArray *arr0=getOrCreateAndGetArray();//tony
1876 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1877 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1879 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1883 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1885 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1887 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1888 sz+=(*it).second.second-(*it).second.first;
1891 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1893 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1894 ////////////////////
1895 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1896 int *workI2=explicitIdsOldInMesh->getPointer();
1897 int sz1=0,sz2=0,sid=1;
1898 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1899 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1900 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1902 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1903 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1904 int *workI=explicitIdsOldInArr->getPointer();
1905 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1907 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1908 (*itL2)->setLocId(sz2);
1909 (*itL2)->_tmp_work1=(*itL2)->getStart();
1910 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1912 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1914 explicitIdsOldInMesh->reAlloc(sz2);
1915 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1916 ////////////////////
1917 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1918 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1919 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1920 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1922 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1923 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1924 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1926 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1927 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1928 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1930 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1931 int newStart=elt->getLocId();
1932 elt->setLocId((*it)->getGeoType());
1933 elt->setNewStart(newStart);
1934 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1935 entriesKeptNew.push_back(elt);
1936 entriesKeptNew2.push_back(elt);
1938 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1939 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1940 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1941 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1943 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1946 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1948 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1949 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1951 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1952 glob,arr2,otherEntriesNew) || ret;
1956 // Assign new dispatching
1957 assignNewLeaves(otherEntriesNew);
1958 arr->cpyFrom(*arr2);
1963 * \param [in,out] globalNum a global numbering counter for the renumbering.
1964 * \param [out] its - list of pair (start,stop) kept
1966 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1968 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1969 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1971 std::vector< std::pair<int,int> > its2;
1972 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1975 its.insert(its.end(),its2.begin(),its2.end());
1981 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1983 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1984 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1985 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1987 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1988 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1989 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1990 for(;it1!=types.end();it1++,it2++)
1992 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1993 elt->setLeaves((*it1).second);
1996 _field_pm_pt=fieldPmPt;
1999 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2001 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2002 (*it)->changePflsRefsNamesGen(mapOfModif);
2005 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2007 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2008 (*it)->changeLocsRefsNamesGen(mapOfModif);
2012 * \param [in] mesh is the whole mesh
2014 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2016 if(_field_pm_pt.empty())
2017 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2019 std::vector< std::pair<int,int> > dads;
2020 std::vector<const DataArrayInt *> pfls;
2021 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2022 std::vector<int> locs,code;
2023 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2024 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2025 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2027 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2030 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2031 throw INTERP_KERNEL::Exception(oss.str().c_str());
2034 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2035 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2038 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2040 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2043 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2044 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2050 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2054 if(nb!=mesh->getNumberOfNodes())
2056 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2057 oss << " nodes in mesh !";
2058 throw INTERP_KERNEL::Exception(oss.str().c_str());
2060 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2063 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2067 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2069 if(_field_pm_pt.empty())
2070 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2072 std::vector<std::pair<int,int> > dads;
2073 std::vector<const DataArrayInt *> pfls;
2074 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2075 std::vector<int> locs,code;
2076 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2077 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2078 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2080 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2083 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2084 throw INTERP_KERNEL::Exception(oss.str().c_str());
2086 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2087 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2090 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2091 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2096 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2100 if(nb!=mesh->getNumberOfNodes())
2102 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2103 oss << " nodes in mesh !";
2104 throw INTERP_KERNEL::Exception(oss.str().c_str());
2107 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2113 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2117 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2119 (*it)->getSizes(globalSz,nbOfEntries);
2121 entries.resize(nbOfEntries);
2123 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2125 (*it)->fillValues(nbOfEntries,entries);
2129 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2131 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2133 if((*it)->getGeoType()==typ)
2134 return (*it)->getLeafGivenLocId(locId);
2136 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2137 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2138 oss << "Possiblities are : ";
2139 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2141 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2142 oss << "\"" << cm2.getRepr() << "\", ";
2144 throw INTERP_KERNEL::Exception(oss.str().c_str());
2147 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2149 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2151 if((*it)->getGeoType()==typ)
2152 return (*it)->getLeafGivenLocId(locId);
2154 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2155 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2156 oss << "Possiblities are : ";
2157 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2159 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2160 oss << "\"" << cm2.getRepr() << "\", ";
2162 throw INTERP_KERNEL::Exception(oss.str().c_str());
2165 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2168 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2169 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2170 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2172 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2177 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2182 int ret=std::distance(_field_pm_pt.begin(),it2);
2183 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2188 * 'dads' and 'locs' input parameters have the same number of elements
2189 * \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
2191 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2192 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2193 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2196 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2197 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2198 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2199 const std::vector<std::string>& infos=getInfo();
2200 da->setInfoOnComponents(infos);
2202 if(type==ON_GAUSS_PT)
2205 int nbOfArrs=dads.size();
2206 for(int i=0;i<nbOfArrs;i++)
2208 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2209 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2210 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2211 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2212 di->alloc(nbOfElems,1);
2214 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2215 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2224 * 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.
2225 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2226 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2227 * The order of cells in the returned field is those imposed by the profile.
2228 * \param [in] mesh is the global mesh.
2230 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2231 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2232 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2233 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2235 if(da->isIdentity())
2237 int nbOfTuples=da->getNumberOfTuples();
2238 if(nbOfTuples==mesh->getNumberOfCells())
2239 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2241 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2242 m2->setName(mesh->getName());
2243 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2249 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2251 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2252 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2253 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2255 if(da->isIdentity())
2257 int nbOfTuples=da->getNumberOfTuples();
2258 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2259 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2261 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2262 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2265 if(meshu->getNodalConnectivity()==0)
2267 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2268 int nb=da->getNbOfElems();
2269 const int *ptr=da->getConstPointer();
2270 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2271 meshuc->allocateCells(nb);
2272 for(int i=0;i<nb;i++)
2273 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2274 meshuc->finishInsertingCells();
2275 ret->setMesh(meshuc);
2276 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2277 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2278 disc->checkCoherencyBetween(meshuc,arrOut);
2283 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2285 DataArrayInt *arr2=0;
2286 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2287 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2288 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2289 int nnodes=mesh2->getNumberOfNodes();
2290 if(nnodes==(int)da->getNbOfElems())
2292 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2293 arrOut->renumberInPlace(da3->getConstPointer());
2294 mesh2->setName(mesh->getName());
2295 ret->setMesh(mesh2);
2300 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 !!!";
2301 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2302 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2303 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2304 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2305 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2306 throw INTERP_KERNEL::Exception(oss.str().c_str());
2312 * This method is the most light method of field retrieving.
2314 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2318 pflOut=DataArrayInt::New();
2319 pflOut->alloc(nbOfElems,1);
2324 pflOut=const_cast<DataArrayInt*>(pflIn);
2327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2328 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2329 const std::vector<std::string>& infos=getInfo();
2330 int nbOfComp=infos.size();
2331 for(int i=0;i<nbOfComp;i++)
2332 da->setInfoOnComponent(i,infos[i].c_str());
2337 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),
2338 _mesh_csit(meshCsit),_father(fath)
2340 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2341 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2342 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2343 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2345 int nbProfile =MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],_mesh_csit,meshName,pflName,locName);
2346 int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2347 if(nbProfile>0 || nbProfile2>0)
2349 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2350 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2353 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2356 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2357 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2361 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2363 copyTinyInfoFrom(mesh);
2366 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2368 if(id>=(int)_pfls.size())
2370 _pfls[id]=DataArrayInt::New();
2371 int lgth=MEDprofileSizeByName(fid,pflName);
2372 _pfls[id]->setName(pflName);
2373 _pfls[id]->alloc(lgth,1);
2374 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2375 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2378 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2380 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2382 MEDprofileInfo(fid,i+1,pflName,&sz);
2383 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2384 if(i>=(int)_pfls.size())
2386 _pfls[i]=DataArrayInt::New();
2387 _pfls[i]->alloc(sz,1);
2388 _pfls[i]->setName(pflCpp.c_str());
2389 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2390 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2393 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2395 int nbOfPfls=_pfls.size();
2396 for(int i=0;i<nbOfPfls;i++)
2398 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2399 cpy->applyLin(1,1,0);
2400 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2401 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2402 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2405 int nbOfLocs=_locs.size();
2406 for(int i=0;i<nbOfLocs;i++)
2407 _locs[i]->writeLL(fid);
2410 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2412 std::vector<std::string> pfls=getPfls();
2413 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2415 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2418 _pfls.push_back(*it);
2422 int id=std::distance(pfls.begin(),it2);
2423 if(!(*it)->isEqual(*_pfls[id]))
2425 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2426 throw INTERP_KERNEL::Exception(oss.str().c_str());
2430 std::vector<std::string> locs=getLocs();
2431 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2433 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2436 _locs.push_back(*it);
2440 int id=std::distance(locs.begin(),it2);
2441 if(!(*it)->isEqual(*_locs[id],eps))
2443 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2444 throw INTERP_KERNEL::Exception(oss.str().c_str());
2450 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2452 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2453 getProfile((*it).c_str());
2456 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2458 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2459 getLocalization((*it).c_str());
2462 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2464 std::vector<std::string> profiles=real.getPflsReallyUsed();
2465 int sz=profiles.size();
2467 for(int i=0;i<sz;i++)
2468 loadProfileInFile(fid,i,profiles[i].c_str());
2470 std::vector<std::string> locs=real.getLocsReallyUsed();
2473 for(int i=0;i<sz;i++)
2474 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2477 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2479 int nProfil=MEDnProfile(fid);
2480 for(int i=0;i<nProfil;i++)
2481 loadProfileInFile(fid,i);
2482 int sz=MEDnLocalization(fid);
2484 for(int i=0;i<sz;i++)
2486 _locs[i]=MEDFileFieldLoc::New(fid,i);
2490 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2492 return new MEDFileFieldGlobs(fname);
2495 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2497 return new MEDFileFieldGlobs;
2500 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2502 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2503 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2504 ret+=(*it)->getHeapMemorySize();
2505 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2506 ret+=(*it)->getHeapMemorySize();
2510 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2512 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2514 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2516 if((const DataArrayInt *)*it)
2517 ret->_pfls[i]=(*it)->deepCpy();
2520 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2522 if((const MEDFileFieldLoc*)*it)
2523 ret->_locs[i]=(*it)->deepCpy();
2529 * \throw if a profile in \a pfls in not in \a this.
2530 * \throw if a localization in \a locs in not in \a this.
2531 * \sa MEDFileFieldGlobs::deepCpyPart
2533 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2535 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2536 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2538 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2540 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2542 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2543 ret->_pfls.push_back(pfl2);
2545 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2547 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2549 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2551 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2552 ret->_locs.push_back(loc2);
2554 ret->setFileName(getFileName());
2559 * \throw if a profile in \a pfls in not in \a this.
2560 * \throw if a localization in \a locs in not in \a this.
2561 * \sa MEDFileFieldGlobs::shallowCpyPart
2563 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2565 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2566 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2568 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2570 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2571 ret->_pfls.push_back(pfl->deepCpy());
2573 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2575 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2577 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2578 ret->_locs.push_back(loc->deepCpy());
2580 ret->setFileName(getFileName());
2584 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2588 MEDFileFieldGlobs::MEDFileFieldGlobs()
2592 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2596 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2598 oss << "Profiles :\n";
2599 std::size_t n=_pfls.size();
2600 for(std::size_t i=0;i<n;i++)
2602 oss << " - #" << i << " ";
2603 const DataArrayInt *pfl=_pfls[i];
2605 oss << "\"" << pfl->getName() << "\"\n";
2610 oss << "Localizations :\n";
2611 for(std::size_t i=0;i<n;i++)
2613 oss << " - #" << i << " ";
2614 const MEDFileFieldLoc *loc=_locs[i];
2616 loc->simpleRepr(oss);
2622 void MEDFileFieldGlobs::setFileName(const char *fileName)
2624 _file_name=fileName;
2627 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2629 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2631 DataArrayInt *elt(*it);
2634 std::string name(elt->getName());
2635 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2637 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2639 elt->setName((*it2).second.c_str());
2647 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2649 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2651 MEDFileFieldLoc *elt(*it);
2654 std::string name(elt->getName());
2655 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2657 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2659 elt->setName((*it2).second.c_str());
2667 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2669 if(locId<0 || locId>=(int)_locs.size())
2670 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2671 return _locs[locId]->getNbOfGaussPtPerCell();
2674 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2676 return getLocalizationFromId(getLocalizationId(locName));
2679 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2681 if(locId<0 || locId>=(int)_locs.size())
2682 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2683 return *_locs[locId];
2686 namespace ParaMEDMEMImpl
2691 LocFinder(const char *loc):_loc(loc) { }
2692 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2700 PflFinder(const std::string& pfl):_pfl(pfl) { }
2701 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2703 const std::string& _pfl;
2707 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2709 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2712 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2713 for(it=_locs.begin();it!=_locs.end();it++)
2714 oss << "\"" << (*it)->getName() << "\", ";
2715 throw INTERP_KERNEL::Exception(oss.str().c_str());
2717 return std::distance(_locs.begin(),it);
2721 * The returned value is never null.
2723 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2725 std::string pflNameCpp(pflName);
2726 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2729 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2730 for(it=_pfls.begin();it!=_pfls.end();it++)
2731 oss << "\"" << (*it)->getName() << "\", ";
2732 throw INTERP_KERNEL::Exception(oss.str().c_str());
2737 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2739 if(pflId<0 || pflId>=(int)_pfls.size())
2740 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2741 return _pfls[pflId];
2744 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2746 if(locId<0 || locId>=(int)_locs.size())
2747 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2748 return *_locs[locId];
2751 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2753 return getLocalizationFromId(getLocalizationId(locName));
2757 * The returned value is never null.
2759 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2761 std::string pflNameCpp(pflName);
2762 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2765 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2766 for(it=_pfls.begin();it!=_pfls.end();it++)
2767 oss << "\"" << (*it)->getName() << "\", ";
2768 throw INTERP_KERNEL::Exception(oss.str().c_str());
2773 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2775 if(pflId<0 || pflId>=(int)_pfls.size())
2776 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2777 return _pfls[pflId];
2780 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2782 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2784 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2786 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2787 newPfls.push_back(*it);
2792 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2794 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2796 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2798 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2799 newLocs.push_back(*it);
2804 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2806 int sz=_pfls.size();
2807 std::vector<std::string> ret(sz);
2808 for(int i=0;i<sz;i++)
2809 ret[i]=_pfls[i]->getName();
2813 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2815 int sz=_locs.size();
2816 std::vector<std::string> ret(sz);
2817 for(int i=0;i<sz;i++)
2818 ret[i]=_locs[i]->getName();
2822 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2824 std::vector<std::string> v=getPfls();
2825 std::string s(pflName);
2826 return std::find(v.begin(),v.end(),s)!=v.end();
2829 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2831 std::vector<std::string> v=getLocs();
2832 std::string s(locName);
2833 return std::find(v.begin(),v.end(),s)!=v.end();
2836 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2838 std::map<int,std::vector<int> > m;
2840 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2842 const DataArrayInt *tmp=(*it);
2845 m[tmp->getHashCode()].push_back(i);
2848 std::vector< std::vector<int> > ret;
2849 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2851 if((*it2).second.size()>1)
2853 std::vector<int> ret0;
2854 bool equalityOrNot=false;
2855 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2857 std::vector<int>::const_iterator it4=it3; it4++;
2858 for(;it4!=(*it2).second.end();it4++)
2860 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2863 ret0.push_back(*it3);
2864 ret0.push_back(*it4);
2870 ret.push_back(ret0);
2876 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2878 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2881 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2883 std::string name(pfl->getName());
2885 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2886 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2887 if(name==(*it)->getName())
2889 if(!pfl->isEqual(*(*it)))
2891 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2892 throw INTERP_KERNEL::Exception(oss.str().c_str());
2896 _pfls.push_back(pfl);
2899 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)
2901 std::string name(locName);
2903 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2904 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2905 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2906 if((*it)->isName(locName))
2908 if(!(*it)->isEqual(*obj,1e-12))
2910 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2911 throw INTERP_KERNEL::Exception(oss.str().c_str());
2914 _locs.push_back(obj);
2917 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2919 std::vector<std::string> names=getPfls();
2920 return CreateNewNameNotIn("NewPfl_",names);
2923 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2925 std::vector<std::string> names=getLocs();
2926 return CreateNewNameNotIn("NewLoc_",names);
2929 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2931 for(std::size_t sz=0;sz<100000;sz++)
2933 std::ostringstream tryName;
2934 tryName << prefix << sz;
2935 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2936 return tryName.str();
2938 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2942 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2943 * \param [in] fname - the file name.
2945 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2950 * Creates an empty MEDFileFieldGlobsReal.
2952 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2956 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2959 if((const MEDFileFieldGlobs *)_globals)
2960 ret+=_globals->getHeapMemorySize();
2965 * Returns a string describing profiles and Gauss points held in \a this.
2966 * \return std::string - the description string.
2968 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2970 const MEDFileFieldGlobs *glob=_globals;
2971 std::ostringstream oss2; oss2 << glob;
2972 std::string stars(oss2.str().length(),'*');
2973 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2975 glob->simpleRepr(oss);
2977 oss << "NO GLOBAL INFORMATION !\n";
2980 void MEDFileFieldGlobsReal::resetContent()
2982 _globals=MEDFileFieldGlobs::New();
2985 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2990 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2991 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2993 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2995 _globals=other._globals;
2999 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3000 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3002 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3004 const MEDFileFieldGlobs *otherg(other._globals);
3007 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3011 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3012 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3014 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3016 const MEDFileFieldGlobs *otherg(other._globals);
3019 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3022 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3024 _globals=other._globals;
3025 if((const MEDFileFieldGlobs *)_globals)
3026 _globals=other._globals->deepCpy();
3030 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3031 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3032 * \param [in] eps - a precision used to compare Gauss points with same name held by
3033 * \a this and \a other MEDFileFieldGlobsReal.
3034 * \throw If \a this and \a other hold profiles with equal names but different ids.
3035 * \throw If \a this and \a other hold different Gauss points with equal names.
3037 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3039 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3040 if(thisGlobals==otherGlobals)
3044 _globals=other._globals;
3047 _globals->appendGlobs(*other._globals,eps);
3050 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3052 checkGlobsPflsPartCoherency();
3053 checkGlobsLocsPartCoherency();
3056 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3058 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3061 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3063 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3066 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3068 contentNotNull()->loadProfileInFile(fid,id,pflName);
3071 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3073 contentNotNull()->loadProfileInFile(fid,id);
3076 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3078 contentNotNull()->loadGlobals(fid,*this);
3081 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3083 contentNotNull()->loadAllGlobals(fid);
3086 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3088 contentNotNull()->writeGlobals(fid,opt);
3092 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3093 * or getPflsReallyUsedMulti().
3094 * \return std::vector<std::string> - a sequence of names of all profiles.
3096 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3098 return contentNotNull()->getPfls();
3102 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3103 * or getLocsReallyUsedMulti().
3104 * \return std::vector<std::string> - a sequence of names of all localizations.
3106 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3108 return contentNotNull()->getLocs();
3112 * Checks if the profile with a given name exists.
3113 * \param [in] pflName - the profile name of interest.
3114 * \return bool - \c true if the profile named \a pflName exists.
3116 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3118 return contentNotNull()->existsPfl(pflName);
3122 * Checks if the localization with a given name exists.
3123 * \param [in] locName - the localization name of interest.
3124 * \return bool - \c true if the localization named \a locName exists.
3126 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3128 return contentNotNull()->existsLoc(locName);
3131 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3133 return contentNotNull()->createNewNameOfPfl();
3136 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3138 return contentNotNull()->createNewNameOfLoc();
3142 * Sets the name of a MED file.
3143 * \param [inout] fileName - the file name.
3145 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3147 contentNotNull()->setFileName(fileName);
3151 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3152 * in the same order.
3153 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3154 * Each item of this sequence is a vector containing ids of equal profiles.
3156 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3158 return contentNotNull()->whichAreEqualProfiles();
3162 * Finds equal localizations.
3163 * \param [in] eps - a precision used to compare real values of the localizations.
3164 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3165 * Each item of this sequence is a vector containing ids of equal localizations.
3167 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3169 return contentNotNull()->whichAreEqualLocs(eps);
3173 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3174 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3175 * this sequence is a pair whose
3176 * - the first item is a vector of profile names to replace by the second item,
3177 * - the second item is a profile name to replace every profile name of the first item.
3179 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3181 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3185 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3186 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3187 * this sequence is a pair whose
3188 * - the first item is a vector of localization names to replace by the second item,
3189 * - the second item is a localization name to replace every localization name of the first item.
3191 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3193 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3197 * Replaces references to some profiles (a reference is a profile name) by references
3198 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3199 * them-selves accordingly. <br>
3200 * This method is a generalization of changePflName().
3201 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3202 * this sequence is a pair whose
3203 * - the first item is a vector of profile names to replace by the second item,
3204 * - the second item is a profile name to replace every profile of the first item.
3205 * \sa changePflsRefsNamesGen()
3206 * \sa changePflName()
3208 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3210 changePflsRefsNamesGen(mapOfModif);
3211 changePflsNamesInStruct(mapOfModif);
3215 * Replaces references to some localizations (a reference is a localization name) by references
3216 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3217 * them-selves accordingly. <br>
3218 * This method is a generalization of changeLocName().
3219 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3220 * this sequence is a pair whose
3221 * - the first item is a vector of localization names to replace by the second item,
3222 * - the second item is a localization name to replace every localization of the first item.
3223 * \sa changeLocsRefsNamesGen()
3224 * \sa changeLocName()
3226 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3228 changeLocsRefsNamesGen(mapOfModif);
3229 changeLocsNamesInStruct(mapOfModif);
3233 * Renames the profile having a given name and updates references to this profile.
3234 * \param [in] oldName - the name of the profile to rename.
3235 * \param [in] newName - a new name of the profile.
3236 * \sa changePflsNames().
3238 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3240 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3241 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3243 changePflsNames(mapOfModif);
3247 * Renames the localization having a given name and updates references to this localization.
3248 * \param [in] oldName - the name of the localization to rename.
3249 * \param [in] newName - a new name of the localization.
3250 * \sa changeLocsNames().
3252 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3254 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3255 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3257 changeLocsNames(mapOfModif);
3261 * Removes duplicated profiles. Returns a map used to update references to removed
3262 * profiles via changePflsRefsNamesGen().
3263 * Equal profiles are found using whichAreEqualProfiles().
3264 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3265 * a sequence describing the performed replacements of profiles. Each element of
3266 * this sequence is a pair whose
3267 * - the first item is a vector of profile names replaced by the second item,
3268 * - the second item is a profile name replacing every profile of the first item.
3270 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3272 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3273 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3275 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3277 std::vector< std::string > tmp((*it).size());
3279 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3280 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3281 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3283 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3284 killProfileIds(tmp2);
3286 changePflsRefsNamesGen(ret);
3291 * Removes duplicated localizations. Returns a map used to update references to removed
3292 * localizations via changeLocsRefsNamesGen().
3293 * Equal localizations are found using whichAreEqualLocs().
3294 * \param [in] eps - a precision used to compare real values of the localizations.
3295 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3296 * a sequence describing the performed replacements of localizations. Each element of
3297 * this sequence is a pair whose
3298 * - the first item is a vector of localization names replaced by the second item,
3299 * - the second item is a localization name replacing every localization of the first item.
3301 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3303 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3304 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3306 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3308 std::vector< std::string > tmp((*it).size());
3310 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3311 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3312 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3314 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3315 killLocalizationIds(tmp2);
3317 changeLocsRefsNamesGen(ret);
3322 * Returns number of Gauss points per cell in a given localization.
3323 * \param [in] locId - an id of the localization of interest.
3324 * \return int - the number of the Gauss points per cell.
3326 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3328 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3332 * Returns an id of a localization by its name.
3333 * \param [in] loc - the localization name of interest.
3334 * \return int - the id of the localization.
3335 * \throw If there is no a localization named \a loc.
3337 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3339 return contentNotNull()->getLocalizationId(loc);
3343 * Returns the name of the MED file.
3344 * \return const char * - the MED file name.
3346 const char *MEDFileFieldGlobsReal::getFileName() const
3348 return contentNotNull()->getFileName();
3351 std::string MEDFileFieldGlobsReal::getFileName2() const
3353 return contentNotNull()->getFileName2();
3357 * Returns a localization object by its name.
3358 * \param [in] locName - the name of the localization of interest.
3359 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3360 * \throw If there is no a localization named \a locName.
3362 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3364 return contentNotNull()->getLocalization(locName);
3368 * Returns a localization object by its id.
3369 * \param [in] locId - the id of the localization of interest.
3370 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3371 * \throw If there is no a localization with id \a locId.
3373 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3375 return contentNotNull()->getLocalizationFromId(locId);
3379 * Returns a profile array by its name.
3380 * \param [in] pflName - the name of the profile of interest.
3381 * \return const DataArrayInt * - the profile array having the name \a pflName.
3382 * \throw If there is no a profile named \a pflName.
3384 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3386 return contentNotNull()->getProfile(pflName);
3390 * Returns a profile array by its id.
3391 * \param [in] pflId - the id of the profile of interest.
3392 * \return const DataArrayInt * - the profile array having the id \a pflId.
3393 * \throw If there is no a profile with id \a pflId.
3395 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3397 return contentNotNull()->getProfileFromId(pflId);
3401 * Returns a localization object, apt for modification, by its id.
3402 * \param [in] locId - the id of the localization of interest.
3403 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3404 * having the id \a locId.
3405 * \throw If there is no a localization with id \a locId.
3407 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3409 return contentNotNull()->getLocalizationFromId(locId);
3413 * Returns a localization object, apt for modification, by its name.
3414 * \param [in] locName - the name of the localization of interest.
3415 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3416 * having the name \a locName.
3417 * \throw If there is no a localization named \a locName.
3419 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3421 return contentNotNull()->getLocalization(locName);
3425 * Returns a profile array, apt for modification, by its name.
3426 * \param [in] pflName - the name of the profile of interest.
3427 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3428 * \throw If there is no a profile named \a pflName.
3430 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3432 return contentNotNull()->getProfile(pflName);
3436 * Returns a profile array, apt for modification, by its id.
3437 * \param [in] pflId - the id of the profile of interest.
3438 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3439 * \throw If there is no a profile with id \a pflId.
3441 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3443 return contentNotNull()->getProfileFromId(pflId);
3447 * Removes profiles given by their ids. No data is updated to track this removal.
3448 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3450 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3452 contentNotNull()->killProfileIds(pflIds);
3456 * Removes localizations given by their ids. No data is updated to track this removal.
3457 * \param [in] locIds - a sequence of ids of the localizations to remove.
3459 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3461 contentNotNull()->killLocalizationIds(locIds);
3465 * Stores a profile array.
3466 * \param [in] pfl - the profile array to store.
3467 * \throw If the name of \a pfl is empty.
3468 * \throw If a profile with the same name as that of \a pfl already exists but contains
3471 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3473 contentNotNull()->appendProfile(pfl);
3477 * Adds a new localization of Gauss points.
3478 * \param [in] locName - the name of the new localization.
3479 * \param [in] geoType - a geometrical type of the reference cell.
3480 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3481 * must be \c nbOfNodesPerCell * \c dimOfType.
3482 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3483 * must be _wg_.size() * \c dimOfType.
3484 * \param [in] w - the weights of Gauss points.
3485 * \throw If \a locName is empty.
3486 * \throw If a localization with the name \a locName already exists but is
3487 * different form the new one.
3489 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)
3491 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3494 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3496 MEDFileFieldGlobs *g(_globals);
3498 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3502 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3504 const MEDFileFieldGlobs *g(_globals);
3506 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3510 //= MEDFileFieldNameScope
3512 MEDFileFieldNameScope::MEDFileFieldNameScope()
3516 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3521 * Returns the name of \a this field.
3522 * \return std::string - a string containing the field name.
3524 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3530 * Sets name of \a this field
3531 * \param [in] name - the new field name.
3533 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3538 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3543 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3548 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3551 _dt_unit=other._dt_unit;
3554 //= MEDFileAnyTypeField1TSWithoutSDA
3556 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3558 _field_per_mesh.resize(other._field_per_mesh.size());
3560 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3562 if((const MEDFileFieldPerMesh *)*it)
3563 _field_per_mesh[i]=(*it)->deepCpy(this);
3568 * Prints a string describing \a this field into a stream. This string is outputted
3569 * by \c print Python command.
3570 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3571 * \param [in,out] oss - the out stream.
3572 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3573 * info id printed, else, not.
3575 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3577 std::string startOfLine(bkOffset,' ');
3578 oss << startOfLine << "Field ";
3580 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3581 oss << "on one time Step ";
3583 oss << "(" << f1tsId << ") ";
3584 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3585 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3586 const DataArray *arr=getUndergroundDataArray();
3589 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3592 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3593 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3594 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3596 if(arr->isAllocated())
3598 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3601 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3605 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3607 oss << startOfLine << "----------------------" << std::endl;
3608 if(!_field_per_mesh.empty())
3611 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3613 const MEDFileFieldPerMesh *cur=(*it2);
3615 cur->simpleRepr(bkOffset,oss,i);
3617 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3622 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3624 oss << startOfLine << "----------------------" << std::endl;
3627 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3629 const DataArray *arr(getUndergroundDataArray());
3631 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3632 int nbOfCompo=arr->getNumberOfComponents();
3633 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3634 for(int i=0;i<nbOfCompo;i++)
3637 std::vector<int> v(1,i);
3638 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3639 ret[i]->setArray(arr2);
3644 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)
3648 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3653 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3654 * empty. Returns -1 if this in on nodes.
3655 * \return int - the dimension of \a this.
3657 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3660 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3661 (*it)->getDimension(ret);
3666 * Returns the mesh name.
3667 * \return std::string - a string holding the mesh name.
3668 * \throw If \c _field_per_mesh.empty()
3670 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3672 if(_field_per_mesh.empty())
3673 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3674 return _field_per_mesh[0]->getMeshName();
3677 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3679 std::string oldName(getMeshName());
3680 std::vector< std::pair<std::string,std::string> > v(1);
3681 v[0].first=oldName; v[0].second=newMeshName;
3685 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3688 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3690 MEDFileFieldPerMesh *cur(*it);
3692 ret=cur->changeMeshNames(modifTab) || ret;
3698 * Returns the number of iteration of the state of underlying mesh.
3699 * \return int - the iteration number.
3700 * \throw If \c _field_per_mesh.empty()
3702 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3704 if(_field_per_mesh.empty())
3705 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3706 return _field_per_mesh[0]->getMeshIteration();
3710 * Returns the order number of iteration of the state of underlying mesh.
3711 * \return int - the order number.
3712 * \throw If \c _field_per_mesh.empty()
3714 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3716 if(_field_per_mesh.empty())
3717 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3718 return _field_per_mesh[0]->getMeshOrder();
3722 * Checks if \a this field is tagged by a given iteration number and a given
3723 * iteration order number.
3724 * \param [in] iteration - the iteration number of interest.
3725 * \param [in] order - the iteration order number of interest.
3726 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3727 * \a this->getOrder() == \a order.
3729 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3731 return iteration==_iteration && order==_order;
3735 * Returns number of iteration and order number of iteration when
3736 * \a this field has been calculated.
3737 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3740 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3742 std::pair<int,int> p;
3748 * Returns number of iteration and order number of iteration when
3749 * \a this field has been calculated.
3750 * \param [in,out] p - a pair returning the iteration number and the iteration
3753 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3760 * Returns all types of spatial discretization of \a this field.
3761 * \param [in,out] types - a sequence of types of \a this field.
3763 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3765 std::set<TypeOfField> types2;
3766 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3768 (*it)->fillTypesOfFieldAvailable(types2);
3770 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3771 std::copy(types2.begin(),types2.end(),bi);
3775 * Returns all types of spatial discretization of \a this field.
3776 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3779 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3781 std::vector<TypeOfField> ret;
3782 fillTypesOfFieldAvailable(ret);
3786 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3788 std::vector<std::string> ret;
3789 std::set<std::string> ret2;
3790 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3792 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3793 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3794 if(ret2.find(*it2)==ret2.end())
3796 ret.push_back(*it2);
3803 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3805 std::vector<std::string> ret;
3806 std::set<std::string> ret2;
3807 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3809 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3810 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3811 if(ret2.find(*it2)==ret2.end())
3813 ret.push_back(*it2);
3820 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3822 std::vector<std::string> ret;
3823 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3825 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3826 ret.insert(ret.end(),tmp.begin(),tmp.end());
3831 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3833 std::vector<std::string> ret;
3834 std::set<std::string> ret2;
3835 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3837 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3838 ret.insert(ret.end(),tmp.begin(),tmp.end());
3843 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3845 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3846 (*it)->changePflsRefsNamesGen(mapOfModif);
3849 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3851 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3852 (*it)->changeLocsRefsNamesGen(mapOfModif);
3856 * Returns all attributes of parts of \a this field lying on a given mesh.
3857 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3858 * item of every of returned sequences refers to the _i_-th part of \a this field.
3859 * Thus all sequences returned by this method are of the same length equal to number
3860 * of different types of supporting entities.<br>
3861 * A field part can include sub-parts with several different spatial discretizations,
3862 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3863 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3864 * of a nested sequence corresponds to a type of spatial discretization.<br>
3865 * This method allows for iteration over MEDFile DataStructure without any overhead.
3866 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3867 * for the case with only one underlying mesh. (Actually, the number of meshes is
3868 * not checked if \a mname == \c NULL).
3869 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3870 * a field part is returned.
3871 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3872 * This sequence is of the same length as \a types.
3873 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3874 * discretization. A profile name can be empty.
3875 * Length of this and of nested sequences is the same as that of \a typesF.
3876 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3877 * discretization. A localization name can be empty.
3878 * Length of this and of nested sequences is the same as that of \a typesF.
3879 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3880 * of ids of tuples within the data array, per each type of spatial
3881 * discretization within one mesh entity type.
3882 * Length of this and of nested sequences is the same as that of \a typesF.
3883 * \throw If no field is lying on \a mname.
3885 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)
3889 meshId=getMeshIdFromMeshName(mname);
3891 if(_field_per_mesh.empty())
3892 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3893 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3897 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3898 * maximal absolute dimension and values returned via the out parameter \a levs are
3899 * dimensions relative to the maximal absolute dimension. <br>
3900 * This method is designed for MEDFileField1TS instances that have a discretization
3901 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3902 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3903 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3904 * Only these 3 discretizations will be taken into account here. If \a this is
3905 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3906 * This method is useful to make the link between the dimension of the underlying mesh
3907 * and the levels of \a this, because it is possible that the highest dimension of \a this
3908 * field is not equal to the dimension of the underlying mesh.
3910 * Let's consider the following case:
3911 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3912 * TETRA4, HEXA8, TRI3 and SEG2.
3913 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3914 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3916 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3917 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3918 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3919 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3920 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3921 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3923 * to retrieve the highest level of
3924 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3925 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3926 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3927 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3928 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3929 * for the case with only one underlying mesh. (Actually, the number of meshes is
3930 * not checked if \a mname == \c NULL).
3931 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3932 * absolute one. They are in decreasing order. This sequence is cleared before
3934 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3935 * \throw If no field is lying on \a mname.
3937 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3940 int meshId=getMeshIdFromMeshName(mname);
3941 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3942 std::vector< std::vector<TypeOfField> > typesF;
3943 std::vector< std::vector<std::string> > pfls, locs;
3944 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3946 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3947 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3948 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3950 st.erase(INTERP_KERNEL::NORM_ERROR);
3952 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3954 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3955 ret1.insert((int)cm.getDimension());
3957 int ret=*std::max_element(ret1.begin(),ret1.end());
3958 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3959 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3964 * \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.
3965 * \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.
3966 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3967 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3969 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3971 int mid=getMeshIdFromMeshName(mName);
3972 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3976 * \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.
3977 * \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.
3978 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3979 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3981 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3983 int mid=getMeshIdFromMeshName(mName);
3984 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3988 * \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.
3990 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3992 if(_field_per_mesh.empty())
3993 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3996 std::string mName2(mName);
3998 std::vector<std::string> msg;
3999 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4000 if(mName2==(*it)->getMeshName())
4003 msg.push_back((*it)->getMeshName());
4004 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4005 oss << "Possible meshes are : ";
4006 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4007 oss << "\"" << (*it2) << "\" ";
4008 throw INTERP_KERNEL::Exception(oss.str().c_str());
4011 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4014 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4015 std::string tmp(mesh->getName());
4017 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4018 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4020 for(;it!=_field_per_mesh.end();it++,i++)
4022 if((*it)->getMeshName()==tmp)
4025 int sz=_field_per_mesh.size();
4026 _field_per_mesh.resize(sz+1);
4027 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4031 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4032 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4035 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4037 MEDFileFieldPerMesh *fpm(*it);
4039 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4044 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4046 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4047 std::vector< std::vector<TypeOfField> > typesF;
4048 std::vector< std::vector<std::string> > pfls,locs;
4049 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4050 std::set<TypeOfField> allEnt;
4051 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4052 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4053 allEnt.insert(*it2);
4054 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4055 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4056 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4058 std::vector< std::pair<int,int> > its;
4059 ret[i]=shallowCpy();
4060 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4061 ret[i]->updateData(newLgth,its);
4066 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4068 int globalCounter=0;
4069 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4070 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4071 return globalCounter;
4074 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4076 if(_nb_of_tuples_to_be_allocated>=0)
4078 _nb_of_tuples_to_be_allocated=newLgth;
4081 if(_nb_of_tuples_to_be_allocated==-1)
4083 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4085 const DataArray *oldArr=getUndergroundDataArray();
4086 if(!oldArr || !oldArr->isAllocated())
4087 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4088 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4089 newArr->alloc(newLgth,getNumberOfComponents());
4091 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4093 if((*it).second<(*it).first)
4094 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4095 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4096 pos+=(*it).second-(*it).first;
4101 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4104 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4106 if(_field_per_mesh.empty())
4107 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4108 if(_field_per_mesh.size()>1)
4109 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4110 _field_per_mesh[0]->copyOptionsFrom(opts);
4111 _field_per_mesh[0]->writeLL(fid,nasc);
4115 * 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.
4116 * If false is returned the memory allocation is not required.
4118 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4120 if(_nb_of_tuples_to_be_allocated>=0)
4122 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4123 _nb_of_tuples_to_be_allocated=-2;
4126 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4128 if(_nb_of_tuples_to_be_allocated==-1)
4129 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4130 if(_nb_of_tuples_to_be_allocated<-3)
4131 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4135 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4137 med_int numdt,numit;
4141 med_int meshnumdt,meshnumit;
4142 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4143 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4144 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4145 if(_iteration!=numdt || _order!=numit)
4146 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4147 _field_per_mesh.resize(nmesh);
4148 for(int i=0;i<nmesh;i++)
4149 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4150 _nb_of_tuples_to_be_allocated=0;
4151 for(int i=0;i<nmesh;i++)
4152 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4155 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4157 allocIfNecessaryTheArrayToReceiveDataFromFile();
4158 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4159 (*it)->loadBigArraysRecursively(fid,nasc);
4162 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4164 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4165 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4166 (*it)->loadBigArraysRecursively(fid,nasc);
4169 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4171 loadOnlyStructureOfDataRecursively(fid,nasc);
4172 loadBigArraysRecursively(fid,nasc);
4175 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4177 DataArray *thisArr(getUndergroundDataArray());
4178 if(thisArr && thisArr->isAllocated())
4180 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4181 thisArr->desallocate();
4185 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4187 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4188 if(getUndergroundDataArray())
4189 ret+=getUndergroundDataArray()->getHeapMemorySize();
4190 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4191 ret+=(*it)->getHeapMemorySize();
4196 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4197 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4198 * "Sort By Type"), if not, an exception is thrown.
4199 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4200 * \param [in] arr - the array of values.
4201 * \param [in,out] glob - the global data where profiles and localization present in
4202 * \a field, if any, are added.
4203 * \throw If the name of \a field is empty.
4204 * \throw If the data array of \a field is not set.
4205 * \throw If \a this->_arr is already allocated but has different number of components
4207 * \throw If the underlying mesh of \a field has no name.
4208 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4210 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4212 const MEDCouplingMesh *mesh=field->getMesh();
4214 TypeOfField type=field->getTypeOfField();
4215 std::vector<DataArrayInt *> dummy;
4216 int start=copyTinyInfoFrom(field,arr);
4217 int pos=addNewEntryIfNecessary(mesh);
4220 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4221 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4224 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4228 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4229 * of a given mesh are used as the support of the given field (a real support is not used).
4230 * Elements of the given mesh must be sorted suitable for writing to MED file.
4231 * Order of underlying mesh entities of the given field specified by \a profile parameter
4232 * is not prescribed; this method permutes field values to have them sorted by element
4233 * type as required for writing to MED file. A new profile is added only if no equal
4234 * profile is missing.
4235 * \param [in] field - the field to add to \a this. The field double values are ignored.
4236 * \param [in] arrOfVals - the values of the field \a field used.
4237 * \param [in] mesh - the supporting mesh of \a field.
4238 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4239 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4240 * \param [in,out] glob - the global data where profiles and localization present in
4241 * \a field, if any, are added.
4242 * \throw If either \a field or \a mesh or \a profile has an empty name.
4243 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4244 * \throw If the data array of \a field is not set.
4245 * \throw If \a this->_arr is already allocated but has different number of components
4247 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4248 * \sa setFieldNoProfileSBT()
4250 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)
4253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4254 if(!arrOfVals || !arrOfVals->isAllocated())
4255 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4256 TypeOfField type=field->getTypeOfField();
4257 std::vector<DataArrayInt *> idsInPflPerType;
4258 std::vector<DataArrayInt *> idsPerType;
4259 std::vector<int> code,code2;
4260 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4263 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4264 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4265 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4266 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4268 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4269 if(type==ON_GAUSS_NE)
4271 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4272 field2->setMesh(mPart);
4274 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4275 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4277 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4278 throw INTERP_KERNEL::Exception(oss.str().c_str());
4281 int start=copyTinyInfoFrom(field,arrOfVals);
4282 code2=m->getDistributionOfTypes();
4284 int pos=addNewEntryIfNecessary(m);
4285 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4289 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4290 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4291 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4292 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4293 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4294 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4296 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4297 throw INTERP_KERNEL::Exception(oss.str().c_str());
4299 int start=copyTinyInfoFrom(field,arrOfVals);
4300 int pos=addNewEntryIfNecessary(m);
4301 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4306 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4308 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4310 if(_nb_of_tuples_to_be_allocated>=0)
4311 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 !");
4312 DataArray *arr(getOrCreateAndGetArray());
4313 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4314 _nb_of_tuples_to_be_allocated=-3;
4318 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4319 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4320 * larger by the size of \a field. Returns an id of the first not filled
4321 * tuple of \a this->_arr.
4322 * \param [in] field - the field to copy the info on components and the name from.
4323 * \return int - the id of first not initialized tuple of \a this->_arr.
4324 * \throw If the name of \a field is empty.
4325 * \throw If the data array of \a field is not set.
4326 * \throw If \a this->_arr is already allocated but has different number of components
4329 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4332 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4333 std::string name(field->getName());
4334 setName(name.c_str());
4335 setDtUnit(field->getTimeUnit());
4337 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4339 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4340 if(!arr->isAllocated())
4341 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4342 _dt=field->getTime(_iteration,_order);
4343 int nbOfComponents=arr->getNumberOfComponents();
4344 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4345 if(!getOrCreateAndGetArray()->isAllocated())
4347 allocNotFromFile(arr->getNumberOfTuples());
4352 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4353 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4354 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4355 _nb_of_tuples_to_be_allocated=-3;
4356 return oldNbOfTuples;
4361 * Returns number of components in \a this field
4362 * \return int - the number of components.
4364 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4366 return getOrCreateAndGetArray()->getNumberOfComponents();
4370 * Change info on components in \a this.
4371 * \throw If size of \a infos is not equal to the number of components already in \a this.
4373 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4375 DataArray *arr=getOrCreateAndGetArray();
4376 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4380 * Returns info on components of \a this field.
4381 * \return const std::vector<std::string>& - a sequence of strings each being an
4382 * information on _i_-th component.
4384 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4386 const DataArray *arr=getOrCreateAndGetArray();
4387 return arr->getInfoOnComponents();
4391 * Returns a mutable info on components of \a this field.
4392 * \return std::vector<std::string>& - a sequence of strings each being an
4393 * information on _i_-th component.
4395 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4397 DataArray *arr=getOrCreateAndGetArray();
4398 return arr->getInfoOnComponents();
4402 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4403 * \param [in] type - a spatial discretization of the new field.
4404 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4405 * \param [in] mName - a name of the supporting mesh.
4406 * \param [in] renumPol - specifies how to permute values of the result field according to
4407 * the optional numbers of cells and nodes, if any. The valid values are
4408 * - 0 - do not permute.
4409 * - 1 - permute cells.
4410 * - 2 - permute nodes.
4411 * - 3 - permute cells and nodes.
4413 * \param [in] glob - the global data storing profiles and localization.
4414 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4415 * caller is to delete this field using decrRef() as it is no more needed.
4416 * \throw If the MED file is not readable.
4417 * \throw If there is no mesh named \a mName in the MED file.
4418 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4419 * \throw If no field of \a this is lying on the mesh \a mName.
4420 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4422 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)
4424 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4426 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4428 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4429 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4433 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4434 * \param [in] type - a spatial discretization of the new field.
4435 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4436 * \param [in] renumPol - specifies how to permute values of the result field according to
4437 * the optional numbers of cells and nodes, if any. The valid values are
4438 * - 0 - do not permute.
4439 * - 1 - permute cells.
4440 * - 2 - permute nodes.
4441 * - 3 - permute cells and nodes.
4443 * \param [in] glob - the global data storing profiles and localization.
4444 * \param [in] mesh - the supporting mesh.
4445 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4446 * caller is to delete this field using decrRef() as it is no more needed.
4447 * \throw If the MED file is not readable.
4448 * \throw If no field of \a this is lying on \a mesh.
4449 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4450 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4452 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)
4454 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4455 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4456 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4457 if(meshDimRelToMax==1)
4458 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4459 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4463 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4465 * \param [in] type - a spatial discretization of the new field.
4466 * \param [in] mName - a name of the supporting mesh.
4467 * \param [in] renumPol - specifies how to permute values of the result field according to
4468 * the optional numbers of cells and nodes, if any. The valid values are
4469 * - 0 - do not permute.
4470 * - 1 - permute cells.
4471 * - 2 - permute nodes.
4472 * - 3 - permute cells and nodes.
4474 * \param [in] glob - the global data storing profiles and localization.
4475 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4476 * caller is to delete this field using decrRef() as it is no more needed.
4477 * \throw If the MED file is not readable.
4478 * \throw If there is no mesh named \a mName in the MED file.
4479 * \throw If there are no mesh entities in the mesh.
4480 * \throw If no field values of the given \a type are available.
4482 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4484 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4486 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4488 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4489 int absDim=getDimension();
4490 int meshDimRelToMax=absDim-mm->getMeshDimension();
4491 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4495 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4496 * \param [in] type - a spatial discretization of the new field.
4497 * \param [in] renumPol - specifies how to permute values of the result field according to
4498 * the optional numbers of cells and nodes, if any. The valid values are
4499 * - 0 - do not permute.
4500 * - 1 - permute cells.
4501 * - 2 - permute nodes.
4502 * - 3 - permute cells and nodes.
4504 * \param [in] glob - the global data storing profiles and localization.
4505 * \param [in] mesh - the supporting mesh.
4506 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4507 * field according to \a renumPol.
4508 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4509 * field according to \a renumPol.
4510 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4511 * caller is to delete this field using decrRef() as it is no more needed.
4512 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4513 * \throw If no field of \a this is lying on \a mesh.
4514 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4516 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)
4518 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4519 int meshId=getMeshIdFromMeshName(mesh->getName());
4521 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4526 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4533 throw INTERP_KERNEL::Exception(msg1);
4534 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4537 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4539 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4540 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4541 throw INTERP_KERNEL::Exception(oss.str().c_str());
4543 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4544 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4545 std::vector<DataArray *> arrOut2(1,arrOut);
4546 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4547 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4548 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4555 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4557 throw INTERP_KERNEL::Exception(msg1);
4560 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4562 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4563 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4564 throw INTERP_KERNEL::Exception(oss.str().c_str());
4566 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4567 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4568 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4569 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4574 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4579 * Returns values and a profile of the field of a given type lying on a given support.
4580 * \param [in] type - a spatial discretization of the field.
4581 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4582 * \param [in] mesh - the supporting mesh.
4583 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4584 * field of interest lies on. If the field lies on all entities of the given
4585 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4586 * using decrRef() as it is no more needed.
4587 * \param [in] glob - the global data storing profiles and localization.
4588 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4589 * field. The caller is to delete this array using decrRef() as it is no more needed.
4590 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4591 * \throw If no field of \a this is lying on \a mesh.
4592 * \throw If no field values of the given \a type are available.
4594 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4596 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4597 int meshId=getMeshIdFromMeshName(mesh->getName());
4598 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4599 ret->setName(nasc.getName().c_str());
4603 //= MEDFileField1TSWithoutSDA
4606 * Throws if a given value is not a valid (non-extended) relative dimension.
4607 * \param [in] meshDimRelToMax - the relative dimension value.
4608 * \throw If \a meshDimRelToMax > 0.
4610 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4612 if(meshDimRelToMax>0)
4613 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4617 * Checks if elements of a given mesh are in the order suitable for writing
4618 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4619 * vector describing types of elements and their number.
4620 * \param [in] mesh - the mesh to check.
4621 * \return std::vector<int> - a vector holding for each element type (1) item of
4622 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4623 * These values are in full-interlace mode.
4624 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4626 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4629 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4630 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4631 int nbOfTypes=geoTypes.size();
4632 std::vector<int> code(3*nbOfTypes);
4633 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4634 arr1->alloc(nbOfTypes,1);
4635 int *arrPtr=arr1->getPointer();
4636 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4637 for(int i=0;i<nbOfTypes;i++,it++)
4638 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4639 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4640 const int *arrPtr2=arr2->getConstPointer();
4642 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4645 int nbCells=mesh->getNumberOfCellsWithType(*it);
4646 code[3*pos]=(int)(*it);
4647 code[3*pos+1]=nbCells;
4648 code[3*pos+2]=-1;//no profiles
4650 std::vector<const DataArrayInt *> idsPerType;//no profiles
4651 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4655 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4660 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4662 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4666 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4667 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4668 * item of every of returned sequences refers to the _i_-th part of \a this field.
4669 * Thus all sequences returned by this method are of the same length equal to number
4670 * of different types of supporting entities.<br>
4671 * A field part can include sub-parts with several different spatial discretizations,
4672 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4673 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4674 * of a nested sequence corresponds to a type of spatial discretization.<br>
4675 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4676 * The overhead is due to selecting values into new instances of DataArrayDouble.
4677 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4678 * for the case with only one underlying mesh. (Actually, the number of meshes is
4679 * not checked if \a mname == \c NULL).
4680 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4681 * a field part is returned.
4682 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4683 * A field part can include sub-parts with several different spatial discretizations,
4684 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4685 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4686 * This sequence is of the same length as \a types.
4687 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4688 * discretization. A profile name can be empty.
4689 * Length of this and of nested sequences is the same as that of \a typesF.
4690 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4691 * discretization. A localization name can be empty.
4692 * Length of this and of nested sequences is the same as that of \a typesF.
4693 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4694 * per each type of spatial discretization within one mesh entity type.
4695 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4696 * Length of this and of nested sequences is the same as that of \a typesF.
4697 * \throw If no field is lying on \a mname.
4699 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)
4703 meshId=getMeshIdFromMeshName(mname);
4705 if(_field_per_mesh.empty())
4706 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4707 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4708 int nbOfRet=ret0.size();
4709 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4710 for(int i=0;i<nbOfRet;i++)
4712 const std::vector< std::pair<int,int> >& p=ret0[i];
4713 int nbOfRet1=p.size();
4714 ret[i].resize(nbOfRet1);
4715 for(int j=0;j<nbOfRet1;j++)
4717 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4725 * Returns a pointer to the underground DataArrayDouble instance. So the
4726 * caller should not decrRef() it. This method allows for a direct access to the field
4727 * values. This method is quite unusable if there is more than a nodal field or a cell
4728 * field on single geometric cell type.
4729 * \return DataArrayDouble * - the pointer to the field values array.
4731 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4733 const DataArrayDouble *ret=_arr;
4735 return const_cast<DataArrayDouble *>(ret);
4740 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4745 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4747 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4748 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4749 ret->deepCpyLeavesFrom(*this);
4750 const DataArrayDouble *arr(_arr);
4753 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4754 ret->setArray(arr2);
4760 * Returns a pointer to the underground DataArrayDouble instance. So the
4761 * caller should not decrRef() it. This method allows for a direct access to the field
4762 * values. This method is quite unusable if there is more than a nodal field or a cell
4763 * field on single geometric cell type.
4764 * \return DataArrayDouble * - the pointer to the field values array.
4766 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4768 return getUndergroundDataArrayDouble();
4772 * Returns a pointer to the underground DataArrayDouble instance and a
4773 * sequence describing parameters of a support of each part of \a this field. The
4774 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4775 * direct access to the field values. This method is intended for the field lying on one
4777 * \param [in,out] entries - the sequence describing parameters of a support of each
4778 * part of \a this field. Each item of this sequence consists of two parts. The
4779 * first part describes a type of mesh entity and an id of discretization of a
4780 * current field part. The second part describes a range of values [begin,end)
4781 * within the returned array relating to the current field part.
4782 * \return DataArrayDouble * - the pointer to the field values array.
4783 * \throw If the number of underlying meshes is not equal to 1.
4784 * \throw If no field values are available.
4785 * \sa getUndergroundDataArray()
4787 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4789 if(_field_per_mesh.size()!=1)
4790 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4791 if(_field_per_mesh[0]==0)
4792 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4793 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4794 return getUndergroundDataArrayDouble();
4798 * Returns a pointer to the underground DataArrayDouble instance and a
4799 * sequence describing parameters of a support of each part of \a this field. The
4800 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4801 * direct access to the field values. This method is intended for the field lying on one
4803 * \param [in,out] entries - the sequence describing parameters of a support of each
4804 * part of \a this field. Each item of this sequence consists of two parts. The
4805 * first part describes a type of mesh entity and an id of discretization of a
4806 * current field part. The second part describes a range of values [begin,end)
4807 * within the returned array relating to the current field part.
4808 * \return DataArrayDouble * - the pointer to the field values array.
4809 * \throw If the number of underlying meshes is not equal to 1.
4810 * \throw If no field values are available.
4811 * \sa getUndergroundDataArray()
4813 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4815 return getUndergroundDataArrayDoubleExt(entries);
4818 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4819 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4821 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4822 arr->setInfoAndChangeNbOfCompo(infos);
4825 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4829 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4831 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4832 ret->deepCpyLeavesFrom(*this);
4836 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4838 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4839 if((const DataArrayDouble *)_arr)
4840 ret->_arr=_arr->deepCpy();
4844 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4848 _nb_of_tuples_to_be_allocated=-1;
4852 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4854 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4856 _nb_of_tuples_to_be_allocated=-3;
4861 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4863 return DataArrayDouble::New();
4866 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4868 DataArrayDouble *ret=_arr;
4871 _arr=DataArrayDouble::New();
4875 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4877 return getOrCreateAndGetArrayDouble();
4880 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4882 const DataArrayDouble *ret=_arr;
4885 DataArrayDouble *ret2=DataArrayDouble::New();
4886 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4890 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4892 return getOrCreateAndGetArrayDouble();
4895 //= MEDFileIntField1TSWithoutSDA
4897 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4898 const std::vector<std::string>& infos)
4900 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4903 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4907 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4908 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4910 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4911 arr->setInfoAndChangeNbOfCompo(infos);
4914 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4919 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4921 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4922 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4923 ret->deepCpyLeavesFrom(*this);
4924 const DataArrayInt *arr(_arr);
4927 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4928 ret->setArray(arr2);
4934 * Returns a pointer to the underground DataArrayInt instance. So the
4935 * caller should not decrRef() it. This method allows for a direct access to the field
4936 * values. This method is quite unusable if there is more than a nodal field or a cell
4937 * field on single geometric cell type.
4938 * \return DataArrayInt * - the pointer to the field values array.
4940 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4942 return getUndergroundDataArrayInt();
4946 * Returns a pointer to the underground DataArrayInt instance. So the
4947 * caller should not decrRef() it. This method allows for a direct access to the field
4948 * values. This method is quite unusable if there is more than a nodal field or a cell
4949 * field on single geometric cell type.
4950 * \return DataArrayInt * - the pointer to the field values array.
4952 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4954 const DataArrayInt *ret=_arr;
4956 return const_cast<DataArrayInt *>(ret);
4962 * Returns a pointer to the underground DataArrayInt instance and a
4963 * sequence describing parameters of a support of each part of \a this field. The
4964 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4965 * direct access to the field values. This method is intended for the field lying on one
4967 * \param [in,out] entries - the sequence describing parameters of a support of each
4968 * part of \a this field. Each item of this sequence consists of two parts. The
4969 * first part describes a type of mesh entity and an id of discretization of a
4970 * current field part. The second part describes a range of values [begin,end)
4971 * within the returned array relating to the current field part.
4972 * \return DataArrayInt * - the pointer to the field values array.
4973 * \throw If the number of underlying meshes is not equal to 1.
4974 * \throw If no field values are available.
4975 * \sa getUndergroundDataArray()
4977 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4979 return getUndergroundDataArrayIntExt(entries);
4983 * Returns a pointer to the underground DataArrayInt instance and a
4984 * sequence describing parameters of a support of each part of \a this field. The
4985 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4986 * direct access to the field values. This method is intended for the field lying on one
4988 * \param [in,out] entries - the sequence describing parameters of a support of each
4989 * part of \a this field. Each item of this sequence consists of two parts. The
4990 * first part describes a type of mesh entity and an id of discretization of a
4991 * current field part. The second part describes a range of values [begin,end)
4992 * within the returned array relating to the current field part.
4993 * \return DataArrayInt * - the pointer to the field values array.
4994 * \throw If the number of underlying meshes is not equal to 1.
4995 * \throw If no field values are available.
4996 * \sa getUndergroundDataArray()
4998 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5000 if(_field_per_mesh.size()!=1)
5001 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5002 if(_field_per_mesh[0]==0)
5003 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5004 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5005 return getUndergroundDataArrayInt();
5008 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
5010 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5011 ret->deepCpyLeavesFrom(*this);
5015 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
5017 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5018 if((const DataArrayInt *)_arr)
5019 ret->_arr=_arr->deepCpy();
5023 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5027 _nb_of_tuples_to_be_allocated=-1;
5031 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5033 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5035 _nb_of_tuples_to_be_allocated=-3;
5040 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5042 return DataArrayInt::New();
5045 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5047 DataArrayInt *ret=_arr;
5050 _arr=DataArrayInt::New();
5054 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5056 return getOrCreateAndGetArrayInt();
5059 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5061 const DataArrayInt *ret=_arr;
5064 DataArrayInt *ret2=DataArrayInt::New();
5065 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5069 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5071 return getOrCreateAndGetArrayInt();
5074 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5078 //= MEDFileAnyTypeField1TS
5080 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5082 med_field_type typcha;
5084 std::vector<std::string> infos;
5085 std::string dtunit,fieldName;
5086 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5087 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5092 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5097 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5102 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] !";
5103 throw INTERP_KERNEL::Exception(oss.str().c_str());
5106 ret->setDtUnit(dtunit.c_str());
5107 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5109 med_int numdt,numit;
5111 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5112 ret->setTime(numdt,numit,dt);
5115 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5117 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5121 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5122 try:MEDFileFieldGlobsReal(fileName)
5124 MEDFileUtilities::CheckFileForRead(fileName);
5125 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5126 _content=BuildContentFrom(fid,fileName,loadAll);
5129 catch(INTERP_KERNEL::Exception& e)
5134 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5136 med_field_type typcha;
5137 std::vector<std::string> infos;
5140 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5141 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5146 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5151 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5156 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] !";
5157 throw INTERP_KERNEL::Exception(oss.str().c_str());
5160 ret->setDtUnit(dtunit.c_str());
5161 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5165 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5166 throw INTERP_KERNEL::Exception(oss.str().c_str());
5169 med_int numdt,numit;
5171 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5172 ret->setTime(numdt,numit,dt);
5175 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5177 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5181 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5182 try:MEDFileFieldGlobsReal(fileName)
5184 MEDFileUtilities::CheckFileForRead(fileName);
5185 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5186 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5189 catch(INTERP_KERNEL::Exception& e)
5194 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5197 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5198 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5200 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5201 ret->setFileName(fileName);
5202 ret->_content=c; c->incrRef();
5205 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5207 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5208 ret->setFileName(fileName);
5209 ret->_content=c; c->incrRef();
5212 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5215 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5217 MEDFileUtilities::CheckFileForRead(fileName);
5218 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5219 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5220 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5221 ret->loadGlobals(fid);
5225 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5227 MEDFileUtilities::CheckFileForRead(fileName);
5228 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5229 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5230 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5231 ret->loadGlobals(fid);
5235 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5237 MEDFileUtilities::CheckFileForRead(fileName);
5238 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5239 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5240 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5241 ret->loadGlobals(fid);
5245 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5247 med_field_type typcha;
5248 std::vector<std::string> infos;
5251 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5252 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5257 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5262 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5267 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] !";
5268 throw INTERP_KERNEL::Exception(oss.str().c_str());
5271 ret->setDtUnit(dtunit.c_str());
5272 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5275 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5276 for(int i=0;i<nbOfStep2 && !found;i++)
5278 med_int numdt,numit;
5280 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5281 if(numdt==iteration && numit==order)
5287 dtits[i]=std::pair<int,int>(numdt,numit);
5291 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5292 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5293 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5294 throw INTERP_KERNEL::Exception(oss.str().c_str());
5297 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5299 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5303 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5304 try:MEDFileFieldGlobsReal(fileName)
5306 MEDFileUtilities::CheckFileForRead(fileName);
5307 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5308 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5311 catch(INTERP_KERNEL::Exception& e)
5317 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5318 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5320 * \warning this is a shallow copy constructor
5322 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5324 if(!shallowCopyOfContent)
5326 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5327 otherPtr->incrRef();
5328 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5332 _content=other.shallowCpy();
5336 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)
5340 int nbFields=MEDnField(fid);
5341 if(fieldIdCFormat>=nbFields)
5343 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5344 throw INTERP_KERNEL::Exception(oss.str().c_str());
5347 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5348 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5349 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5350 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5351 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5352 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5355 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5356 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5357 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5358 infos.clear(); infos.resize(ncomp);
5359 for(int j=0;j<ncomp;j++)
5360 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5365 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5368 * \return in case of success the number of time steps available for the field with name \a fieldName.
5370 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)
5372 int nbFields=MEDnField(fid);
5374 std::vector<std::string> fns(nbFields);
5376 for(int i=0;i<nbFields && !found;i++)
5379 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5381 found=(tmp==fieldName);
5387 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5388 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5389 oss << "\"" << *it << "\" ";
5390 throw INTERP_KERNEL::Exception(oss.str().c_str());
5396 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5397 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5398 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5399 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5400 * to keep a valid instance.
5401 * 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.
5402 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5403 * 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.
5405 * \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.
5406 * \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.
5407 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5408 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5409 * \param [in] newLocName is the new localization name.
5410 * \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.
5411 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5413 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5415 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5416 std::string oldPflName=disc->getProfile();
5417 std::vector<std::string> vv=getPflsReallyUsedMulti();
5418 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5419 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5421 disc->setProfile(newPflName);
5422 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5423 pfl->setName(newPflName);
5427 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5428 throw INTERP_KERNEL::Exception(oss.str().c_str());
5433 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5434 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5435 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5436 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5437 * to keep a valid instance.
5438 * 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.
5439 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5440 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5441 * 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.
5443 * \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.
5444 * \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.
5445 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5446 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5447 * \param [in] newLocName is the new localization name.
5448 * \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.
5449 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5451 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5453 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5454 std::string oldLocName=disc->getLocalization();
5455 std::vector<std::string> vv=getLocsReallyUsedMulti();
5456 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5457 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5459 disc->setLocalization(newLocName);
5460 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5461 loc.setName(newLocName);
5465 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5466 throw INTERP_KERNEL::Exception(oss.str().c_str());
5470 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5472 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5474 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5478 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5480 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5487 * Writes \a this field into a MED file specified by its name.
5488 * \param [in] fileName - the MED file name.
5489 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5490 * - 2 - erase; an existing file is removed.
5491 * - 1 - append; same data should not be present in an existing file.
5492 * - 0 - overwrite; same data present in an existing file is overwritten.
5493 * \throw If the field name is not set.
5494 * \throw If no field data is set.
5495 * \throw If \a mode == 1 and the same data is present in an existing file.
5497 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5499 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5500 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5505 * This method alloc the arrays and load potentially huge arrays contained in this field.
5506 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5507 * This method can be also called to refresh or reinit values from a file.
5509 * \throw If the fileName is not set or points to a non readable MED file.
5510 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5512 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5514 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5515 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5519 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5520 * But once data loaded once, this method does nothing.
5522 * \throw If the fileName is not set or points to a non readable MED file.
5523 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5525 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5527 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5528 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5532 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5533 * This method does not release arrays set outside the context of a MED file.
5535 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5537 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5539 contentNotNullBase()->releaseArrays();
5542 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5544 int nbComp=getNumberOfComponents();
5545 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5546 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5547 for(int i=0;i<nbComp;i++)
5549 std::string info=getInfo()[i];
5551 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5552 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5553 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5555 if(getName().empty())
5556 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5557 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5558 writeGlobals(fid,*this);
5559 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5562 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5565 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5566 ret+=_content->getHeapMemorySize();
5567 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5571 * Returns a string describing \a this field. This string is outputted
5572 * by \c print Python command.
5574 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5576 std::ostringstream oss;
5577 contentNotNullBase()->simpleRepr(0,oss,-1);
5578 simpleReprGlobs(oss);
5583 * This method returns all profiles whose name is non empty used.
5584 * \b WARNING If profile is used several times it will be reported \b only \b once.
5585 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5587 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5589 return contentNotNullBase()->getPflsReallyUsed2();
5593 * This method returns all localizations whose name is non empty used.
5594 * \b WARNING If localization is used several times it will be reported \b only \b once.
5596 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5598 return contentNotNullBase()->getLocsReallyUsed2();
5602 * This method returns all profiles whose name is non empty used.
5603 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5605 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5607 return contentNotNullBase()->getPflsReallyUsedMulti2();
5611 * This method returns all localizations whose name is non empty used.
5612 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5614 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5616 return contentNotNullBase()->getLocsReallyUsedMulti2();
5619 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5621 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5624 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5626 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5629 int MEDFileAnyTypeField1TS::getDimension() const
5631 return contentNotNullBase()->getDimension();
5634 int MEDFileAnyTypeField1TS::getIteration() const
5636 return contentNotNullBase()->getIteration();
5639 int MEDFileAnyTypeField1TS::getOrder() const
5641 return contentNotNullBase()->getOrder();
5644 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5646 return contentNotNullBase()->getTime(iteration,order);
5649 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5651 contentNotNullBase()->setTime(iteration,order,val);
5654 std::string MEDFileAnyTypeField1TS::getName() const
5656 return contentNotNullBase()->getName();
5659 void MEDFileAnyTypeField1TS::setName(const char *name)
5661 contentNotNullBase()->setName(name);
5664 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5666 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5669 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5671 return contentNotNullBase()->getDtUnit();
5674 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5676 contentNotNullBase()->setDtUnit(dtUnit);
5679 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5681 return contentNotNullBase()->getMeshName();
5684 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5686 contentNotNullBase()->setMeshName(newMeshName);
5689 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5691 return contentNotNullBase()->changeMeshNames(modifTab);
5694 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5696 return contentNotNullBase()->getMeshIteration();
5699 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5701 return contentNotNullBase()->getMeshOrder();
5704 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5706 return contentNotNullBase()->getNumberOfComponents();
5709 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5711 return contentNotNullBase()->isDealingTS(iteration,order);
5714 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5716 return contentNotNullBase()->getDtIt();
5719 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5721 contentNotNullBase()->fillIteration(p);
5724 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5726 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5729 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5731 contentNotNullBase()->setInfo(infos);
5734 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5736 return contentNotNullBase()->getInfo();
5738 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5740 return contentNotNullBase()->getInfo();
5743 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5745 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5748 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5750 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5753 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5755 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5758 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5760 return contentNotNullBase()->getTypesOfFieldAvailable();
5763 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,
5764 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5766 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5770 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5771 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5772 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5774 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5776 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5778 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5779 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5780 std::size_t sz(contentsSplit.size());
5781 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5782 for(std::size_t i=0;i<sz;i++)
5784 ret[i]=shallowCpy();
5785 ret[i]->_content=contentsSplit[i];
5791 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5792 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5794 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5796 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5798 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5799 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5800 std::size_t sz(contentsSplit.size());
5801 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5802 for(std::size_t i=0;i<sz;i++)
5804 ret[i]=shallowCpy();
5805 ret[i]->_content=contentsSplit[i];
5810 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5812 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5813 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5814 ret->_content=_content->deepCpy();
5815 ret->deepCpyGlobs(*this);
5819 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5821 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5827 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5828 * the first field that has been read from a specified MED file.
5829 * \param [in] fileName - the name of the MED file to read.
5830 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5831 * is to delete this field using decrRef() as it is no more needed.
5832 * \throw If reading the file fails.
5834 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5836 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5837 ret->contentNotNull();
5842 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5843 * a given field that has been read from a specified MED file.
5844 * \param [in] fileName - the name of the MED file to read.
5845 * \param [in] fieldName - the name of the field to read.
5846 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5847 * is to delete this field using decrRef() as it is no more needed.
5848 * \throw If reading the file fails.
5849 * \throw If there is no field named \a fieldName in the file.
5851 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5853 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5854 ret->contentNotNull();
5859 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5860 * a given field that has been read from a specified MED file.
5861 * \param [in] fileName - the name of the MED file to read.
5862 * \param [in] fieldName - the name of the field to read.
5863 * \param [in] iteration - the iteration number of a required time step.
5864 * \param [in] order - the iteration order number of required time step.
5865 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5866 * is to delete this field using decrRef() as it is no more needed.
5867 * \throw If reading the file fails.
5868 * \throw If there is no field named \a fieldName in the file.
5869 * \throw If the required time step is missing from the file.
5871 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5873 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5874 ret->contentNotNull();
5879 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5880 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5882 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5883 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5884 * \warning this is a shallow copy constructor
5885 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5886 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5887 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5888 * is to delete this field using decrRef() as it is no more needed.
5890 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5892 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5893 ret->contentNotNull();
5898 * Returns a new empty instance of MEDFileField1TS.
5899 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5900 * is to delete this field using decrRef() as it is no more needed.
5902 MEDFileField1TS *MEDFileField1TS::New()
5904 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5905 ret->contentNotNull();
5910 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5911 * following the given input policy.
5913 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5914 * By default (true) the globals are deeply copied.
5915 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5917 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5919 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5920 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5923 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5925 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5926 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5927 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5930 ret=MEDFileIntField1TS::New();
5932 ret->deepCpyGlobs(*this);
5934 ret->shallowCpyGlobs(*this);
5938 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5940 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5942 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5943 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5945 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 !");
5949 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5951 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5953 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5954 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5956 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 !");
5960 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5963 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5964 if(!((DataArray*)arr))
5965 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5966 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5968 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5969 f->setArray(arrOutC);
5972 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5974 if(!((DataArray*)arr))
5975 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5976 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5978 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5983 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5984 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5987 catch(INTERP_KERNEL::Exception& e)
5990 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5991 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5994 catch(INTERP_KERNEL::Exception& e)
5997 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5998 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6001 catch(INTERP_KERNEL::Exception& e)
6005 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6006 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6008 * \warning this is a shallow copy constructor
6010 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6011 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6014 catch(INTERP_KERNEL::Exception& e)
6017 MEDFileField1TS::MEDFileField1TS()
6019 _content=new MEDFileField1TSWithoutSDA;
6023 * Returns a new MEDCouplingFieldDouble of a given type lying on
6024 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6025 * has not been constructed via file reading, an exception is thrown.
6026 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6027 * \param [in] type - a spatial discretization of interest.
6028 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6029 * \param [in] renumPol - specifies how to permute values of the result field according to
6030 * the optional numbers of cells and nodes, if any. The valid values are
6031 * - 0 - do not permute.
6032 * - 1 - permute cells.
6033 * - 2 - permute nodes.
6034 * - 3 - permute cells and nodes.
6036 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6037 * caller is to delete this field using decrRef() as it is no more needed.
6038 * \throw If \a this field has not been constructed via file reading.
6039 * \throw If the MED file is not readable.
6040 * \throw If there is no mesh in the MED file.
6041 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6042 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6043 * \sa getFieldOnMeshAtLevel()
6045 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6047 if(getFileName2().empty())
6048 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6049 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6050 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6051 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6056 * Returns a new MEDCouplingFieldDouble of a given type lying on
6057 * the top level cells of the first mesh in MED file. If \a this field
6058 * has not been constructed via file reading, an exception is thrown.
6059 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6060 * \param [in] type - a spatial discretization of interest.
6061 * \param [in] renumPol - specifies how to permute values of the result field according to
6062 * the optional numbers of cells and nodes, if any. The valid values are
6063 * - 0 - do not permute.
6064 * - 1 - permute cells.
6065 * - 2 - permute nodes.
6066 * - 3 - permute cells and nodes.
6068 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6069 * caller is to delete this field using decrRef() as it is no more needed.
6070 * \throw If \a this field has not been constructed via file reading.
6071 * \throw If the MED file is not readable.
6072 * \throw If there is no mesh in the MED file.
6073 * \throw If no field values of the given \a type.
6074 * \throw If no field values lying on the top level support.
6075 * \sa getFieldAtLevel()
6077 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6079 if(getFileName2().empty())
6080 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6081 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6082 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6083 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6088 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6089 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6090 * \param [in] type - a spatial discretization of the new field.
6091 * \param [in] mesh - the supporting mesh.
6092 * \param [in] renumPol - specifies how to permute values of the result field according to
6093 * the optional numbers of cells and nodes, if any. The valid values are
6094 * - 0 - do not permute.
6095 * - 1 - permute cells.
6096 * - 2 - permute nodes.
6097 * - 3 - permute cells and nodes.
6099 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6100 * caller is to delete this field using decrRef() as it is no more needed.
6101 * \throw If no field of \a this is lying on \a mesh.
6102 * \throw If the mesh is empty.
6103 * \throw If no field values of the given \a type are available.
6104 * \sa getFieldAtLevel()
6105 * \sa getFieldOnMeshAtLevel()
6107 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6109 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6110 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6111 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6116 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6117 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6118 * \param [in] type - a spatial discretization of interest.
6119 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6120 * \param [in] mesh - the supporting mesh.
6121 * \param [in] renumPol - specifies how to permute values of the result field according to
6122 * the optional numbers of cells and nodes, if any. The valid values are
6123 * - 0 - do not permute.
6124 * - 1 - permute cells.
6125 * - 2 - permute nodes.
6126 * - 3 - permute cells and nodes.
6128 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6129 * caller is to delete this field using decrRef() as it is no more needed.
6130 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6131 * \throw If no field of \a this is lying on \a mesh.
6132 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6133 * \sa getFieldAtLevel()
6134 * \sa getFieldOnMeshAtLevel()
6136 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6138 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6139 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6140 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6145 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6146 * This method is called "Old" because in MED3 norm a field has only one meshName
6147 * attached, so this method is for readers of MED2 files. If \a this field
6148 * has not been constructed via file reading, an exception is thrown.
6149 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6150 * \param [in] type - a spatial discretization of interest.
6151 * \param [in] mName - a name of the supporting mesh.
6152 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6153 * \param [in] renumPol - specifies how to permute values of the result field according to
6154 * the optional numbers of cells and nodes, if any. The valid values are
6155 * - 0 - do not permute.
6156 * - 1 - permute cells.
6157 * - 2 - permute nodes.
6158 * - 3 - permute cells and nodes.
6160 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6161 * caller is to delete this field using decrRef() as it is no more needed.
6162 * \throw If the MED file is not readable.
6163 * \throw If there is no mesh named \a mName in the MED file.
6164 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6165 * \throw If \a this field has not been constructed via file reading.
6166 * \throw If no field of \a this is lying on the mesh named \a mName.
6167 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6168 * \sa getFieldAtLevel()
6170 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6172 if(getFileName2().empty())
6173 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6174 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6175 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6176 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6181 * Returns values and a profile of the field of a given type lying on a given support.
6182 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6183 * \param [in] type - a spatial discretization of the field.
6184 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6185 * \param [in] mesh - the supporting mesh.
6186 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6187 * field of interest lies on. If the field lies on all entities of the given
6188 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6189 * using decrRef() as it is no more needed.
6190 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6191 * field. The caller is to delete this array using decrRef() as it is no more needed.
6192 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6193 * \throw If no field of \a this is lying on \a mesh.
6194 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6196 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6198 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6199 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6203 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6204 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6205 * "Sort By Type"), if not, an exception is thrown.
6206 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6207 * \param [in] field - the field to add to \a this.
6208 * \throw If the name of \a field is empty.
6209 * \throw If the data array of \a field is not set.
6210 * \throw If the data array is already allocated but has different number of components
6212 * \throw If the underlying mesh of \a field has no name.
6213 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6215 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6218 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6222 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6223 * can be an aggregation of several MEDCouplingFieldDouble instances.
6224 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6225 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6228 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6229 * A new profile is added only if no equal profile is missing.
6230 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6231 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6232 * \param [in] mesh - the supporting mesh of \a field.
6233 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6234 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6235 * \throw If either \a field or \a mesh or \a profile has an empty name.
6236 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6237 * \throw If the data array of \a field is not set.
6238 * \throw If the data array of \a this is already allocated but has different number of
6239 * components than \a field.
6240 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6241 * \sa setFieldNoProfileSBT()
6243 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6246 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6249 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6251 return new MEDFileField1TS(*this);
6254 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6256 return contentNotNull()->getUndergroundDataArrayDouble();
6259 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6261 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6264 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6265 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6267 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6270 //= MEDFileIntField1TS
6272 MEDFileIntField1TS *MEDFileIntField1TS::New()
6274 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6275 ret->contentNotNull();
6279 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6281 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6282 ret->contentNotNull();
6286 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6288 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6289 ret->contentNotNull();
6293 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6295 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6296 ret->contentNotNull();
6300 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6302 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6303 ret->contentNotNull();
6307 MEDFileIntField1TS::MEDFileIntField1TS()
6309 _content=new MEDFileIntField1TSWithoutSDA;
6312 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6313 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6316 catch(INTERP_KERNEL::Exception& e)
6319 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6320 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6323 catch(INTERP_KERNEL::Exception& e)
6326 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6327 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6330 catch(INTERP_KERNEL::Exception& e)
6334 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6335 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6337 * \warning this is a shallow copy constructor
6339 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6343 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6345 return new MEDFileIntField1TS(*this);
6349 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6350 * following the given input policy.
6352 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6353 * By default (true) the globals are deeply copied.
6354 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6356 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6358 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6359 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6362 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6364 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6365 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6366 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6369 ret=MEDFileField1TS::New();
6371 ret->deepCpyGlobs(*this);
6373 ret->shallowCpyGlobs(*this);
6378 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6379 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6380 * "Sort By Type"), if not, an exception is thrown.
6381 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6382 * \param [in] field - the field to add to \a this. The field double values are ignored.
6383 * \param [in] arrOfVals - the values of the field \a field used.
6384 * \throw If the name of \a field is empty.
6385 * \throw If the data array of \a field is not set.
6386 * \throw If the data array is already allocated but has different number of components
6388 * \throw If the underlying mesh of \a field has no name.
6389 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6391 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6394 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6398 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6399 * can be an aggregation of several MEDCouplingFieldDouble instances.
6400 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6401 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6404 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6405 * A new profile is added only if no equal profile is missing.
6406 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6407 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6408 * \param [in] arrOfVals - the values of the field \a field used.
6409 * \param [in] mesh - the supporting mesh of \a field.
6410 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6411 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6412 * \throw If either \a field or \a mesh or \a profile has an empty name.
6413 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6414 * \throw If the data array of \a field is not set.
6415 * \throw If the data array of \a this is already allocated but has different number of
6416 * components than \a field.
6417 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6418 * \sa setFieldNoProfileSBT()
6420 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6423 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6426 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6428 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6430 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6431 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6433 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 !");
6437 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6439 if(getFileName2().empty())
6440 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6441 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6442 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6443 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6445 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6450 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6452 if(!((DataArray *)arr))
6453 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6454 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6456 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6462 * Returns a new MEDCouplingFieldDouble of a given type lying on
6463 * the top level cells of the first mesh in MED file. If \a this field
6464 * has not been constructed via file reading, an exception is thrown.
6465 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6466 * \param [in] type - a spatial discretization of interest.
6467 * \param [out] arrOut - the DataArrayInt containing values of field.
6468 * \param [in] renumPol - specifies how to permute values of the result field according to
6469 * the optional numbers of cells and nodes, if any. The valid values are
6470 * - 0 - do not permute.
6471 * - 1 - permute cells.
6472 * - 2 - permute nodes.
6473 * - 3 - permute cells and nodes.
6475 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6476 * caller is to delete this field using decrRef() as it is no more needed.
6477 * \throw If \a this field has not been constructed via file reading.
6478 * \throw If the MED file is not readable.
6479 * \throw If there is no mesh in the MED file.
6480 * \throw If no field values of the given \a type.
6481 * \throw If no field values lying on the top level support.
6482 * \sa getFieldAtLevel()
6484 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6486 if(getFileName2().empty())
6487 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6488 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6489 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6490 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6495 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6496 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6497 * \param [in] type - a spatial discretization of the new field.
6498 * \param [in] mesh - the supporting mesh.
6499 * \param [out] arrOut - the DataArrayInt containing values of field.
6500 * \param [in] renumPol - specifies how to permute values of the result field according to
6501 * the optional numbers of cells and nodes, if any. The valid values are
6502 * - 0 - do not permute.
6503 * - 1 - permute cells.
6504 * - 2 - permute nodes.
6505 * - 3 - permute cells and nodes.
6507 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6508 * caller is to delete this field using decrRef() as it is no more needed.
6509 * \throw If no field of \a this is lying on \a mesh.
6510 * \throw If the mesh is empty.
6511 * \throw If no field values of the given \a type are available.
6512 * \sa getFieldAtLevel()
6513 * \sa getFieldOnMeshAtLevel()
6515 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6517 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6518 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6519 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6524 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6525 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6526 * \param [in] type - a spatial discretization of interest.
6527 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6528 * \param [out] arrOut - the DataArrayInt containing values of field.
6529 * \param [in] mesh - the supporting mesh.
6530 * \param [in] renumPol - specifies how to permute values of the result field according to
6531 * the optional numbers of cells and nodes, if any. The valid values are
6532 * - 0 - do not permute.
6533 * - 1 - permute cells.
6534 * - 2 - permute nodes.
6535 * - 3 - permute cells and nodes.
6537 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6538 * caller is to delete this field using decrRef() as it is no more needed.
6539 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6540 * \throw If no field of \a this is lying on \a mesh.
6541 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6542 * \sa getFieldAtLevel()
6543 * \sa getFieldOnMeshAtLevel()
6545 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6547 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6548 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6549 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6554 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6555 * This method is called "Old" because in MED3 norm a field has only one meshName
6556 * attached, so this method is for readers of MED2 files. If \a this field
6557 * has not been constructed via file reading, an exception is thrown.
6558 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6559 * \param [in] type - a spatial discretization of interest.
6560 * \param [in] mName - a name of the supporting mesh.
6561 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6562 * \param [out] arrOut - the DataArrayInt containing values of field.
6563 * \param [in] renumPol - specifies how to permute values of the result field according to
6564 * the optional numbers of cells and nodes, if any. The valid values are
6565 * - 0 - do not permute.
6566 * - 1 - permute cells.
6567 * - 2 - permute nodes.
6568 * - 3 - permute cells and nodes.
6570 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6571 * caller is to delete this field using decrRef() as it is no more needed.
6572 * \throw If the MED file is not readable.
6573 * \throw If there is no mesh named \a mName in the MED file.
6574 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6575 * \throw If \a this field has not been constructed via file reading.
6576 * \throw If no field of \a this is lying on the mesh named \a mName.
6577 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6578 * \sa getFieldAtLevel()
6580 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6582 if(getFileName2().empty())
6583 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6584 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6585 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6586 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6591 * Returns values and a profile of the field of a given type lying on a given support.
6592 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6593 * \param [in] type - a spatial discretization of the field.
6594 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6595 * \param [in] mesh - the supporting mesh.
6596 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6597 * field of interest lies on. If the field lies on all entities of the given
6598 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6599 * using decrRef() as it is no more needed.
6600 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6601 * field. The caller is to delete this array using decrRef() as it is no more needed.
6602 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6603 * \throw If no field of \a this is lying on \a mesh.
6604 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6606 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6608 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6609 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6612 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6614 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6616 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6617 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6619 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 !");
6623 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6625 return contentNotNull()->getUndergroundDataArrayInt();
6628 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6630 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6634 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6639 * \param [in] fieldId field id in C mode
6641 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6643 med_field_type typcha;
6644 std::string dtunitOut;
6645 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6646 setDtUnit(dtunitOut.c_str());
6647 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6650 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)
6651 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6653 setDtUnit(dtunit.c_str());
6654 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6656 catch(INTERP_KERNEL::Exception& e)
6661 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6663 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6664 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6665 ret+=(*it).capacity();
6666 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6667 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6668 ret+=(*it)->getHeapMemorySize();
6673 * 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
6676 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6678 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6679 ret->setInfo(_infos);
6680 int sz=(int)_time_steps.size();
6681 for(const int *id=startIds;id!=endIds;id++)
6683 if(*id>=0 && *id<sz)
6685 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6686 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6690 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6692 ret->pushBackTimeStep(tse2);
6696 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6697 oss << " ! Should be in [0," << sz << ") !";
6698 throw INTERP_KERNEL::Exception(oss.str().c_str());
6701 if(ret->getNumberOfTS()>0)
6702 ret->synchronizeNameScope();
6703 ret->copyNameScope(*this);
6708 * 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
6711 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6713 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6714 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6715 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6716 ret->setInfo(_infos);
6717 int sz=(int)_time_steps.size();
6719 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6723 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6724 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6728 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6730 ret->pushBackTimeStep(tse2);
6734 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6735 oss << " ! Should be in [0," << sz << ") !";
6736 throw INTERP_KERNEL::Exception(oss.str().c_str());
6739 if(ret->getNumberOfTS()>0)
6740 ret->synchronizeNameScope();
6741 ret->copyNameScope(*this);
6745 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6748 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6749 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6751 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6754 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6755 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6756 ids->pushBackSilent(id);
6758 return buildFromTimeStepIds(ids->begin(),ids->end());
6761 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6764 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6765 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6767 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6770 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6771 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6772 ids->pushBackSilent(id);
6774 return buildFromTimeStepIds(ids->begin(),ids->end());
6777 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6782 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6787 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6790 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6792 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6793 if(pt->isDealingTS(iteration,order))
6796 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6797 std::vector< std::pair<int,int> > vp=getIterations();
6798 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6799 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6800 throw INTERP_KERNEL::Exception(oss.str().c_str());
6803 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6805 return *_time_steps[getTimeStepPos(iteration,order)];
6808 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6810 return *_time_steps[getTimeStepPos(iteration,order)];
6813 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6815 if(_time_steps.empty())
6816 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6817 return _time_steps[0]->getMeshName();
6820 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6822 std::string oldName(getMeshName());
6823 std::vector< std::pair<std::string,std::string> > v(1);
6824 v[0].first=oldName; v[0].second=newMeshName;
6828 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6831 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6833 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6835 ret=cur->changeMeshNames(modifTab) || ret;
6841 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6843 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6845 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6849 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6851 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)
6853 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6856 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6857 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6860 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6862 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6864 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6869 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6871 std::string startLine(bkOffset,' ');
6872 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6874 oss << " (" << fmtsId << ")";
6875 oss << " has the following name: \"" << _name << "\"." << std::endl;
6876 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6877 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6879 oss << startLine << " - \"" << *it << "\"" << std::endl;
6882 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6884 std::string chapter(17,'0'+i);
6885 oss << startLine << chapter << std::endl;
6886 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6888 cur->simpleRepr(bkOffset+2,oss,i);
6890 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6891 oss << startLine << chapter << std::endl;
6895 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6897 std::size_t sz=_time_steps.size();
6898 std::vector< std::pair<int,int> > ret(sz);
6900 for(std::size_t i=0;i<sz;i++)
6902 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6905 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6909 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6910 throw INTERP_KERNEL::Exception(oss.str().c_str());
6916 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6918 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6920 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6921 checkCoherencyOfType(tse2);
6922 if(_time_steps.empty())
6924 setName(tse2->getName().c_str());
6925 setInfo(tse2->getInfo());
6927 checkThatComponentsMatch(tse2->getInfo());
6928 _time_steps.push_back(tse);
6931 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6933 std::size_t nbOfCompo=_infos.size();
6934 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6936 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6939 if((cur->getInfo()).size()!=nbOfCompo)
6941 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6942 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6943 throw INTERP_KERNEL::Exception(oss.str().c_str());
6945 cur->copyNameScope(*this);
6950 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6952 _time_steps.resize(nbPdt);
6953 for(int i=0;i<nbPdt;i++)
6955 std::vector< std::pair<int,int> > ts;
6956 med_int numdt=0,numo=0;
6957 med_int meshIt=0,meshOrder=0;
6959 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6964 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6969 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6973 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6976 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6978 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6984 if(_time_steps.empty())
6985 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6986 checkThatNbOfCompoOfTSMatchThis();
6987 std::vector<std::string> infos(getInfo());
6988 int nbComp=infos.size();
6989 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6990 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6991 for(int i=0;i<nbComp;i++)
6993 std::string info=infos[i];
6995 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6996 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6997 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7000 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7001 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7002 int nbOfTS=_time_steps.size();
7003 for(int i=0;i<nbOfTS;i++)
7004 _time_steps[i]->writeLL(fid,opts,*this);
7007 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7009 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7011 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7013 elt->loadBigArraysRecursively(fid,nasc);
7017 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7019 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7021 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7023 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7027 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
7029 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7031 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7033 elt->releaseArrays();
7037 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7039 return _time_steps.size();
7042 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7044 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7045 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7047 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7049 newTS.push_back(*it);
7054 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7056 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7057 int maxId=(int)_time_steps.size();
7059 std::set<int> idsToDel;
7060 for(const int *id=startIds;id!=endIds;id++,ii++)
7062 if(*id>=0 && *id<maxId)
7064 idsToDel.insert(*id);
7068 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7069 throw INTERP_KERNEL::Exception(oss.str().c_str());
7072 for(int iii=0;iii<maxId;iii++)
7073 if(idsToDel.find(iii)==idsToDel.end())
7074 newTS.push_back(_time_steps[iii]);
7078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7080 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7081 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7082 if(nbOfEntriesToKill==0)
7084 std::size_t sz=_time_steps.size();
7085 std::vector<bool> b(sz,true);
7087 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7089 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7090 for(std::size_t i=0;i<sz;i++)
7092 newTS.push_back(_time_steps[i]);
7096 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7099 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7100 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7102 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7106 tmp->getTime(it2,ord);
7107 if(it2==iteration && order==ord)
7110 oss << "(" << it2 << "," << ord << "), ";
7113 throw INTERP_KERNEL::Exception(oss.str().c_str());
7116 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7119 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7121 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7123 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7127 double ti=tmp->getTime(it2,ord);
7128 if(fabs(time-ti)<eps)
7134 throw INTERP_KERNEL::Exception(oss.str().c_str());
7137 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7139 int lgth=_time_steps.size();
7140 std::vector< std::pair<int,int> > ret(lgth);
7141 for(int i=0;i<lgth;i++)
7142 _time_steps[i]->fillIteration(ret[i]);
7147 * 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'
7148 * This method returns two things.
7149 * - The absolute dimension of 'this' in first parameter.
7150 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7151 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7153 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7154 * Only these 3 discretizations will be taken into account here.
7156 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7157 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7158 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7160 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7161 * 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'.
7163 * Let's consider the typical following case :
7164 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7165 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7166 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7168 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7170 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7172 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7173 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7174 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7175 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7177 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7179 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7182 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7184 if(pos<0 || pos>=(int)_time_steps.size())
7186 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7187 throw INTERP_KERNEL::Exception(oss.str().c_str());
7189 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7192 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7193 oss << "\nTry to use following method eraseEmptyTS !";
7194 throw INTERP_KERNEL::Exception(oss.str().c_str());
7199 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7201 if(pos<0 || pos>=(int)_time_steps.size())
7203 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7204 throw INTERP_KERNEL::Exception(oss.str().c_str());
7206 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7209 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7210 oss << "\nTry to use following method eraseEmptyTS !";
7211 throw INTERP_KERNEL::Exception(oss.str().c_str());
7216 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7218 std::vector<std::string> ret;
7219 std::set<std::string> ret2;
7220 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7222 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7223 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7224 if(ret2.find(*it2)==ret2.end())
7226 ret.push_back(*it2);
7233 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7235 std::vector<std::string> ret;
7236 std::set<std::string> ret2;
7237 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7239 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7240 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7241 if(ret2.find(*it2)==ret2.end())
7243 ret.push_back(*it2);
7250 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7252 std::vector<std::string> ret;
7253 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7255 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7256 ret.insert(ret.end(),tmp.begin(),tmp.end());
7261 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7263 std::vector<std::string> ret;
7264 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7266 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7267 ret.insert(ret.end(),tmp.begin(),tmp.end());
7272 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7274 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7275 (*it)->changePflsRefsNamesGen2(mapOfModif);
7278 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7280 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7281 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7284 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7286 int lgth=_time_steps.size();
7287 std::vector< std::vector<TypeOfField> > ret(lgth);
7288 for(int i=0;i<lgth;i++)
7289 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7294 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7296 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)
7298 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7301 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7303 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7305 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7307 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7308 ret->_time_steps[i]=(*it)->deepCpy();
7313 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7315 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7316 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7317 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7318 for(std::size_t i=0;i<sz;i++)
7320 ret[i]=shallowCpy();
7321 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7323 for(std::size_t i=0;i<sz2;i++)
7325 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7328 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7329 throw INTERP_KERNEL::Exception(oss.str().c_str());
7333 for(std::size_t i=0;i<sz;i++)
7334 for(std::size_t j=0;j<sz2;j++)
7335 ret[i]->_time_steps[j]=ts[j][i];
7340 * This method splits into discretization each time steps in \a this.
7341 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7343 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7345 std::size_t sz(_time_steps.size());
7346 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7347 for(std::size_t i=0;i<sz;i++)
7349 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7352 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7353 throw INTERP_KERNEL::Exception(oss.str().c_str());
7355 items[i]=timeStep->splitDiscretizations();
7358 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7359 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7360 std::vector< TypeOfField > types;
7361 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7362 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7364 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7366 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7367 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7368 if(it2==types.end())
7369 types.push_back(ts[0]);
7371 ret.resize(types.size()); ret2.resize(types.size());
7372 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7373 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7375 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7376 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7377 ret2[pos].push_back(*it1);
7379 for(std::size_t i=0;i<types.size();i++)
7381 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7383 elt->pushBackTimeStep(*it1);//also updates infos in elt
7385 elt->MEDFileFieldNameScope::operator=(*this);
7390 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7392 _name=field->getName();
7394 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7396 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7397 _infos=arr->getInfoOnComponents();
7400 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7402 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7403 if(_name!=field->getName())
7405 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7406 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7407 throw INTERP_KERNEL::Exception(oss.str().c_str());
7410 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7411 checkThatComponentsMatch(arr->getInfoOnComponents());
7414 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7416 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7417 if(getInfo().size()!=compos.size())
7419 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7420 oss << " number of components of element to append (" << compos.size() << ") !";
7421 throw INTERP_KERNEL::Exception(oss.str().c_str());
7425 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7426 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7427 oss << " But compo in input fields are : ";
7428 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7430 throw INTERP_KERNEL::Exception(oss.str().c_str());
7434 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7436 std::size_t sz=_infos.size();
7438 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7440 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7442 if(elt->getInfo().size()!=sz)
7444 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7445 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7446 throw INTERP_KERNEL::Exception(oss.str().c_str());
7451 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7455 if(!_time_steps.empty())
7456 checkCoherencyOfTinyInfo(field,arr);
7457 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7458 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7459 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7460 copyTinyInfoFrom(field,arr);
7461 _time_steps.push_back(obj);
7464 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7467 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7468 if(!_time_steps.empty())
7469 checkCoherencyOfTinyInfo(field,arr);
7470 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7471 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7472 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7473 copyTinyInfoFrom(field,arr);
7474 _time_steps.push_back(obj);
7477 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7479 int sz=(int)_time_steps.size();
7482 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7483 throw INTERP_KERNEL::Exception(oss.str().c_str());
7485 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7488 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7490 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7491 throw INTERP_KERNEL::Exception(oss.str().c_str());
7497 //= MEDFileFieldMultiTSWithoutSDA
7499 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)
7501 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7504 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7508 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7513 * \param [in] fieldId field id in C mode
7515 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7516 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7519 catch(INTERP_KERNEL::Exception& e)
7522 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)
7523 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7526 catch(INTERP_KERNEL::Exception& e)
7529 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7531 return new MEDFileField1TSWithoutSDA;
7534 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7537 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7538 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7540 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7543 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7545 return MEDFileField1TSWithoutSDA::TYPE_STR;
7548 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7550 return new MEDFileFieldMultiTSWithoutSDA(*this);
7553 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7555 return new MEDFileFieldMultiTSWithoutSDA;
7559 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7560 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7562 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)
7564 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7565 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7567 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7568 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7571 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7573 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7574 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7576 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7578 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7581 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7583 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7584 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7585 ret->setIteration(i,elt);
7591 //= MEDFileAnyTypeFieldMultiTS
7593 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7597 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7598 try:MEDFileFieldGlobsReal(fileName)
7600 MEDFileUtilities::CheckFileForRead(fileName);
7601 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7602 _content=BuildContentFrom(fid,fileName,loadAll);
7605 catch(INTERP_KERNEL::Exception& e)
7610 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7612 med_field_type typcha;
7613 std::vector<std::string> infos;
7616 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7617 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7622 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7627 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7632 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] !";
7633 throw INTERP_KERNEL::Exception(oss.str().c_str());
7636 ret->setDtUnit(dtunit.c_str());
7640 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7642 med_field_type typcha;
7644 std::vector<std::string> infos;
7645 std::string dtunit,fieldName;
7646 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7647 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7652 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7657 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7662 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] !";
7663 throw INTERP_KERNEL::Exception(oss.str().c_str());
7666 ret->setDtUnit(dtunit.c_str());
7670 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7673 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7674 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7676 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7677 ret->setFileName(fileName);
7678 ret->_content=c; c->incrRef();
7681 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7683 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7684 ret->setFileName(fileName);
7685 ret->_content=c; c->incrRef();
7688 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7691 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7692 try:MEDFileFieldGlobsReal(fileName)
7694 MEDFileUtilities::CheckFileForRead(fileName);
7695 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7696 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7699 catch(INTERP_KERNEL::Exception& e)
7704 //= MEDFileIntFieldMultiTSWithoutSDA
7706 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)
7708 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7711 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7715 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7719 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)
7720 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7723 catch(INTERP_KERNEL::Exception& e)
7727 * \param [in] fieldId field id in C mode
7729 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7730 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7733 catch(INTERP_KERNEL::Exception& e)
7736 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7738 return new MEDFileIntField1TSWithoutSDA;
7741 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7744 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7745 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7747 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7750 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7752 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7755 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7757 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7760 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7762 return new MEDFileIntFieldMultiTSWithoutSDA;
7765 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7767 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7768 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7770 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7772 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7775 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7777 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7778 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7779 ret->setIteration(i,elt);
7785 //= MEDFileAnyTypeFieldMultiTS
7788 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7789 * that has been read from a specified MED file.
7790 * \param [in] fileName - the name of the MED file to read.
7791 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7792 * is to delete this field using decrRef() as it is no more needed.
7793 * \throw If reading the file fails.
7795 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7797 MEDFileUtilities::CheckFileForRead(fileName);
7798 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7799 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7800 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7801 ret->loadGlobals(fid);
7806 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7807 * that has been read from a specified MED file.
7808 * \param [in] fileName - the name of the MED file to read.
7809 * \param [in] fieldName - the name of the field to read.
7810 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7811 * is to delete this field using decrRef() as it is no more needed.
7812 * \throw If reading the file fails.
7813 * \throw If there is no field named \a fieldName in the file.
7815 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7817 MEDFileUtilities::CheckFileForRead(fileName);
7818 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7819 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7820 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7821 ret->loadGlobals(fid);
7826 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7827 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7829 * \warning this is a shallow copy constructor
7831 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7833 if(!shallowCopyOfContent)
7835 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7836 otherPtr->incrRef();
7837 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7841 _content=other.shallowCpy();
7845 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7847 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7849 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7853 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7855 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7857 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7861 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7863 return contentNotNullBase()->getPflsReallyUsed2();
7866 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7868 return contentNotNullBase()->getLocsReallyUsed2();
7871 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7873 return contentNotNullBase()->getPflsReallyUsedMulti2();
7876 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7878 return contentNotNullBase()->getLocsReallyUsedMulti2();
7881 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7883 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7886 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7888 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7891 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7893 return contentNotNullBase()->getNumberOfTS();
7896 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7898 contentNotNullBase()->eraseEmptyTS();
7901 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7903 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7906 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7908 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7911 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7913 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7914 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7919 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7921 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7922 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7927 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7929 return contentNotNullBase()->getIterations();
7932 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7934 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7935 pushBackTimeStep(*it);
7938 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7941 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7942 checkCoherencyOfType(f1ts);
7944 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7945 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7947 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7948 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7949 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7950 _content->pushBackTimeStep(cSafe);
7951 appendGlobs(*f1ts,1e-12);
7954 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7956 contentNotNullBase()->synchronizeNameScope();
7959 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7961 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7964 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7966 return contentNotNullBase()->getPosGivenTime(time,eps);
7969 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7971 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7974 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7976 return contentNotNullBase()->getTypesOfFieldAvailable();
7979 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)
7981 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7984 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7986 return contentNotNullBase()->getName();
7989 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7991 contentNotNullBase()->setName(name);
7994 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7996 return contentNotNullBase()->getDtUnit();
7999 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
8001 contentNotNullBase()->setDtUnit(dtUnit);
8004 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8006 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8009 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
8011 return contentNotNullBase()->getTimeSteps(ret1);
8014 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
8016 return contentNotNullBase()->getMeshName();
8019 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
8021 contentNotNullBase()->setMeshName(newMeshName);
8024 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8026 return contentNotNullBase()->changeMeshNames(modifTab);
8029 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8031 return contentNotNullBase()->getInfo();
8034 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8036 return contentNotNullBase()->setInfo(info);
8039 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8041 const std::vector<std::string> ret=getInfo();
8042 return (int)ret.size();
8045 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8047 writeGlobals(fid,*this);
8048 contentNotNullBase()->writeLL(fid,*this);
8052 * Writes \a this field into a MED file specified by its name.
8053 * \param [in] fileName - the MED file name.
8054 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8055 * - 2 - erase; an existing file is removed.
8056 * - 1 - append; same data should not be present in an existing file.
8057 * - 0 - overwrite; same data present in an existing file is overwritten.
8058 * \throw If the field name is not set.
8059 * \throw If no field data is set.
8060 * \throw If \a mode == 1 and the same data is present in an existing file.
8062 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8064 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8065 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8070 * This method alloc the arrays and load potentially huge arrays contained in this field.
8071 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8072 * This method can be also called to refresh or reinit values from a file.
8074 * \throw If the fileName is not set or points to a non readable MED file.
8076 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8078 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8079 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8083 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8084 * But once data loaded once, this method does nothing.
8086 * \throw If the fileName is not set or points to a non readable MED file.
8087 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
8089 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8091 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8092 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8096 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8097 * This method does not release arrays set outside the context of a MED file.
8099 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8101 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
8103 contentNotNullBase()->releaseArrays();
8106 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8108 std::ostringstream oss;
8109 contentNotNullBase()->simpleRepr(0,oss,-1);
8110 simpleReprGlobs(oss);
8114 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8117 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8118 ret+=_content->getHeapMemorySize();
8119 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8123 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8124 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8125 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8127 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8129 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8131 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8132 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8133 std::size_t sz(contentsSplit.size());
8134 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8135 for(std::size_t i=0;i<sz;i++)
8137 ret[i]=shallowCpy();
8138 ret[i]->_content=contentsSplit[i];
8144 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8145 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8147 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8149 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8151 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8152 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8153 std::size_t sz(contentsSplit.size());
8154 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8155 for(std::size_t i=0;i<sz;i++)
8157 ret[i]=shallowCpy();
8158 ret[i]->_content=contentsSplit[i];
8163 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8165 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8166 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8167 ret->_content=_content->deepCpy();
8168 ret->deepCpyGlobs(*this);
8172 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8178 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8179 * \param [in] iteration - the iteration number of a required time step.
8180 * \param [in] order - the iteration order number of required time step.
8181 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8182 * delete this field using decrRef() as it is no more needed.
8183 * \throw If there is no required time step in \a this field.
8185 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8187 int pos=getPosOfTimeStep(iteration,order);
8188 return getTimeStepAtPos(pos);
8192 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8193 * \param [in] time - the time of the time step of interest.
8194 * \param [in] eps - a precision used to compare time values.
8195 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8196 * delete this field using decrRef() as it is no more needed.
8197 * \throw If there is no required time step in \a this field.
8199 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8201 int pos=getPosGivenTime(time,eps);
8202 return getTimeStepAtPos(pos);
8206 * 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.
8207 * The float64 value of time attached to the pair of integers are not considered here.
8209 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8210 * \throw If there is a null pointer in \a vectFMTS.
8212 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8214 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8215 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8216 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8217 while(!lstFMTS.empty())
8219 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8220 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8222 throw INTERP_KERNEL::Exception(msg);
8223 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8224 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8225 elt.push_back(curIt); it=lstFMTS.erase(it);
8226 while(it!=lstFMTS.end())
8230 throw INTERP_KERNEL::Exception(msg);
8231 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8233 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8243 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8244 * All returned instances in a subvector can be safely loaded, rendered along time
8245 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8246 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8247 * 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).
8248 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8249 * 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.
8251 * \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().
8252 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8254 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8255 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8256 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8257 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8258 * \throw If mesh is null.
8259 * \throw If an element in \a vectFMTS is null.
8260 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8262 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
8264 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8266 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8267 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8268 if(vectFMTS.empty())
8270 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8271 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8273 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8274 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8275 for(;it!=vectFMTS.end();it++,i++)
8277 TypeOfField tof0,tof1;
8278 int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
8282 vectFMTSNotNodes.push_back(*it);
8284 vectFMTSNodes.push_back(*it);
8287 vectFMTSNotNodes.push_back(*it);
8289 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8290 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8292 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8295 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8298 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8299 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8300 ret[i].push_back(*it2);
8303 std::vector<MEDFileAnyTypeFieldMultiTS *> ret0(1,*it2);
8304 ret.push_back(ret0);
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.
8313 * \param [out] cmps - same size than the returned vector.
8315 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception)
8317 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8318 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8319 while(!lstFMTS.empty())
8321 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8322 MEDFileAnyTypeFieldMultiTS *ref(*it);
8323 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8324 elt.push_back(ref); it=lstFMTS.erase(it);
8325 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mesh,ref));
8326 while(it!=lstFMTS.end())
8328 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8329 if(cmp->isEqual(ref))
8330 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8334 ret.push_back(elt); cmps.push_back(cmp);
8340 * 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.
8341 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8343 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8344 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8345 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8346 * \thorw If \a f0 and \a f1 do not have the same times steps.
8347 * \throw If mesh is null.
8348 * \throw If \a f0 or \a f1 is null.
8349 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8351 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception)
8354 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8356 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8357 if(f0->getMeshName()!=mesh->getName())
8359 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8360 throw INTERP_KERNEL::Exception(oss.str().c_str());
8362 if(f1->getMeshName()!=mesh->getName())
8364 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8365 throw INTERP_KERNEL::Exception(oss.str().c_str());
8367 int nts=f0->getNumberOfTS();
8368 if(nts!=f1->getNumberOfTS())
8369 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8372 for(int i=0;i<nts;i++)
8374 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8375 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8376 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8377 if(tofs0.size()!=1 || tofs1.size()!=1)
8378 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8381 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8382 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8385 { tof0=tofs0[0]; tof1=tofs1[0]; }
8386 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8388 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() << ") !";
8389 throw INTERP_KERNEL::Exception(oss.str().c_str());
8391 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8393 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() << ") !";
8394 throw INTERP_KERNEL::Exception(oss.str().c_str());
8396 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8398 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() << ") !";
8399 throw INTERP_KERNEL::Exception(oss.str().c_str());
8405 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8407 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8410 //= MEDFileFieldMultiTS
8413 * Returns a new empty instance of MEDFileFieldMultiTS.
8414 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8415 * is to delete this field using decrRef() as it is no more needed.
8417 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8419 return new MEDFileFieldMultiTS;
8423 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8424 * that has been read from a specified MED file.
8425 * \param [in] fileName - the name of the MED file to read.
8426 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8427 * is to delete this field using decrRef() as it is no more needed.
8428 * \throw If reading the file fails.
8430 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8432 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8433 ret->contentNotNull();//to check that content type matches with \a this type.
8438 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8439 * that has been read from a specified MED file.
8440 * \param [in] fileName - the name of the MED file to read.
8441 * \param [in] fieldName - the name of the field to read.
8442 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8443 * is to delete this field using decrRef() as it is no more needed.
8444 * \throw If reading the file fails.
8445 * \throw If there is no field named \a fieldName in the file.
8447 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8449 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8450 ret->contentNotNull();//to check that content type matches with \a this type.
8455 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8456 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8458 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8459 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8460 * \warning this is a shallow copy constructor
8461 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8462 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8463 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8464 * is to delete this field using decrRef() as it is no more needed.
8466 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8468 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8471 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8473 return new MEDFileFieldMultiTS(*this);
8476 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8479 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8480 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8482 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8486 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8487 * following the given input policy.
8489 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8490 * By default (true) the globals are deeply copied.
8491 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8493 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8495 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8496 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8499 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8501 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8502 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8503 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8506 ret=MEDFileIntFieldMultiTS::New();
8508 ret->deepCpyGlobs(*this);
8510 ret->shallowCpyGlobs(*this);
8515 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8516 * \param [in] pos - a time step id.
8517 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8518 * delete this field using decrRef() as it is no more needed.
8519 * \throw If \a pos is not a valid time step id.
8521 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8523 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8526 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8527 throw INTERP_KERNEL::Exception(oss.str().c_str());
8529 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8532 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8533 ret->shallowCpyGlobs(*this);
8536 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8537 throw INTERP_KERNEL::Exception(oss.str().c_str());
8541 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8542 * mesh entities of a given dimension of the first mesh in MED file.
8543 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8544 * \param [in] type - a spatial discretization of interest.
8545 * \param [in] iteration - the iteration number of a required time step.
8546 * \param [in] order - the iteration order number of required time step.
8547 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8548 * \param [in] renumPol - specifies how to permute values of the result field according to
8549 * the optional numbers of cells and nodes, if any. The valid values are
8550 * - 0 - do not permute.
8551 * - 1 - permute cells.
8552 * - 2 - permute nodes.
8553 * - 3 - permute cells and nodes.
8555 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8556 * caller is to delete this field using decrRef() as it is no more needed.
8557 * \throw If the MED file is not readable.
8558 * \throw If there is no mesh in the MED file.
8559 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8560 * \throw If no field values of the required parameters are available.
8562 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8564 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8565 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8567 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8568 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8569 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8570 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8575 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8576 * the top level cells of the first mesh in MED file.
8577 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8578 * \param [in] type - a spatial discretization of interest.
8579 * \param [in] iteration - the iteration number of a required time step.
8580 * \param [in] order - the iteration order number of required time step.
8581 * \param [in] renumPol - specifies how to permute values of the result field according to
8582 * the optional numbers of cells and nodes, if any. The valid values are
8583 * - 0 - do not permute.
8584 * - 1 - permute cells.
8585 * - 2 - permute nodes.
8586 * - 3 - permute cells and nodes.
8588 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8589 * caller is to delete this field using decrRef() as it is no more needed.
8590 * \throw If the MED file is not readable.
8591 * \throw If there is no mesh in the MED file.
8592 * \throw If no field values of the required parameters are available.
8594 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8596 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8597 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8599 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8600 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8601 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8602 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8607 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8609 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8610 * \param [in] type - a spatial discretization of interest.
8611 * \param [in] iteration - the iteration number of a required time step.
8612 * \param [in] order - the iteration order number of required time step.
8613 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8614 * \param [in] mesh - the supporting mesh.
8615 * \param [in] renumPol - specifies how to permute values of the result field according to
8616 * the optional numbers of cells and nodes, if any. The valid values are
8617 * - 0 - do not permute.
8618 * - 1 - permute cells.
8619 * - 2 - permute nodes.
8620 * - 3 - permute cells and nodes.
8622 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8623 * caller is to delete this field using decrRef() as it is no more needed.
8624 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8625 * \throw If no field of \a this is lying on \a mesh.
8626 * \throw If no field values of the required parameters are available.
8628 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8630 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8631 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8633 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8634 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8635 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8636 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8641 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8643 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8644 * \param [in] type - a spatial discretization of the new field.
8645 * \param [in] iteration - the iteration number of a required time step.
8646 * \param [in] order - the iteration order number of required time step.
8647 * \param [in] mesh - the supporting mesh.
8648 * \param [in] renumPol - specifies how to permute values of the result field according to
8649 * the optional numbers of cells and nodes, if any. The valid values are
8650 * - 0 - do not permute.
8651 * - 1 - permute cells.
8652 * - 2 - permute nodes.
8653 * - 3 - permute cells and nodes.
8655 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8656 * caller is to delete this field using decrRef() as it is no more needed.
8657 * \throw If no field of \a this is lying on \a mesh.
8658 * \throw If no field values of the required parameters are available.
8660 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8662 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8663 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8665 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8666 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8667 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8668 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8673 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8674 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8675 * This method is useful for MED2 file format when field on different mesh was autorized.
8677 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8679 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8680 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8682 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8683 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8684 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8685 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8690 * Returns values and a profile of the field of a given type, of a given time step,
8691 * lying on a given support.
8692 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8693 * \param [in] type - a spatial discretization of the field.
8694 * \param [in] iteration - the iteration number of a required time step.
8695 * \param [in] order - the iteration order number of required time step.
8696 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8697 * \param [in] mesh - the supporting mesh.
8698 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8699 * field of interest lies on. If the field lies on all entities of the given
8700 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8701 * using decrRef() as it is no more needed.
8702 * \param [in] glob - the global data storing profiles and localization.
8703 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8704 * field. The caller is to delete this array using decrRef() as it is no more needed.
8705 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8706 * \throw If no field of \a this is lying on \a mesh.
8707 * \throw If no field values of the required parameters are available.
8709 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8711 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8712 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8714 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8715 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8716 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8719 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8721 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8723 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8724 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8726 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 !");
8730 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8732 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8734 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8735 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8737 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 !");
8742 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8743 * the given field is checked if its elements are sorted suitable for writing to MED file
8744 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8745 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8746 * \param [in] field - the field to add to \a this.
8747 * \throw If the name of \a field is empty.
8748 * \throw If the data array of \a field is not set.
8749 * \throw If existing time steps have different name or number of components than \a field.
8750 * \throw If the underlying mesh of \a field has no name.
8751 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8753 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8755 const DataArrayDouble *arr=0;
8757 arr=field->getArray();
8758 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8762 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8763 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8764 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8767 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8768 * A new profile is added only if no equal profile is missing.
8769 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8770 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8771 * \param [in] mesh - the supporting mesh of \a field.
8772 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8773 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8774 * \throw If either \a field or \a mesh or \a profile has an empty name.
8775 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8776 * \throw If the data array of \a field is not set.
8777 * \throw If the data array of \a this is already allocated but has different number of
8778 * components than \a field.
8779 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8780 * \sa setFieldNoProfileSBT()
8782 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8784 const DataArrayDouble *arr=0;
8786 arr=field->getArray();
8787 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8790 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8792 _content=new MEDFileFieldMultiTSWithoutSDA;
8795 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8796 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8799 catch(INTERP_KERNEL::Exception& e)
8802 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8803 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8806 catch(INTERP_KERNEL::Exception& e)
8809 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8813 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)
8815 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8818 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8820 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8823 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)
8825 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8828 //= MEDFileAnyTypeFieldMultiTSIterator
8830 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8835 _nb_iter=fmts->getNumberOfTS();
8839 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8843 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8845 if(_iter_id<_nb_iter)
8847 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8849 return fmts->getTimeStepAtPos(_iter_id++);
8857 //= MEDFileIntFieldMultiTS
8860 * Returns a new empty instance of MEDFileFieldMultiTS.
8861 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8862 * is to delete this field using decrRef() as it is no more needed.
8864 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8866 return new MEDFileIntFieldMultiTS;
8870 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8871 * that has been read from a specified MED file.
8872 * \param [in] fileName - the name of the MED file to read.
8873 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8874 * is to delete this field using decrRef() as it is no more needed.
8875 * \throw If reading the file fails.
8877 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8879 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8880 ret->contentNotNull();//to check that content type matches with \a this type.
8885 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8886 * that has been read from a specified MED file.
8887 * \param [in] fileName - the name of the MED file to read.
8888 * \param [in] fieldName - the name of the field to read.
8889 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8890 * is to delete this field using decrRef() as it is no more needed.
8891 * \throw If reading the file fails.
8892 * \throw If there is no field named \a fieldName in the file.
8894 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8896 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8897 ret->contentNotNull();//to check that content type matches with \a this type.
8902 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8903 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8905 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8906 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8907 * \warning this is a shallow copy constructor
8908 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8909 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8910 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8911 * is to delete this field using decrRef() as it is no more needed.
8913 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8915 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8919 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8920 * following the given input policy.
8922 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8923 * By default (true) the globals are deeply copied.
8924 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8926 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8928 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8929 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8932 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8934 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8935 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8936 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8939 ret=MEDFileFieldMultiTS::New();
8941 ret->deepCpyGlobs(*this);
8943 ret->shallowCpyGlobs(*this);
8947 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8949 return new MEDFileIntFieldMultiTS(*this);
8952 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8955 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8956 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8958 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8962 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8963 * mesh entities of a given dimension of the first mesh in MED file.
8964 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8965 * \param [in] type - a spatial discretization of interest.
8966 * \param [in] iteration - the iteration number of a required time step.
8967 * \param [in] order - the iteration order number of required time step.
8968 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8969 * \param [out] arrOut - the DataArrayInt containing values of field.
8970 * \param [in] renumPol - specifies how to permute values of the result field according to
8971 * the optional numbers of cells and nodes, if any. The valid values are
8972 * - 0 - do not permute.
8973 * - 1 - permute cells.
8974 * - 2 - permute nodes.
8975 * - 3 - permute cells and nodes.
8977 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8978 * caller is to delete this field using decrRef() as it is no more needed.
8979 * \throw If the MED file is not readable.
8980 * \throw If there is no mesh in the MED file.
8981 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8982 * \throw If no field values of the required parameters are available.
8984 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8986 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8987 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8989 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8990 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8991 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8992 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8997 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8998 * the top level cells of the first mesh in MED file.
8999 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9000 * \param [in] type - a spatial discretization of interest.
9001 * \param [in] iteration - the iteration number of a required time step.
9002 * \param [in] order - the iteration order number of required time step.
9003 * \param [out] arrOut - the DataArrayInt containing values of field.
9004 * \param [in] renumPol - specifies how to permute values of the result field according to
9005 * the optional numbers of cells and nodes, if any. The valid values are
9006 * - 0 - do not permute.
9007 * - 1 - permute cells.
9008 * - 2 - permute nodes.
9009 * - 3 - permute cells and nodes.
9011 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9012 * caller is to delete this field using decrRef() as it is no more needed.
9013 * \throw If the MED file is not readable.
9014 * \throw If there is no mesh in the MED file.
9015 * \throw If no field values of the required parameters are available.
9017 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9019 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9020 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9022 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9023 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9024 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
9025 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9030 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9032 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9033 * \param [in] type - a spatial discretization of interest.
9034 * \param [in] iteration - the iteration number of a required time step.
9035 * \param [in] order - the iteration order number of required time step.
9036 * \param [out] arrOut - the DataArrayInt containing values of field.
9037 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9038 * \param [in] mesh - the supporting mesh.
9039 * \param [in] renumPol - specifies how to permute values of the result field according to
9040 * the optional numbers of cells and nodes, if any. The valid values are
9041 * - 0 - do not permute.
9042 * - 1 - permute cells.
9043 * - 2 - permute nodes.
9044 * - 3 - permute cells and nodes.
9046 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9047 * caller is to delete this field using decrRef() as it is no more needed.
9048 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9049 * \throw If no field of \a this is lying on \a mesh.
9050 * \throw If no field values of the required parameters are available.
9052 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9054 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9055 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9057 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9058 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9059 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9060 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9065 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9067 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9068 * \param [in] type - a spatial discretization of the new field.
9069 * \param [in] iteration - the iteration number of a required time step.
9070 * \param [in] order - the iteration order number of required time step.
9071 * \param [in] mesh - the supporting mesh.
9072 * \param [out] arrOut - the DataArrayInt containing values of field.
9073 * \param [in] renumPol - specifies how to permute values of the result field according to
9074 * the optional numbers of cells and nodes, if any. The valid values are
9075 * - 0 - do not permute.
9076 * - 1 - permute cells.
9077 * - 2 - permute nodes.
9078 * - 3 - permute cells and nodes.
9080 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9081 * caller is to delete this field using decrRef() as it is no more needed.
9082 * \throw If no field of \a this is lying on \a mesh.
9083 * \throw If no field values of the required parameters are available.
9085 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9087 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9088 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9090 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9091 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9092 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9093 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9098 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9099 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9100 * This method is useful for MED2 file format when field on different mesh was autorized.
9102 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9104 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9105 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9107 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9108 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9109 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9110 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9115 * Returns values and a profile of the field of a given type, of a given time step,
9116 * lying on a given support.
9117 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9118 * \param [in] type - a spatial discretization of the field.
9119 * \param [in] iteration - the iteration number of a required time step.
9120 * \param [in] order - the iteration order number of required time step.
9121 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9122 * \param [in] mesh - the supporting mesh.
9123 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9124 * field of interest lies on. If the field lies on all entities of the given
9125 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9126 * using decrRef() as it is no more needed.
9127 * \param [in] glob - the global data storing profiles and localization.
9128 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9129 * field. The caller is to delete this array using decrRef() as it is no more needed.
9130 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9131 * \throw If no field of \a this is lying on \a mesh.
9132 * \throw If no field values of the required parameters are available.
9134 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
9136 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9137 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9139 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9140 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9141 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9145 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9146 * \param [in] pos - a time step id.
9147 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9148 * delete this field using decrRef() as it is no more needed.
9149 * \throw If \a pos is not a valid time step id.
9151 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
9153 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9156 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9157 throw INTERP_KERNEL::Exception(oss.str().c_str());
9159 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9162 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9163 ret->shallowCpyGlobs(*this);
9166 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9167 throw INTERP_KERNEL::Exception(oss.str().c_str());
9171 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9172 * the given field is checked if its elements are sorted suitable for writing to MED file
9173 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9174 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9175 * \param [in] field - the field to add to \a this.
9176 * \throw If the name of \a field is empty.
9177 * \throw If the data array of \a field is not set.
9178 * \throw If existing time steps have different name or number of components than \a field.
9179 * \throw If the underlying mesh of \a field has no name.
9180 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9182 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
9184 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9188 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9189 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9190 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9193 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9194 * A new profile is added only if no equal profile is missing.
9195 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9196 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9197 * \param [in] arrOfVals - the values of the field \a field used.
9198 * \param [in] mesh - the supporting mesh of \a field.
9199 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9200 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9201 * \throw If either \a field or \a mesh or \a profile has an empty name.
9202 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9203 * \throw If the data array of \a field is not set.
9204 * \throw If the data array of \a this is already allocated but has different number of
9205 * components than \a field.
9206 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9207 * \sa setFieldNoProfileSBT()
9209 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9211 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9214 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9216 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9218 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9219 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9221 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 !");
9225 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9227 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9229 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9230 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9232 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 !");
9236 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9238 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9241 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9245 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9246 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9249 catch(INTERP_KERNEL::Exception& e)
9252 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9253 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9256 catch(INTERP_KERNEL::Exception& e)
9259 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9261 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9266 MEDFileFields *MEDFileFields::New()
9268 return new MEDFileFields;
9271 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9273 return new MEDFileFields(fileName,loadAll);
9276 std::size_t MEDFileFields::getHeapMemorySize() const
9278 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9279 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9280 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9281 ret+=(*it)->getHeapMemorySize();
9282 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9285 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9287 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9289 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9291 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9292 ret->_fields[i]=(*it)->deepCpy();
9294 ret->deepCpyGlobs(*this);
9298 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9300 return new MEDFileFields(*this);
9304 * 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
9305 * 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.
9306 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9308 * \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.
9309 * \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.
9311 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9313 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9315 std::set< std::pair<int,int> > s;
9316 bool firstShot=true;
9317 areThereSomeForgottenTS=false;
9318 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9320 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9322 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9323 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9325 { s=s1; firstShot=false; }
9328 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9330 areThereSomeForgottenTS=true;
9334 std::vector< std::pair<int,int> > ret;
9335 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9339 int MEDFileFields::getNumberOfFields() const
9341 return _fields.size();
9344 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9346 std::vector<std::string> ret(_fields.size());
9348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9350 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9353 ret[i]=f->getName();
9357 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9358 throw INTERP_KERNEL::Exception(oss.str().c_str());
9364 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9366 std::vector<std::string> ret;
9367 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9369 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9371 ret.push_back(cur->getMeshName());
9376 std::string MEDFileFields::simpleRepr() const
9378 std::ostringstream oss;
9379 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9384 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9386 int nbOfFields=getNumberOfFields();
9387 std::string startLine(bkOffset,' ');
9388 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9390 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9392 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9395 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9399 oss << startLine << " - not defined !" << std::endl;
9403 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9405 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9406 std::string chapter(17,'0'+i);
9407 oss << startLine << chapter << std::endl;
9410 cur->simpleRepr(bkOffset+2,oss,i);
9414 oss << startLine << " - not defined !" << std::endl;
9416 oss << startLine << chapter << std::endl;
9418 simpleReprGlobs(oss);
9421 MEDFileFields::MEDFileFields()
9425 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9426 try:MEDFileFieldGlobsReal(fileName)
9428 MEDFileUtilities::CheckFileForRead(fileName);
9429 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9430 int nbFields=MEDnField(fid);
9431 _fields.resize(nbFields);
9432 med_field_type typcha;
9433 for(int i=0;i<nbFields;i++)
9435 std::vector<std::string> infos;
9436 std::string fieldName,dtunit;
9437 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9442 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9447 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9452 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] !";
9453 throw INTERP_KERNEL::Exception(oss.str().c_str());
9457 loadAllGlobals(fid);
9459 catch(INTERP_KERNEL::Exception& e)
9464 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9467 writeGlobals(fid,*this);
9468 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9470 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9473 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9474 throw INTERP_KERNEL::Exception(oss.str().c_str());
9476 elt->writeLL(fid,*this);
9480 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9482 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9483 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9488 * This method alloc the arrays and load potentially huge arrays contained in this field.
9489 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9490 * This method can be also called to refresh or reinit values from a file.
9492 * \throw If the fileName is not set or points to a non readable MED file.
9494 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9496 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9497 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9499 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9501 elt->loadBigArraysRecursively(fid,*elt);
9506 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9507 * But once data loaded once, this method does nothing.
9509 * \throw If the fileName is not set or points to a non readable MED file.
9510 * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9512 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9514 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9515 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9517 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9519 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9524 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9525 * This method does not release arrays set outside the context of a MED file.
9527 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9529 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9531 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9532 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9534 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9536 elt->releaseArrays();
9540 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9542 std::vector<std::string> ret;
9543 std::set<std::string> ret2;
9544 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9546 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9547 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9548 if(ret2.find(*it2)==ret2.end())
9550 ret.push_back(*it2);
9557 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9559 std::vector<std::string> ret;
9560 std::set<std::string> ret2;
9561 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9563 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9564 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9565 if(ret2.find(*it2)==ret2.end())
9567 ret.push_back(*it2);
9574 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9576 std::vector<std::string> ret;
9577 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9579 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9580 ret.insert(ret.end(),tmp.begin(),tmp.end());
9585 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9587 std::vector<std::string> ret;
9588 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9590 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9591 ret.insert(ret.end(),tmp.begin(),tmp.end());
9596 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9598 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9599 (*it)->changePflsRefsNamesGen2(mapOfModif);
9602 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9604 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9605 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9608 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9610 _fields.resize(newSize);
9613 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9615 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9619 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9622 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9623 _fields.push_back(field->getContent());
9624 appendGlobs(*field,1e-12);
9627 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9630 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9631 if(i>=(int)_fields.size())
9632 _fields.resize(i+1);
9633 _fields[i]=field->getContent();
9634 appendGlobs(*field,1e-12);
9637 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9639 destroyFieldsAtPos(&i,&i+1);
9642 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9644 std::vector<bool> b(_fields.size(),true);
9645 for(const int *i=startIds;i!=endIds;i++)
9647 if(*i<0 || *i>=(int)_fields.size())
9649 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9650 throw INTERP_KERNEL::Exception(oss.str().c_str());
9654 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9656 for(std::size_t i=0;i<_fields.size();i++)
9658 fields[j++]=_fields[i];
9662 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9664 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9665 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9666 std::vector<bool> b(_fields.size(),true);
9668 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9670 if(k<0 || k>=(int)_fields.size())
9672 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9673 throw INTERP_KERNEL::Exception(oss.str().c_str());
9677 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9679 for(std::size_t i=0;i<_fields.size();i++)
9681 fields[j++]=_fields[i];
9685 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9688 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9690 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9692 ret=cur->changeMeshNames(modifTab) || ret;
9698 * \param [in] meshName the name of the mesh that will be renumbered.
9699 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9700 * This code corresponds to the distribution of types in the corresponding mesh.
9701 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9702 * \param [in] renumO2N the old to new renumber array.
9703 * \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
9706 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9709 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9711 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9714 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9720 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9722 if(i<0 || i>=(int)_fields.size())
9724 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9725 throw INTERP_KERNEL::Exception(oss.str().c_str());
9727 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9730 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9731 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9732 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9734 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9736 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9739 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9740 throw INTERP_KERNEL::Exception(oss.str().c_str());
9742 ret->shallowCpyGlobs(*this);
9747 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9748 * This method is accessible in python using __getitem__ with a list in input.
9749 * \return a new object that the caller should deal with.
9751 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9753 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9754 std::size_t sz=std::distance(startIds,endIds);
9755 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9757 for(const int *i=startIds;i!=endIds;i++,j++)
9759 if(*i<0 || *i>=(int)_fields.size())
9761 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9762 throw INTERP_KERNEL::Exception(oss.str().c_str());
9764 fields[j]=_fields[*i];
9766 ret->_fields=fields;
9770 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9772 return getFieldAtPos(getPosFromFieldName(fieldName));
9776 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9777 * This method can be seen as a filter applied on \a this, that returns an object containing
9778 * 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
9779 * shallow copied from \a this.
9781 * \param [in] meshName - the name of the mesh on w
9782 * \return a new object that the caller should deal with.
9784 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9786 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9787 ret->shallowCpyOnlyUsedGlobs(*this);
9788 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9790 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9793 if(cur->getMeshName()==meshName)
9796 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9797 ret->_fields.push_back(cur2);
9804 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9805 * Input time steps are specified using a pair of integer (iteration, order).
9806 * 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,
9807 * but for each multitimestep only the time steps in \a timeSteps are kept.
9808 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9810 * The returned object points to shallow copy of elements in \a this.
9812 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9813 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9814 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9816 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9818 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9819 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9821 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9824 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9825 ret->_fields.push_back(elt);
9827 ret->shallowCpyOnlyUsedGlobs(*this);
9832 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9834 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9836 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9837 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9839 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9842 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9843 if(elt->getNumberOfTS()!=0)
9844 ret->_fields.push_back(elt);
9846 ret->shallowCpyOnlyUsedGlobs(*this);
9850 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9852 return new MEDFileFieldsIterator(this);
9855 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9857 std::string tmp(fieldName);
9858 std::vector<std::string> poss;
9859 for(std::size_t i=0;i<_fields.size();i++)
9861 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9864 std::string fname(f->getName());
9868 poss.push_back(fname);
9871 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9872 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9874 throw INTERP_KERNEL::Exception(oss.str().c_str());
9877 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9882 _nb_iter=fs->getNumberOfFields();
9886 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9890 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9892 if(_iter_id<_nb_iter)
9894 MEDFileFields *fs(_fs);
9896 return fs->getFieldAtPos(_iter_id++);