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().c_str());
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().c_str());
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 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2347 int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2348 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2349 if(nbProfile>0 || nbProfile2>0)
2351 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2358 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2361 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2362 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2366 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2368 copyTinyInfoFrom(mesh);
2371 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2373 if(id>=(int)_pfls.size())
2375 _pfls[id]=DataArrayInt::New();
2376 int lgth=MEDprofileSizeByName(fid,pflName);
2377 _pfls[id]->setName(pflName);
2378 _pfls[id]->alloc(lgth,1);
2379 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2380 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2383 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2385 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2387 MEDprofileInfo(fid,i+1,pflName,&sz);
2388 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2389 if(i>=(int)_pfls.size())
2391 _pfls[i]=DataArrayInt::New();
2392 _pfls[i]->alloc(sz,1);
2393 _pfls[i]->setName(pflCpp.c_str());
2394 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2395 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2398 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2400 int nbOfPfls=_pfls.size();
2401 for(int i=0;i<nbOfPfls;i++)
2403 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2404 cpy->applyLin(1,1,0);
2405 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2406 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2407 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2410 int nbOfLocs=_locs.size();
2411 for(int i=0;i<nbOfLocs;i++)
2412 _locs[i]->writeLL(fid);
2415 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2417 std::vector<std::string> pfls=getPfls();
2418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2420 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2423 _pfls.push_back(*it);
2427 int id=std::distance(pfls.begin(),it2);
2428 if(!(*it)->isEqual(*_pfls[id]))
2430 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2431 throw INTERP_KERNEL::Exception(oss.str().c_str());
2435 std::vector<std::string> locs=getLocs();
2436 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2438 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2441 _locs.push_back(*it);
2445 int id=std::distance(locs.begin(),it2);
2446 if(!(*it)->isEqual(*_locs[id],eps))
2448 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2449 throw INTERP_KERNEL::Exception(oss.str().c_str());
2455 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2457 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2458 getProfile((*it).c_str());
2461 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2463 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2464 getLocalization((*it).c_str());
2467 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2469 std::vector<std::string> profiles=real.getPflsReallyUsed();
2470 int sz=profiles.size();
2472 for(int i=0;i<sz;i++)
2473 loadProfileInFile(fid,i,profiles[i].c_str());
2475 std::vector<std::string> locs=real.getLocsReallyUsed();
2478 for(int i=0;i<sz;i++)
2479 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2482 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2484 int nProfil=MEDnProfile(fid);
2485 for(int i=0;i<nProfil;i++)
2486 loadProfileInFile(fid,i);
2487 int sz=MEDnLocalization(fid);
2489 for(int i=0;i<sz;i++)
2491 _locs[i]=MEDFileFieldLoc::New(fid,i);
2495 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2497 return new MEDFileFieldGlobs(fname);
2500 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2502 return new MEDFileFieldGlobs;
2505 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2507 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2509 ret+=(*it)->getHeapMemorySize();
2510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2511 ret+=(*it)->getHeapMemorySize();
2515 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2517 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2519 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2521 if((const DataArrayInt *)*it)
2522 ret->_pfls[i]=(*it)->deepCpy();
2525 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2527 if((const MEDFileFieldLoc*)*it)
2528 ret->_locs[i]=(*it)->deepCpy();
2534 * \throw if a profile in \a pfls in not in \a this.
2535 * \throw if a localization in \a locs in not in \a this.
2536 * \sa MEDFileFieldGlobs::deepCpyPart
2538 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2540 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2541 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2543 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2545 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2547 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2548 ret->_pfls.push_back(pfl2);
2550 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2552 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2554 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2556 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2557 ret->_locs.push_back(loc2);
2559 ret->setFileName(getFileName());
2564 * \throw if a profile in \a pfls in not in \a this.
2565 * \throw if a localization in \a locs in not in \a this.
2566 * \sa MEDFileFieldGlobs::shallowCpyPart
2568 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2570 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2571 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2573 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2575 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2576 ret->_pfls.push_back(pfl->deepCpy());
2578 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2580 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2582 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2583 ret->_locs.push_back(loc->deepCpy());
2585 ret->setFileName(getFileName());
2589 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2593 MEDFileFieldGlobs::MEDFileFieldGlobs()
2597 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2601 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2603 oss << "Profiles :\n";
2604 std::size_t n=_pfls.size();
2605 for(std::size_t i=0;i<n;i++)
2607 oss << " - #" << i << " ";
2608 const DataArrayInt *pfl=_pfls[i];
2610 oss << "\"" << pfl->getName() << "\"\n";
2615 oss << "Localizations :\n";
2616 for(std::size_t i=0;i<n;i++)
2618 oss << " - #" << i << " ";
2619 const MEDFileFieldLoc *loc=_locs[i];
2621 loc->simpleRepr(oss);
2627 void MEDFileFieldGlobs::setFileName(const char *fileName)
2629 _file_name=fileName;
2632 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2634 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2636 DataArrayInt *elt(*it);
2639 std::string name(elt->getName());
2640 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2642 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2644 elt->setName((*it2).second.c_str());
2652 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2654 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2656 MEDFileFieldLoc *elt(*it);
2659 std::string name(elt->getName());
2660 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2662 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2664 elt->setName((*it2).second.c_str());
2672 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2674 if(locId<0 || locId>=(int)_locs.size())
2675 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2676 return _locs[locId]->getNbOfGaussPtPerCell();
2679 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2681 return getLocalizationFromId(getLocalizationId(locName));
2684 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2686 if(locId<0 || locId>=(int)_locs.size())
2687 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2688 return *_locs[locId];
2691 namespace ParaMEDMEMImpl
2696 LocFinder(const char *loc):_loc(loc) { }
2697 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2705 PflFinder(const std::string& pfl):_pfl(pfl) { }
2706 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2708 const std::string& _pfl;
2712 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2714 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2717 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2718 for(it=_locs.begin();it!=_locs.end();it++)
2719 oss << "\"" << (*it)->getName() << "\", ";
2720 throw INTERP_KERNEL::Exception(oss.str().c_str());
2722 return std::distance(_locs.begin(),it);
2726 * The returned value is never null.
2728 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2730 std::string pflNameCpp(pflName);
2731 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2734 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2735 for(it=_pfls.begin();it!=_pfls.end();it++)
2736 oss << "\"" << (*it)->getName() << "\", ";
2737 throw INTERP_KERNEL::Exception(oss.str().c_str());
2742 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2744 if(pflId<0 || pflId>=(int)_pfls.size())
2745 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2746 return _pfls[pflId];
2749 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2751 if(locId<0 || locId>=(int)_locs.size())
2752 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2753 return *_locs[locId];
2756 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2758 return getLocalizationFromId(getLocalizationId(locName));
2762 * The returned value is never null.
2764 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2766 std::string pflNameCpp(pflName);
2767 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2770 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2771 for(it=_pfls.begin();it!=_pfls.end();it++)
2772 oss << "\"" << (*it)->getName() << "\", ";
2773 throw INTERP_KERNEL::Exception(oss.str().c_str());
2778 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2780 if(pflId<0 || pflId>=(int)_pfls.size())
2781 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2782 return _pfls[pflId];
2785 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2787 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2789 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2791 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2792 newPfls.push_back(*it);
2797 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2799 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2801 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2803 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2804 newLocs.push_back(*it);
2809 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2811 int sz=_pfls.size();
2812 std::vector<std::string> ret(sz);
2813 for(int i=0;i<sz;i++)
2814 ret[i]=_pfls[i]->getName();
2818 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2820 int sz=_locs.size();
2821 std::vector<std::string> ret(sz);
2822 for(int i=0;i<sz;i++)
2823 ret[i]=_locs[i]->getName();
2827 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2829 std::vector<std::string> v=getPfls();
2830 std::string s(pflName);
2831 return std::find(v.begin(),v.end(),s)!=v.end();
2834 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2836 std::vector<std::string> v=getLocs();
2837 std::string s(locName);
2838 return std::find(v.begin(),v.end(),s)!=v.end();
2841 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2843 std::map<int,std::vector<int> > m;
2845 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2847 const DataArrayInt *tmp=(*it);
2850 m[tmp->getHashCode()].push_back(i);
2853 std::vector< std::vector<int> > ret;
2854 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2856 if((*it2).second.size()>1)
2858 std::vector<int> ret0;
2859 bool equalityOrNot=false;
2860 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2862 std::vector<int>::const_iterator it4=it3; it4++;
2863 for(;it4!=(*it2).second.end();it4++)
2865 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2868 ret0.push_back(*it3);
2869 ret0.push_back(*it4);
2875 ret.push_back(ret0);
2881 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2883 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2886 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2888 std::string name(pfl->getName());
2890 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2891 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2892 if(name==(*it)->getName())
2894 if(!pfl->isEqual(*(*it)))
2896 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2897 throw INTERP_KERNEL::Exception(oss.str().c_str());
2901 _pfls.push_back(pfl);
2904 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)
2906 std::string name(locName);
2908 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2909 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2910 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2911 if((*it)->isName(locName))
2913 if(!(*it)->isEqual(*obj,1e-12))
2915 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2916 throw INTERP_KERNEL::Exception(oss.str().c_str());
2919 _locs.push_back(obj);
2922 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2924 std::vector<std::string> names=getPfls();
2925 return CreateNewNameNotIn("NewPfl_",names);
2928 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2930 std::vector<std::string> names=getLocs();
2931 return CreateNewNameNotIn("NewLoc_",names);
2934 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2936 for(std::size_t sz=0;sz<100000;sz++)
2938 std::ostringstream tryName;
2939 tryName << prefix << sz;
2940 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2941 return tryName.str();
2943 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2947 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2948 * \param [in] fname - the file name.
2950 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2955 * Creates an empty MEDFileFieldGlobsReal.
2957 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2961 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2964 if((const MEDFileFieldGlobs *)_globals)
2965 ret+=_globals->getHeapMemorySize();
2970 * Returns a string describing profiles and Gauss points held in \a this.
2971 * \return std::string - the description string.
2973 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2975 const MEDFileFieldGlobs *glob=_globals;
2976 std::ostringstream oss2; oss2 << glob;
2977 std::string stars(oss2.str().length(),'*');
2978 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2980 glob->simpleRepr(oss);
2982 oss << "NO GLOBAL INFORMATION !\n";
2985 void MEDFileFieldGlobsReal::resetContent()
2987 _globals=MEDFileFieldGlobs::New();
2990 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2995 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2996 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2998 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3000 _globals=other._globals;
3004 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3005 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3007 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3009 const MEDFileFieldGlobs *otherg(other._globals);
3012 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3016 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3017 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3019 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3021 const MEDFileFieldGlobs *otherg(other._globals);
3024 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3027 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3029 _globals=other._globals;
3030 if((const MEDFileFieldGlobs *)_globals)
3031 _globals=other._globals->deepCpy();
3035 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3036 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3037 * \param [in] eps - a precision used to compare Gauss points with same name held by
3038 * \a this and \a other MEDFileFieldGlobsReal.
3039 * \throw If \a this and \a other hold profiles with equal names but different ids.
3040 * \throw If \a this and \a other hold different Gauss points with equal names.
3042 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3044 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3045 if(thisGlobals==otherGlobals)
3049 _globals=other._globals;
3052 _globals->appendGlobs(*other._globals,eps);
3055 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3057 checkGlobsPflsPartCoherency();
3058 checkGlobsLocsPartCoherency();
3061 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3063 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3066 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3068 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3071 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3073 contentNotNull()->loadProfileInFile(fid,id,pflName);
3076 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3078 contentNotNull()->loadProfileInFile(fid,id);
3081 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3083 contentNotNull()->loadGlobals(fid,*this);
3086 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3088 contentNotNull()->loadAllGlobals(fid);
3091 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3093 contentNotNull()->writeGlobals(fid,opt);
3097 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3098 * or getPflsReallyUsedMulti().
3099 * \return std::vector<std::string> - a sequence of names of all profiles.
3101 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3103 return contentNotNull()->getPfls();
3107 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3108 * or getLocsReallyUsedMulti().
3109 * \return std::vector<std::string> - a sequence of names of all localizations.
3111 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3113 return contentNotNull()->getLocs();
3117 * Checks if the profile with a given name exists.
3118 * \param [in] pflName - the profile name of interest.
3119 * \return bool - \c true if the profile named \a pflName exists.
3121 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3123 return contentNotNull()->existsPfl(pflName);
3127 * Checks if the localization with a given name exists.
3128 * \param [in] locName - the localization name of interest.
3129 * \return bool - \c true if the localization named \a locName exists.
3131 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3133 return contentNotNull()->existsLoc(locName);
3136 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3138 return contentNotNull()->createNewNameOfPfl();
3141 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3143 return contentNotNull()->createNewNameOfLoc();
3147 * Sets the name of a MED file.
3148 * \param [inout] fileName - the file name.
3150 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3152 contentNotNull()->setFileName(fileName);
3156 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3157 * in the same order.
3158 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3159 * Each item of this sequence is a vector containing ids of equal profiles.
3161 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3163 return contentNotNull()->whichAreEqualProfiles();
3167 * Finds equal localizations.
3168 * \param [in] eps - a precision used to compare real values of the localizations.
3169 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3170 * Each item of this sequence is a vector containing ids of equal localizations.
3172 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3174 return contentNotNull()->whichAreEqualLocs(eps);
3178 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3179 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3180 * this sequence is a pair whose
3181 * - the first item is a vector of profile names to replace by the second item,
3182 * - the second item is a profile name to replace every profile name of the first item.
3184 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3186 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3190 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3191 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3192 * this sequence is a pair whose
3193 * - the first item is a vector of localization names to replace by the second item,
3194 * - the second item is a localization name to replace every localization name of the first item.
3196 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3198 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3202 * Replaces references to some profiles (a reference is a profile name) by references
3203 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3204 * them-selves accordingly. <br>
3205 * This method is a generalization of changePflName().
3206 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3207 * this sequence is a pair whose
3208 * - the first item is a vector of profile names to replace by the second item,
3209 * - the second item is a profile name to replace every profile of the first item.
3210 * \sa changePflsRefsNamesGen()
3211 * \sa changePflName()
3213 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3215 changePflsRefsNamesGen(mapOfModif);
3216 changePflsNamesInStruct(mapOfModif);
3220 * Replaces references to some localizations (a reference is a localization name) by references
3221 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3222 * them-selves accordingly. <br>
3223 * This method is a generalization of changeLocName().
3224 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3225 * this sequence is a pair whose
3226 * - the first item is a vector of localization names to replace by the second item,
3227 * - the second item is a localization name to replace every localization of the first item.
3228 * \sa changeLocsRefsNamesGen()
3229 * \sa changeLocName()
3231 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3233 changeLocsRefsNamesGen(mapOfModif);
3234 changeLocsNamesInStruct(mapOfModif);
3238 * Renames the profile having a given name and updates references to this profile.
3239 * \param [in] oldName - the name of the profile to rename.
3240 * \param [in] newName - a new name of the profile.
3241 * \sa changePflsNames().
3243 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3245 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3246 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3248 changePflsNames(mapOfModif);
3252 * Renames the localization having a given name and updates references to this localization.
3253 * \param [in] oldName - the name of the localization to rename.
3254 * \param [in] newName - a new name of the localization.
3255 * \sa changeLocsNames().
3257 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3259 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3260 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3262 changeLocsNames(mapOfModif);
3266 * Removes duplicated profiles. Returns a map used to update references to removed
3267 * profiles via changePflsRefsNamesGen().
3268 * Equal profiles are found using whichAreEqualProfiles().
3269 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3270 * a sequence describing the performed replacements of profiles. Each element of
3271 * this sequence is a pair whose
3272 * - the first item is a vector of profile names replaced by the second item,
3273 * - the second item is a profile name replacing every profile of the first item.
3275 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3277 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3278 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3280 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3282 std::vector< std::string > tmp((*it).size());
3284 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3285 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3286 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3288 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3289 killProfileIds(tmp2);
3291 changePflsRefsNamesGen(ret);
3296 * Removes duplicated localizations. Returns a map used to update references to removed
3297 * localizations via changeLocsRefsNamesGen().
3298 * Equal localizations are found using whichAreEqualLocs().
3299 * \param [in] eps - a precision used to compare real values of the localizations.
3300 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3301 * a sequence describing the performed replacements of localizations. Each element of
3302 * this sequence is a pair whose
3303 * - the first item is a vector of localization names replaced by the second item,
3304 * - the second item is a localization name replacing every localization of the first item.
3306 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3308 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3309 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3311 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3313 std::vector< std::string > tmp((*it).size());
3315 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3316 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3317 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3319 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3320 killLocalizationIds(tmp2);
3322 changeLocsRefsNamesGen(ret);
3327 * Returns number of Gauss points per cell in a given localization.
3328 * \param [in] locId - an id of the localization of interest.
3329 * \return int - the number of the Gauss points per cell.
3331 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3333 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3337 * Returns an id of a localization by its name.
3338 * \param [in] loc - the localization name of interest.
3339 * \return int - the id of the localization.
3340 * \throw If there is no a localization named \a loc.
3342 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3344 return contentNotNull()->getLocalizationId(loc);
3348 * Returns the name of the MED file.
3349 * \return const char * - the MED file name.
3351 const char *MEDFileFieldGlobsReal::getFileName() const
3353 return contentNotNull()->getFileName();
3356 std::string MEDFileFieldGlobsReal::getFileName2() const
3358 return contentNotNull()->getFileName2();
3362 * Returns a localization object by its name.
3363 * \param [in] locName - the name of the localization of interest.
3364 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3365 * \throw If there is no a localization named \a locName.
3367 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3369 return contentNotNull()->getLocalization(locName);
3373 * Returns a localization object by its id.
3374 * \param [in] locId - the id of the localization of interest.
3375 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3376 * \throw If there is no a localization with id \a locId.
3378 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3380 return contentNotNull()->getLocalizationFromId(locId);
3384 * Returns a profile array by its name.
3385 * \param [in] pflName - the name of the profile of interest.
3386 * \return const DataArrayInt * - the profile array having the name \a pflName.
3387 * \throw If there is no a profile named \a pflName.
3389 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3391 return contentNotNull()->getProfile(pflName);
3395 * Returns a profile array by its id.
3396 * \param [in] pflId - the id of the profile of interest.
3397 * \return const DataArrayInt * - the profile array having the id \a pflId.
3398 * \throw If there is no a profile with id \a pflId.
3400 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3402 return contentNotNull()->getProfileFromId(pflId);
3406 * Returns a localization object, apt for modification, by its id.
3407 * \param [in] locId - the id of the localization of interest.
3408 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3409 * having the id \a locId.
3410 * \throw If there is no a localization with id \a locId.
3412 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3414 return contentNotNull()->getLocalizationFromId(locId);
3418 * Returns a localization object, apt for modification, by its name.
3419 * \param [in] locName - the name of the localization of interest.
3420 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3421 * having the name \a locName.
3422 * \throw If there is no a localization named \a locName.
3424 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3426 return contentNotNull()->getLocalization(locName);
3430 * Returns a profile array, apt for modification, by its name.
3431 * \param [in] pflName - the name of the profile of interest.
3432 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3433 * \throw If there is no a profile named \a pflName.
3435 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3437 return contentNotNull()->getProfile(pflName);
3441 * Returns a profile array, apt for modification, by its id.
3442 * \param [in] pflId - the id of the profile of interest.
3443 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3444 * \throw If there is no a profile with id \a pflId.
3446 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3448 return contentNotNull()->getProfileFromId(pflId);
3452 * Removes profiles given by their ids. No data is updated to track this removal.
3453 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3455 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3457 contentNotNull()->killProfileIds(pflIds);
3461 * Removes localizations given by their ids. No data is updated to track this removal.
3462 * \param [in] locIds - a sequence of ids of the localizations to remove.
3464 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3466 contentNotNull()->killLocalizationIds(locIds);
3470 * Stores a profile array.
3471 * \param [in] pfl - the profile array to store.
3472 * \throw If the name of \a pfl is empty.
3473 * \throw If a profile with the same name as that of \a pfl already exists but contains
3476 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3478 contentNotNull()->appendProfile(pfl);
3482 * Adds a new localization of Gauss points.
3483 * \param [in] locName - the name of the new localization.
3484 * \param [in] geoType - a geometrical type of the reference cell.
3485 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3486 * must be \c nbOfNodesPerCell * \c dimOfType.
3487 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3488 * must be _wg_.size() * \c dimOfType.
3489 * \param [in] w - the weights of Gauss points.
3490 * \throw If \a locName is empty.
3491 * \throw If a localization with the name \a locName already exists but is
3492 * different form the new one.
3494 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)
3496 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3499 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3501 MEDFileFieldGlobs *g(_globals);
3503 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3507 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3509 const MEDFileFieldGlobs *g(_globals);
3511 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3515 //= MEDFileFieldNameScope
3517 MEDFileFieldNameScope::MEDFileFieldNameScope()
3521 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3526 * Returns the name of \a this field.
3527 * \return std::string - a string containing the field name.
3529 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3535 * Sets name of \a this field
3536 * \param [in] name - the new field name.
3538 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3543 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3548 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3553 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3556 _dt_unit=other._dt_unit;
3559 //= MEDFileAnyTypeField1TSWithoutSDA
3561 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3563 _field_per_mesh.resize(other._field_per_mesh.size());
3565 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3567 if((const MEDFileFieldPerMesh *)*it)
3568 _field_per_mesh[i]=(*it)->deepCpy(this);
3573 * Prints a string describing \a this field into a stream. This string is outputted
3574 * by \c print Python command.
3575 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3576 * \param [in,out] oss - the out stream.
3577 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3578 * info id printed, else, not.
3580 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3582 std::string startOfLine(bkOffset,' ');
3583 oss << startOfLine << "Field ";
3585 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3586 oss << "on one time Step ";
3588 oss << "(" << f1tsId << ") ";
3589 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3590 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3591 const DataArray *arr=getUndergroundDataArray();
3594 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3597 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3598 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3599 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3601 if(arr->isAllocated())
3603 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3606 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3610 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3612 oss << startOfLine << "----------------------" << std::endl;
3613 if(!_field_per_mesh.empty())
3616 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3618 const MEDFileFieldPerMesh *cur=(*it2);
3620 cur->simpleRepr(bkOffset,oss,i);
3622 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3627 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3629 oss << startOfLine << "----------------------" << std::endl;
3632 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3634 const DataArray *arr(getUndergroundDataArray());
3636 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3637 int nbOfCompo=arr->getNumberOfComponents();
3638 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3639 for(int i=0;i<nbOfCompo;i++)
3642 std::vector<int> v(1,i);
3643 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3644 ret[i]->setArray(arr2);
3649 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)
3653 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3658 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3659 * empty. Returns -1 if this in on nodes.
3660 * \return int - the dimension of \a this.
3662 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3665 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3666 (*it)->getDimension(ret);
3671 * Returns the mesh name.
3672 * \return std::string - a string holding the mesh name.
3673 * \throw If \c _field_per_mesh.empty()
3675 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3677 if(_field_per_mesh.empty())
3678 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3679 return _field_per_mesh[0]->getMeshName();
3682 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3684 std::string oldName(getMeshName());
3685 std::vector< std::pair<std::string,std::string> > v(1);
3686 v[0].first=oldName; v[0].second=newMeshName;
3690 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3693 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3695 MEDFileFieldPerMesh *cur(*it);
3697 ret=cur->changeMeshNames(modifTab) || ret;
3703 * Returns the number of iteration of the state of underlying mesh.
3704 * \return int - the iteration number.
3705 * \throw If \c _field_per_mesh.empty()
3707 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3709 if(_field_per_mesh.empty())
3710 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3711 return _field_per_mesh[0]->getMeshIteration();
3715 * Returns the order number of iteration of the state of underlying mesh.
3716 * \return int - the order number.
3717 * \throw If \c _field_per_mesh.empty()
3719 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3721 if(_field_per_mesh.empty())
3722 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3723 return _field_per_mesh[0]->getMeshOrder();
3727 * Checks if \a this field is tagged by a given iteration number and a given
3728 * iteration order number.
3729 * \param [in] iteration - the iteration number of interest.
3730 * \param [in] order - the iteration order number of interest.
3731 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3732 * \a this->getOrder() == \a order.
3734 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3736 return iteration==_iteration && order==_order;
3740 * Returns number of iteration and order number of iteration when
3741 * \a this field has been calculated.
3742 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3745 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3747 std::pair<int,int> p;
3753 * Returns number of iteration and order number of iteration when
3754 * \a this field has been calculated.
3755 * \param [in,out] p - a pair returning the iteration number and the iteration
3758 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3765 * Returns all types of spatial discretization of \a this field.
3766 * \param [in,out] types - a sequence of types of \a this field.
3768 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3770 std::set<TypeOfField> types2;
3771 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3773 (*it)->fillTypesOfFieldAvailable(types2);
3775 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3776 std::copy(types2.begin(),types2.end(),bi);
3780 * Returns all types of spatial discretization of \a this field.
3781 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3784 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3786 std::vector<TypeOfField> ret;
3787 fillTypesOfFieldAvailable(ret);
3791 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3793 std::vector<std::string> ret;
3794 std::set<std::string> ret2;
3795 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3797 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3798 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3799 if(ret2.find(*it2)==ret2.end())
3801 ret.push_back(*it2);
3808 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3810 std::vector<std::string> ret;
3811 std::set<std::string> ret2;
3812 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3814 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3815 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3816 if(ret2.find(*it2)==ret2.end())
3818 ret.push_back(*it2);
3825 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3827 std::vector<std::string> ret;
3828 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3830 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3831 ret.insert(ret.end(),tmp.begin(),tmp.end());
3836 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3838 std::vector<std::string> ret;
3839 std::set<std::string> ret2;
3840 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3842 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3843 ret.insert(ret.end(),tmp.begin(),tmp.end());
3848 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3850 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3851 (*it)->changePflsRefsNamesGen(mapOfModif);
3854 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3856 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3857 (*it)->changeLocsRefsNamesGen(mapOfModif);
3861 * Returns all attributes of parts of \a this field lying on a given mesh.
3862 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3863 * item of every of returned sequences refers to the _i_-th part of \a this field.
3864 * Thus all sequences returned by this method are of the same length equal to number
3865 * of different types of supporting entities.<br>
3866 * A field part can include sub-parts with several different spatial discretizations,
3867 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3868 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3869 * of a nested sequence corresponds to a type of spatial discretization.<br>
3870 * This method allows for iteration over MEDFile DataStructure without any overhead.
3871 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3872 * for the case with only one underlying mesh. (Actually, the number of meshes is
3873 * not checked if \a mname == \c NULL).
3874 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3875 * a field part is returned.
3876 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3877 * This sequence is of the same length as \a types.
3878 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3879 * discretization. A profile name can be empty.
3880 * Length of this and of nested sequences is the same as that of \a typesF.
3881 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3882 * discretization. A localization name can be empty.
3883 * Length of this and of nested sequences is the same as that of \a typesF.
3884 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3885 * of ids of tuples within the data array, per each type of spatial
3886 * discretization within one mesh entity type.
3887 * Length of this and of nested sequences is the same as that of \a typesF.
3888 * \throw If no field is lying on \a mname.
3890 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)
3894 meshId=getMeshIdFromMeshName(mname);
3896 if(_field_per_mesh.empty())
3897 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3898 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3902 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3903 * maximal absolute dimension and values returned via the out parameter \a levs are
3904 * dimensions relative to the maximal absolute dimension. <br>
3905 * This method is designed for MEDFileField1TS instances that have a discretization
3906 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3907 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3908 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3909 * Only these 3 discretizations will be taken into account here. If \a this is
3910 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3911 * This method is useful to make the link between the dimension of the underlying mesh
3912 * and the levels of \a this, because it is possible that the highest dimension of \a this
3913 * field is not equal to the dimension of the underlying mesh.
3915 * Let's consider the following case:
3916 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3917 * TETRA4, HEXA8, TRI3 and SEG2.
3918 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3919 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3921 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3922 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3923 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3924 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3925 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3926 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3928 * to retrieve the highest level of
3929 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3930 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3931 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3932 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3933 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3934 * for the case with only one underlying mesh. (Actually, the number of meshes is
3935 * not checked if \a mname == \c NULL).
3936 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3937 * absolute one. They are in decreasing order. This sequence is cleared before
3939 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3940 * \throw If no field is lying on \a mname.
3942 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3945 int meshId=getMeshIdFromMeshName(mname);
3946 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3947 std::vector< std::vector<TypeOfField> > typesF;
3948 std::vector< std::vector<std::string> > pfls, locs;
3949 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3951 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3952 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3953 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3955 st.erase(INTERP_KERNEL::NORM_ERROR);
3957 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3959 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3960 ret1.insert((int)cm.getDimension());
3962 int ret=*std::max_element(ret1.begin(),ret1.end());
3963 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3964 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3969 * \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.
3970 * \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.
3971 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3972 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3974 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3976 int mid=getMeshIdFromMeshName(mName);
3977 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3981 * \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.
3982 * \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.
3983 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3984 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3986 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3988 int mid=getMeshIdFromMeshName(mName);
3989 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3993 * \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.
3995 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3997 if(_field_per_mesh.empty())
3998 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4001 std::string mName2(mName);
4003 std::vector<std::string> msg;
4004 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4005 if(mName2==(*it)->getMeshName())
4008 msg.push_back((*it)->getMeshName());
4009 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4010 oss << "Possible meshes are : ";
4011 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4012 oss << "\"" << (*it2) << "\" ";
4013 throw INTERP_KERNEL::Exception(oss.str().c_str());
4016 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4019 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4020 std::string tmp(mesh->getName());
4022 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4023 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4025 for(;it!=_field_per_mesh.end();it++,i++)
4027 if((*it)->getMeshName()==tmp)
4030 int sz=_field_per_mesh.size();
4031 _field_per_mesh.resize(sz+1);
4032 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4036 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4037 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4040 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4042 MEDFileFieldPerMesh *fpm(*it);
4044 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4049 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4051 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4052 std::vector< std::vector<TypeOfField> > typesF;
4053 std::vector< std::vector<std::string> > pfls,locs;
4054 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4055 std::set<TypeOfField> allEnt;
4056 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4057 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4058 allEnt.insert(*it2);
4059 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4060 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4061 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4063 std::vector< std::pair<int,int> > its;
4064 ret[i]=shallowCpy();
4065 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4066 ret[i]->updateData(newLgth,its);
4071 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4073 int globalCounter=0;
4074 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4075 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4076 return globalCounter;
4079 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4081 if(_nb_of_tuples_to_be_allocated>=0)
4083 _nb_of_tuples_to_be_allocated=newLgth;
4086 if(_nb_of_tuples_to_be_allocated==-1)
4088 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4090 const DataArray *oldArr=getUndergroundDataArray();
4091 if(!oldArr || !oldArr->isAllocated())
4092 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4093 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4094 newArr->alloc(newLgth,getNumberOfComponents());
4096 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4098 if((*it).second<(*it).first)
4099 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4100 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4101 pos+=(*it).second-(*it).first;
4106 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4109 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4111 if(_field_per_mesh.empty())
4112 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4113 if(_field_per_mesh.size()>1)
4114 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4115 _field_per_mesh[0]->copyOptionsFrom(opts);
4116 _field_per_mesh[0]->writeLL(fid,nasc);
4120 * 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.
4121 * If false is returned the memory allocation is not required.
4123 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4125 if(_nb_of_tuples_to_be_allocated>=0)
4127 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4128 _nb_of_tuples_to_be_allocated=-2;
4131 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4133 if(_nb_of_tuples_to_be_allocated==-1)
4134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4135 if(_nb_of_tuples_to_be_allocated<-3)
4136 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4137 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4140 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4142 med_int numdt,numit;
4146 med_int meshnumdt,meshnumit;
4147 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4148 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4149 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4150 if(_iteration!=numdt || _order!=numit)
4151 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4152 _field_per_mesh.resize(nmesh);
4153 for(int i=0;i<nmesh;i++)
4154 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4155 _nb_of_tuples_to_be_allocated=0;
4156 for(int i=0;i<nmesh;i++)
4157 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4160 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4162 allocIfNecessaryTheArrayToReceiveDataFromFile();
4163 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4164 (*it)->loadBigArraysRecursively(fid,nasc);
4167 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4169 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4170 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4171 (*it)->loadBigArraysRecursively(fid,nasc);
4174 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4176 loadOnlyStructureOfDataRecursively(fid,nasc);
4177 loadBigArraysRecursively(fid,nasc);
4180 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays() throw(INTERP_KERNEL::Exception)
4182 DataArray *thisArr(getUndergroundDataArray());
4183 if(thisArr && thisArr->isAllocated())
4185 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4186 thisArr->desallocate();
4190 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4192 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4193 if(getUndergroundDataArray())
4194 ret+=getUndergroundDataArray()->getHeapMemorySize();
4195 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4196 ret+=(*it)->getHeapMemorySize();
4201 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4202 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4203 * "Sort By Type"), if not, an exception is thrown.
4204 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4205 * \param [in] arr - the array of values.
4206 * \param [in,out] glob - the global data where profiles and localization present in
4207 * \a field, if any, are added.
4208 * \throw If the name of \a field is empty.
4209 * \throw If the data array of \a field is not set.
4210 * \throw If \a this->_arr is already allocated but has different number of components
4212 * \throw If the underlying mesh of \a field has no name.
4213 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4215 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4217 const MEDCouplingMesh *mesh=field->getMesh();
4219 TypeOfField type=field->getTypeOfField();
4220 std::vector<DataArrayInt *> dummy;
4221 int start=copyTinyInfoFrom(field,arr);
4222 int pos=addNewEntryIfNecessary(mesh);
4225 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4226 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4229 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4233 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4234 * of a given mesh are used as the support of the given field (a real support is not used).
4235 * Elements of the given mesh must be sorted suitable for writing to MED file.
4236 * Order of underlying mesh entities of the given field specified by \a profile parameter
4237 * is not prescribed; this method permutes field values to have them sorted by element
4238 * type as required for writing to MED file. A new profile is added only if no equal
4239 * profile is missing.
4240 * \param [in] field - the field to add to \a this. The field double values are ignored.
4241 * \param [in] arrOfVals - the values of the field \a field used.
4242 * \param [in] mesh - the supporting mesh of \a field.
4243 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4244 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4245 * \param [in,out] glob - the global data where profiles and localization present in
4246 * \a field, if any, are added.
4247 * \throw If either \a field or \a mesh or \a profile has an empty name.
4248 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4249 * \throw If the data array of \a field is not set.
4250 * \throw If \a this->_arr is already allocated but has different number of components
4252 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4253 * \sa setFieldNoProfileSBT()
4255 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)
4258 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4259 if(!arrOfVals || !arrOfVals->isAllocated())
4260 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4261 TypeOfField type=field->getTypeOfField();
4262 std::vector<DataArrayInt *> idsInPflPerType;
4263 std::vector<DataArrayInt *> idsPerType;
4264 std::vector<int> code,code2;
4265 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4268 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4269 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4270 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4271 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4273 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4274 if(type==ON_GAUSS_NE)
4276 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4277 field2->setMesh(mPart);
4279 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4280 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4282 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4283 throw INTERP_KERNEL::Exception(oss.str().c_str());
4286 int start=copyTinyInfoFrom(field,arrOfVals);
4287 code2=m->getDistributionOfTypes();
4289 int pos=addNewEntryIfNecessary(m);
4290 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4294 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4295 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4296 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4297 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4298 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4299 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4301 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4302 throw INTERP_KERNEL::Exception(oss.str().c_str());
4304 int start=copyTinyInfoFrom(field,arrOfVals);
4305 int pos=addNewEntryIfNecessary(m);
4306 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4311 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4313 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4315 if(_nb_of_tuples_to_be_allocated>=0)
4316 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 !");
4317 DataArray *arr(getOrCreateAndGetArray());
4318 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4319 _nb_of_tuples_to_be_allocated=-3;
4323 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4324 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4325 * larger by the size of \a field. Returns an id of the first not filled
4326 * tuple of \a this->_arr.
4327 * \param [in] field - the field to copy the info on components and the name from.
4328 * \return int - the id of first not initialized tuple of \a this->_arr.
4329 * \throw If the name of \a field is empty.
4330 * \throw If the data array of \a field is not set.
4331 * \throw If \a this->_arr is already allocated but has different number of components
4334 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4337 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4338 std::string name(field->getName());
4339 setName(name.c_str());
4340 setDtUnit(field->getTimeUnit());
4342 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4344 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4345 if(!arr->isAllocated())
4346 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4347 _dt=field->getTime(_iteration,_order);
4348 int nbOfComponents=arr->getNumberOfComponents();
4349 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4350 if(!getOrCreateAndGetArray()->isAllocated())
4352 allocNotFromFile(arr->getNumberOfTuples());
4357 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4358 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4359 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4360 _nb_of_tuples_to_be_allocated=-3;
4361 return oldNbOfTuples;
4366 * Returns number of components in \a this field
4367 * \return int - the number of components.
4369 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4371 return getOrCreateAndGetArray()->getNumberOfComponents();
4375 * Change info on components in \a this.
4376 * \throw If size of \a infos is not equal to the number of components already in \a this.
4378 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4380 DataArray *arr=getOrCreateAndGetArray();
4381 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4385 * Returns info on components of \a this field.
4386 * \return const std::vector<std::string>& - a sequence of strings each being an
4387 * information on _i_-th component.
4389 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4391 const DataArray *arr=getOrCreateAndGetArray();
4392 return arr->getInfoOnComponents();
4396 * Returns a mutable info on components of \a this field.
4397 * \return std::vector<std::string>& - a sequence of strings each being an
4398 * information on _i_-th component.
4400 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4402 DataArray *arr=getOrCreateAndGetArray();
4403 return arr->getInfoOnComponents();
4407 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4408 * \param [in] type - a spatial discretization of the new field.
4409 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4410 * \param [in] mName - a name of the supporting mesh.
4411 * \param [in] renumPol - specifies how to permute values of the result field according to
4412 * the optional numbers of cells and nodes, if any. The valid values are
4413 * - 0 - do not permute.
4414 * - 1 - permute cells.
4415 * - 2 - permute nodes.
4416 * - 3 - permute cells and nodes.
4418 * \param [in] glob - the global data storing profiles and localization.
4419 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4420 * caller is to delete this field using decrRef() as it is no more needed.
4421 * \throw If the MED file is not readable.
4422 * \throw If there is no mesh named \a mName in the MED file.
4423 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4424 * \throw If no field of \a this is lying on the mesh \a mName.
4425 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4427 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)
4429 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4431 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4433 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4434 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4438 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4439 * \param [in] type - a spatial discretization of the new field.
4440 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4441 * \param [in] renumPol - specifies how to permute values of the result field according to
4442 * the optional numbers of cells and nodes, if any. The valid values are
4443 * - 0 - do not permute.
4444 * - 1 - permute cells.
4445 * - 2 - permute nodes.
4446 * - 3 - permute cells and nodes.
4448 * \param [in] glob - the global data storing profiles and localization.
4449 * \param [in] mesh - the supporting mesh.
4450 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4451 * caller is to delete this field using decrRef() as it is no more needed.
4452 * \throw If the MED file is not readable.
4453 * \throw If no field of \a this is lying on \a mesh.
4454 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4455 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4457 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)
4459 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4460 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4461 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4462 if(meshDimRelToMax==1)
4463 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4464 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4468 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4470 * \param [in] type - a spatial discretization of the new field.
4471 * \param [in] mName - a name of the supporting mesh.
4472 * \param [in] renumPol - specifies how to permute values of the result field according to
4473 * the optional numbers of cells and nodes, if any. The valid values are
4474 * - 0 - do not permute.
4475 * - 1 - permute cells.
4476 * - 2 - permute nodes.
4477 * - 3 - permute cells and nodes.
4479 * \param [in] glob - the global data storing profiles and localization.
4480 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4481 * caller is to delete this field using decrRef() as it is no more needed.
4482 * \throw If the MED file is not readable.
4483 * \throw If there is no mesh named \a mName in the MED file.
4484 * \throw If there are no mesh entities in the mesh.
4485 * \throw If no field values of the given \a type are available.
4487 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4489 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4491 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4493 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4494 int absDim=getDimension();
4495 int meshDimRelToMax=absDim-mm->getMeshDimension();
4496 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4500 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4501 * \param [in] type - a spatial discretization of the new field.
4502 * \param [in] renumPol - specifies how to permute values of the result field according to
4503 * the optional numbers of cells and nodes, if any. The valid values are
4504 * - 0 - do not permute.
4505 * - 1 - permute cells.
4506 * - 2 - permute nodes.
4507 * - 3 - permute cells and nodes.
4509 * \param [in] glob - the global data storing profiles and localization.
4510 * \param [in] mesh - the supporting mesh.
4511 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4512 * field according to \a renumPol.
4513 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4514 * field according to \a renumPol.
4515 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4516 * caller is to delete this field using decrRef() as it is no more needed.
4517 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4518 * \throw If no field of \a this is lying on \a mesh.
4519 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4521 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)
4523 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4524 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4526 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4531 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4538 throw INTERP_KERNEL::Exception(msg1);
4539 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4542 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4544 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4545 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4546 throw INTERP_KERNEL::Exception(oss.str().c_str());
4548 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4549 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4550 std::vector<DataArray *> arrOut2(1,arrOut);
4551 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4552 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4553 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4560 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4562 throw INTERP_KERNEL::Exception(msg1);
4565 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4567 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4568 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4569 throw INTERP_KERNEL::Exception(oss.str().c_str());
4571 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4572 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4573 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4574 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4579 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4584 * Returns values and a profile of the field of a given type lying on a given support.
4585 * \param [in] type - a spatial discretization of the field.
4586 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4587 * \param [in] mesh - the supporting mesh.
4588 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4589 * field of interest lies on. If the field lies on all entities of the given
4590 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4591 * using decrRef() as it is no more needed.
4592 * \param [in] glob - the global data storing profiles and localization.
4593 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4594 * field. The caller is to delete this array using decrRef() as it is no more needed.
4595 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4596 * \throw If no field of \a this is lying on \a mesh.
4597 * \throw If no field values of the given \a type are available.
4599 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4601 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4602 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4603 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4604 ret->setName(nasc.getName().c_str());
4608 //= MEDFileField1TSWithoutSDA
4611 * Throws if a given value is not a valid (non-extended) relative dimension.
4612 * \param [in] meshDimRelToMax - the relative dimension value.
4613 * \throw If \a meshDimRelToMax > 0.
4615 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4617 if(meshDimRelToMax>0)
4618 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4622 * Checks if elements of a given mesh are in the order suitable for writing
4623 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4624 * vector describing types of elements and their number.
4625 * \param [in] mesh - the mesh to check.
4626 * \return std::vector<int> - a vector holding for each element type (1) item of
4627 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4628 * These values are in full-interlace mode.
4629 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4631 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4634 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4635 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4636 int nbOfTypes=geoTypes.size();
4637 std::vector<int> code(3*nbOfTypes);
4638 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4639 arr1->alloc(nbOfTypes,1);
4640 int *arrPtr=arr1->getPointer();
4641 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4642 for(int i=0;i<nbOfTypes;i++,it++)
4643 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4644 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4645 const int *arrPtr2=arr2->getConstPointer();
4647 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4650 int nbCells=mesh->getNumberOfCellsWithType(*it);
4651 code[3*pos]=(int)(*it);
4652 code[3*pos+1]=nbCells;
4653 code[3*pos+2]=-1;//no profiles
4655 std::vector<const DataArrayInt *> idsPerType;//no profiles
4656 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4660 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4665 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4667 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4671 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4672 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4673 * item of every of returned sequences refers to the _i_-th part of \a this field.
4674 * Thus all sequences returned by this method are of the same length equal to number
4675 * of different types of supporting entities.<br>
4676 * A field part can include sub-parts with several different spatial discretizations,
4677 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4678 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4679 * of a nested sequence corresponds to a type of spatial discretization.<br>
4680 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4681 * The overhead is due to selecting values into new instances of DataArrayDouble.
4682 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4683 * for the case with only one underlying mesh. (Actually, the number of meshes is
4684 * not checked if \a mname == \c NULL).
4685 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4686 * a field part is returned.
4687 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4688 * A field part can include sub-parts with several different spatial discretizations,
4689 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4690 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4691 * This sequence is of the same length as \a types.
4692 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4693 * discretization. A profile name can be empty.
4694 * Length of this and of nested sequences is the same as that of \a typesF.
4695 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4696 * discretization. A localization name can be empty.
4697 * Length of this and of nested sequences is the same as that of \a typesF.
4698 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4699 * per each type of spatial discretization within one mesh entity type.
4700 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4701 * Length of this and of nested sequences is the same as that of \a typesF.
4702 * \throw If no field is lying on \a mname.
4704 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)
4708 meshId=getMeshIdFromMeshName(mname);
4710 if(_field_per_mesh.empty())
4711 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4712 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4713 int nbOfRet=ret0.size();
4714 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4715 for(int i=0;i<nbOfRet;i++)
4717 const std::vector< std::pair<int,int> >& p=ret0[i];
4718 int nbOfRet1=p.size();
4719 ret[i].resize(nbOfRet1);
4720 for(int j=0;j<nbOfRet1;j++)
4722 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4730 * Returns a pointer to the underground DataArrayDouble instance. So the
4731 * caller should not decrRef() it. This method allows for a direct access to the field
4732 * values. This method is quite unusable if there is more than a nodal field or a cell
4733 * field on single geometric cell type.
4734 * \return DataArrayDouble * - the pointer to the field values array.
4736 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4738 const DataArrayDouble *ret=_arr;
4740 return const_cast<DataArrayDouble *>(ret);
4745 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4750 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4752 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4753 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4754 ret->deepCpyLeavesFrom(*this);
4755 const DataArrayDouble *arr(_arr);
4758 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4759 ret->setArray(arr2);
4765 * Returns a pointer to the underground DataArrayDouble instance. So the
4766 * caller should not decrRef() it. This method allows for a direct access to the field
4767 * values. This method is quite unusable if there is more than a nodal field or a cell
4768 * field on single geometric cell type.
4769 * \return DataArrayDouble * - the pointer to the field values array.
4771 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4773 return getUndergroundDataArrayDouble();
4777 * Returns a pointer to the underground DataArrayDouble instance and a
4778 * sequence describing parameters of a support of each part of \a this field. The
4779 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4780 * direct access to the field values. This method is intended for the field lying on one
4782 * \param [in,out] entries - the sequence describing parameters of a support of each
4783 * part of \a this field. Each item of this sequence consists of two parts. The
4784 * first part describes a type of mesh entity and an id of discretization of a
4785 * current field part. The second part describes a range of values [begin,end)
4786 * within the returned array relating to the current field part.
4787 * \return DataArrayDouble * - the pointer to the field values array.
4788 * \throw If the number of underlying meshes is not equal to 1.
4789 * \throw If no field values are available.
4790 * \sa getUndergroundDataArray()
4792 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4794 if(_field_per_mesh.size()!=1)
4795 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4796 if(_field_per_mesh[0]==0)
4797 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4798 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4799 return getUndergroundDataArrayDouble();
4803 * Returns a pointer to the underground DataArrayDouble instance and a
4804 * sequence describing parameters of a support of each part of \a this field. The
4805 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4806 * direct access to the field values. This method is intended for the field lying on one
4808 * \param [in,out] entries - the sequence describing parameters of a support of each
4809 * part of \a this field. Each item of this sequence consists of two parts. The
4810 * first part describes a type of mesh entity and an id of discretization of a
4811 * current field part. The second part describes a range of values [begin,end)
4812 * within the returned array relating to the current field part.
4813 * \return DataArrayDouble * - the pointer to the field values array.
4814 * \throw If the number of underlying meshes is not equal to 1.
4815 * \throw If no field values are available.
4816 * \sa getUndergroundDataArray()
4818 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4820 return getUndergroundDataArrayDoubleExt(entries);
4823 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4824 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4826 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4827 arr->setInfoAndChangeNbOfCompo(infos);
4830 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4834 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4836 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4837 ret->deepCpyLeavesFrom(*this);
4841 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4843 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4844 if((const DataArrayDouble *)_arr)
4845 ret->_arr=_arr->deepCpy();
4849 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4853 _nb_of_tuples_to_be_allocated=-1;
4857 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4859 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4861 _nb_of_tuples_to_be_allocated=-3;
4866 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4868 return DataArrayDouble::New();
4871 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4873 DataArrayDouble *ret=_arr;
4876 _arr=DataArrayDouble::New();
4880 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4882 return getOrCreateAndGetArrayDouble();
4885 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4887 const DataArrayDouble *ret=_arr;
4890 DataArrayDouble *ret2=DataArrayDouble::New();
4891 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4895 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4897 return getOrCreateAndGetArrayDouble();
4900 //= MEDFileIntField1TSWithoutSDA
4902 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4903 const std::vector<std::string>& infos)
4905 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4908 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4912 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4913 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4915 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4916 arr->setInfoAndChangeNbOfCompo(infos);
4919 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4924 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4926 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4927 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4928 ret->deepCpyLeavesFrom(*this);
4929 const DataArrayInt *arr(_arr);
4932 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4933 ret->setArray(arr2);
4939 * Returns a pointer to the underground DataArrayInt instance. So the
4940 * caller should not decrRef() it. This method allows for a direct access to the field
4941 * values. This method is quite unusable if there is more than a nodal field or a cell
4942 * field on single geometric cell type.
4943 * \return DataArrayInt * - the pointer to the field values array.
4945 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4947 return getUndergroundDataArrayInt();
4951 * Returns a pointer to the underground DataArrayInt instance. So the
4952 * caller should not decrRef() it. This method allows for a direct access to the field
4953 * values. This method is quite unusable if there is more than a nodal field or a cell
4954 * field on single geometric cell type.
4955 * \return DataArrayInt * - the pointer to the field values array.
4957 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4959 const DataArrayInt *ret=_arr;
4961 return const_cast<DataArrayInt *>(ret);
4967 * Returns a pointer to the underground DataArrayInt instance and a
4968 * sequence describing parameters of a support of each part of \a this field. The
4969 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4970 * direct access to the field values. This method is intended for the field lying on one
4972 * \param [in,out] entries - the sequence describing parameters of a support of each
4973 * part of \a this field. Each item of this sequence consists of two parts. The
4974 * first part describes a type of mesh entity and an id of discretization of a
4975 * current field part. The second part describes a range of values [begin,end)
4976 * within the returned array relating to the current field part.
4977 * \return DataArrayInt * - the pointer to the field values array.
4978 * \throw If the number of underlying meshes is not equal to 1.
4979 * \throw If no field values are available.
4980 * \sa getUndergroundDataArray()
4982 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4984 return getUndergroundDataArrayIntExt(entries);
4988 * Returns a pointer to the underground DataArrayInt instance and a
4989 * sequence describing parameters of a support of each part of \a this field. The
4990 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4991 * direct access to the field values. This method is intended for the field lying on one
4993 * \param [in,out] entries - the sequence describing parameters of a support of each
4994 * part of \a this field. Each item of this sequence consists of two parts. The
4995 * first part describes a type of mesh entity and an id of discretization of a
4996 * current field part. The second part describes a range of values [begin,end)
4997 * within the returned array relating to the current field part.
4998 * \return DataArrayInt * - the pointer to the field values array.
4999 * \throw If the number of underlying meshes is not equal to 1.
5000 * \throw If no field values are available.
5001 * \sa getUndergroundDataArray()
5003 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5005 if(_field_per_mesh.size()!=1)
5006 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5007 if(_field_per_mesh[0]==0)
5008 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5009 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5010 return getUndergroundDataArrayInt();
5013 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
5015 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5016 ret->deepCpyLeavesFrom(*this);
5020 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
5022 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5023 if((const DataArrayInt *)_arr)
5024 ret->_arr=_arr->deepCpy();
5028 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5032 _nb_of_tuples_to_be_allocated=-1;
5036 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5038 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5040 _nb_of_tuples_to_be_allocated=-3;
5045 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5047 return DataArrayInt::New();
5050 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5052 DataArrayInt *ret=_arr;
5055 _arr=DataArrayInt::New();
5059 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5061 return getOrCreateAndGetArrayInt();
5064 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5066 const DataArrayInt *ret=_arr;
5069 DataArrayInt *ret2=DataArrayInt::New();
5070 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5074 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5076 return getOrCreateAndGetArrayInt();
5079 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5083 //= MEDFileAnyTypeField1TS
5085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5087 med_field_type typcha;
5089 std::vector<std::string> infos;
5090 std::string dtunit,fieldName;
5091 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5092 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5097 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5102 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5107 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] !";
5108 throw INTERP_KERNEL::Exception(oss.str().c_str());
5111 ret->setDtUnit(dtunit.c_str());
5112 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5114 med_int numdt,numit;
5116 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5117 ret->setTime(numdt,numit,dt);
5120 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5122 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5126 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5127 try:MEDFileFieldGlobsReal(fileName)
5129 MEDFileUtilities::CheckFileForRead(fileName);
5130 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5131 _content=BuildContentFrom(fid,fileName,loadAll);
5134 catch(INTERP_KERNEL::Exception& e)
5139 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5141 med_field_type typcha;
5142 std::vector<std::string> infos;
5145 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5146 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5151 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5156 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5161 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] !";
5162 throw INTERP_KERNEL::Exception(oss.str().c_str());
5165 ret->setDtUnit(dtunit.c_str());
5166 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5170 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5171 throw INTERP_KERNEL::Exception(oss.str().c_str());
5174 med_int numdt,numit;
5176 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5177 ret->setTime(numdt,numit,dt);
5180 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5182 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5186 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5187 try:MEDFileFieldGlobsReal(fileName)
5189 MEDFileUtilities::CheckFileForRead(fileName);
5190 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5191 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5194 catch(INTERP_KERNEL::Exception& e)
5199 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5202 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5203 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5205 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5206 ret->setFileName(fileName);
5207 ret->_content=c; c->incrRef();
5210 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5212 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5213 ret->setFileName(fileName);
5214 ret->_content=c; c->incrRef();
5217 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5220 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5222 MEDFileUtilities::CheckFileForRead(fileName);
5223 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5224 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5225 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5226 ret->loadGlobals(fid);
5230 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5232 MEDFileUtilities::CheckFileForRead(fileName);
5233 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5234 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5235 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5236 ret->loadGlobals(fid);
5240 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5242 MEDFileUtilities::CheckFileForRead(fileName);
5243 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5244 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5245 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5246 ret->loadGlobals(fid);
5250 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5252 med_field_type typcha;
5253 std::vector<std::string> infos;
5256 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5257 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5262 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5267 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5272 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] !";
5273 throw INTERP_KERNEL::Exception(oss.str().c_str());
5276 ret->setDtUnit(dtunit.c_str());
5277 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5280 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5281 for(int i=0;i<nbOfStep2 && !found;i++)
5283 med_int numdt,numit;
5285 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5286 if(numdt==iteration && numit==order)
5292 dtits[i]=std::pair<int,int>(numdt,numit);
5296 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5297 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5298 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5299 throw INTERP_KERNEL::Exception(oss.str().c_str());
5302 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5304 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5308 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5309 try:MEDFileFieldGlobsReal(fileName)
5311 MEDFileUtilities::CheckFileForRead(fileName);
5312 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5313 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5316 catch(INTERP_KERNEL::Exception& e)
5322 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5323 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5325 * \warning this is a shallow copy constructor
5327 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5329 if(!shallowCopyOfContent)
5331 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5332 otherPtr->incrRef();
5333 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5337 _content=other.shallowCpy();
5341 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)
5345 int nbFields=MEDnField(fid);
5346 if(fieldIdCFormat>=nbFields)
5348 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5349 throw INTERP_KERNEL::Exception(oss.str().c_str());
5352 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5353 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5354 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5355 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5356 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5357 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5360 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5361 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5362 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5363 infos.clear(); infos.resize(ncomp);
5364 for(int j=0;j<ncomp;j++)
5365 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5370 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5373 * \return in case of success the number of time steps available for the field with name \a fieldName.
5375 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)
5377 int nbFields=MEDnField(fid);
5379 std::vector<std::string> fns(nbFields);
5381 for(int i=0;i<nbFields && !found;i++)
5384 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5386 found=(tmp==fieldName);
5392 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5393 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5394 oss << "\"" << *it << "\" ";
5395 throw INTERP_KERNEL::Exception(oss.str().c_str());
5401 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5402 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5403 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5404 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5405 * to keep a valid instance.
5406 * 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.
5407 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5408 * 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.
5410 * \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.
5411 * \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.
5412 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5413 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5414 * \param [in] newLocName is the new localization name.
5415 * \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.
5416 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5418 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5420 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5421 std::string oldPflName=disc->getProfile();
5422 std::vector<std::string> vv=getPflsReallyUsedMulti();
5423 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5424 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5426 disc->setProfile(newPflName);
5427 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5428 pfl->setName(newPflName);
5432 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5433 throw INTERP_KERNEL::Exception(oss.str().c_str());
5438 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5439 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5440 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5441 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5442 * to keep a valid instance.
5443 * 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.
5444 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5445 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5446 * 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.
5448 * \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.
5449 * \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.
5450 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5451 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5452 * \param [in] newLocName is the new localization name.
5453 * \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.
5454 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5456 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5458 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5459 std::string oldLocName=disc->getLocalization();
5460 std::vector<std::string> vv=getLocsReallyUsedMulti();
5461 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5462 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5464 disc->setLocalization(newLocName);
5465 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5466 loc.setName(newLocName);
5470 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5471 throw INTERP_KERNEL::Exception(oss.str().c_str());
5475 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5477 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5479 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5483 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5485 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5487 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5492 * Writes \a this field into a MED file specified by its name.
5493 * \param [in] fileName - the MED file name.
5494 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5495 * - 2 - erase; an existing file is removed.
5496 * - 1 - append; same data should not be present in an existing file.
5497 * - 0 - overwrite; same data present in an existing file is overwritten.
5498 * \throw If the field name is not set.
5499 * \throw If no field data is set.
5500 * \throw If \a mode == 1 and the same data is present in an existing file.
5502 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5504 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5505 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5510 * This method alloc the arrays and load potentially huge arrays contained in this field.
5511 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5512 * This method can be also called to refresh or reinit values from a file.
5514 * \throw If the fileName is not set or points to a non readable MED file.
5515 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5517 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5519 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5520 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5524 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5525 * But once data loaded once, this method does nothing.
5527 * \throw If the fileName is not set or points to a non readable MED file.
5528 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5530 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5532 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5533 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5537 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5538 * This method does not release arrays set outside the context of a MED file.
5540 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5542 void MEDFileAnyTypeField1TS::unloadArrays() throw(INTERP_KERNEL::Exception)
5544 contentNotNullBase()->unloadArrays();
5547 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5549 int nbComp=getNumberOfComponents();
5550 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5551 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5552 for(int i=0;i<nbComp;i++)
5554 std::string info=getInfo()[i];
5556 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5557 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5558 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5560 if(getName().empty())
5561 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5562 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5563 writeGlobals(fid,*this);
5564 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5567 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5570 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5571 ret+=_content->getHeapMemorySize();
5572 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5576 * Returns a string describing \a this field. This string is outputted
5577 * by \c print Python command.
5579 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5581 std::ostringstream oss;
5582 contentNotNullBase()->simpleRepr(0,oss,-1);
5583 simpleReprGlobs(oss);
5588 * This method returns all profiles whose name is non empty used.
5589 * \b WARNING If profile is used several times it will be reported \b only \b once.
5590 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5592 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5594 return contentNotNullBase()->getPflsReallyUsed2();
5598 * This method returns all localizations whose name is non empty used.
5599 * \b WARNING If localization is used several times it will be reported \b only \b once.
5601 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5603 return contentNotNullBase()->getLocsReallyUsed2();
5607 * This method returns all profiles whose name is non empty used.
5608 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5610 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5612 return contentNotNullBase()->getPflsReallyUsedMulti2();
5616 * This method returns all localizations whose name is non empty used.
5617 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5619 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5621 return contentNotNullBase()->getLocsReallyUsedMulti2();
5624 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5626 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5629 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5631 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5634 int MEDFileAnyTypeField1TS::getDimension() const
5636 return contentNotNullBase()->getDimension();
5639 int MEDFileAnyTypeField1TS::getIteration() const
5641 return contentNotNullBase()->getIteration();
5644 int MEDFileAnyTypeField1TS::getOrder() const
5646 return contentNotNullBase()->getOrder();
5649 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5651 return contentNotNullBase()->getTime(iteration,order);
5654 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5656 contentNotNullBase()->setTime(iteration,order,val);
5659 std::string MEDFileAnyTypeField1TS::getName() const
5661 return contentNotNullBase()->getName();
5664 void MEDFileAnyTypeField1TS::setName(const char *name)
5666 contentNotNullBase()->setName(name);
5669 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5671 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5674 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5676 return contentNotNullBase()->getDtUnit();
5679 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5681 contentNotNullBase()->setDtUnit(dtUnit);
5684 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5686 return contentNotNullBase()->getMeshName();
5689 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5691 contentNotNullBase()->setMeshName(newMeshName);
5694 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5696 return contentNotNullBase()->changeMeshNames(modifTab);
5699 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5701 return contentNotNullBase()->getMeshIteration();
5704 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5706 return contentNotNullBase()->getMeshOrder();
5709 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5711 return contentNotNullBase()->getNumberOfComponents();
5714 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5716 return contentNotNullBase()->isDealingTS(iteration,order);
5719 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5721 return contentNotNullBase()->getDtIt();
5724 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5726 contentNotNullBase()->fillIteration(p);
5729 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5731 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5734 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5736 contentNotNullBase()->setInfo(infos);
5739 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5741 return contentNotNullBase()->getInfo();
5743 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5745 return contentNotNullBase()->getInfo();
5748 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5750 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5753 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5755 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5758 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5760 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5763 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5765 return contentNotNullBase()->getTypesOfFieldAvailable();
5768 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,
5769 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5771 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5775 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5776 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5777 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5779 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5781 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5783 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5784 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5785 std::size_t sz(contentsSplit.size());
5786 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5787 for(std::size_t i=0;i<sz;i++)
5789 ret[i]=shallowCpy();
5790 ret[i]->_content=contentsSplit[i];
5796 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5797 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5799 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5801 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5803 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5804 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5805 std::size_t sz(contentsSplit.size());
5806 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5807 for(std::size_t i=0;i<sz;i++)
5809 ret[i]=shallowCpy();
5810 ret[i]->_content=contentsSplit[i];
5815 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5817 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5818 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5819 ret->_content=_content->deepCpy();
5820 ret->deepCpyGlobs(*this);
5824 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5826 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5832 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5833 * the first field that has been read from a specified MED file.
5834 * \param [in] fileName - the name of the MED file to read.
5835 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5836 * is to delete this field using decrRef() as it is no more needed.
5837 * \throw If reading the file fails.
5839 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5841 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5842 ret->contentNotNull();
5847 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5848 * a given field that has been read from a specified MED file.
5849 * \param [in] fileName - the name of the MED file to read.
5850 * \param [in] fieldName - the name of the field to read.
5851 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5852 * is to delete this field using decrRef() as it is no more needed.
5853 * \throw If reading the file fails.
5854 * \throw If there is no field named \a fieldName in the file.
5856 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5858 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5859 ret->contentNotNull();
5864 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5865 * a given field that has been read from a specified MED file.
5866 * \param [in] fileName - the name of the MED file to read.
5867 * \param [in] fieldName - the name of the field to read.
5868 * \param [in] iteration - the iteration number of a required time step.
5869 * \param [in] order - the iteration order number of required time step.
5870 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5871 * is to delete this field using decrRef() as it is no more needed.
5872 * \throw If reading the file fails.
5873 * \throw If there is no field named \a fieldName in the file.
5874 * \throw If the required time step is missing from the file.
5876 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5878 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5879 ret->contentNotNull();
5884 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5885 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5887 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5888 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5889 * \warning this is a shallow copy constructor
5890 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5891 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5892 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5893 * is to delete this field using decrRef() as it is no more needed.
5895 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5897 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5898 ret->contentNotNull();
5903 * Returns a new empty instance of MEDFileField1TS.
5904 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5905 * is to delete this field using decrRef() as it is no more needed.
5907 MEDFileField1TS *MEDFileField1TS::New()
5909 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5910 ret->contentNotNull();
5915 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5916 * following the given input policy.
5918 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5919 * By default (true) the globals are deeply copied.
5920 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5922 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5924 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5925 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5928 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5930 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5931 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5932 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5935 ret=MEDFileIntField1TS::New();
5937 ret->deepCpyGlobs(*this);
5939 ret->shallowCpyGlobs(*this);
5943 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5945 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5947 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5948 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5950 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 !");
5954 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5956 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5958 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5959 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5961 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 !");
5965 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5968 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5969 if(!((DataArray*)arr))
5970 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5971 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5973 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5974 f->setArray(arrOutC);
5977 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5979 if(!((DataArray*)arr))
5980 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5981 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5983 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5988 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5989 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5992 catch(INTERP_KERNEL::Exception& e)
5995 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5996 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5999 catch(INTERP_KERNEL::Exception& e)
6002 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6003 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6006 catch(INTERP_KERNEL::Exception& e)
6010 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6011 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6013 * \warning this is a shallow copy constructor
6015 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6016 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6019 catch(INTERP_KERNEL::Exception& e)
6022 MEDFileField1TS::MEDFileField1TS()
6024 _content=new MEDFileField1TSWithoutSDA;
6028 * Returns a new MEDCouplingFieldDouble of a given type lying on
6029 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6030 * has not been constructed via file reading, an exception is thrown.
6031 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6032 * \param [in] type - a spatial discretization of interest.
6033 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6034 * \param [in] renumPol - specifies how to permute values of the result field according to
6035 * the optional numbers of cells and nodes, if any. The valid values are
6036 * - 0 - do not permute.
6037 * - 1 - permute cells.
6038 * - 2 - permute nodes.
6039 * - 3 - permute cells and nodes.
6041 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6042 * caller is to delete this field using decrRef() as it is no more needed.
6043 * \throw If \a this field has not been constructed via file reading.
6044 * \throw If the MED file is not readable.
6045 * \throw If there is no mesh in the MED file.
6046 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6047 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6048 * \sa getFieldOnMeshAtLevel()
6050 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6052 if(getFileName2().empty())
6053 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6054 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6055 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6056 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6061 * Returns a new MEDCouplingFieldDouble of a given type lying on
6062 * the top level cells of the first mesh in MED file. If \a this field
6063 * has not been constructed via file reading, an exception is thrown.
6064 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6065 * \param [in] type - a spatial discretization of interest.
6066 * \param [in] renumPol - specifies how to permute values of the result field according to
6067 * the optional numbers of cells and nodes, if any. The valid values are
6068 * - 0 - do not permute.
6069 * - 1 - permute cells.
6070 * - 2 - permute nodes.
6071 * - 3 - permute cells and nodes.
6073 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6074 * caller is to delete this field using decrRef() as it is no more needed.
6075 * \throw If \a this field has not been constructed via file reading.
6076 * \throw If the MED file is not readable.
6077 * \throw If there is no mesh in the MED file.
6078 * \throw If no field values of the given \a type.
6079 * \throw If no field values lying on the top level support.
6080 * \sa getFieldAtLevel()
6082 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6084 if(getFileName2().empty())
6085 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6086 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6087 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6088 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6093 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6094 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6095 * \param [in] type - a spatial discretization of the new field.
6096 * \param [in] mesh - the supporting mesh.
6097 * \param [in] renumPol - specifies how to permute values of the result field according to
6098 * the optional numbers of cells and nodes, if any. The valid values are
6099 * - 0 - do not permute.
6100 * - 1 - permute cells.
6101 * - 2 - permute nodes.
6102 * - 3 - permute cells and nodes.
6104 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6105 * caller is to delete this field using decrRef() as it is no more needed.
6106 * \throw If no field of \a this is lying on \a mesh.
6107 * \throw If the mesh is empty.
6108 * \throw If no field values of the given \a type are available.
6109 * \sa getFieldAtLevel()
6110 * \sa getFieldOnMeshAtLevel()
6112 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6114 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6115 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6116 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6121 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6122 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6123 * \param [in] type - a spatial discretization of interest.
6124 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6125 * \param [in] mesh - the supporting mesh.
6126 * \param [in] renumPol - specifies how to permute values of the result field according to
6127 * the optional numbers of cells and nodes, if any. The valid values are
6128 * - 0 - do not permute.
6129 * - 1 - permute cells.
6130 * - 2 - permute nodes.
6131 * - 3 - permute cells and nodes.
6133 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6134 * caller is to delete this field using decrRef() as it is no more needed.
6135 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6136 * \throw If no field of \a this is lying on \a mesh.
6137 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6138 * \sa getFieldAtLevel()
6139 * \sa getFieldOnMeshAtLevel()
6141 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6143 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6144 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6145 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6150 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6151 * This method is called "Old" because in MED3 norm a field has only one meshName
6152 * attached, so this method is for readers of MED2 files. If \a this field
6153 * has not been constructed via file reading, an exception is thrown.
6154 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6155 * \param [in] type - a spatial discretization of interest.
6156 * \param [in] mName - a name of the supporting mesh.
6157 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6158 * \param [in] renumPol - specifies how to permute values of the result field according to
6159 * the optional numbers of cells and nodes, if any. The valid values are
6160 * - 0 - do not permute.
6161 * - 1 - permute cells.
6162 * - 2 - permute nodes.
6163 * - 3 - permute cells and nodes.
6165 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6166 * caller is to delete this field using decrRef() as it is no more needed.
6167 * \throw If the MED file is not readable.
6168 * \throw If there is no mesh named \a mName in the MED file.
6169 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6170 * \throw If \a this field has not been constructed via file reading.
6171 * \throw If no field of \a this is lying on the mesh named \a mName.
6172 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6173 * \sa getFieldAtLevel()
6175 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6177 if(getFileName2().empty())
6178 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6179 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6180 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6181 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6186 * Returns values and a profile of the field of a given type lying on a given support.
6187 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6188 * \param [in] type - a spatial discretization of the field.
6189 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6190 * \param [in] mesh - the supporting mesh.
6191 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6192 * field of interest lies on. If the field lies on all entities of the given
6193 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6194 * using decrRef() as it is no more needed.
6195 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6196 * field. The caller is to delete this array using decrRef() as it is no more needed.
6197 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6198 * \throw If no field of \a this is lying on \a mesh.
6199 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6201 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6203 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6204 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6208 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6209 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6210 * "Sort By Type"), if not, an exception is thrown.
6211 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6212 * \param [in] field - the field to add to \a this.
6213 * \throw If the name of \a field is empty.
6214 * \throw If the data array of \a field is not set.
6215 * \throw If the data array is already allocated but has different number of components
6217 * \throw If the underlying mesh of \a field has no name.
6218 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6220 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6223 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6227 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6228 * can be an aggregation of several MEDCouplingFieldDouble instances.
6229 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6230 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6233 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6234 * A new profile is added only if no equal profile is missing.
6235 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6236 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6237 * \param [in] mesh - the supporting mesh of \a field.
6238 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6239 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6240 * \throw If either \a field or \a mesh or \a profile has an empty name.
6241 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6242 * \throw If the data array of \a field is not set.
6243 * \throw If the data array of \a this is already allocated but has different number of
6244 * components than \a field.
6245 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6246 * \sa setFieldNoProfileSBT()
6248 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6251 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6254 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6256 return new MEDFileField1TS(*this);
6259 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6261 return contentNotNull()->getUndergroundDataArrayDouble();
6264 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6266 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6269 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6270 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6272 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6275 //= MEDFileIntField1TS
6277 MEDFileIntField1TS *MEDFileIntField1TS::New()
6279 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6280 ret->contentNotNull();
6284 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6286 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6287 ret->contentNotNull();
6291 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6293 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6294 ret->contentNotNull();
6298 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6300 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6301 ret->contentNotNull();
6305 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6307 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6308 ret->contentNotNull();
6312 MEDFileIntField1TS::MEDFileIntField1TS()
6314 _content=new MEDFileIntField1TSWithoutSDA;
6317 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6318 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6321 catch(INTERP_KERNEL::Exception& e)
6324 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6325 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6328 catch(INTERP_KERNEL::Exception& e)
6331 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6332 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6335 catch(INTERP_KERNEL::Exception& e)
6339 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6340 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6342 * \warning this is a shallow copy constructor
6344 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6348 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6350 return new MEDFileIntField1TS(*this);
6354 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6355 * following the given input policy.
6357 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6358 * By default (true) the globals are deeply copied.
6359 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6361 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6363 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6364 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6367 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6369 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6370 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6371 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6374 ret=MEDFileField1TS::New();
6376 ret->deepCpyGlobs(*this);
6378 ret->shallowCpyGlobs(*this);
6383 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6384 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6385 * "Sort By Type"), if not, an exception is thrown.
6386 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6387 * \param [in] field - the field to add to \a this. The field double values are ignored.
6388 * \param [in] arrOfVals - the values of the field \a field used.
6389 * \throw If the name of \a field is empty.
6390 * \throw If the data array of \a field is not set.
6391 * \throw If the data array is already allocated but has different number of components
6393 * \throw If the underlying mesh of \a field has no name.
6394 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6396 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6399 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6403 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6404 * can be an aggregation of several MEDCouplingFieldDouble instances.
6405 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6406 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6409 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6410 * A new profile is added only if no equal profile is missing.
6411 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6412 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6413 * \param [in] arrOfVals - the values of the field \a field used.
6414 * \param [in] mesh - the supporting mesh of \a field.
6415 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6416 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6417 * \throw If either \a field or \a mesh or \a profile has an empty name.
6418 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6419 * \throw If the data array of \a field is not set.
6420 * \throw If the data array of \a this is already allocated but has different number of
6421 * components than \a field.
6422 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6423 * \sa setFieldNoProfileSBT()
6425 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6428 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6431 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6433 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6435 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6436 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6438 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 !");
6442 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6444 if(getFileName2().empty())
6445 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6446 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6447 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6448 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6450 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6455 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6457 if(!((DataArray *)arr))
6458 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6459 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6461 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6467 * Returns a new MEDCouplingFieldDouble of a given type lying on
6468 * the top level cells of the first mesh in MED file. If \a this field
6469 * has not been constructed via file reading, an exception is thrown.
6470 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6471 * \param [in] type - a spatial discretization of interest.
6472 * \param [out] arrOut - the DataArrayInt containing values of field.
6473 * \param [in] renumPol - specifies how to permute values of the result field according to
6474 * the optional numbers of cells and nodes, if any. The valid values are
6475 * - 0 - do not permute.
6476 * - 1 - permute cells.
6477 * - 2 - permute nodes.
6478 * - 3 - permute cells and nodes.
6480 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6481 * caller is to delete this field using decrRef() as it is no more needed.
6482 * \throw If \a this field has not been constructed via file reading.
6483 * \throw If the MED file is not readable.
6484 * \throw If there is no mesh in the MED file.
6485 * \throw If no field values of the given \a type.
6486 * \throw If no field values lying on the top level support.
6487 * \sa getFieldAtLevel()
6489 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6491 if(getFileName2().empty())
6492 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6493 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6494 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6495 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6500 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6501 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6502 * \param [in] type - a spatial discretization of the new field.
6503 * \param [in] mesh - the supporting mesh.
6504 * \param [out] arrOut - the DataArrayInt containing values of field.
6505 * \param [in] renumPol - specifies how to permute values of the result field according to
6506 * the optional numbers of cells and nodes, if any. The valid values are
6507 * - 0 - do not permute.
6508 * - 1 - permute cells.
6509 * - 2 - permute nodes.
6510 * - 3 - permute cells and nodes.
6512 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6513 * caller is to delete this field using decrRef() as it is no more needed.
6514 * \throw If no field of \a this is lying on \a mesh.
6515 * \throw If the mesh is empty.
6516 * \throw If no field values of the given \a type are available.
6517 * \sa getFieldAtLevel()
6518 * \sa getFieldOnMeshAtLevel()
6520 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6522 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6523 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6524 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6529 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6530 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6531 * \param [in] type - a spatial discretization of interest.
6532 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6533 * \param [out] arrOut - the DataArrayInt containing values of field.
6534 * \param [in] mesh - the supporting mesh.
6535 * \param [in] renumPol - specifies how to permute values of the result field according to
6536 * the optional numbers of cells and nodes, if any. The valid values are
6537 * - 0 - do not permute.
6538 * - 1 - permute cells.
6539 * - 2 - permute nodes.
6540 * - 3 - permute cells and nodes.
6542 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6543 * caller is to delete this field using decrRef() as it is no more needed.
6544 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6545 * \throw If no field of \a this is lying on \a mesh.
6546 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6547 * \sa getFieldAtLevel()
6548 * \sa getFieldOnMeshAtLevel()
6550 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6552 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6553 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6554 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6559 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6560 * This method is called "Old" because in MED3 norm a field has only one meshName
6561 * attached, so this method is for readers of MED2 files. If \a this field
6562 * has not been constructed via file reading, an exception is thrown.
6563 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6564 * \param [in] type - a spatial discretization of interest.
6565 * \param [in] mName - a name of the supporting mesh.
6566 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6567 * \param [out] arrOut - the DataArrayInt containing values of field.
6568 * \param [in] renumPol - specifies how to permute values of the result field according to
6569 * the optional numbers of cells and nodes, if any. The valid values are
6570 * - 0 - do not permute.
6571 * - 1 - permute cells.
6572 * - 2 - permute nodes.
6573 * - 3 - permute cells and nodes.
6575 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6576 * caller is to delete this field using decrRef() as it is no more needed.
6577 * \throw If the MED file is not readable.
6578 * \throw If there is no mesh named \a mName in the MED file.
6579 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6580 * \throw If \a this field has not been constructed via file reading.
6581 * \throw If no field of \a this is lying on the mesh named \a mName.
6582 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6583 * \sa getFieldAtLevel()
6585 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6587 if(getFileName2().empty())
6588 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6589 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6590 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6591 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6596 * Returns values and a profile of the field of a given type lying on a given support.
6597 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6598 * \param [in] type - a spatial discretization of the field.
6599 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6600 * \param [in] mesh - the supporting mesh.
6601 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6602 * field of interest lies on. If the field lies on all entities of the given
6603 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6604 * using decrRef() as it is no more needed.
6605 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6606 * field. The caller is to delete this array using decrRef() as it is no more needed.
6607 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6608 * \throw If no field of \a this is lying on \a mesh.
6609 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6611 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6613 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6614 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6617 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6619 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6621 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6622 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6624 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 !");
6628 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6630 return contentNotNull()->getUndergroundDataArrayInt();
6633 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6635 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6639 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6644 * \param [in] fieldId field id in C mode
6646 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6648 med_field_type typcha;
6649 std::string dtunitOut;
6650 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6651 setDtUnit(dtunitOut.c_str());
6652 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6655 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)
6656 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6658 setDtUnit(dtunit.c_str());
6659 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6661 catch(INTERP_KERNEL::Exception& e)
6666 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6668 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6669 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6670 ret+=(*it).capacity();
6671 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6672 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6673 ret+=(*it)->getHeapMemorySize();
6678 * 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
6681 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6683 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6684 ret->setInfo(_infos);
6685 int sz=(int)_time_steps.size();
6686 for(const int *id=startIds;id!=endIds;id++)
6688 if(*id>=0 && *id<sz)
6690 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6691 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6695 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6697 ret->pushBackTimeStep(tse2);
6701 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6702 oss << " ! Should be in [0," << sz << ") !";
6703 throw INTERP_KERNEL::Exception(oss.str().c_str());
6706 if(ret->getNumberOfTS()>0)
6707 ret->synchronizeNameScope();
6708 ret->copyNameScope(*this);
6713 * 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
6716 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6718 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6719 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6720 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6721 ret->setInfo(_infos);
6722 int sz=(int)_time_steps.size();
6724 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6728 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6729 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6733 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6735 ret->pushBackTimeStep(tse2);
6739 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6740 oss << " ! Should be in [0," << sz << ") !";
6741 throw INTERP_KERNEL::Exception(oss.str().c_str());
6744 if(ret->getNumberOfTS()>0)
6745 ret->synchronizeNameScope();
6746 ret->copyNameScope(*this);
6750 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6753 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6754 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6756 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6759 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6760 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6761 ids->pushBackSilent(id);
6763 return buildFromTimeStepIds(ids->begin(),ids->end());
6766 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6769 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6770 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6772 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6775 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6776 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6777 ids->pushBackSilent(id);
6779 return buildFromTimeStepIds(ids->begin(),ids->end());
6782 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6787 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6792 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6795 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6797 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6798 if(pt->isDealingTS(iteration,order))
6801 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6802 std::vector< std::pair<int,int> > vp=getIterations();
6803 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6804 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6805 throw INTERP_KERNEL::Exception(oss.str().c_str());
6808 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6810 return *_time_steps[getTimeStepPos(iteration,order)];
6813 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6815 return *_time_steps[getTimeStepPos(iteration,order)];
6818 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6820 if(_time_steps.empty())
6821 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6822 return _time_steps[0]->getMeshName();
6825 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6827 std::string oldName(getMeshName());
6828 std::vector< std::pair<std::string,std::string> > v(1);
6829 v[0].first=oldName; v[0].second=newMeshName;
6833 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6836 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6838 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6840 ret=cur->changeMeshNames(modifTab) || ret;
6846 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6848 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6850 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6854 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6856 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)
6858 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6861 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6862 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6865 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6867 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6869 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6874 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6876 std::string startLine(bkOffset,' ');
6877 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6879 oss << " (" << fmtsId << ")";
6880 oss << " has the following name: \"" << _name << "\"." << std::endl;
6881 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6882 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6884 oss << startLine << " - \"" << *it << "\"" << std::endl;
6887 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6889 std::string chapter(17,'0'+i);
6890 oss << startLine << chapter << std::endl;
6891 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6893 cur->simpleRepr(bkOffset+2,oss,i);
6895 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6896 oss << startLine << chapter << std::endl;
6900 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6902 std::size_t sz=_time_steps.size();
6903 std::vector< std::pair<int,int> > ret(sz);
6905 for(std::size_t i=0;i<sz;i++)
6907 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6910 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6914 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6915 throw INTERP_KERNEL::Exception(oss.str().c_str());
6921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6923 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6925 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6926 checkCoherencyOfType(tse2);
6927 if(_time_steps.empty())
6929 setName(tse2->getName().c_str());
6930 setInfo(tse2->getInfo());
6932 checkThatComponentsMatch(tse2->getInfo());
6933 _time_steps.push_back(tse);
6936 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6938 std::size_t nbOfCompo=_infos.size();
6939 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6941 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6944 if((cur->getInfo()).size()!=nbOfCompo)
6946 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6947 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6948 throw INTERP_KERNEL::Exception(oss.str().c_str());
6950 cur->copyNameScope(*this);
6955 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6957 _time_steps.resize(nbPdt);
6958 for(int i=0;i<nbPdt;i++)
6960 std::vector< std::pair<int,int> > ts;
6961 med_int numdt=0,numo=0;
6962 med_int meshIt=0,meshOrder=0;
6964 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6969 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6974 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6981 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6983 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6987 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6989 if(_time_steps.empty())
6990 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6991 checkThatNbOfCompoOfTSMatchThis();
6992 std::vector<std::string> infos(getInfo());
6993 int nbComp=infos.size();
6994 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6995 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6996 for(int i=0;i<nbComp;i++)
6998 std::string info=infos[i];
7000 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7001 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7002 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7005 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7006 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7007 int nbOfTS=_time_steps.size();
7008 for(int i=0;i<nbOfTS;i++)
7009 _time_steps[i]->writeLL(fid,opts,*this);
7012 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7014 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7016 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7018 elt->loadBigArraysRecursively(fid,nasc);
7022 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7024 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7026 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7028 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7032 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays() throw(INTERP_KERNEL::Exception)
7034 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7036 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7038 elt->unloadArrays();
7042 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7044 return _time_steps.size();
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7049 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7050 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7052 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7054 newTS.push_back(*it);
7059 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7061 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7062 int maxId=(int)_time_steps.size();
7064 std::set<int> idsToDel;
7065 for(const int *id=startIds;id!=endIds;id++,ii++)
7067 if(*id>=0 && *id<maxId)
7069 idsToDel.insert(*id);
7073 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7074 throw INTERP_KERNEL::Exception(oss.str().c_str());
7077 for(int iii=0;iii<maxId;iii++)
7078 if(idsToDel.find(iii)==idsToDel.end())
7079 newTS.push_back(_time_steps[iii]);
7083 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7085 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7086 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7087 if(nbOfEntriesToKill==0)
7089 std::size_t sz=_time_steps.size();
7090 std::vector<bool> b(sz,true);
7092 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7094 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7095 for(std::size_t i=0;i<sz;i++)
7097 newTS.push_back(_time_steps[i]);
7101 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7104 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7105 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7107 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7111 tmp->getTime(it2,ord);
7112 if(it2==iteration && order==ord)
7115 oss << "(" << it2 << "," << ord << "), ";
7118 throw INTERP_KERNEL::Exception(oss.str().c_str());
7121 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7124 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7126 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7128 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7132 double ti=tmp->getTime(it2,ord);
7133 if(fabs(time-ti)<eps)
7139 throw INTERP_KERNEL::Exception(oss.str().c_str());
7142 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7144 int lgth=_time_steps.size();
7145 std::vector< std::pair<int,int> > ret(lgth);
7146 for(int i=0;i<lgth;i++)
7147 _time_steps[i]->fillIteration(ret[i]);
7152 * 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'
7153 * This method returns two things.
7154 * - The absolute dimension of 'this' in first parameter.
7155 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7156 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7158 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7159 * Only these 3 discretizations will be taken into account here.
7161 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7162 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7163 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7165 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7166 * 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'.
7168 * Let's consider the typical following case :
7169 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7170 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7171 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7173 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7175 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7177 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7178 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7179 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7180 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7182 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7184 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7187 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7189 if(pos<0 || pos>=(int)_time_steps.size())
7191 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7192 throw INTERP_KERNEL::Exception(oss.str().c_str());
7194 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7197 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7198 oss << "\nTry to use following method eraseEmptyTS !";
7199 throw INTERP_KERNEL::Exception(oss.str().c_str());
7204 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7206 if(pos<0 || pos>=(int)_time_steps.size())
7208 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7209 throw INTERP_KERNEL::Exception(oss.str().c_str());
7211 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7214 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7215 oss << "\nTry to use following method eraseEmptyTS !";
7216 throw INTERP_KERNEL::Exception(oss.str().c_str());
7221 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7223 std::vector<std::string> ret;
7224 std::set<std::string> ret2;
7225 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7227 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7228 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7229 if(ret2.find(*it2)==ret2.end())
7231 ret.push_back(*it2);
7238 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7240 std::vector<std::string> ret;
7241 std::set<std::string> ret2;
7242 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7244 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7245 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7246 if(ret2.find(*it2)==ret2.end())
7248 ret.push_back(*it2);
7255 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7257 std::vector<std::string> ret;
7258 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7260 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7261 ret.insert(ret.end(),tmp.begin(),tmp.end());
7266 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7268 std::vector<std::string> ret;
7269 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7271 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7272 ret.insert(ret.end(),tmp.begin(),tmp.end());
7277 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7279 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7280 (*it)->changePflsRefsNamesGen2(mapOfModif);
7283 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7285 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7286 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7289 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7291 int lgth=_time_steps.size();
7292 std::vector< std::vector<TypeOfField> > ret(lgth);
7293 for(int i=0;i<lgth;i++)
7294 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7299 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7301 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)
7303 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7306 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7308 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7310 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7312 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7313 ret->_time_steps[i]=(*it)->deepCpy();
7318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7320 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7321 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7322 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7323 for(std::size_t i=0;i<sz;i++)
7325 ret[i]=shallowCpy();
7326 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7328 for(std::size_t i=0;i<sz2;i++)
7330 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7333 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7334 throw INTERP_KERNEL::Exception(oss.str().c_str());
7338 for(std::size_t i=0;i<sz;i++)
7339 for(std::size_t j=0;j<sz2;j++)
7340 ret[i]->_time_steps[j]=ts[j][i];
7345 * This method splits into discretization each time steps in \a this.
7346 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7348 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7350 std::size_t sz(_time_steps.size());
7351 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7352 for(std::size_t i=0;i<sz;i++)
7354 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7357 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7358 throw INTERP_KERNEL::Exception(oss.str().c_str());
7360 items[i]=timeStep->splitDiscretizations();
7363 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7364 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7365 std::vector< TypeOfField > types;
7366 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7367 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7369 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7372 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7373 if(it2==types.end())
7374 types.push_back(ts[0]);
7376 ret.resize(types.size()); ret2.resize(types.size());
7377 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7378 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7380 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7381 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7382 ret2[pos].push_back(*it1);
7384 for(std::size_t i=0;i<types.size();i++)
7386 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7387 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7388 elt->pushBackTimeStep(*it1);//also updates infos in elt
7390 elt->MEDFileFieldNameScope::operator=(*this);
7395 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7397 _name=field->getName();
7399 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7401 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7402 _infos=arr->getInfoOnComponents();
7405 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7407 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7408 if(_name!=field->getName())
7410 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7411 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7412 throw INTERP_KERNEL::Exception(oss.str().c_str());
7415 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7416 checkThatComponentsMatch(arr->getInfoOnComponents());
7419 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7421 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7422 if(getInfo().size()!=compos.size())
7424 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7425 oss << " number of components of element to append (" << compos.size() << ") !";
7426 throw INTERP_KERNEL::Exception(oss.str().c_str());
7430 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7431 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7432 oss << " But compo in input fields are : ";
7433 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7435 throw INTERP_KERNEL::Exception(oss.str().c_str());
7439 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7441 std::size_t sz=_infos.size();
7443 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7445 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7447 if(elt->getInfo().size()!=sz)
7449 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7450 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7451 throw INTERP_KERNEL::Exception(oss.str().c_str());
7456 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7459 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7460 if(!_time_steps.empty())
7461 checkCoherencyOfTinyInfo(field,arr);
7462 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7463 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7464 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7465 copyTinyInfoFrom(field,arr);
7466 _time_steps.push_back(obj);
7469 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7472 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7473 if(!_time_steps.empty())
7474 checkCoherencyOfTinyInfo(field,arr);
7475 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7476 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7477 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7478 copyTinyInfoFrom(field,arr);
7479 _time_steps.push_back(obj);
7482 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7484 int sz=(int)_time_steps.size();
7487 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7488 throw INTERP_KERNEL::Exception(oss.str().c_str());
7490 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7493 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7495 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7496 throw INTERP_KERNEL::Exception(oss.str().c_str());
7502 //= MEDFileFieldMultiTSWithoutSDA
7504 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)
7506 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7509 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7513 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7518 * \param [in] fieldId field id in C mode
7520 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7521 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7524 catch(INTERP_KERNEL::Exception& e)
7527 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)
7528 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7531 catch(INTERP_KERNEL::Exception& e)
7534 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7536 return new MEDFileField1TSWithoutSDA;
7539 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7542 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7543 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7545 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7548 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7550 return MEDFileField1TSWithoutSDA::TYPE_STR;
7553 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7555 return new MEDFileFieldMultiTSWithoutSDA(*this);
7558 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7560 return new MEDFileFieldMultiTSWithoutSDA;
7564 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7565 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7567 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)
7569 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7570 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7572 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7573 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7576 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7578 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7579 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7581 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7583 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7586 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7588 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7589 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7590 ret->setIteration(i,elt);
7596 //= MEDFileAnyTypeFieldMultiTS
7598 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7602 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7603 try:MEDFileFieldGlobsReal(fileName)
7605 MEDFileUtilities::CheckFileForRead(fileName);
7606 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7607 _content=BuildContentFrom(fid,fileName,loadAll);
7610 catch(INTERP_KERNEL::Exception& e)
7615 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7617 med_field_type typcha;
7618 std::vector<std::string> infos;
7621 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7622 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7627 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7632 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7637 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] !";
7638 throw INTERP_KERNEL::Exception(oss.str().c_str());
7641 ret->setDtUnit(dtunit.c_str());
7645 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7647 med_field_type typcha;
7649 std::vector<std::string> infos;
7650 std::string dtunit,fieldName;
7651 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7652 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7657 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7662 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7667 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] !";
7668 throw INTERP_KERNEL::Exception(oss.str().c_str());
7671 ret->setDtUnit(dtunit.c_str());
7675 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7678 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7679 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7681 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7682 ret->setFileName(fileName);
7683 ret->_content=c; c->incrRef();
7686 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7688 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7689 ret->setFileName(fileName);
7690 ret->_content=c; c->incrRef();
7693 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7696 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7697 try:MEDFileFieldGlobsReal(fileName)
7699 MEDFileUtilities::CheckFileForRead(fileName);
7700 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7701 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7704 catch(INTERP_KERNEL::Exception& e)
7709 //= MEDFileIntFieldMultiTSWithoutSDA
7711 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)
7713 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7716 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7720 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7724 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)
7725 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7728 catch(INTERP_KERNEL::Exception& e)
7732 * \param [in] fieldId field id in C mode
7734 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7735 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7738 catch(INTERP_KERNEL::Exception& e)
7741 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7743 return new MEDFileIntField1TSWithoutSDA;
7746 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7749 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7750 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7752 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7755 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7757 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7760 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7762 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7765 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7767 return new MEDFileIntFieldMultiTSWithoutSDA;
7770 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7772 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7773 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7775 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7777 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7780 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7782 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7783 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7784 ret->setIteration(i,elt);
7790 //= MEDFileAnyTypeFieldMultiTS
7793 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7794 * that has been read from a specified MED file.
7795 * \param [in] fileName - the name of the MED file to read.
7796 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7797 * is to delete this field using decrRef() as it is no more needed.
7798 * \throw If reading the file fails.
7800 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7802 MEDFileUtilities::CheckFileForRead(fileName);
7803 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7804 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7805 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7806 ret->loadGlobals(fid);
7811 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7812 * that has been read from a specified MED file.
7813 * \param [in] fileName - the name of the MED file to read.
7814 * \param [in] fieldName - the name of the field to read.
7815 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7816 * is to delete this field using decrRef() as it is no more needed.
7817 * \throw If reading the file fails.
7818 * \throw If there is no field named \a fieldName in the file.
7820 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7822 MEDFileUtilities::CheckFileForRead(fileName);
7823 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7824 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7825 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7826 ret->loadGlobals(fid);
7831 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7832 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7834 * \warning this is a shallow copy constructor
7836 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7838 if(!shallowCopyOfContent)
7840 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7841 otherPtr->incrRef();
7842 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7846 _content=other.shallowCpy();
7850 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7852 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7854 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7858 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7860 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7862 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7866 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7868 return contentNotNullBase()->getPflsReallyUsed2();
7871 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7873 return contentNotNullBase()->getLocsReallyUsed2();
7876 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7878 return contentNotNullBase()->getPflsReallyUsedMulti2();
7881 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7883 return contentNotNullBase()->getLocsReallyUsedMulti2();
7886 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7888 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7891 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7893 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7896 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7898 return contentNotNullBase()->getNumberOfTS();
7901 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7903 contentNotNullBase()->eraseEmptyTS();
7906 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7908 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7911 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7913 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7916 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7918 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7919 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7924 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7926 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7927 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7932 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7934 return contentNotNullBase()->getIterations();
7937 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7939 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7940 pushBackTimeStep(*it);
7943 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7946 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7947 checkCoherencyOfType(f1ts);
7949 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7950 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7952 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7953 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7954 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7955 _content->pushBackTimeStep(cSafe);
7956 appendGlobs(*f1ts,1e-12);
7959 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7961 contentNotNullBase()->synchronizeNameScope();
7964 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7966 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7969 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7971 return contentNotNullBase()->getPosGivenTime(time,eps);
7974 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7976 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7979 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7981 return contentNotNullBase()->getTypesOfFieldAvailable();
7984 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)
7986 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7989 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7991 return contentNotNullBase()->getName();
7994 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7996 contentNotNullBase()->setName(name);
7999 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
8001 return contentNotNullBase()->getDtUnit();
8004 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
8006 contentNotNullBase()->setDtUnit(dtUnit);
8009 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8011 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8014 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
8016 return contentNotNullBase()->getTimeSteps(ret1);
8019 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
8021 return contentNotNullBase()->getMeshName();
8024 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
8026 contentNotNullBase()->setMeshName(newMeshName);
8029 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8031 return contentNotNullBase()->changeMeshNames(modifTab);
8034 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8036 return contentNotNullBase()->getInfo();
8039 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8041 return contentNotNullBase()->setInfo(info);
8044 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8046 const std::vector<std::string> ret=getInfo();
8047 return (int)ret.size();
8050 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8052 writeGlobals(fid,*this);
8053 contentNotNullBase()->writeLL(fid,*this);
8057 * Writes \a this field into a MED file specified by its name.
8058 * \param [in] fileName - the MED file name.
8059 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8060 * - 2 - erase; an existing file is removed.
8061 * - 1 - append; same data should not be present in an existing file.
8062 * - 0 - overwrite; same data present in an existing file is overwritten.
8063 * \throw If the field name is not set.
8064 * \throw If no field data is set.
8065 * \throw If \a mode == 1 and the same data is present in an existing file.
8067 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8069 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8070 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8075 * This method alloc the arrays and load potentially huge arrays contained in this field.
8076 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8077 * This method can be also called to refresh or reinit values from a file.
8079 * \throw If the fileName is not set or points to a non readable MED file.
8081 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8083 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8084 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8088 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8089 * But once data loaded once, this method does nothing.
8091 * \throw If the fileName is not set or points to a non readable MED file.
8092 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8094 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8096 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8097 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8101 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8102 * This method does not release arrays set outside the context of a MED file.
8104 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8106 void MEDFileAnyTypeFieldMultiTS::unloadArrays() throw(INTERP_KERNEL::Exception)
8108 contentNotNullBase()->unloadArrays();
8111 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8113 std::ostringstream oss;
8114 contentNotNullBase()->simpleRepr(0,oss,-1);
8115 simpleReprGlobs(oss);
8119 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8122 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8123 ret+=_content->getHeapMemorySize();
8124 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8128 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8129 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8130 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8132 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8134 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8136 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8137 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8138 std::size_t sz(contentsSplit.size());
8139 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8140 for(std::size_t i=0;i<sz;i++)
8142 ret[i]=shallowCpy();
8143 ret[i]->_content=contentsSplit[i];
8149 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8150 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8152 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8154 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8156 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8157 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8158 std::size_t sz(contentsSplit.size());
8159 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8160 for(std::size_t i=0;i<sz;i++)
8162 ret[i]=shallowCpy();
8163 ret[i]->_content=contentsSplit[i];
8168 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8170 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8171 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8172 ret->_content=_content->deepCpy();
8173 ret->deepCpyGlobs(*this);
8177 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8183 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8184 * \param [in] iteration - the iteration number of a required time step.
8185 * \param [in] order - the iteration order number of required time step.
8186 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8187 * delete this field using decrRef() as it is no more needed.
8188 * \throw If there is no required time step in \a this field.
8190 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8192 int pos=getPosOfTimeStep(iteration,order);
8193 return getTimeStepAtPos(pos);
8197 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8198 * \param [in] time - the time of the time step of interest.
8199 * \param [in] eps - a precision used to compare time values.
8200 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8201 * delete this field using decrRef() as it is no more needed.
8202 * \throw If there is no required time step in \a this field.
8204 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8206 int pos=getPosGivenTime(time,eps);
8207 return getTimeStepAtPos(pos);
8211 * 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.
8212 * The float64 value of time attached to the pair of integers are not considered here.
8214 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8215 * \throw If there is a null pointer in \a vectFMTS.
8217 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8219 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8220 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8221 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8222 while(!lstFMTS.empty())
8224 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8225 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8227 throw INTERP_KERNEL::Exception(msg);
8228 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8229 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8230 elt.push_back(curIt); it=lstFMTS.erase(it);
8231 while(it!=lstFMTS.end())
8235 throw INTERP_KERNEL::Exception(msg);
8236 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8238 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8248 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8249 * All returned instances in a subvector can be safely loaded, rendered along time
8250 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8251 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8252 * 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).
8253 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8254 * 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.
8256 * \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().
8257 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8258 * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
8260 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8261 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8262 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8263 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8264 * \throw If mesh is null.
8265 * \throw If an element in \a vectFMTS is null.
8266 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8268 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc) throw(INTERP_KERNEL::Exception)
8270 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8272 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8273 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8274 if(vectFMTS.empty())
8276 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8277 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8279 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8280 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8281 for(;it!=vectFMTS.end();it++,i++)
8283 TypeOfField tof0,tof1;
8284 int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
8288 vectFMTSNotNodes.push_back(*it);
8290 vectFMTSNodes.push_back(*it);
8293 vectFMTSNotNodes.push_back(*it);
8295 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8296 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8298 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8301 bool isFetched(false);
8302 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8305 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8306 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8307 { ret[i].push_back(*it2); isFetched=true; }
8311 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8312 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8313 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8321 * 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.
8322 * \param [out] cmps - same size than the returned vector.
8324 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception)
8326 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8327 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8328 while(!lstFMTS.empty())
8330 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8331 MEDFileAnyTypeFieldMultiTS *ref(*it);
8332 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8333 elt.push_back(ref); it=lstFMTS.erase(it);
8334 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8335 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8336 while(it!=lstFMTS.end())
8338 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8339 if(cmp->isEqual(curIt))
8340 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8344 ret.push_back(elt); cmps.push_back(cmp);
8350 * 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.
8351 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8353 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8354 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8355 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8356 * \thorw If \a f0 and \a f1 do not have the same times steps.
8357 * \throw If mesh is null.
8358 * \throw If \a f0 or \a f1 is null.
8359 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8361 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception)
8364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8366 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8367 if(f0->getMeshName()!=mesh->getName())
8369 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8370 throw INTERP_KERNEL::Exception(oss.str().c_str());
8372 if(f1->getMeshName()!=mesh->getName())
8374 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8375 throw INTERP_KERNEL::Exception(oss.str().c_str());
8377 int nts=f0->getNumberOfTS();
8378 if(nts!=f1->getNumberOfTS())
8379 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8382 for(int i=0;i<nts;i++)
8384 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8385 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8386 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8387 if(tofs0.size()!=1 || tofs1.size()!=1)
8388 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8391 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8392 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8395 { tof0=tofs0[0]; tof1=tofs1[0]; }
8396 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8398 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() << ") !";
8399 throw INTERP_KERNEL::Exception(oss.str().c_str());
8401 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8403 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() << ") !";
8404 throw INTERP_KERNEL::Exception(oss.str().c_str());
8406 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8408 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() << ") !";
8409 throw INTERP_KERNEL::Exception(oss.str().c_str());
8415 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8417 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8420 //= MEDFileFieldMultiTS
8423 * Returns a new empty instance of MEDFileFieldMultiTS.
8424 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8425 * is to delete this field using decrRef() as it is no more needed.
8427 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8429 return new MEDFileFieldMultiTS;
8433 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8434 * that has been read from a specified MED file.
8435 * \param [in] fileName - the name of the MED file to read.
8436 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8437 * is to delete this field using decrRef() as it is no more needed.
8438 * \throw If reading the file fails.
8440 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8442 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8443 ret->contentNotNull();//to check that content type matches with \a this type.
8448 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8449 * that has been read from a specified MED file.
8450 * \param [in] fileName - the name of the MED file to read.
8451 * \param [in] fieldName - the name of the field to read.
8452 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8453 * is to delete this field using decrRef() as it is no more needed.
8454 * \throw If reading the file fails.
8455 * \throw If there is no field named \a fieldName in the file.
8457 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8459 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8460 ret->contentNotNull();//to check that content type matches with \a this type.
8465 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8466 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8468 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8469 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8470 * \warning this is a shallow copy constructor
8471 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8472 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8473 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8474 * is to delete this field using decrRef() as it is no more needed.
8476 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8478 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8481 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8483 return new MEDFileFieldMultiTS(*this);
8486 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8489 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8490 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8492 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8496 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8497 * following the given input policy.
8499 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8500 * By default (true) the globals are deeply copied.
8501 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8503 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8505 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8506 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8509 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8511 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8512 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8513 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8516 ret=MEDFileIntFieldMultiTS::New();
8518 ret->deepCpyGlobs(*this);
8520 ret->shallowCpyGlobs(*this);
8525 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8526 * \param [in] pos - a time step id.
8527 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8528 * delete this field using decrRef() as it is no more needed.
8529 * \throw If \a pos is not a valid time step id.
8531 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8533 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8536 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8537 throw INTERP_KERNEL::Exception(oss.str().c_str());
8539 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8542 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8543 ret->shallowCpyGlobs(*this);
8546 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8547 throw INTERP_KERNEL::Exception(oss.str().c_str());
8551 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8552 * mesh entities of a given dimension of the first mesh in MED file.
8553 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8554 * \param [in] type - a spatial discretization of interest.
8555 * \param [in] iteration - the iteration number of a required time step.
8556 * \param [in] order - the iteration order number of required time step.
8557 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8558 * \param [in] renumPol - specifies how to permute values of the result field according to
8559 * the optional numbers of cells and nodes, if any. The valid values are
8560 * - 0 - do not permute.
8561 * - 1 - permute cells.
8562 * - 2 - permute nodes.
8563 * - 3 - permute cells and nodes.
8565 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8566 * caller is to delete this field using decrRef() as it is no more needed.
8567 * \throw If the MED file is not readable.
8568 * \throw If there is no mesh in the MED file.
8569 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8570 * \throw If no field values of the required parameters are available.
8572 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8574 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8575 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8577 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8578 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8579 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8580 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8585 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8586 * the top level cells of the first mesh in MED file.
8587 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8588 * \param [in] type - a spatial discretization of interest.
8589 * \param [in] iteration - the iteration number of a required time step.
8590 * \param [in] order - the iteration order number of required time step.
8591 * \param [in] renumPol - specifies how to permute values of the result field according to
8592 * the optional numbers of cells and nodes, if any. The valid values are
8593 * - 0 - do not permute.
8594 * - 1 - permute cells.
8595 * - 2 - permute nodes.
8596 * - 3 - permute cells and nodes.
8598 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8599 * caller is to delete this field using decrRef() as it is no more needed.
8600 * \throw If the MED file is not readable.
8601 * \throw If there is no mesh in the MED file.
8602 * \throw If no field values of the required parameters are available.
8604 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8606 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8607 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8609 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8610 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8611 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8612 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8617 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8619 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8620 * \param [in] type - a spatial discretization of interest.
8621 * \param [in] iteration - the iteration number of a required time step.
8622 * \param [in] order - the iteration order number of required time step.
8623 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8624 * \param [in] mesh - the supporting mesh.
8625 * \param [in] renumPol - specifies how to permute values of the result field according to
8626 * the optional numbers of cells and nodes, if any. The valid values are
8627 * - 0 - do not permute.
8628 * - 1 - permute cells.
8629 * - 2 - permute nodes.
8630 * - 3 - permute cells and nodes.
8632 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8633 * caller is to delete this field using decrRef() as it is no more needed.
8634 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8635 * \throw If no field of \a this is lying on \a mesh.
8636 * \throw If no field values of the required parameters are available.
8638 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8640 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8641 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8643 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8644 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8645 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8646 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8651 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8653 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8654 * \param [in] type - a spatial discretization of the new field.
8655 * \param [in] iteration - the iteration number of a required time step.
8656 * \param [in] order - the iteration order number of required time step.
8657 * \param [in] mesh - the supporting mesh.
8658 * \param [in] renumPol - specifies how to permute values of the result field according to
8659 * the optional numbers of cells and nodes, if any. The valid values are
8660 * - 0 - do not permute.
8661 * - 1 - permute cells.
8662 * - 2 - permute nodes.
8663 * - 3 - permute cells and nodes.
8665 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8666 * caller is to delete this field using decrRef() as it is no more needed.
8667 * \throw If no field of \a this is lying on \a mesh.
8668 * \throw If no field values of the required parameters are available.
8670 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8672 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8673 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8675 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8676 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8677 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8678 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8683 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8684 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8685 * This method is useful for MED2 file format when field on different mesh was autorized.
8687 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8689 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8690 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8692 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8693 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8694 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8695 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8700 * Returns values and a profile of the field of a given type, of a given time step,
8701 * lying on a given support.
8702 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8703 * \param [in] type - a spatial discretization of the field.
8704 * \param [in] iteration - the iteration number of a required time step.
8705 * \param [in] order - the iteration order number of required time step.
8706 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8707 * \param [in] mesh - the supporting mesh.
8708 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8709 * field of interest lies on. If the field lies on all entities of the given
8710 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8711 * using decrRef() as it is no more needed.
8712 * \param [in] glob - the global data storing profiles and localization.
8713 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8714 * field. The caller is to delete this array using decrRef() as it is no more needed.
8715 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8716 * \throw If no field of \a this is lying on \a mesh.
8717 * \throw If no field values of the required parameters are available.
8719 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8721 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8722 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8724 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8725 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8726 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8729 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8731 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8733 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8734 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8736 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 !");
8740 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8742 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8744 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8745 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8747 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 !");
8752 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8753 * the given field is checked if its elements are sorted suitable for writing to MED file
8754 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8755 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8756 * \param [in] field - the field to add to \a this.
8757 * \throw If the name of \a field is empty.
8758 * \throw If the data array of \a field is not set.
8759 * \throw If existing time steps have different name or number of components than \a field.
8760 * \throw If the underlying mesh of \a field has no name.
8761 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8763 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8765 const DataArrayDouble *arr=0;
8767 arr=field->getArray();
8768 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8772 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8773 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8774 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8777 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8778 * A new profile is added only if no equal profile is missing.
8779 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8780 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8781 * \param [in] mesh - the supporting mesh of \a field.
8782 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8783 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8784 * \throw If either \a field or \a mesh or \a profile has an empty name.
8785 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8786 * \throw If the data array of \a field is not set.
8787 * \throw If the data array of \a this is already allocated but has different number of
8788 * components than \a field.
8789 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8790 * \sa setFieldNoProfileSBT()
8792 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8794 const DataArrayDouble *arr=0;
8796 arr=field->getArray();
8797 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8800 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8802 _content=new MEDFileFieldMultiTSWithoutSDA;
8805 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8806 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8809 catch(INTERP_KERNEL::Exception& e)
8812 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8813 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8816 catch(INTERP_KERNEL::Exception& e)
8819 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8823 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)
8825 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8828 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8830 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8833 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)
8835 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8838 //= MEDFileAnyTypeFieldMultiTSIterator
8840 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8845 _nb_iter=fmts->getNumberOfTS();
8849 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8853 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8855 if(_iter_id<_nb_iter)
8857 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8859 return fmts->getTimeStepAtPos(_iter_id++);
8867 //= MEDFileIntFieldMultiTS
8870 * Returns a new empty instance of MEDFileFieldMultiTS.
8871 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8872 * is to delete this field using decrRef() as it is no more needed.
8874 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8876 return new MEDFileIntFieldMultiTS;
8880 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8881 * that has been read from a specified MED file.
8882 * \param [in] fileName - the name of the MED file to read.
8883 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8884 * is to delete this field using decrRef() as it is no more needed.
8885 * \throw If reading the file fails.
8887 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8889 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8890 ret->contentNotNull();//to check that content type matches with \a this type.
8895 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8896 * that has been read from a specified MED file.
8897 * \param [in] fileName - the name of the MED file to read.
8898 * \param [in] fieldName - the name of the field to read.
8899 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8900 * is to delete this field using decrRef() as it is no more needed.
8901 * \throw If reading the file fails.
8902 * \throw If there is no field named \a fieldName in the file.
8904 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8906 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8907 ret->contentNotNull();//to check that content type matches with \a this type.
8912 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8913 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8915 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8916 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8917 * \warning this is a shallow copy constructor
8918 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8919 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8920 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8921 * is to delete this field using decrRef() as it is no more needed.
8923 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8925 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8929 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8930 * following the given input policy.
8932 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8933 * By default (true) the globals are deeply copied.
8934 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8936 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8938 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8939 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8942 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8944 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8945 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8946 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8949 ret=MEDFileFieldMultiTS::New();
8951 ret->deepCpyGlobs(*this);
8953 ret->shallowCpyGlobs(*this);
8957 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8959 return new MEDFileIntFieldMultiTS(*this);
8962 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8965 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8966 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8968 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8972 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8973 * mesh entities of a given dimension of the first mesh in MED file.
8974 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8975 * \param [in] type - a spatial discretization of interest.
8976 * \param [in] iteration - the iteration number of a required time step.
8977 * \param [in] order - the iteration order number of required time step.
8978 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8979 * \param [out] arrOut - the DataArrayInt containing values of field.
8980 * \param [in] renumPol - specifies how to permute values of the result field according to
8981 * the optional numbers of cells and nodes, if any. The valid values are
8982 * - 0 - do not permute.
8983 * - 1 - permute cells.
8984 * - 2 - permute nodes.
8985 * - 3 - permute cells and nodes.
8987 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8988 * caller is to delete this field using decrRef() as it is no more needed.
8989 * \throw If the MED file is not readable.
8990 * \throw If there is no mesh in the MED file.
8991 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8992 * \throw If no field values of the required parameters are available.
8994 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8996 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8997 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8999 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9000 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9001 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
9002 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9007 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9008 * the top level cells of the first mesh in MED file.
9009 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9010 * \param [in] type - a spatial discretization of interest.
9011 * \param [in] iteration - the iteration number of a required time step.
9012 * \param [in] order - the iteration order number of required time step.
9013 * \param [out] arrOut - the DataArrayInt containing values of field.
9014 * \param [in] renumPol - specifies how to permute values of the result field according to
9015 * the optional numbers of cells and nodes, if any. The valid values are
9016 * - 0 - do not permute.
9017 * - 1 - permute cells.
9018 * - 2 - permute nodes.
9019 * - 3 - permute cells and nodes.
9021 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9022 * caller is to delete this field using decrRef() as it is no more needed.
9023 * \throw If the MED file is not readable.
9024 * \throw If there is no mesh in the MED file.
9025 * \throw If no field values of the required parameters are available.
9027 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9029 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9030 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9032 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9033 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9034 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
9035 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9040 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9042 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9043 * \param [in] type - a spatial discretization of interest.
9044 * \param [in] iteration - the iteration number of a required time step.
9045 * \param [in] order - the iteration order number of required time step.
9046 * \param [out] arrOut - the DataArrayInt containing values of field.
9047 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9048 * \param [in] mesh - the supporting mesh.
9049 * \param [in] renumPol - specifies how to permute values of the result field according to
9050 * the optional numbers of cells and nodes, if any. The valid values are
9051 * - 0 - do not permute.
9052 * - 1 - permute cells.
9053 * - 2 - permute nodes.
9054 * - 3 - permute cells and nodes.
9056 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9057 * caller is to delete this field using decrRef() as it is no more needed.
9058 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9059 * \throw If no field of \a this is lying on \a mesh.
9060 * \throw If no field values of the required parameters are available.
9062 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9064 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9065 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9067 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9068 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9069 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9070 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9075 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9077 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9078 * \param [in] type - a spatial discretization of the new field.
9079 * \param [in] iteration - the iteration number of a required time step.
9080 * \param [in] order - the iteration order number of required time step.
9081 * \param [in] mesh - the supporting mesh.
9082 * \param [out] arrOut - the DataArrayInt containing values of field.
9083 * \param [in] renumPol - specifies how to permute values of the result field according to
9084 * the optional numbers of cells and nodes, if any. The valid values are
9085 * - 0 - do not permute.
9086 * - 1 - permute cells.
9087 * - 2 - permute nodes.
9088 * - 3 - permute cells and nodes.
9090 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9091 * caller is to delete this field using decrRef() as it is no more needed.
9092 * \throw If no field of \a this is lying on \a mesh.
9093 * \throw If no field values of the required parameters are available.
9095 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9097 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9098 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9100 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9101 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9102 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9103 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9108 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9109 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9110 * This method is useful for MED2 file format when field on different mesh was autorized.
9112 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9114 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9115 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9117 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9118 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9119 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9120 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9125 * Returns values and a profile of the field of a given type, of a given time step,
9126 * lying on a given support.
9127 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9128 * \param [in] type - a spatial discretization of the field.
9129 * \param [in] iteration - the iteration number of a required time step.
9130 * \param [in] order - the iteration order number of required time step.
9131 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9132 * \param [in] mesh - the supporting mesh.
9133 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9134 * field of interest lies on. If the field lies on all entities of the given
9135 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9136 * using decrRef() as it is no more needed.
9137 * \param [in] glob - the global data storing profiles and localization.
9138 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9139 * field. The caller is to delete this array using decrRef() as it is no more needed.
9140 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9141 * \throw If no field of \a this is lying on \a mesh.
9142 * \throw If no field values of the required parameters are available.
9144 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
9146 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9147 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9149 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9150 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9151 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9155 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9156 * \param [in] pos - a time step id.
9157 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9158 * delete this field using decrRef() as it is no more needed.
9159 * \throw If \a pos is not a valid time step id.
9161 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
9163 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9166 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9167 throw INTERP_KERNEL::Exception(oss.str().c_str());
9169 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9172 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9173 ret->shallowCpyGlobs(*this);
9176 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9177 throw INTERP_KERNEL::Exception(oss.str().c_str());
9181 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9182 * the given field is checked if its elements are sorted suitable for writing to MED file
9183 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9184 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9185 * \param [in] field - the field to add to \a this.
9186 * \throw If the name of \a field is empty.
9187 * \throw If the data array of \a field is not set.
9188 * \throw If existing time steps have different name or number of components than \a field.
9189 * \throw If the underlying mesh of \a field has no name.
9190 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9192 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
9194 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9198 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9199 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9200 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9203 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9204 * A new profile is added only if no equal profile is missing.
9205 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9206 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9207 * \param [in] arrOfVals - the values of the field \a field used.
9208 * \param [in] mesh - the supporting mesh of \a field.
9209 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9210 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9211 * \throw If either \a field or \a mesh or \a profile has an empty name.
9212 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9213 * \throw If the data array of \a field is not set.
9214 * \throw If the data array of \a this is already allocated but has different number of
9215 * components than \a field.
9216 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9217 * \sa setFieldNoProfileSBT()
9219 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9221 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9224 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9226 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9228 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9229 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9231 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 !");
9235 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9237 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9239 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9240 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9242 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 !");
9246 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9248 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9251 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9255 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9256 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9259 catch(INTERP_KERNEL::Exception& e)
9262 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9263 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9266 catch(INTERP_KERNEL::Exception& e)
9269 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9271 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9276 MEDFileFields *MEDFileFields::New()
9278 return new MEDFileFields;
9281 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9283 return new MEDFileFields(fileName,loadAll);
9286 std::size_t MEDFileFields::getHeapMemorySize() const
9288 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9289 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9290 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9291 ret+=(*it)->getHeapMemorySize();
9292 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9295 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9297 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9299 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9301 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9302 ret->_fields[i]=(*it)->deepCpy();
9304 ret->deepCpyGlobs(*this);
9308 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9310 return new MEDFileFields(*this);
9314 * 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
9315 * 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.
9316 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9318 * \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.
9319 * \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.
9321 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9323 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9325 std::set< std::pair<int,int> > s;
9326 bool firstShot=true;
9327 areThereSomeForgottenTS=false;
9328 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9330 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9332 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9333 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9335 { s=s1; firstShot=false; }
9338 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9340 areThereSomeForgottenTS=true;
9344 std::vector< std::pair<int,int> > ret;
9345 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9349 int MEDFileFields::getNumberOfFields() const
9351 return _fields.size();
9354 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9356 std::vector<std::string> ret(_fields.size());
9358 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9360 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9363 ret[i]=f->getName();
9367 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9368 throw INTERP_KERNEL::Exception(oss.str().c_str());
9374 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9376 std::vector<std::string> ret;
9377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9379 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9381 ret.push_back(cur->getMeshName());
9386 std::string MEDFileFields::simpleRepr() const
9388 std::ostringstream oss;
9389 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9394 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9396 int nbOfFields=getNumberOfFields();
9397 std::string startLine(bkOffset,' ');
9398 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9400 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9402 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9405 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9409 oss << startLine << " - not defined !" << std::endl;
9413 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9415 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9416 std::string chapter(17,'0'+i);
9417 oss << startLine << chapter << std::endl;
9420 cur->simpleRepr(bkOffset+2,oss,i);
9424 oss << startLine << " - not defined !" << std::endl;
9426 oss << startLine << chapter << std::endl;
9428 simpleReprGlobs(oss);
9431 MEDFileFields::MEDFileFields()
9435 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9436 try:MEDFileFieldGlobsReal(fileName)
9438 MEDFileUtilities::CheckFileForRead(fileName);
9439 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9440 int nbFields=MEDnField(fid);
9441 _fields.resize(nbFields);
9442 med_field_type typcha;
9443 for(int i=0;i<nbFields;i++)
9445 std::vector<std::string> infos;
9446 std::string fieldName,dtunit;
9447 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9452 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9457 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9462 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] !";
9463 throw INTERP_KERNEL::Exception(oss.str().c_str());
9467 loadAllGlobals(fid);
9469 catch(INTERP_KERNEL::Exception& e)
9474 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9477 writeGlobals(fid,*this);
9478 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9480 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9483 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9484 throw INTERP_KERNEL::Exception(oss.str().c_str());
9486 elt->writeLL(fid,*this);
9490 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9492 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9493 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9498 * This method alloc the arrays and load potentially huge arrays contained in this field.
9499 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9500 * This method can be also called to refresh or reinit values from a file.
9502 * \throw If the fileName is not set or points to a non readable MED file.
9504 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9506 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9509 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9511 elt->loadBigArraysRecursively(fid,*elt);
9516 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9517 * But once data loaded once, this method does nothing.
9519 * \throw If the fileName is not set or points to a non readable MED file.
9520 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9522 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9524 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9525 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9527 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9529 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9534 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9535 * This method does not release arrays set outside the context of a MED file.
9537 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9539 void MEDFileFields::unloadArrays() throw(INTERP_KERNEL::Exception)
9541 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9542 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9544 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9546 elt->unloadArrays();
9550 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9552 std::vector<std::string> ret;
9553 std::set<std::string> ret2;
9554 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9556 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9557 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9558 if(ret2.find(*it2)==ret2.end())
9560 ret.push_back(*it2);
9567 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9569 std::vector<std::string> ret;
9570 std::set<std::string> ret2;
9571 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9573 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9574 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9575 if(ret2.find(*it2)==ret2.end())
9577 ret.push_back(*it2);
9584 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9586 std::vector<std::string> ret;
9587 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9589 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9590 ret.insert(ret.end(),tmp.begin(),tmp.end());
9595 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9597 std::vector<std::string> ret;
9598 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9600 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9601 ret.insert(ret.end(),tmp.begin(),tmp.end());
9606 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9608 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9609 (*it)->changePflsRefsNamesGen2(mapOfModif);
9612 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9614 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9615 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9618 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9620 _fields.resize(newSize);
9623 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9625 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9629 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9632 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9633 _fields.push_back(field->getContent());
9634 appendGlobs(*field,1e-12);
9637 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9640 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9641 if(i>=(int)_fields.size())
9642 _fields.resize(i+1);
9643 _fields[i]=field->getContent();
9644 appendGlobs(*field,1e-12);
9647 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9649 destroyFieldsAtPos(&i,&i+1);
9652 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9654 std::vector<bool> b(_fields.size(),true);
9655 for(const int *i=startIds;i!=endIds;i++)
9657 if(*i<0 || *i>=(int)_fields.size())
9659 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9660 throw INTERP_KERNEL::Exception(oss.str().c_str());
9664 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9666 for(std::size_t i=0;i<_fields.size();i++)
9668 fields[j++]=_fields[i];
9672 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9674 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9675 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9676 std::vector<bool> b(_fields.size(),true);
9678 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9680 if(k<0 || k>=(int)_fields.size())
9682 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9683 throw INTERP_KERNEL::Exception(oss.str().c_str());
9687 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9689 for(std::size_t i=0;i<_fields.size();i++)
9691 fields[j++]=_fields[i];
9695 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9698 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9700 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9702 ret=cur->changeMeshNames(modifTab) || ret;
9708 * \param [in] meshName the name of the mesh that will be renumbered.
9709 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9710 * This code corresponds to the distribution of types in the corresponding mesh.
9711 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9712 * \param [in] renumO2N the old to new renumber array.
9713 * \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
9716 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9719 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9721 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9724 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9730 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9732 if(i<0 || i>=(int)_fields.size())
9734 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9735 throw INTERP_KERNEL::Exception(oss.str().c_str());
9737 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9740 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9741 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9742 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9744 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9746 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9749 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9750 throw INTERP_KERNEL::Exception(oss.str().c_str());
9752 ret->shallowCpyGlobs(*this);
9757 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9758 * This method is accessible in python using __getitem__ with a list in input.
9759 * \return a new object that the caller should deal with.
9761 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9763 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9764 std::size_t sz=std::distance(startIds,endIds);
9765 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9767 for(const int *i=startIds;i!=endIds;i++,j++)
9769 if(*i<0 || *i>=(int)_fields.size())
9771 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9772 throw INTERP_KERNEL::Exception(oss.str().c_str());
9774 fields[j]=_fields[*i];
9776 ret->_fields=fields;
9780 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9782 return getFieldAtPos(getPosFromFieldName(fieldName));
9786 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9787 * This method can be seen as a filter applied on \a this, that returns an object containing
9788 * 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
9789 * shallow copied from \a this.
9791 * \param [in] meshName - the name of the mesh on w
9792 * \return a new object that the caller should deal with.
9794 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9796 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9797 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9799 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9802 if(cur->getMeshName()==meshName)
9805 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9806 ret->_fields.push_back(cur2);
9809 ret->shallowCpyOnlyUsedGlobs(*this);
9814 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9815 * Input time steps are specified using a pair of integer (iteration, order).
9816 * 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,
9817 * but for each multitimestep only the time steps in \a timeSteps are kept.
9818 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9820 * The returned object points to shallow copy of elements in \a this.
9822 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9823 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9824 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9826 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9828 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9829 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9831 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9834 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9835 ret->_fields.push_back(elt);
9837 ret->shallowCpyOnlyUsedGlobs(*this);
9842 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9844 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9846 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9847 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9849 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9852 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9853 if(elt->getNumberOfTS()!=0)
9854 ret->_fields.push_back(elt);
9856 ret->shallowCpyOnlyUsedGlobs(*this);
9860 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9862 return new MEDFileFieldsIterator(this);
9865 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9867 std::string tmp(fieldName);
9868 std::vector<std::string> poss;
9869 for(std::size_t i=0;i<_fields.size();i++)
9871 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9874 std::string fname(f->getName());
9878 poss.push_back(fname);
9881 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9882 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9884 throw INTERP_KERNEL::Exception(oss.str().c_str());
9887 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9892 _nb_iter=fs->getNumberOfFields();
9896 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9900 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9902 if(_iter_id<_nb_iter)
9904 MEDFileFields *fs(_fs);
9906 return fs->getFieldAtPos(_iter_id++);