1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
47 return new MEDFileFieldLoc(fid,locName);
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
52 return new MEDFileFieldLoc(fid,id);
55 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
57 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
62 med_geometry_type geotype;
63 med_geometry_type sectiongeotype;
65 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
68 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70 _nb_node_per_cell=cm.getNumberOfNodes();
71 _ref_coo.resize(_dim*_nb_node_per_cell);
72 _gs_coo.resize(_dim*_nb_gauss_pt);
73 _w.resize(_nb_gauss_pt);
74 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
79 med_geometry_type geotype;
80 med_geometry_type sectiongeotype;
82 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
87 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89 _nb_node_per_cell=cm.getNumberOfNodes();
90 _ref_coo.resize(_dim*_nb_node_per_cell);
91 _gs_coo.resize(_dim*_nb_gauss_pt);
92 _w.resize(_nb_gauss_pt);
93 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101 _dim=cm.getDimension();
102 _nb_node_per_cell=cm.getNumberOfNodes();
103 _nb_gauss_pt=_w.size();
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
108 return new MEDFileFieldLoc(*this);
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
113 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
118 static const char OFF7[]="\n ";
119 oss << "\"" << _name << "\"" << OFF7;
120 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121 oss << "Dimension=" << _dim << OFF7;
122 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
129 void MEDFileFieldLoc::setName(const char *name)
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
136 if(_name!=other._name)
140 if(_nb_gauss_pt!=other._nb_gauss_pt)
142 if(_nb_node_per_cell!=other._nb_node_per_cell)
144 if(_geo_type!=other._geo_type)
146 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
148 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
150 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
158 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
161 std::string MEDFileFieldLoc::repr() const
163 std::ostringstream oss; oss.precision(15);
164 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
166 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
167 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
168 oss << "\n - Ref coords are : ";
169 int sz=_ref_coo.size();
172 int nbOfTuples=sz/_dim;
173 for(int i=0;i<nbOfTuples;i++)
176 for(int j=0;j<_dim;j++)
177 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
182 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183 oss << "\n - Gauss coords in reference element : ";
187 int nbOfTuples=sz/_dim;
188 for(int i=0;i<nbOfTuples;i++)
191 for(int j=0;j<_dim;j++)
192 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
197 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
204 _type=field->getTypeOfField();
210 getArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211 _end=_start+nbOfCells;
217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218 const int *arrPtr=arr->getConstPointer();
219 getArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
226 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
230 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233 const int *dai2Ptr=dai2->getConstPointer();
234 int nbi=gsLoc.getWeights().size();
235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237 const int *da3Ptr=da3->getConstPointer();
238 if(da3->getNumberOfTuples()!=nbOfCells)
239 {//profile : for gauss even in NoProfile !!!
240 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
242 da3->setName(_profile.c_str());
243 glob.appendProfile(da3);
245 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246 _nval=da3->getNbOfElems();
247 da4->alloc(_nval*nbi,1);
248 int *da4Ptr=da4->getPointer();
249 for(int i=0;i<_nval;i++)
251 int ref=dai2Ptr[offset+da3Ptr[i]];
252 for(int j=0;j<nbi;j++)
255 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256 _localization=oss2.str();
257 getArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258 _end=_start+_nval*nbi;
259 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
269 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
271 * \param [in] multiTypePfl is the end user profile specified in high level API
272 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
274 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
280 _type=field->getTypeOfField();
281 std::string pflName(multiTypePfl->getName());
282 std::ostringstream oss; oss << pflName;
283 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288 if(_type!=ON_GAUSS_PT)
290 locIds->setName(oss.str().c_str());
291 glob.appendProfile(locIds);
300 _nval=idsInPfl->getNumberOfTuples();
301 getArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
307 _nval=idsInPfl->getNumberOfTuples();
308 getArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
314 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317 arr3->computeOffsets2();
318 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319 int trueNval=tmp->getNumberOfTuples();
320 _nval=idsInPfl->getNumberOfTuples();
321 getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322 _end=_start+trueNval;
327 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
329 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
336 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
339 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
341 for(const int *pt=da4->begin();pt!=da4->end();pt++)
342 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343 tmp->alloc(trueNval,1);
344 int *tmpPtr=tmp->getPointer();
345 for(const int *pt=da4->begin();pt!=da4->end();pt++)
346 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
349 _nval=da4->getNumberOfTuples();
350 getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351 _end=_start+trueNval;
352 oss << "_loc_" << _loc_id;
355 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356 da5->setName(oss.str().c_str());
357 glob.appendProfile(da5);
362 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
364 da3->setName(oss.str().c_str());
365 glob.appendProfile(da3);
369 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370 _localization=oss2.str();
371 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
383 _nval=arrr->getNumberOfTuples();
384 getArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
391 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
396 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
401 return new MEDFileFieldPerMeshPerTypePerDisc(other);
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
406 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
411 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
420 catch(INTERP_KERNEL::Exception& e)
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
443 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
445 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447 std::string fieldName=nasc.getName();
448 std::string meshName=getMeshName();
449 int iteration=getIteration();
450 int order=getOrder();
451 TypeOfField type=getType();
452 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
454 med_geometry_type mgeoti;
455 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457 pflname,&profilesize,locname,&nbi);
458 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
461 _end=start+_nval*nbi;
463 if(type==ON_CELLS && !_localization.empty())
465 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466 setType(ON_GAUSS_PT);
469 setType(ON_GAUSS_NE);
470 _localization.clear();
475 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
477 std::string fieldName=nasc.getName();
478 std::string meshName=getMeshName();
479 int iteration=getIteration();
480 int order=getOrder();
481 TypeOfField type=getType();
482 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483 med_geometry_type mgeoti;
484 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
485 DataArray *arr=getArray();
486 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
489 double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents();
490 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
491 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
494 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
497 int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents();
498 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
499 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
502 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
506 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
508 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
510 int delta=_end-_start;
511 _start=newValueOfStart;
515 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
517 return _father->getIteration();
520 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
522 return _father->getOrder();
525 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
527 return _father->getTime();
530 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
532 return _father->getMeshName();
535 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
537 const char startLine[]=" ## ";
538 std::string startLine2(bkOffset,' ');
539 startLine2+=startLine;
540 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
541 oss << startLine2 << "Localization #" << id << "." << std::endl;
542 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
544 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
545 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
546 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
549 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
554 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
559 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
564 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
566 return _father->getGeoType();
569 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
571 return _father->getNumberOfComponents();
574 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
579 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray()
581 return _father->getArray();
584 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
586 const MEDFileFieldPerMeshPerType *fath=_father;
587 return fath->getArray();
590 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
592 return _father->getInfo();
595 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
600 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
605 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
607 return _localization;
610 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
612 _localization=newLocName;
615 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
617 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
619 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
621 _profile=(*it2).second;
627 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
629 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
631 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
633 _localization=(*it2).second;
639 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
643 dads.push_back(std::pair<int,int>(_start,_end));
644 geoTypes.push_back(getGeoType());
649 pfls.push_back(glob->getProfile(_profile.c_str()));
651 if(_localization.empty())
655 locs.push_back(glob->getLocalizationId(_localization.c_str()));
659 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
661 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));
665 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
667 TypeOfField type=getType();
668 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
669 med_geometry_type mgeoti;
670 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
671 const DataArray *arr=getArray();
673 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
674 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
675 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
676 const unsigned char *locToWrite=0;
678 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
680 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
682 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
683 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
684 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
688 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
693 dad.first=_start; dad.second=_end;
697 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
698 * This code corresponds to the distribution of types in the corresponding mesh.
699 * \param [out] ptToFill memory zone where the output will be stored.
700 * \return the size of data pushed into output param \a ptToFill
702 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
705 std::ostringstream oss;
706 std::size_t nbOfType=codeOfMesh.size()/3;
708 for(std::size_t i=0;i<nbOfType && found==-1;i++)
709 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
713 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
714 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
715 throw INTERP_KERNEL::Exception(oss.str().c_str());
720 if(_nval!=codeOfMesh[3*found+1])
722 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
723 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
724 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
725 throw INTERP_KERNEL::Exception(oss.str().c_str());
727 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
732 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
733 if(pfl->getNumberOfTuples()!=_nval)
735 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
736 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
738 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
739 throw INTERP_KERNEL::Exception(oss.str().c_str());
741 int offset2=codeOfMesh[3*found+2];
742 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
744 if(*pflId<codeOfMesh[3*found+1])
745 *work++=offset2+*pflId;
751 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
753 for(int i=_start;i<_end;i++)
758 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
769 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
773 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
776 std::map<std::pair<std::string,TypeOfField>,int> m;
777 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
778 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
779 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
780 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
782 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
783 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
788 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
790 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
791 * \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.
792 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
793 * \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)
794 * \param [in,out] glob if necessary by the method, new profiles can be added to it
795 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
796 * \param [out] result All new entries will be appended on it.
797 * \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 !)
799 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
800 const DataArrayInt *explicitIdsInMesh,
801 const std::vector<int>& newCode,
802 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
803 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
805 if(entriesOnSameDisc.empty())
807 TypeOfField type=entriesOnSameDisc[0]->getType();
808 int szEntities=0,szTuples=0;
809 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
810 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
811 int nbi=szTuples/szEntities;
812 if(szTuples%szEntities!=0)
813 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
814 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
815 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
816 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
817 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
818 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
819 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
820 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
822 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
824 int startOfEltIdOfChunk=(*it)->_start;
825 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
827 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
829 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
830 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
832 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
833 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
835 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
836 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
840 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
842 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
843 arrPart->renumberInPlace(renumTupleIds->begin());
844 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
846 const int *idIt=diffVals->begin();
847 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
849 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
851 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
853 int nbEntityElts=subIds->getNumberOfTuples();
855 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
856 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
860 result.push_back(eltToAdd);
861 offset2+=nbEntityElts*nbi;
863 ret=ret || li.empty();
868 * \param [in] typeF type of field of new chunk
869 * \param [in] geoType the geometric type of the chunk
870 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
871 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
872 * \param [in] nbi number of integration points
873 * \param [in] offset The offset in the **global array of data**.
874 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
875 * to the new chunk to create.
876 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
877 * \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
878 * and corresponding entry erased from \a entriesOnSameDisc.
879 * \return a newly allocated chunk
881 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
882 bool isPfl, int nbi, int offset,
883 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
884 MEDFileFieldGlobsReal& glob,
885 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
887 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
888 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
889 for(;it!=entriesOnSameDisc.end();it++)
891 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
895 if((*it)->_profile.empty())
898 if(!(*it)->_profile.empty())
900 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
901 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
907 if(it==entriesOnSameDisc.end())
910 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
912 ret->_loc_id=(int)geoType;
913 ret->_nval=nbMeshEntities;
915 ret->_end=ret->_start+ret->_nval*nbi;
918 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
919 glob.appendProfile(idsOfMeshElt);
920 ret->_profile=idsOfMeshElt->getName();
922 //tony treatment of localization
928 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
929 ret->_loc_id=(int)geoType;
930 ret->setNewStart(offset);
931 entriesOnSameDisc.erase(it);
937 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
939 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
942 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
944 return new MEDFileFieldPerMeshPerType(fath,geoType);
947 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
949 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
950 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
951 ret+=(*it)->getHeapMemorySize();
955 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
957 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
960 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
962 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
963 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
968 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
970 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
971 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
972 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
976 * This method is the most general one. No optimization is done here.
977 * \param [in] multiTypePfl is the end user profile specified in high level API
978 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
979 * \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.
980 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
981 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
982 * \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.
984 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)
986 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
987 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
988 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
991 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
993 _field_pm_pt_pd.resize(1);
994 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
995 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
998 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1000 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1002 _field_pm_pt_pd.resize(1);
1003 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1004 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1007 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1009 TypeOfField type=field->getTypeOfField();
1010 if(type!=ON_GAUSS_PT)
1012 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1013 int sz=_field_pm_pt_pd.size();
1015 for(int j=0;j<sz && !found;j++)
1017 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1019 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1025 _field_pm_pt_pd.resize(sz+1);
1026 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1028 std::vector<int> ret(1,0);
1033 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1034 int sz2=ret2.size();
1035 std::vector<int> ret3(sz2);
1037 for(int i=0;i<sz2;i++)
1039 int sz=_field_pm_pt_pd.size();
1040 int locIdToFind=ret2[i];
1042 for(int j=0;j<sz && !found;j++)
1044 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1046 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1053 _field_pm_pt_pd.resize(sz+1);
1054 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1062 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1064 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1065 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1067 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1068 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1070 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1071 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1072 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1073 if(retTmp->presenceOfValue(-1))
1074 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1075 std::vector<int> ret(retTmp->begin(),retTmp->end());
1079 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1081 TypeOfField type=field->getTypeOfField();
1082 if(type!=ON_GAUSS_PT)
1084 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1085 int sz=_field_pm_pt_pd.size();
1087 for(int j=0;j<sz && !found;j++)
1089 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1091 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1097 _field_pm_pt_pd.resize(sz+1);
1098 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1100 std::vector<int> ret(1,0);
1105 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1106 int sz2=ret2.size();
1107 std::vector<int> ret3(sz2);
1109 for(int i=0;i<sz2;i++)
1111 int sz=_field_pm_pt_pd.size();
1112 int locIdToFind=ret2[i];
1114 for(int j=0;j<sz && !found;j++)
1116 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1118 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1125 _field_pm_pt_pd.resize(sz+1);
1126 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1134 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1136 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1137 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1139 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1140 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1142 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1143 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1144 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1145 if(retTmp->presenceOfValue(-1))
1146 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1147 std::vector<int> ret(retTmp->begin(),retTmp->end());
1151 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1156 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1158 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1159 int curDim=(int)cm.getDimension();
1160 dim=std::max(dim,curDim);
1163 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1165 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1167 (*it)->fillTypesOfFieldAvailable(types);
1171 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)
1173 int sz=_field_pm_pt_pd.size();
1174 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1175 for(int i=0;i<sz;i++)
1177 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1181 int MEDFileFieldPerMeshPerType::getIteration() const
1183 return _father->getIteration();
1186 int MEDFileFieldPerMeshPerType::getOrder() const
1188 return _father->getOrder();
1191 double MEDFileFieldPerMeshPerType::getTime() const
1193 return _father->getTime();
1196 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1198 return _father->getMeshName();
1201 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1203 const char startLine[]=" ## ";
1204 std::string startLine2(bkOffset,' ');
1205 std::string startLine3(startLine2);
1206 startLine3+=startLine;
1207 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1209 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1210 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1213 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1214 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1216 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1218 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1220 cur->simpleRepr(bkOffset,oss,i);
1223 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1228 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1230 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1232 globalSz+=(*it)->getNumberOfTuples();
1234 nbOfEntries+=(int)_field_pm_pt_pd.size();
1237 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1243 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1245 return _father->getNumberOfComponents();
1248 DataArray *MEDFileFieldPerMeshPerType::getArray()
1250 return _father->getArray();
1253 const DataArray *MEDFileFieldPerMeshPerType::getArray() const
1255 const MEDFileFieldPerMesh *fath=_father;
1256 return fath->getArray();
1259 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1261 return _father->getInfo();
1264 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1266 std::vector<std::string> ret;
1267 std::set<std::string> ret2;
1268 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1270 std::string tmp=(*it1)->getProfile();
1272 if(ret2.find(tmp)==ret2.end())
1281 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1283 std::vector<std::string> ret;
1284 std::set<std::string> ret2;
1285 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1287 std::string tmp=(*it1)->getLocalization();
1288 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1289 if(ret2.find(tmp)==ret2.end())
1298 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1300 std::vector<std::string> ret;
1301 std::set<std::string> ret2;
1302 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1304 std::string tmp=(*it1)->getProfile();
1311 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1313 std::vector<std::string> ret;
1314 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1316 std::string tmp=(*it1)->getLocalization();
1317 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1323 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1325 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1326 (*it1)->changePflsRefsNamesGen(mapOfModif);
1329 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1331 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1332 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1335 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1337 if(_field_pm_pt_pd.empty())
1339 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1340 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1341 throw INTERP_KERNEL::Exception(oss.str().c_str());
1343 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1344 return _field_pm_pt_pd[locId];
1345 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1346 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1347 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1348 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1349 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1352 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1354 if(_field_pm_pt_pd.empty())
1356 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1357 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1358 throw INTERP_KERNEL::Exception(oss.str().c_str());
1360 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1361 return _field_pm_pt_pd[locId];
1362 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1363 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1364 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1365 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1366 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1369 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
1371 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1373 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1374 if(meshDim!=(int)cm.getDimension())
1377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1378 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1381 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1384 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1386 (*it)->fillValues(i,startEntryId,entries);
1390 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1392 _field_pm_pt_pd=leaves;
1393 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1394 (*it)->setFather(this);
1397 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1401 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)
1403 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1404 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1405 med_geometry_type mgeoti;
1406 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1407 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1408 _field_pm_pt_pd.resize(nbProfiles);
1409 for(int i=0;i<nbProfiles;i++)
1411 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1415 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1420 (*it)->prepareLoading(fid,pflId+1,start,nasc);//tony
1424 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1427 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1429 (*it)->finishLoading(fid,pflId+1,nasc);//tony
1433 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1435 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1437 (*it)->copyOptionsFrom(*this);
1438 (*it)->writeLL(fid,nasc);
1442 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1447 medfGeoType=typmai3[(int)ikGeoType];
1450 medfGeoType=MED_NONE;
1453 medfGeoType=typmai3[(int)ikGeoType];
1454 return MED_NODE_ELEMENT;
1456 medfGeoType=typmai3[(int)ikGeoType];
1459 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1461 return MED_UNDEF_ENTITY_TYPE;
1464 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1466 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1469 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1471 return new MEDFileFieldPerMesh(fath,mesh);
1474 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1476 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1477 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1478 if((const MEDFileFieldPerMeshPerType *)*it)
1479 ret+=(*it)->getHeapMemorySize();
1483 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1485 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1486 ret->_father=father;
1488 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1490 if((const MEDFileFieldPerMeshPerType *)*it)
1491 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1496 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1498 std::string startLine(bkOffset,' ');
1499 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1500 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1502 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1504 const MEDFileFieldPerMeshPerType *cur=*it;
1506 cur->simpleRepr(bkOffset,oss,i);
1509 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1514 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1516 _mesh_name=mesh->getName();
1517 mesh->getTime(_mesh_iteration,_mesh_order);
1520 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)
1522 int nbOfTypes=code.size()/3;
1524 for(int i=0;i<nbOfTypes;i++)
1526 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1527 int nbOfCells=code[3*i+1];
1528 int pos=addNewEntryIfNecessary(type);
1529 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1535 * This method is the most general one. No optimization is done here.
1536 * \param [in] multiTypePfl is the end user profile specified in high level API
1537 * \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].
1538 * \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.
1539 * \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.
1540 * \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.
1541 * \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.
1543 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)
1545 int nbOfTypes=code.size()/3;
1546 for(int i=0;i<nbOfTypes;i++)
1548 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1549 int pos=addNewEntryIfNecessary(type);
1550 DataArrayInt *pfl=0;
1552 pfl=idsPerType[code[3*i+2]];
1553 int nbOfTupes2=code2.size()/3;
1555 for(;found<nbOfTupes2;found++)
1556 if(code[3*i]==code2[3*found])
1558 if(found==nbOfTupes2)
1559 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1560 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1564 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1566 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1567 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1570 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1572 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1573 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1576 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1578 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1579 (*it)->prepareLoading(fid,start,nasc);
1582 void MEDFileFieldPerMesh::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1584 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1585 (*it)->finishLoading(fid,nasc);
1588 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1590 int nbOfTypes=_field_pm_pt.size();
1591 for(int i=0;i<nbOfTypes;i++)
1593 _field_pm_pt[i]->copyOptionsFrom(*this);
1594 _field_pm_pt[i]->writeLL(fid,nasc);
1598 void MEDFileFieldPerMesh::getDimension(int& dim) const
1600 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1601 (*it)->getDimension(dim);
1604 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1606 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1607 (*it)->fillTypesOfFieldAvailable(types);
1610 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)
1612 int sz=_field_pm_pt.size();
1613 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1614 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1615 for(int i=0;i<sz;i++)
1617 types[i]=_field_pm_pt[i]->getGeoType();
1618 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1623 double MEDFileFieldPerMesh::getTime() const
1626 return _father->getTime(tmp1,tmp2);
1629 int MEDFileFieldPerMesh::getIteration() const
1631 return _father->getIteration();
1634 int MEDFileFieldPerMesh::getOrder() const
1636 return _father->getOrder();
1639 int MEDFileFieldPerMesh::getNumberOfComponents() const
1641 return _father->getNumberOfComponents();
1644 DataArray *MEDFileFieldPerMesh::getArray()
1647 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1648 return _father->getOrCreateAndGetArray();
1651 const DataArray *MEDFileFieldPerMesh::getArray() const
1654 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1655 return _father->getOrCreateAndGetArray();
1658 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1660 return _father->getInfo();
1664 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1665 * 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.
1666 * It returns 2 output vectors :
1667 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1668 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1669 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1671 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)
1673 int notNullPflsSz=0;
1674 int nbOfArrs=geoTypes.size();
1675 for(int i=0;i<nbOfArrs;i++)
1678 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1679 int nbOfDiffGeoTypes=geoTypes3.size();
1680 code.resize(3*nbOfDiffGeoTypes);
1681 notNullPfls.resize(notNullPflsSz);
1684 for(int i=0;i<nbOfDiffGeoTypes;i++)
1687 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1688 std::vector<const DataArrayInt *> notNullTmp;
1690 notNullTmp.push_back(pfls[j]);
1692 for(;j<nbOfArrs;j++)
1693 if(geoTypes[j]==refType)
1696 notNullTmp.push_back(pfls[j]);
1700 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1701 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1702 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1703 code[3*i]=(int)refType;
1704 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1705 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1706 if(notNullTmp.empty())
1710 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1711 code[3*i+2]=notNullPflsSz++;
1717 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1719 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)
1723 for(int i=0;i<sz;i++)
1727 if(type!=ON_GAUSS_NE)
1728 ret+=dads[i].second-dads[i].first;
1731 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1732 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1737 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1738 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1744 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1746 std::vector<std::string> ret;
1747 std::set<std::string> ret2;
1748 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1750 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1751 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1752 if(ret2.find(*it2)==ret2.end())
1754 ret.push_back(*it2);
1761 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1763 std::vector<std::string> ret;
1764 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1766 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1767 ret.insert(ret.end(),tmp.begin(),tmp.end());
1772 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1774 std::vector<std::string> ret;
1775 std::set<std::string> ret2;
1776 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1779 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1780 if(ret2.find(*it2)==ret2.end())
1782 ret.push_back(*it2);
1789 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1791 std::vector<std::string> ret;
1792 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1794 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1795 ret.insert(ret.end(),tmp.begin(),tmp.end());
1800 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1802 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1804 if((*it).first==_mesh_name)
1806 _mesh_name=(*it).second;
1813 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1814 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1816 if(_mesh_name!=meshName)
1818 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1819 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1820 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1821 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1822 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1823 getUndergroundDataArrayExt(entries);
1824 DataArray *arr0=getArray();//tony
1826 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1827 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1829 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1832 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1833 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1835 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1837 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1838 sz+=(*it).second.second-(*it).second.first;
1841 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1843 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1844 ////////////////////
1845 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1846 int *workI2=explicitIdsOldInMesh->getPointer();
1847 int sz1=0,sz2=0,sid=1;
1848 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1849 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1850 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1852 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1853 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1854 int *workI=explicitIdsOldInArr->getPointer();
1855 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1857 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1858 (*itL2)->setLocId(sz2);
1859 (*itL2)->_tmp_work1=(*itL2)->getStart();
1860 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1862 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1864 explicitIdsOldInMesh->reAlloc(sz2);
1865 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1866 ////////////////////
1867 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1868 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1869 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1870 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1872 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1873 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1874 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1876 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1877 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1878 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1880 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1881 int newStart=elt->getLocId();
1882 elt->setLocId((*it)->getGeoType());
1883 elt->setNewStart(newStart);
1884 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1885 entriesKeptNew.push_back(elt);
1886 entriesKeptNew2.push_back(elt);
1888 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1889 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1890 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1891 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1893 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1896 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1898 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1899 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1901 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1902 glob,arr2,otherEntriesNew) || ret;
1906 // Assign new dispatching
1907 assignNewLeaves(otherEntriesNew);
1908 arr->cpyFrom(*arr2);
1912 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1914 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1915 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1916 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1918 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1919 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1920 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1921 for(;it1!=types.end();it1++,it2++)
1923 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1924 elt->setLeaves((*it1).second);
1927 _field_pm_pt=fieldPmPt;
1930 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1932 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933 (*it)->changePflsRefsNamesGen(mapOfModif);
1936 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1938 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1939 (*it)->changeLocsRefsNamesGen(mapOfModif);
1943 * \param [in] mesh is the whole mesh
1945 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1947 if(_field_pm_pt.empty())
1948 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1950 std::vector< std::pair<int,int> > dads;
1951 std::vector<const DataArrayInt *> pfls;
1952 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1953 std::vector<int> locs,code;
1954 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1955 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1956 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1958 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1961 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1962 throw INTERP_KERNEL::Exception(oss.str().c_str());
1965 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1966 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1969 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1971 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1974 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1975 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
1981 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1985 if(nb!=mesh->getNumberOfNodes())
1987 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1988 oss << " nodes in mesh !";
1989 throw INTERP_KERNEL::Exception(oss.str().c_str());
1991 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1994 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
1998 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2000 if(_field_pm_pt.empty())
2001 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2003 std::vector<std::pair<int,int> > dads;
2004 std::vector<const DataArrayInt *> pfls;
2005 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2006 std::vector<int> locs,code;
2007 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2008 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2009 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2011 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2014 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2015 throw INTERP_KERNEL::Exception(oss.str().c_str());
2017 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2018 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2021 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2022 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2027 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2031 if(nb!=mesh->getNumberOfNodes())
2033 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2034 oss << " nodes in mesh !";
2035 throw INTERP_KERNEL::Exception(oss.str().c_str());
2038 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2044 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2048 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2050 (*it)->getSizes(globalSz,nbOfEntries);
2052 entries.resize(nbOfEntries);
2054 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2056 (*it)->fillValues(nbOfEntries,entries);
2060 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2062 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2064 if((*it)->getGeoType()==typ)
2065 return (*it)->getLeafGivenLocId(locId);
2067 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2068 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2069 oss << "Possiblities are : ";
2070 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2072 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2073 oss << "\"" << cm2.getRepr() << "\", ";
2075 throw INTERP_KERNEL::Exception(oss.str().c_str());
2078 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2080 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2082 if((*it)->getGeoType()==typ)
2083 return (*it)->getLeafGivenLocId(locId);
2085 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2086 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2087 oss << "Possiblities are : ";
2088 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2090 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2091 oss << "\"" << cm2.getRepr() << "\", ";
2093 throw INTERP_KERNEL::Exception(oss.str().c_str());
2096 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2099 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2100 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2101 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2103 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2108 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2113 int ret=std::distance(_field_pm_pt.begin(),it2);
2114 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2119 * 'dads' and 'locs' input parameters have the same number of elements
2120 * \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
2122 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2123 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2124 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2127 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2128 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2129 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2130 const std::vector<std::string>& infos=getInfo();
2131 da->setInfoOnComponents(infos);
2133 if(type==ON_GAUSS_PT)
2136 int nbOfArrs=dads.size();
2137 for(int i=0;i<nbOfArrs;i++)
2139 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2140 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2141 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2142 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2143 di->alloc(nbOfElems,1);
2145 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2146 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2155 * 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.
2156 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2157 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2158 * The order of cells in the returned field is those imposed by the profile.
2159 * \param [in] mesh is the global mesh.
2161 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2162 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2163 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2164 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2166 if(da->isIdentity())
2168 int nbOfTuples=da->getNumberOfTuples();
2169 if(nbOfTuples==mesh->getNumberOfCells())
2170 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2172 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2173 m2->setName(mesh->getName());
2174 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2180 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2182 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2183 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2184 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2186 if(da->isIdentity())
2188 int nbOfTuples=da->getNumberOfTuples();
2189 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2190 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2192 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2193 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2196 if(meshu->getNodalConnectivity()==0)
2198 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2199 int nb=da->getNbOfElems();
2200 const int *ptr=da->getConstPointer();
2201 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2202 meshuc->allocateCells(nb);
2203 for(int i=0;i<nb;i++)
2204 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2205 meshuc->finishInsertingCells();
2206 ret->setMesh(meshuc);
2207 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2208 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2209 disc->checkCoherencyBetween(meshuc,arrOut);
2214 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2216 DataArrayInt *arr2=0;
2217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2218 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2219 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2220 int nnodes=mesh2->getNumberOfNodes();
2221 if(nnodes==(int)da->getNbOfElems())
2223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2224 arrOut->renumberInPlace(da3->getConstPointer());
2225 mesh2->setName(mesh->getName());
2226 ret->setMesh(mesh2);
2231 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 !!!";
2232 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2233 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2234 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2235 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2236 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2237 throw INTERP_KERNEL::Exception(oss.str().c_str());
2243 * This method is the most light method of field retrieving.
2245 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2249 pflOut=DataArrayInt::New();
2250 pflOut->alloc(nbOfElems,1);
2255 pflOut=const_cast<DataArrayInt*>(pflIn);
2258 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2259 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2260 const std::vector<std::string>& infos=getInfo();
2261 int nbOfComp=infos.size();
2262 for(int i=0;i<nbOfComp;i++)
2263 da->setInfoOnComponent(i,infos[i].c_str());
2268 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),
2269 _mesh_csit(meshCsit),_father(fath)
2271 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2272 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2273 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2274 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2276 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2279 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2280 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2282 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2285 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2286 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2289 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2292 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2293 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2297 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2299 copyTinyInfoFrom(mesh);
2302 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2304 if(id>=(int)_pfls.size())
2306 _pfls[id]=DataArrayInt::New();
2307 int lgth=MEDprofileSizeByName(fid,pflName);
2308 _pfls[id]->setName(pflName);
2309 _pfls[id]->alloc(lgth,1);
2310 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2311 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2314 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2316 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2318 MEDprofileInfo(fid,i+1,pflName,&sz);
2319 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2320 if(i>=(int)_pfls.size())
2322 _pfls[i]=DataArrayInt::New();
2323 _pfls[i]->alloc(sz,1);
2324 _pfls[i]->setName(pflCpp.c_str());
2325 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2326 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2329 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2331 int nbOfPfls=_pfls.size();
2332 for(int i=0;i<nbOfPfls;i++)
2334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2335 cpy->applyLin(1,1,0);
2336 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2337 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2338 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2341 int nbOfLocs=_locs.size();
2342 for(int i=0;i<nbOfLocs;i++)
2343 _locs[i]->writeLL(fid);
2346 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2348 std::vector<std::string> pfls=getPfls();
2349 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2351 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2354 _pfls.push_back(*it);
2358 int id=std::distance(pfls.begin(),it2);
2359 if(!(*it)->isEqual(*_pfls[id]))
2361 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2362 throw INTERP_KERNEL::Exception(oss.str().c_str());
2366 std::vector<std::string> locs=getLocs();
2367 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2369 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2372 _locs.push_back(*it);
2376 int id=std::distance(locs.begin(),it2);
2377 if(!(*it)->isEqual(*_locs[id],eps))
2379 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2380 throw INTERP_KERNEL::Exception(oss.str().c_str());
2386 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2388 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2389 getProfile((*it).c_str());
2392 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2394 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2395 getLocalization((*it).c_str());
2398 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2400 std::vector<std::string> profiles=real.getPflsReallyUsed();
2401 int sz=profiles.size();
2403 for(int i=0;i<sz;i++)
2404 loadProfileInFile(fid,i,profiles[i].c_str());
2406 std::vector<std::string> locs=real.getLocsReallyUsed();
2409 for(int i=0;i<sz;i++)
2410 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2413 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2415 int nProfil=MEDnProfile(fid);
2416 for(int i=0;i<nProfil;i++)
2417 loadProfileInFile(fid,i);
2418 int sz=MEDnLocalization(fid);
2420 for(int i=0;i<sz;i++)
2422 _locs[i]=MEDFileFieldLoc::New(fid,i);
2426 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2428 return new MEDFileFieldGlobs(fname);
2431 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2433 return new MEDFileFieldGlobs;
2436 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2438 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2439 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2440 ret+=(*it)->getHeapMemorySize();
2441 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2442 ret+=(*it)->getHeapMemorySize();
2446 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2448 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2450 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2452 if((const DataArrayInt *)*it)
2453 ret->_pfls[i]=(*it)->deepCpy();
2456 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2458 if((const MEDFileFieldLoc*)*it)
2459 ret->_locs[i]=(*it)->deepCpy();
2465 * \throw if a profile in \a pfls in not in \a this.
2466 * \throw if a localization in \a locs in not in \a this.
2467 * \sa MEDFileFieldGlobs::deepCpyPart
2469 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2471 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2472 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2474 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2476 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2478 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2479 ret->_pfls.push_back(pfl2);
2481 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2483 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2485 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2487 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2488 ret->_locs.push_back(loc2);
2490 ret->setFileName(getFileName());
2495 * \throw if a profile in \a pfls in not in \a this.
2496 * \throw if a localization in \a locs in not in \a this.
2497 * \sa MEDFileFieldGlobs::shallowCpyPart
2499 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2501 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2502 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2504 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2506 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2507 ret->_pfls.push_back(pfl->deepCpy());
2509 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2511 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2513 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2514 ret->_locs.push_back(loc->deepCpy());
2516 ret->setFileName(getFileName());
2520 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2524 MEDFileFieldGlobs::MEDFileFieldGlobs()
2528 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2532 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2534 oss << "Profiles :\n";
2535 std::size_t n=_pfls.size();
2536 for(std::size_t i=0;i<n;i++)
2538 oss << " - #" << i << " ";
2539 const DataArrayInt *pfl=_pfls[i];
2541 oss << "\"" << pfl->getName() << "\"\n";
2546 oss << "Localizations :\n";
2547 for(std::size_t i=0;i<n;i++)
2549 oss << " - #" << i << " ";
2550 const MEDFileFieldLoc *loc=_locs[i];
2552 loc->simpleRepr(oss);
2558 void MEDFileFieldGlobs::setFileName(const char *fileName)
2560 _file_name=fileName;
2563 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2565 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2567 DataArrayInt *elt(*it);
2570 std::string name(elt->getName());
2571 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2573 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2575 elt->setName((*it2).second.c_str());
2583 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2585 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2587 MEDFileFieldLoc *elt(*it);
2590 std::string name(elt->getName());
2591 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2593 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2595 elt->setName((*it2).second.c_str());
2603 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2605 if(locId<0 || locId>=(int)_locs.size())
2606 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2607 return _locs[locId]->getNbOfGaussPtPerCell();
2610 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2612 return getLocalizationFromId(getLocalizationId(locName));
2615 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2617 if(locId<0 || locId>=(int)_locs.size())
2618 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2619 return *_locs[locId];
2622 namespace ParaMEDMEMImpl
2627 LocFinder(const char *loc):_loc(loc) { }
2628 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2636 PflFinder(const std::string& pfl):_pfl(pfl) { }
2637 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2639 const std::string& _pfl;
2643 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2645 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2648 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2649 for(it=_locs.begin();it!=_locs.end();it++)
2650 oss << "\"" << (*it)->getName() << "\", ";
2651 throw INTERP_KERNEL::Exception(oss.str().c_str());
2653 return std::distance(_locs.begin(),it);
2657 * The returned value is never null.
2659 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2661 std::string pflNameCpp(pflName);
2662 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2665 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2666 for(it=_pfls.begin();it!=_pfls.end();it++)
2667 oss << "\"" << (*it)->getName() << "\", ";
2668 throw INTERP_KERNEL::Exception(oss.str().c_str());
2673 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2675 if(pflId<0 || pflId>=(int)_pfls.size())
2676 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2677 return _pfls[pflId];
2680 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2682 if(locId<0 || locId>=(int)_locs.size())
2683 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2684 return *_locs[locId];
2687 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2689 return getLocalizationFromId(getLocalizationId(locName));
2693 * The returned value is never null.
2695 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2697 std::string pflNameCpp(pflName);
2698 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2701 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2702 for(it=_pfls.begin();it!=_pfls.end();it++)
2703 oss << "\"" << (*it)->getName() << "\", ";
2704 throw INTERP_KERNEL::Exception(oss.str().c_str());
2709 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2711 if(pflId<0 || pflId>=(int)_pfls.size())
2712 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2713 return _pfls[pflId];
2716 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2718 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2720 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2722 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2723 newPfls.push_back(*it);
2728 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2730 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2732 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2734 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2735 newLocs.push_back(*it);
2740 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2742 int sz=_pfls.size();
2743 std::vector<std::string> ret(sz);
2744 for(int i=0;i<sz;i++)
2745 ret[i]=_pfls[i]->getName();
2749 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2751 int sz=_locs.size();
2752 std::vector<std::string> ret(sz);
2753 for(int i=0;i<sz;i++)
2754 ret[i]=_locs[i]->getName();
2758 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2760 std::vector<std::string> v=getPfls();
2761 std::string s(pflName);
2762 return std::find(v.begin(),v.end(),s)!=v.end();
2765 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2767 std::vector<std::string> v=getLocs();
2768 std::string s(locName);
2769 return std::find(v.begin(),v.end(),s)!=v.end();
2772 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2774 std::map<int,std::vector<int> > m;
2776 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2778 const DataArrayInt *tmp=(*it);
2781 m[tmp->getHashCode()].push_back(i);
2784 std::vector< std::vector<int> > ret;
2785 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2787 if((*it2).second.size()>1)
2789 std::vector<int> ret0;
2790 bool equalityOrNot=false;
2791 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2793 std::vector<int>::const_iterator it4=it3; it4++;
2794 for(;it4!=(*it2).second.end();it4++)
2796 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2799 ret0.push_back(*it3);
2800 ret0.push_back(*it4);
2806 ret.push_back(ret0);
2812 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2814 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2817 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2819 std::string name(pfl->getName());
2821 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2822 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2823 if(name==(*it)->getName())
2825 if(!pfl->isEqual(*(*it)))
2827 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2828 throw INTERP_KERNEL::Exception(oss.str().c_str());
2832 _pfls.push_back(pfl);
2835 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)
2837 std::string name(locName);
2839 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2840 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2841 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2842 if((*it)->isName(locName))
2844 if(!(*it)->isEqual(*obj,1e-12))
2846 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2847 throw INTERP_KERNEL::Exception(oss.str().c_str());
2850 _locs.push_back(obj);
2853 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2855 std::vector<std::string> names=getPfls();
2856 return CreateNewNameNotIn("NewPfl_",names);
2859 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2861 std::vector<std::string> names=getLocs();
2862 return CreateNewNameNotIn("NewLoc_",names);
2865 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2867 for(std::size_t sz=0;sz<100000;sz++)
2869 std::ostringstream tryName;
2870 tryName << prefix << sz;
2871 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2872 return tryName.str();
2874 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2878 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2879 * \param [in] fname - the file name.
2881 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2886 * Creates an empty MEDFileFieldGlobsReal.
2888 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2892 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2895 if((const MEDFileFieldGlobs *)_globals)
2896 ret+=_globals->getHeapMemorySize();
2901 * Returns a string describing profiles and Gauss points held in \a this.
2902 * \return std::string - the description string.
2904 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2906 const MEDFileFieldGlobs *glob=_globals;
2907 std::ostringstream oss2; oss2 << glob;
2908 std::string stars(oss2.str().length(),'*');
2909 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2911 glob->simpleRepr(oss);
2913 oss << "NO GLOBAL INFORMATION !\n";
2916 void MEDFileFieldGlobsReal::resetContent()
2918 _globals=MEDFileFieldGlobs::New();
2921 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2926 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2927 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2929 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2931 _globals=other._globals;
2935 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2936 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2938 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2940 const MEDFileFieldGlobs *otherg(other._globals);
2943 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2947 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2948 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2950 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2952 const MEDFileFieldGlobs *otherg(other._globals);
2955 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2958 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2960 _globals=other._globals;
2961 if((const MEDFileFieldGlobs *)_globals)
2962 _globals=other._globals->deepCpy();
2966 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
2967 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
2968 * \param [in] eps - a precision used to compare Gauss points with same name held by
2969 * \a this and \a other MEDFileFieldGlobsReal.
2970 * \throw If \a this and \a other hold profiles with equal names but different ids.
2971 * \throw If \a this and \a other hold different Gauss points with equal names.
2973 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2975 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
2976 if(thisGlobals==otherGlobals)
2980 _globals=other._globals;
2983 _globals->appendGlobs(*other._globals,eps);
2986 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
2988 checkGlobsPflsPartCoherency();
2989 checkGlobsLocsPartCoherency();
2992 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
2994 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
2997 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
2999 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3002 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3004 contentNotNull()->loadProfileInFile(fid,id,pflName);
3007 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3009 contentNotNull()->loadProfileInFile(fid,id);
3012 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3014 contentNotNull()->loadGlobals(fid,*this);
3017 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3019 contentNotNull()->loadAllGlobals(fid);
3022 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3024 contentNotNull()->writeGlobals(fid,opt);
3028 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3029 * or getPflsReallyUsedMulti().
3030 * \return std::vector<std::string> - a sequence of names of all profiles.
3032 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3034 return contentNotNull()->getPfls();
3038 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3039 * or getLocsReallyUsedMulti().
3040 * \return std::vector<std::string> - a sequence of names of all localizations.
3042 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3044 return contentNotNull()->getLocs();
3048 * Checks if the profile with a given name exists.
3049 * \param [in] pflName - the profile name of interest.
3050 * \return bool - \c true if the profile named \a pflName exists.
3052 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3054 return contentNotNull()->existsPfl(pflName);
3058 * Checks if the localization with a given name exists.
3059 * \param [in] locName - the localization name of interest.
3060 * \return bool - \c true if the localization named \a locName exists.
3062 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3064 return contentNotNull()->existsLoc(locName);
3067 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3069 return contentNotNull()->createNewNameOfPfl();
3072 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3074 return contentNotNull()->createNewNameOfLoc();
3078 * Sets the name of a MED file.
3079 * \param [inout] fileName - the file name.
3081 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3083 contentNotNull()->setFileName(fileName);
3087 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3088 * in the same order.
3089 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3090 * Each item of this sequence is a vector containing ids of equal profiles.
3092 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3094 return contentNotNull()->whichAreEqualProfiles();
3098 * Finds equal localizations.
3099 * \param [in] eps - a precision used to compare real values of the localizations.
3100 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3101 * Each item of this sequence is a vector containing ids of equal localizations.
3103 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3105 return contentNotNull()->whichAreEqualLocs(eps);
3109 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3110 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3111 * this sequence is a pair whose
3112 * - the first item is a vector of profile names to replace by the second item,
3113 * - the second item is a profile name to replace every profile name of the first item.
3115 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3117 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3121 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3122 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3123 * this sequence is a pair whose
3124 * - the first item is a vector of localization names to replace by the second item,
3125 * - the second item is a localization name to replace every localization name of the first item.
3127 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3129 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3133 * Replaces references to some profiles (a reference is a profile name) by references
3134 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3135 * them-selves accordingly. <br>
3136 * This method is a generalization of changePflName().
3137 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3138 * this sequence is a pair whose
3139 * - the first item is a vector of profile names to replace by the second item,
3140 * - the second item is a profile name to replace every profile of the first item.
3141 * \sa changePflsRefsNamesGen()
3142 * \sa changePflName()
3144 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3146 changePflsRefsNamesGen(mapOfModif);
3147 changePflsNamesInStruct(mapOfModif);
3151 * Replaces references to some localizations (a reference is a localization name) by references
3152 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3153 * them-selves accordingly. <br>
3154 * This method is a generalization of changeLocName().
3155 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3156 * this sequence is a pair whose
3157 * - the first item is a vector of localization names to replace by the second item,
3158 * - the second item is a localization name to replace every localization of the first item.
3159 * \sa changeLocsRefsNamesGen()
3160 * \sa changeLocName()
3162 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3164 changeLocsRefsNamesGen(mapOfModif);
3165 changeLocsNamesInStruct(mapOfModif);
3169 * Renames the profile having a given name and updates references to this profile.
3170 * \param [in] oldName - the name of the profile to rename.
3171 * \param [in] newName - a new name of the profile.
3172 * \sa changePflsNames().
3174 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3176 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3177 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3179 changePflsNames(mapOfModif);
3183 * Renames the localization having a given name and updates references to this localization.
3184 * \param [in] oldName - the name of the localization to rename.
3185 * \param [in] newName - a new name of the localization.
3186 * \sa changeLocsNames().
3188 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3190 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3191 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3193 changeLocsNames(mapOfModif);
3197 * Removes duplicated profiles. Returns a map used to update references to removed
3198 * profiles via changePflsRefsNamesGen().
3199 * Equal profiles are found using whichAreEqualProfiles().
3200 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3201 * a sequence describing the performed replacements of profiles. Each element of
3202 * this sequence is a pair whose
3203 * - the first item is a vector of profile names replaced by the second item,
3204 * - the second item is a profile name replacing every profile of the first item.
3206 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3208 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3209 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3211 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3213 std::vector< std::string > tmp((*it).size());
3215 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3216 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3217 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3219 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3220 killProfileIds(tmp2);
3222 changePflsRefsNamesGen(ret);
3227 * Removes duplicated localizations. Returns a map used to update references to removed
3228 * localizations via changeLocsRefsNamesGen().
3229 * Equal localizations are found using whichAreEqualLocs().
3230 * \param [in] eps - a precision used to compare real values of the localizations.
3231 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3232 * a sequence describing the performed replacements of localizations. Each element of
3233 * this sequence is a pair whose
3234 * - the first item is a vector of localization names replaced by the second item,
3235 * - the second item is a localization name replacing every localization of the first item.
3237 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3239 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3240 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3242 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3244 std::vector< std::string > tmp((*it).size());
3246 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3247 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3248 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3250 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3251 killLocalizationIds(tmp2);
3253 changeLocsRefsNamesGen(ret);
3258 * Returns number of Gauss points per cell in a given localization.
3259 * \param [in] locId - an id of the localization of interest.
3260 * \return int - the number of the Gauss points per cell.
3262 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3264 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3268 * Returns an id of a localization by its name.
3269 * \param [in] loc - the localization name of interest.
3270 * \return int - the id of the localization.
3271 * \throw If there is no a localization named \a loc.
3273 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3275 return contentNotNull()->getLocalizationId(loc);
3279 * Returns the name of the MED file.
3280 * \return const char * - the MED file name.
3282 const char *MEDFileFieldGlobsReal::getFileName() const
3284 return contentNotNull()->getFileName();
3287 std::string MEDFileFieldGlobsReal::getFileName2() const
3289 return contentNotNull()->getFileName2();
3293 * Returns a localization object by its name.
3294 * \param [in] locName - the name of the localization of interest.
3295 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3296 * \throw If there is no a localization named \a locName.
3298 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3300 return contentNotNull()->getLocalization(locName);
3304 * Returns a localization object by its id.
3305 * \param [in] locId - the id of the localization of interest.
3306 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3307 * \throw If there is no a localization with id \a locId.
3309 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3311 return contentNotNull()->getLocalizationFromId(locId);
3315 * Returns a profile array by its name.
3316 * \param [in] pflName - the name of the profile of interest.
3317 * \return const DataArrayInt * - the profile array having the name \a pflName.
3318 * \throw If there is no a profile named \a pflName.
3320 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3322 return contentNotNull()->getProfile(pflName);
3326 * Returns a profile array by its id.
3327 * \param [in] pflId - the id of the profile of interest.
3328 * \return const DataArrayInt * - the profile array having the id \a pflId.
3329 * \throw If there is no a profile with id \a pflId.
3331 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3333 return contentNotNull()->getProfileFromId(pflId);
3337 * Returns a localization object, apt for modification, by its id.
3338 * \param [in] locId - the id of the localization of interest.
3339 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3340 * having the id \a locId.
3341 * \throw If there is no a localization with id \a locId.
3343 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3345 return contentNotNull()->getLocalizationFromId(locId);
3349 * Returns a localization object, apt for modification, by its name.
3350 * \param [in] locName - the name of the localization of interest.
3351 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3352 * having the name \a locName.
3353 * \throw If there is no a localization named \a locName.
3355 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3357 return contentNotNull()->getLocalization(locName);
3361 * Returns a profile array, apt for modification, by its name.
3362 * \param [in] pflName - the name of the profile of interest.
3363 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3364 * \throw If there is no a profile named \a pflName.
3366 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3368 return contentNotNull()->getProfile(pflName);
3372 * Returns a profile array, apt for modification, by its id.
3373 * \param [in] pflId - the id of the profile of interest.
3374 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3375 * \throw If there is no a profile with id \a pflId.
3377 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3379 return contentNotNull()->getProfileFromId(pflId);
3383 * Removes profiles given by their ids. No data is updated to track this removal.
3384 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3386 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3388 contentNotNull()->killProfileIds(pflIds);
3392 * Removes localizations given by their ids. No data is updated to track this removal.
3393 * \param [in] locIds - a sequence of ids of the localizations to remove.
3395 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3397 contentNotNull()->killLocalizationIds(locIds);
3401 * Stores a profile array.
3402 * \param [in] pfl - the profile array to store.
3403 * \throw If the name of \a pfl is empty.
3404 * \throw If a profile with the same name as that of \a pfl already exists but contains
3407 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3409 contentNotNull()->appendProfile(pfl);
3413 * Adds a new localization of Gauss points.
3414 * \param [in] locName - the name of the new localization.
3415 * \param [in] geoType - a geometrical type of the reference cell.
3416 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3417 * must be \c nbOfNodesPerCell * \c dimOfType.
3418 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3419 * must be _wg_.size() * \c dimOfType.
3420 * \param [in] w - the weights of Gauss points.
3421 * \throw If \a locName is empty.
3422 * \throw If a localization with the name \a locName already exists but is
3423 * different form the new one.
3425 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)
3427 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3430 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3432 MEDFileFieldGlobs *g(_globals);
3434 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3438 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3440 const MEDFileFieldGlobs *g(_globals);
3442 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3446 //= MEDFileFieldNameScope
3448 MEDFileFieldNameScope::MEDFileFieldNameScope()
3452 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3457 * Returns the name of \a this field.
3458 * \return std::string - a string containing the field name.
3460 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3466 * Sets name of \a this field
3467 * \param [in] name - the new field name.
3469 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3474 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3479 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3484 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3487 _dt_unit=other._dt_unit;
3490 //= MEDFileAnyTypeField1TSWithoutSDA
3492 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3494 _field_per_mesh.resize(other._field_per_mesh.size());
3496 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3498 if((const MEDFileFieldPerMesh *)*it)
3499 _field_per_mesh[i]=(*it)->deepCpy(this);
3504 * Prints a string describing \a this field into a stream. This string is outputted
3505 * by \c print Python command.
3506 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3507 * \param [in,out] oss - the out stream.
3508 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3509 * info id printed, else, not.
3511 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3513 std::string startOfLine(bkOffset,' ');
3514 oss << startOfLine << "Field ";
3516 oss << "[Type=" << getTypeStr() << "] ";
3517 oss << "on One time Step ";
3519 oss << "(" << f1tsId << ") ";
3520 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3521 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3522 const DataArray *arr=getUndergroundDataArray();
3525 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3528 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3529 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3530 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3531 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3533 if(arr->isAllocated())
3535 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3538 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3542 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3544 oss << startOfLine << "----------------------" << std::endl;
3545 if(!_field_per_mesh.empty())
3548 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3550 const MEDFileFieldPerMesh *cur=(*it2);
3552 cur->simpleRepr(bkOffset,oss,i);
3554 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3559 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3561 oss << startOfLine << "----------------------" << std::endl;
3564 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3566 const DataArray *arr(getUndergroundDataArray());
3568 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3569 int nbOfCompo=arr->getNumberOfComponents();
3570 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3571 for(int i=0;i<nbOfCompo;i++)
3574 std::vector<int> v(1,i);
3575 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3576 ret[i]->setArray(arr2);
3581 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit)
3585 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1)
3590 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3591 * empty. Returns -1 if this in on nodes.
3592 * \return int - the dimension of \a this.
3594 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3597 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3598 (*it)->getDimension(ret);
3603 * Returns the mesh name.
3604 * \return std::string - a string holding the mesh name.
3605 * \throw If \c _field_per_mesh.empty()
3607 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3609 if(_field_per_mesh.empty())
3610 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3611 return _field_per_mesh[0]->getMeshName();
3614 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3616 std::string oldName(getMeshName());
3617 std::vector< std::pair<std::string,std::string> > v(1);
3618 v[0].first=oldName; v[0].second=newMeshName;
3622 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3625 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3627 MEDFileFieldPerMesh *cur(*it);
3629 ret=cur->changeMeshNames(modifTab) || ret;
3635 * Returns the number of iteration of the state of underlying mesh.
3636 * \return int - the iteration number.
3637 * \throw If \c _field_per_mesh.empty()
3639 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3641 if(_field_per_mesh.empty())
3642 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3643 return _field_per_mesh[0]->getMeshIteration();
3647 * Returns the order number of iteration of the state of underlying mesh.
3648 * \return int - the order number.
3649 * \throw If \c _field_per_mesh.empty()
3651 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3653 if(_field_per_mesh.empty())
3654 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3655 return _field_per_mesh[0]->getMeshOrder();
3659 * Checks if \a this field is tagged by a given iteration number and a given
3660 * iteration order number.
3661 * \param [in] iteration - the iteration number of interest.
3662 * \param [in] order - the iteration order number of interest.
3663 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3664 * \a this->getOrder() == \a order.
3666 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3668 return iteration==_iteration && order==_order;
3672 * Returns number of iteration and order number of iteration when
3673 * \a this field has been calculated.
3674 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3677 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3679 std::pair<int,int> p;
3685 * Returns number of iteration and order number of iteration when
3686 * \a this field has been calculated.
3687 * \param [in,out] p - a pair returning the iteration number and the iteration
3690 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3697 * Returns all types of spatial discretization of \a this field.
3698 * \param [in,out] types - a sequence of types of \a this field.
3700 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3702 std::set<TypeOfField> types2;
3703 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3705 (*it)->fillTypesOfFieldAvailable(types2);
3707 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3708 std::copy(types2.begin(),types2.end(),bi);
3712 * Returns all types of spatial discretization of \a this field.
3713 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3716 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3718 std::vector<TypeOfField> ret;
3719 fillTypesOfFieldAvailable(ret);
3723 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3725 std::vector<std::string> ret;
3726 std::set<std::string> ret2;
3727 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3729 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3730 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3731 if(ret2.find(*it2)==ret2.end())
3733 ret.push_back(*it2);
3740 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3742 std::vector<std::string> ret;
3743 std::set<std::string> ret2;
3744 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3746 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3747 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3748 if(ret2.find(*it2)==ret2.end())
3750 ret.push_back(*it2);
3757 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3759 std::vector<std::string> ret;
3760 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3762 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3763 ret.insert(ret.end(),tmp.begin(),tmp.end());
3768 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3770 std::vector<std::string> ret;
3771 std::set<std::string> ret2;
3772 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3774 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3775 ret.insert(ret.end(),tmp.begin(),tmp.end());
3780 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3782 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3783 (*it)->changePflsRefsNamesGen(mapOfModif);
3786 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3788 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3789 (*it)->changeLocsRefsNamesGen(mapOfModif);
3793 * Returns all attributes of parts of \a this field lying on a given mesh.
3794 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3795 * item of every of returned sequences refers to the _i_-th part of \a this field.
3796 * Thus all sequences returned by this method are of the same length equal to number
3797 * of different types of supporting entities.<br>
3798 * A field part can include sub-parts with several different spatial discretizations,
3799 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3800 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3801 * of a nested sequence corresponds to a type of spatial discretization.<br>
3802 * This method allows for iteration over MEDFile DataStructure without any overhead.
3803 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3804 * for the case with only one underlying mesh. (Actually, the number of meshes is
3805 * not checked if \a mname == \c NULL).
3806 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3807 * a field part is returned.
3808 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3809 * This sequence is of the same length as \a types.
3810 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3811 * discretization. A profile name can be empty.
3812 * Length of this and of nested sequences is the same as that of \a typesF.
3813 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3814 * discretization. A localization name can be empty.
3815 * Length of this and of nested sequences is the same as that of \a typesF.
3816 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3817 * of ids of tuples within the data array, per each type of spatial
3818 * discretization within one mesh entity type.
3819 * Length of this and of nested sequences is the same as that of \a typesF.
3820 * \throw If no field is lying on \a mname.
3822 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)
3826 meshId=getMeshIdFromMeshName(mname);
3828 if(_field_per_mesh.empty())
3829 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3830 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3834 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3835 * maximal absolute dimension and values returned via the out parameter \a levs are
3836 * dimensions relative to the maximal absolute dimension. <br>
3837 * This method is designed for MEDFileField1TS instances that have a discretization
3838 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3839 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3840 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3841 * Only these 3 discretizations will be taken into account here. If \a this is
3842 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3843 * This method is useful to make the link between the dimension of the underlying mesh
3844 * and the levels of \a this, because it is possible that the highest dimension of \a this
3845 * field is not equal to the dimension of the underlying mesh.
3847 * Let's consider the following case:
3848 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3849 * TETRA4, HEXA8, TRI3 and SEG2.
3850 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3851 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3853 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3854 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3855 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3856 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3857 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3858 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3860 * to retrieve the highest level of
3861 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3862 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3863 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3864 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3865 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3866 * for the case with only one underlying mesh. (Actually, the number of meshes is
3867 * not checked if \a mname == \c NULL).
3868 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3869 * absolute one. They are in decreasing order. This sequence is cleared before
3871 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3872 * \throw If no field is lying on \a mname.
3874 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3877 int meshId=getMeshIdFromMeshName(mname);
3878 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3879 std::vector< std::vector<TypeOfField> > typesF;
3880 std::vector< std::vector<std::string> > pfls, locs;
3881 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3883 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3884 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3885 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3887 st.erase(INTERP_KERNEL::NORM_ERROR);
3889 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3891 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3892 ret1.insert((int)cm.getDimension());
3894 int ret=*std::max_element(ret1.begin(),ret1.end());
3895 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3896 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3901 * \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.
3902 * \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.
3903 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3904 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3906 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3908 int mid=getMeshIdFromMeshName(mName);
3909 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3913 * \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.
3914 * \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.
3915 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3916 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3918 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3920 int mid=getMeshIdFromMeshName(mName);
3921 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3925 * \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.
3927 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3929 if(_field_per_mesh.empty())
3930 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3933 std::string mName2(mName);
3935 std::vector<std::string> msg;
3936 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3937 if(mName2==(*it)->getMeshName())
3940 msg.push_back((*it)->getMeshName());
3941 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3942 oss << "Possible meshes are : ";
3943 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3944 oss << "\"" << (*it2) << "\" ";
3945 throw INTERP_KERNEL::Exception(oss.str().c_str());
3948 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3951 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3952 std::string tmp(mesh->getName());
3954 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3955 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3957 for(;it!=_field_per_mesh.end();it++,i++)
3959 if((*it)->getMeshName()==tmp)
3962 int sz=_field_per_mesh.size();
3963 _field_per_mesh.resize(sz+1);
3964 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3968 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3969 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3972 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3974 MEDFileFieldPerMesh *fpm(*it);
3976 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3981 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
3983 if(_field_per_mesh.empty())
3984 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3985 if(_field_per_mesh.size()>1)
3986 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3987 _field_per_mesh[0]->copyOptionsFrom(opts);
3988 _field_per_mesh[0]->writeLL(fid,nasc);
3991 void MEDFileAnyTypeField1TSWithoutSDA::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
3993 med_int numdt,numit;
3997 med_int meshnumdt,meshnumit;
3998 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3999 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4000 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4001 if(_iteration!=numdt || _order!=numit)
4002 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
4003 _field_per_mesh.resize(nmesh);
4004 for(int i=0;i<nmesh;i++)
4005 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4007 for(int i=0;i<nmesh;i++)
4009 _field_per_mesh[i]->prepareLoading(fid,start,nasc);
4011 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
4012 for(int i=0;i<nmesh;i++)
4014 _field_per_mesh[i]->finishLoading(fid,nasc);
4018 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4020 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4021 if(getUndergroundDataArray())
4022 ret+=getUndergroundDataArray()->getHeapMemorySize();
4023 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4024 ret+=(*it)->getHeapMemorySize();
4029 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4030 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4031 * "Sort By Type"), if not, an exception is thrown.
4032 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4033 * \param [in] arr - the array of values.
4034 * \param [in,out] glob - the global data where profiles and localization present in
4035 * \a field, if any, are added.
4036 * \throw If the name of \a field is empty.
4037 * \throw If the data array of \a field is not set.
4038 * \throw If \a this->_arr is already allocated but has different number of components
4040 * \throw If the underlying mesh of \a field has no name.
4041 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4043 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4045 const MEDCouplingMesh *mesh=field->getMesh();
4047 TypeOfField type=field->getTypeOfField();
4048 std::vector<DataArrayInt *> dummy;
4049 int start=copyTinyInfoFrom(field,arr);
4050 int pos=addNewEntryIfNecessary(mesh);
4053 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4054 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4057 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4061 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4062 * of a given mesh are used as the support of the given field (a real support is not used).
4063 * Elements of the given mesh must be sorted suitable for writing to MED file.
4064 * Order of underlying mesh entities of the given field specified by \a profile parameter
4065 * is not prescribed; this method permutes field values to have them sorted by element
4066 * type as required for writing to MED file. A new profile is added only if no equal
4067 * profile is missing.
4068 * \param [in] field - the field to add to \a this. The field double values are ignored.
4069 * \param [in] arrOfVals - the values of the field \a field used.
4070 * \param [in] mesh - the supporting mesh of \a field.
4071 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4072 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4073 * \param [in,out] glob - the global data where profiles and localization present in
4074 * \a field, if any, are added.
4075 * \throw If either \a field or \a mesh or \a profile has an empty name.
4076 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4077 * \throw If the data array of \a field is not set.
4078 * \throw If \a this->_arr is already allocated but has different number of components
4080 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4081 * \sa setFieldNoProfileSBT()
4083 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)
4085 TypeOfField type=field->getTypeOfField();
4086 int start=copyTinyInfoFrom(field,arrOfVals);
4087 std::vector<DataArrayInt *> idsInPflPerType;
4088 std::vector<DataArrayInt *> idsPerType;
4089 std::vector<int> code,code2;
4090 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4093 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4094 code2=m->getDistributionOfTypes();
4096 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4097 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4098 idsInPflPerType2[i]=idsInPflPerType[i];
4099 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4100 for(std::size_t i=0;i<idsPerType.size();i++)
4101 idsPerType2[i]=idsPerType[i];
4103 int pos=addNewEntryIfNecessary(m);
4104 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4108 int pos=addNewEntryIfNecessary(m);
4109 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4114 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4115 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4116 * larger by the size of \a field. Returns an id of the first not filled
4117 * tuple of \a this->_arr.
4118 * \param [in] field - the field to copy the info on components and the name from.
4119 * \return int - the id of first not initialized tuple of \a this->_arr.
4120 * \throw If the name of \a field is empty.
4121 * \throw If the data array of \a field is not set.
4122 * \throw If \a this->_arr is already allocated but has different number of components
4125 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4128 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4129 std::string name(field->getName());
4130 setName(name.c_str());
4131 setDtUnit(field->getTimeUnit());
4133 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4135 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4136 _dt=field->getTime(_iteration,_order);
4137 int nbOfComponents=arr->getNumberOfComponents();
4138 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4139 if(!getOrCreateAndGetArray()->isAllocated())
4141 getOrCreateAndGetArray()->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
4146 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4147 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4148 MEDCouplingAutoRefCountObjectPtr<DataArray> tmp=createNewEmptyDataArrayInstance();
4149 tmp->alloc(newNbOfTuples,nbOfComponents);
4150 tmp->copyStringInfoFrom(*getOrCreateAndGetArray());
4151 DataArray *arrr=getOrCreateAndGetArray();
4152 tmp->setContigPartOfSelectedValues2(0,arrr,0,oldNbOfTuples,1);
4154 return oldNbOfTuples;
4159 * Returns number of components in \a this field
4160 * \return int - the number of components.
4162 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4164 return getOrCreateAndGetArray()->getNumberOfComponents();
4168 * Change info on components in \a this.
4169 * \throw If size of \a infos is not equal to the number of components already in \a this.
4171 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4173 DataArray *arr=getOrCreateAndGetArray();
4174 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4178 * Returns info on components of \a this field.
4179 * \return const std::vector<std::string>& - a sequence of strings each being an
4180 * information on _i_-th component.
4182 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4184 const DataArray *arr=getOrCreateAndGetArray();
4185 return arr->getInfoOnComponents();
4189 * Returns a mutable info on components of \a this field.
4190 * \return std::vector<std::string>& - a sequence of strings each being an
4191 * information on _i_-th component.
4193 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4195 DataArray *arr=getOrCreateAndGetArray();
4196 return arr->getInfoOnComponents();
4200 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4201 * \param [in] type - a spatial discretization of the new field.
4202 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4203 * \param [in] mName - a name of the supporting mesh.
4204 * \param [in] renumPol - specifies how to permute values of the result field according to
4205 * the optional numbers of cells and nodes, if any. The valid values are
4206 * - 0 - do not permute.
4207 * - 1 - permute cells.
4208 * - 2 - permute nodes.
4209 * - 3 - permute cells and nodes.
4211 * \param [in] glob - the global data storing profiles and localization.
4212 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4213 * caller is to delete this field using decrRef() as it is no more needed.
4214 * \throw If the MED file is not readable.
4215 * \throw If there is no mesh named \a mName in the MED file.
4216 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4217 * \throw If no field of \a this is lying on the mesh \a mName.
4218 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4220 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)
4222 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4224 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4226 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4227 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4231 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4232 * \param [in] type - a spatial discretization of the new field.
4233 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4234 * \param [in] renumPol - specifies how to permute values of the result field according to
4235 * the optional numbers of cells and nodes, if any. The valid values are
4236 * - 0 - do not permute.
4237 * - 1 - permute cells.
4238 * - 2 - permute nodes.
4239 * - 3 - permute cells and nodes.
4241 * \param [in] glob - the global data storing profiles and localization.
4242 * \param [in] mesh - the supporting mesh.
4243 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4244 * caller is to delete this field using decrRef() as it is no more needed.
4245 * \throw If the MED file is not readable.
4246 * \throw If no field of \a this is lying on \a mesh.
4247 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4248 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4250 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)
4252 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4253 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4254 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4255 if(meshDimRelToMax==1)
4256 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4257 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4261 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4263 * \param [in] type - a spatial discretization of the new field.
4264 * \param [in] mName - a name of the supporting mesh.
4265 * \param [in] renumPol - specifies how to permute values of the result field according to
4266 * the optional numbers of cells and nodes, if any. The valid values are
4267 * - 0 - do not permute.
4268 * - 1 - permute cells.
4269 * - 2 - permute nodes.
4270 * - 3 - permute cells and nodes.
4272 * \param [in] glob - the global data storing profiles and localization.
4273 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4274 * caller is to delete this field using decrRef() as it is no more needed.
4275 * \throw If the MED file is not readable.
4276 * \throw If there is no mesh named \a mName in the MED file.
4277 * \throw If there are no mesh entities in the mesh.
4278 * \throw If no field values of the given \a type are available.
4280 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4282 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4284 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4286 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4287 int absDim=getDimension();
4288 int meshDimRelToMax=absDim-mm->getMeshDimension();
4289 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4293 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4294 * \param [in] type - a spatial discretization of the new field.
4295 * \param [in] renumPol - specifies how to permute values of the result field according to
4296 * the optional numbers of cells and nodes, if any. The valid values are
4297 * - 0 - do not permute.
4298 * - 1 - permute cells.
4299 * - 2 - permute nodes.
4300 * - 3 - permute cells and nodes.
4302 * \param [in] glob - the global data storing profiles and localization.
4303 * \param [in] mesh - the supporting mesh.
4304 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4305 * field according to \a renumPol.
4306 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4307 * field according to \a renumPol.
4308 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4309 * caller is to delete this field using decrRef() as it is no more needed.
4310 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4311 * \throw If no field of \a this is lying on \a mesh.
4312 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4314 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)
4316 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4317 int meshId=getMeshIdFromMeshName(mesh->getName());
4319 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4324 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4331 throw INTERP_KERNEL::Exception(msg1);
4332 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4335 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4337 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4338 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4339 throw INTERP_KERNEL::Exception(oss.str().c_str());
4341 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4342 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4343 std::vector<DataArray *> arrOut2(1,arrOut);
4344 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4345 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4346 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4353 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4355 throw INTERP_KERNEL::Exception(msg1);
4358 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4360 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4361 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4362 throw INTERP_KERNEL::Exception(oss.str().c_str());
4364 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4365 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4366 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4367 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4372 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4377 * Returns values and a profile of the field of a given type lying on a given support.
4378 * \param [in] type - a spatial discretization of the field.
4379 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4380 * \param [in] mesh - the supporting mesh.
4381 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4382 * field of interest lies on. If the field lies on all entities of the given
4383 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4384 * using decrRef() as it is no more needed.
4385 * \param [in] glob - the global data storing profiles and localization.
4386 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4387 * field. The caller is to delete this array using decrRef() as it is no more needed.
4388 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4389 * \throw If no field of \a this is lying on \a mesh.
4390 * \throw If no field values of the given \a type are available.
4392 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4394 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4395 int meshId=getMeshIdFromMeshName(mesh->getName());
4396 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4397 ret->setName(nasc.getName().c_str());
4401 //= MEDFileField1TSWithoutSDA
4404 * Throws if a given value is not a valid (non-extended) relative dimension.
4405 * \param [in] meshDimRelToMax - the relative dimension value.
4406 * \throw If \a meshDimRelToMax > 0.
4408 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4410 if(meshDimRelToMax>0)
4411 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4415 * Checks if elements of a given mesh are in the order suitable for writing
4416 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4417 * vector describing types of elements and their number.
4418 * \param [in] mesh - the mesh to check.
4419 * \return std::vector<int> - a vector holding for each element type (1) item of
4420 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4421 * These values are in full-interlace mode.
4422 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4424 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4427 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4428 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4429 int nbOfTypes=geoTypes.size();
4430 std::vector<int> code(3*nbOfTypes);
4431 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4432 arr1->alloc(nbOfTypes,1);
4433 int *arrPtr=arr1->getPointer();
4434 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4435 for(int i=0;i<nbOfTypes;i++,it++)
4436 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4437 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4438 const int *arrPtr2=arr2->getConstPointer();
4440 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4443 int nbCells=mesh->getNumberOfCellsWithType(*it);
4444 code[3*pos]=(int)(*it);
4445 code[3*pos+1]=nbCells;
4446 code[3*pos+2]=-1;//no profiles
4448 std::vector<const DataArrayInt *> idsPerType;//no profiles
4449 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4453 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4458 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4460 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4464 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4465 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4466 * item of every of returned sequences refers to the _i_-th part of \a this field.
4467 * Thus all sequences returned by this method are of the same length equal to number
4468 * of different types of supporting entities.<br>
4469 * A field part can include sub-parts with several different spatial discretizations,
4470 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4471 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4472 * of a nested sequence corresponds to a type of spatial discretization.<br>
4473 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4474 * The overhead is due to selecting values into new instances of DataArrayDouble.
4475 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4476 * for the case with only one underlying mesh. (Actually, the number of meshes is
4477 * not checked if \a mname == \c NULL).
4478 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4479 * a field part is returned.
4480 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4481 * A field part can include sub-parts with several different spatial discretizations,
4482 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4483 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4484 * This sequence is of the same length as \a types.
4485 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4486 * discretization. A profile name can be empty.
4487 * Length of this and of nested sequences is the same as that of \a typesF.
4488 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4489 * discretization. A localization name can be empty.
4490 * Length of this and of nested sequences is the same as that of \a typesF.
4491 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4492 * per each type of spatial discretization within one mesh entity type.
4493 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4494 * Length of this and of nested sequences is the same as that of \a typesF.
4495 * \throw If no field is lying on \a mname.
4497 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)
4501 meshId=getMeshIdFromMeshName(mname);
4503 if(_field_per_mesh.empty())
4504 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4505 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4506 int nbOfRet=ret0.size();
4507 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4508 for(int i=0;i<nbOfRet;i++)
4510 const std::vector< std::pair<int,int> >& p=ret0[i];
4511 int nbOfRet1=p.size();
4512 ret[i].resize(nbOfRet1);
4513 for(int j=0;j<nbOfRet1;j++)
4515 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4523 * Returns a pointer to the underground DataArrayDouble instance. So the
4524 * caller should not decrRef() it. This method allows for a direct access to the field
4525 * values. This method is quite unusable if there is more than a nodal field or a cell
4526 * field on single geometric cell type.
4527 * \return DataArrayDouble * - the pointer to the field values array.
4529 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4531 const DataArrayDouble *ret=_arr;
4533 return const_cast<DataArrayDouble *>(ret);
4538 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4543 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4545 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4546 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4547 ret->deepCpyLeavesFrom(*this);
4548 const DataArrayDouble *arr(_arr);
4551 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4552 ret->setArray(arr2);
4558 * Returns a pointer to the underground DataArrayDouble instance. So the
4559 * caller should not decrRef() it. This method allows for a direct access to the field
4560 * values. This method is quite unusable if there is more than a nodal field or a cell
4561 * field on single geometric cell type.
4562 * \return DataArrayDouble * - the pointer to the field values array.
4564 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4566 return getUndergroundDataArrayDouble();
4570 * Returns a pointer to the underground DataArrayDouble instance and a
4571 * sequence describing parameters of a support of each part of \a this field. The
4572 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4573 * direct access to the field values. This method is intended for the field lying on one
4575 * \param [in,out] entries - the sequence describing parameters of a support of each
4576 * part of \a this field. Each item of this sequence consists of two parts. The
4577 * first part describes a type of mesh entity and an id of discretization of a
4578 * current field part. The second part describes a range of values [begin,end)
4579 * within the returned array relating to the current field part.
4580 * \return DataArrayDouble * - the pointer to the field values array.
4581 * \throw If the number of underlying meshes is not equal to 1.
4582 * \throw If no field values are available.
4583 * \sa getUndergroundDataArray()
4585 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4587 if(_field_per_mesh.size()!=1)
4588 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4589 if(_field_per_mesh[0]==0)
4590 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4591 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4592 return getUndergroundDataArrayDouble();
4596 * Returns a pointer to the underground DataArrayDouble instance and a
4597 * sequence describing parameters of a support of each part of \a this field. The
4598 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4599 * direct access to the field values. This method is intended for the field lying on one
4601 * \param [in,out] entries - the sequence describing parameters of a support of each
4602 * part of \a this field. Each item of this sequence consists of two parts. The
4603 * first part describes a type of mesh entity and an id of discretization of a
4604 * current field part. The second part describes a range of values [begin,end)
4605 * within the returned array relating to the current field part.
4606 * \return DataArrayDouble * - the pointer to the field values array.
4607 * \throw If the number of underlying meshes is not equal to 1.
4608 * \throw If no field values are available.
4609 * \sa getUndergroundDataArray()
4611 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4613 return getUndergroundDataArrayDoubleExt(entries);
4616 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4617 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4619 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4620 arr->setInfoAndChangeNbOfCompo(infos);
4623 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4627 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4629 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4630 ret->deepCpyLeavesFrom(*this);
4634 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4636 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4637 if((const DataArrayDouble *)_arr)
4638 ret->_arr=_arr->deepCpy();
4642 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4646 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4648 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4653 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4655 return DataArrayDouble::New();
4658 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4660 DataArrayDouble *ret=_arr;
4663 _arr=DataArrayDouble::New();
4667 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4669 return getOrCreateAndGetArrayDouble();
4672 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4674 const DataArrayDouble *ret=_arr;
4677 DataArrayDouble *ret2=DataArrayDouble::New();
4678 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4682 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4684 return getOrCreateAndGetArrayDouble();
4687 //= MEDFileIntField1TSWithoutSDA
4689 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4690 const std::vector<std::string>& infos)
4692 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4695 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4699 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4700 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4702 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4703 arr->setInfoAndChangeNbOfCompo(infos);
4706 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4711 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4713 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4714 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4715 ret->deepCpyLeavesFrom(*this);
4716 const DataArrayInt *arr(_arr);
4719 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4720 ret->setArray(arr2);
4726 * Returns a pointer to the underground DataArrayInt instance. So the
4727 * caller should not decrRef() it. This method allows for a direct access to the field
4728 * values. This method is quite unusable if there is more than a nodal field or a cell
4729 * field on single geometric cell type.
4730 * \return DataArrayInt * - the pointer to the field values array.
4732 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4734 return getUndergroundDataArrayInt();
4738 * Returns a pointer to the underground DataArrayInt instance. So the
4739 * caller should not decrRef() it. This method allows for a direct access to the field
4740 * values. This method is quite unusable if there is more than a nodal field or a cell
4741 * field on single geometric cell type.
4742 * \return DataArrayInt * - the pointer to the field values array.
4744 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4746 const DataArrayInt *ret=_arr;
4748 return const_cast<DataArrayInt *>(ret);
4754 * Returns a pointer to the underground DataArrayInt instance and a
4755 * sequence describing parameters of a support of each part of \a this field. The
4756 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4757 * direct access to the field values. This method is intended for the field lying on one
4759 * \param [in,out] entries - the sequence describing parameters of a support of each
4760 * part of \a this field. Each item of this sequence consists of two parts. The
4761 * first part describes a type of mesh entity and an id of discretization of a
4762 * current field part. The second part describes a range of values [begin,end)
4763 * within the returned array relating to the current field part.
4764 * \return DataArrayInt * - the pointer to the field values array.
4765 * \throw If the number of underlying meshes is not equal to 1.
4766 * \throw If no field values are available.
4767 * \sa getUndergroundDataArray()
4769 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4771 return getUndergroundDataArrayIntExt(entries);
4775 * Returns a pointer to the underground DataArrayInt instance and a
4776 * sequence describing parameters of a support of each part of \a this field. The
4777 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4778 * direct access to the field values. This method is intended for the field lying on one
4780 * \param [in,out] entries - the sequence describing parameters of a support of each
4781 * part of \a this field. Each item of this sequence consists of two parts. The
4782 * first part describes a type of mesh entity and an id of discretization of a
4783 * current field part. The second part describes a range of values [begin,end)
4784 * within the returned array relating to the current field part.
4785 * \return DataArrayInt * - the pointer to the field values array.
4786 * \throw If the number of underlying meshes is not equal to 1.
4787 * \throw If no field values are available.
4788 * \sa getUndergroundDataArray()
4790 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4792 if(_field_per_mesh.size()!=1)
4793 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4794 if(_field_per_mesh[0]==0)
4795 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4796 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4797 return getUndergroundDataArrayInt();
4800 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4802 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4803 ret->deepCpyLeavesFrom(*this);
4807 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4809 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4810 if((const DataArrayInt *)_arr)
4811 ret->_arr=_arr->deepCpy();
4815 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4819 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4821 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4826 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4828 return DataArrayInt::New();
4831 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4833 DataArrayInt *ret=_arr;
4836 _arr=DataArrayInt::New();
4840 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4842 return getOrCreateAndGetArrayInt();
4845 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4847 const DataArrayInt *ret=_arr;
4850 DataArrayInt *ret2=DataArrayInt::New();
4851 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4855 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4857 return getOrCreateAndGetArrayInt();
4860 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4864 //= MEDFileAnyTypeField1TS
4866 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
4868 med_field_type typcha;
4870 std::vector<std::string> infos;
4871 std::string dtunit,fieldName;
4872 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4873 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4878 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4883 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4888 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] !";
4889 throw INTERP_KERNEL::Exception(oss.str().c_str());
4892 ret->setDtUnit(dtunit.c_str());
4893 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4895 med_int numdt,numit;
4897 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4898 ret->setTime(numdt,numit,dt);
4900 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4904 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
4905 try:MEDFileFieldGlobsReal(fileName)
4907 MEDFileUtilities::CheckFileForRead(fileName);
4908 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4909 _content=BuildContentFrom(fid,fileName);
4912 catch(INTERP_KERNEL::Exception& e)
4917 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4919 med_field_type typcha;
4920 std::vector<std::string> infos;
4923 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
4924 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4929 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4934 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4939 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] !";
4940 throw INTERP_KERNEL::Exception(oss.str().c_str());
4943 ret->setDtUnit(dtunit.c_str());
4944 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4948 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
4949 throw INTERP_KERNEL::Exception(oss.str().c_str());
4952 med_int numdt,numit;
4954 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
4955 ret->setTime(numdt,numit,dt);
4957 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4961 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4962 try:MEDFileFieldGlobsReal(fileName)
4964 MEDFileUtilities::CheckFileForRead(fileName);
4965 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4966 _content=BuildContentFrom(fid,fileName,fieldName);
4969 catch(INTERP_KERNEL::Exception& e)
4974 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
4977 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
4978 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
4980 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
4981 ret->setFileName(fileName);
4982 ret->_content=c; c->incrRef();
4985 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
4987 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
4988 ret->setFileName(fileName);
4989 ret->_content=c; c->incrRef();
4992 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
4995 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4997 MEDFileUtilities::CheckFileForRead(fileName);
4998 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4999 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName);
5000 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5001 ret->loadGlobals(fid);
5005 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5007 MEDFileUtilities::CheckFileForRead(fileName);
5008 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5009 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
5010 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5011 ret->loadGlobals(fid);
5015 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5017 MEDFileUtilities::CheckFileForRead(fileName);
5018 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5019 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5020 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5021 ret->loadGlobals(fid);
5025 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5027 med_field_type typcha;
5028 std::vector<std::string> infos;
5031 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5032 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5037 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5042 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5047 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] !";
5048 throw INTERP_KERNEL::Exception(oss.str().c_str());
5051 ret->setDtUnit(dtunit.c_str());
5052 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5055 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5056 for(int i=0;i<nbOfStep2 && !found;i++)
5058 med_int numdt,numit;
5060 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5061 if(numdt==iteration && numit==order)
5067 dtits[i]=std::pair<int,int>(numdt,numit);
5071 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5072 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5073 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5074 throw INTERP_KERNEL::Exception(oss.str().c_str());
5076 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5080 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5081 try:MEDFileFieldGlobsReal(fileName)
5083 MEDFileUtilities::CheckFileForRead(fileName);
5084 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5085 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5088 catch(INTERP_KERNEL::Exception& e)
5094 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5095 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5097 * \warning this is a shallow copy constructor
5099 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5101 if(!shallowCopyOfContent)
5103 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5104 otherPtr->incrRef();
5105 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5109 _content=other.shallowCpy();
5113 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)
5117 int nbFields=MEDnField(fid);
5118 if(fieldIdCFormat>=nbFields)
5120 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5121 throw INTERP_KERNEL::Exception(oss.str().c_str());
5124 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5125 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5126 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5127 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5128 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5129 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5132 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5133 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5134 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5135 infos.clear(); infos.resize(ncomp);
5136 for(int j=0;j<ncomp;j++)
5137 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5142 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5145 * \return in case of success the number of time steps available for the field with name \a fieldName.
5147 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)
5149 int nbFields=MEDnField(fid);
5151 std::vector<std::string> fns(nbFields);
5153 for(int i=0;i<nbFields && !found;i++)
5156 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5158 found=(tmp==fieldName);
5164 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5165 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5166 oss << "\"" << *it << "\" ";
5167 throw INTERP_KERNEL::Exception(oss.str().c_str());
5173 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5174 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5175 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5176 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5177 * to keep a valid instance.
5178 * 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.
5179 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5180 * 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.
5182 * \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.
5183 * \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.
5184 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5185 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5186 * \param [in] newLocName is the new localization name.
5187 * \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.
5188 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5190 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5192 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5193 std::string oldPflName=disc->getProfile();
5194 std::vector<std::string> vv=getPflsReallyUsedMulti();
5195 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5196 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5198 disc->setProfile(newPflName);
5199 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5200 pfl->setName(newPflName);
5204 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5205 throw INTERP_KERNEL::Exception(oss.str().c_str());
5210 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5211 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5212 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5213 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5214 * to keep a valid instance.
5215 * 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.
5216 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5217 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5218 * 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.
5220 * \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.
5221 * \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.
5222 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5223 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5224 * \param [in] newLocName is the new localization name.
5225 * \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.
5226 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5228 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5230 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5231 std::string oldLocName=disc->getLocalization();
5232 std::vector<std::string> vv=getLocsReallyUsedMulti();
5233 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5234 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5236 disc->setLocalization(newLocName);
5237 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5238 loc.setName(newLocName);
5242 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5243 throw INTERP_KERNEL::Exception(oss.str().c_str());
5247 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5249 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5255 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5257 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5259 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5264 * Writes \a this field into a MED file specified by its name.
5265 * \param [in] fileName - the MED file name.
5266 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5267 * - 2 - erase; an existing file is removed.
5268 * - 1 - append; same data should not be present in an existing file.
5269 * - 0 - overwrite; same data present in an existing file is overwritten.
5270 * \throw If the field name is not set.
5271 * \throw If no field data is set.
5272 * \throw If \a mode == 1 and the same data is present in an existing file.
5274 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5276 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5277 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5281 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5283 int nbComp=getNumberOfComponents();
5284 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5285 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5286 for(int i=0;i<nbComp;i++)
5288 std::string info=getInfo()[i];
5290 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5291 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5292 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5294 if(getName().empty())
5295 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5296 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5297 writeGlobals(fid,*this);
5298 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5301 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5304 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5305 ret+=_content->getHeapMemorySize();
5306 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5310 * Returns a string describing \a this field. This string is outputted
5311 * by \c print Python command.
5313 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5315 std::ostringstream oss;
5316 contentNotNullBase()->simpleRepr(0,oss,-1);
5317 simpleReprGlobs(oss);
5322 * This method returns all profiles whose name is non empty used.
5323 * \b WARNING If profile is used several times it will be reported \b only \b once.
5324 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5326 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5328 return contentNotNullBase()->getPflsReallyUsed2();
5332 * This method returns all localizations whose name is non empty used.
5333 * \b WARNING If localization is used several times it will be reported \b only \b once.
5335 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5337 return contentNotNullBase()->getLocsReallyUsed2();
5341 * This method returns all profiles whose name is non empty used.
5342 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5344 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5346 return contentNotNullBase()->getPflsReallyUsedMulti2();
5350 * This method returns all localizations whose name is non empty used.
5351 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5353 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5355 return contentNotNullBase()->getLocsReallyUsedMulti2();
5358 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5360 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5363 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5365 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5368 int MEDFileAnyTypeField1TS::getDimension() const
5370 return contentNotNullBase()->getDimension();
5373 int MEDFileAnyTypeField1TS::getIteration() const
5375 return contentNotNullBase()->getIteration();
5378 int MEDFileAnyTypeField1TS::getOrder() const
5380 return contentNotNullBase()->getOrder();
5383 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5385 return contentNotNullBase()->getTime(iteration,order);
5388 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5390 contentNotNullBase()->setTime(iteration,order,val);
5393 std::string MEDFileAnyTypeField1TS::getName() const
5395 return contentNotNullBase()->getName();
5398 void MEDFileAnyTypeField1TS::setName(const char *name)
5400 contentNotNullBase()->setName(name);
5403 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5405 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5408 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5410 return contentNotNullBase()->getDtUnit();
5413 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5415 contentNotNullBase()->setDtUnit(dtUnit);
5418 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5420 return contentNotNullBase()->getMeshName();
5423 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5425 contentNotNullBase()->setMeshName(newMeshName);
5428 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5430 return contentNotNullBase()->changeMeshNames(modifTab);
5433 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5435 return contentNotNullBase()->getMeshIteration();
5438 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5440 return contentNotNullBase()->getMeshOrder();
5443 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5445 return contentNotNullBase()->getNumberOfComponents();
5448 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5450 return contentNotNullBase()->isDealingTS(iteration,order);
5453 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5455 return contentNotNullBase()->getDtIt();
5458 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5460 contentNotNullBase()->fillIteration(p);
5463 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5465 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5468 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5470 contentNotNullBase()->setInfo(infos);
5473 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5475 return contentNotNullBase()->getInfo();
5477 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5479 return contentNotNullBase()->getInfo();
5482 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5484 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5487 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5489 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5492 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5494 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5497 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5499 return contentNotNullBase()->getTypesOfFieldAvailable();
5502 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,
5503 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5505 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5509 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5510 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5511 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5513 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5515 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5517 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5518 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5519 std::size_t sz(contentsSplit.size());
5520 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5521 for(std::size_t i=0;i<sz;i++)
5523 ret[i]=shallowCpy();
5524 ret[i]->_content=contentsSplit[i];
5529 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5531 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5532 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5533 ret->_content=_content->deepCpy();
5534 ret->deepCpyGlobs(*this);
5538 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5540 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5546 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5547 * the first field that has been read from a specified MED file.
5548 * \param [in] fileName - the name of the MED file to read.
5549 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5550 * is to delete this field using decrRef() as it is no more needed.
5551 * \throw If reading the file fails.
5553 MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5555 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName);
5556 ret->contentNotNull();
5561 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5562 * a given field that has been read from a specified MED file.
5563 * \param [in] fileName - the name of the MED file to read.
5564 * \param [in] fieldName - the name of the field to read.
5565 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5566 * is to delete this field using decrRef() as it is no more needed.
5567 * \throw If reading the file fails.
5568 * \throw If there is no field named \a fieldName in the file.
5570 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5572 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName);
5573 ret->contentNotNull();
5578 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5579 * a given field that has been read from a specified MED file.
5580 * \param [in] fileName - the name of the MED file to read.
5581 * \param [in] fieldName - the name of the field to read.
5582 * \param [in] iteration - the iteration number of a required time step.
5583 * \param [in] order - the iteration order number of required time step.
5584 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5585 * is to delete this field using decrRef() as it is no more needed.
5586 * \throw If reading the file fails.
5587 * \throw If there is no field named \a fieldName in the file.
5588 * \throw If the required time step is missing from the file.
5590 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5592 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order);
5593 ret->contentNotNull();
5598 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5599 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5601 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5602 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5603 * \warning this is a shallow copy constructor
5604 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5605 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5606 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5607 * is to delete this field using decrRef() as it is no more needed.
5609 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5611 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5612 ret->contentNotNull();
5617 * Returns a new empty instance of MEDFileField1TS.
5618 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5619 * is to delete this field using decrRef() as it is no more needed.
5621 MEDFileField1TS *MEDFileField1TS::New()
5623 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5624 ret->contentNotNull();
5629 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5630 * following the given input policy.
5632 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5633 * By default (true) the globals are deeply copied.
5634 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5636 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5638 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5639 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5642 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5644 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5645 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5646 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5649 ret=MEDFileIntField1TS::New();
5651 ret->deepCpyGlobs(*this);
5653 ret->shallowCpyGlobs(*this);
5657 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5659 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5661 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5662 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5664 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 !");
5668 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5670 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5672 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5673 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5675 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 !");
5679 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5682 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5683 if(!((DataArray*)arr))
5684 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5685 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5687 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5688 f->setArray(arrOutC);
5691 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5693 if(!((DataArray*)arr))
5694 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5695 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5697 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5702 MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
5703 try:MEDFileAnyTypeField1TS(fileName)
5706 catch(INTERP_KERNEL::Exception& e)
5709 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5710 try:MEDFileAnyTypeField1TS(fileName,fieldName)
5713 catch(INTERP_KERNEL::Exception& e)
5716 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5717 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
5720 catch(INTERP_KERNEL::Exception& e)
5724 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5725 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5727 * \warning this is a shallow copy constructor
5729 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5730 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5733 catch(INTERP_KERNEL::Exception& e)
5736 MEDFileField1TS::MEDFileField1TS()
5738 _content=new MEDFileField1TSWithoutSDA;
5742 * Returns a new MEDCouplingFieldDouble of a given type lying on
5743 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
5744 * has not been constructed via file reading, an exception is thrown.
5745 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5746 * \param [in] type - a spatial discretization of interest.
5747 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5748 * \param [in] renumPol - specifies how to permute values of the result field according to
5749 * the optional numbers of cells and nodes, if any. The valid values are
5750 * - 0 - do not permute.
5751 * - 1 - permute cells.
5752 * - 2 - permute nodes.
5753 * - 3 - permute cells and nodes.
5755 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5756 * caller is to delete this field using decrRef() as it is no more needed.
5757 * \throw If \a this field has not been constructed via file reading.
5758 * \throw If the MED file is not readable.
5759 * \throw If there is no mesh in the MED file.
5760 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5761 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5762 * \sa getFieldOnMeshAtLevel()
5764 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5766 if(getFileName2().empty())
5767 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5768 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5769 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5770 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5775 * Returns a new MEDCouplingFieldDouble of a given type lying on
5776 * the top level cells of the first mesh in MED file. If \a this field
5777 * has not been constructed via file reading, an exception is thrown.
5778 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5779 * \param [in] type - a spatial discretization of interest.
5780 * \param [in] renumPol - specifies how to permute values of the result field according to
5781 * the optional numbers of cells and nodes, if any. The valid values are
5782 * - 0 - do not permute.
5783 * - 1 - permute cells.
5784 * - 2 - permute nodes.
5785 * - 3 - permute cells and nodes.
5787 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5788 * caller is to delete this field using decrRef() as it is no more needed.
5789 * \throw If \a this field has not been constructed via file reading.
5790 * \throw If the MED file is not readable.
5791 * \throw If there is no mesh in the MED file.
5792 * \throw If no field values of the given \a type.
5793 * \throw If no field values lying on the top level support.
5794 * \sa getFieldAtLevel()
5796 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5798 if(getFileName2().empty())
5799 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5800 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5801 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5802 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5807 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5808 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5809 * \param [in] type - a spatial discretization of the new field.
5810 * \param [in] mesh - the supporting mesh.
5811 * \param [in] renumPol - specifies how to permute values of the result field according to
5812 * the optional numbers of cells and nodes, if any. The valid values are
5813 * - 0 - do not permute.
5814 * - 1 - permute cells.
5815 * - 2 - permute nodes.
5816 * - 3 - permute cells and nodes.
5818 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5819 * caller is to delete this field using decrRef() as it is no more needed.
5820 * \throw If no field of \a this is lying on \a mesh.
5821 * \throw If the mesh is empty.
5822 * \throw If no field values of the given \a type are available.
5823 * \sa getFieldAtLevel()
5824 * \sa getFieldOnMeshAtLevel()
5826 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5828 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5829 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5830 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5835 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5836 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5837 * \param [in] type - a spatial discretization of interest.
5838 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5839 * \param [in] mesh - the supporting mesh.
5840 * \param [in] renumPol - specifies how to permute values of the result field according to
5841 * the optional numbers of cells and nodes, if any. The valid values are
5842 * - 0 - do not permute.
5843 * - 1 - permute cells.
5844 * - 2 - permute nodes.
5845 * - 3 - permute cells and nodes.
5847 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5848 * caller is to delete this field using decrRef() as it is no more needed.
5849 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5850 * \throw If no field of \a this is lying on \a mesh.
5851 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5852 * \sa getFieldAtLevel()
5853 * \sa getFieldOnMeshAtLevel()
5855 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5857 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5858 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5859 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5864 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5865 * This method is called "Old" because in MED3 norm a field has only one meshName
5866 * attached, so this method is for readers of MED2 files. If \a this field
5867 * has not been constructed via file reading, an exception is thrown.
5868 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5869 * \param [in] type - a spatial discretization of interest.
5870 * \param [in] mName - a name of the supporting mesh.
5871 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5872 * \param [in] renumPol - specifies how to permute values of the result field according to
5873 * the optional numbers of cells and nodes, if any. The valid values are
5874 * - 0 - do not permute.
5875 * - 1 - permute cells.
5876 * - 2 - permute nodes.
5877 * - 3 - permute cells and nodes.
5879 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5880 * caller is to delete this field using decrRef() as it is no more needed.
5881 * \throw If the MED file is not readable.
5882 * \throw If there is no mesh named \a mName in the MED file.
5883 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5884 * \throw If \a this field has not been constructed via file reading.
5885 * \throw If no field of \a this is lying on the mesh named \a mName.
5886 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5887 * \sa getFieldAtLevel()
5889 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5891 if(getFileName2().empty())
5892 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5893 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5894 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
5895 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5900 * Returns values and a profile of the field of a given type lying on a given support.
5901 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5902 * \param [in] type - a spatial discretization of the field.
5903 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5904 * \param [in] mesh - the supporting mesh.
5905 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5906 * field of interest lies on. If the field lies on all entities of the given
5907 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5908 * using decrRef() as it is no more needed.
5909 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5910 * field. The caller is to delete this array using decrRef() as it is no more needed.
5911 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5912 * \throw If no field of \a this is lying on \a mesh.
5913 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5915 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5917 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
5918 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
5922 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5923 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5924 * "Sort By Type"), if not, an exception is thrown.
5925 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5926 * \param [in] field - the field to add to \a this.
5927 * \throw If the name of \a field is empty.
5928 * \throw If the data array of \a field is not set.
5929 * \throw If the data array is already allocated but has different number of components
5931 * \throw If the underlying mesh of \a field has no name.
5932 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5934 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5937 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
5941 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5942 * of a given mesh are used as the support of the given field (a real support is not used).
5943 * Elements of the given mesh must be sorted suitable for writing to MED file.
5944 * Order of underlying mesh entities of the given field specified by \a profile parameter
5945 * is not prescribed; this method permutes field values to have them sorted by element
5946 * type as required for writing to MED file. A new profile is added only if no equal
5947 * profile is missing.
5948 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5949 * \param [in] field - the field to add to \a this.
5950 * \param [in] mesh - the supporting mesh of \a field.
5951 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5952 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5953 * \throw If either \a field or \a mesh or \a profile has an empty name.
5954 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5955 * \throw If the data array of \a field is not set.
5956 * \throw If the data array of \a this is already allocated but has different number of
5957 * components than \a field.
5958 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5959 * \sa setFieldNoProfileSBT()
5961 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
5964 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
5967 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
5969 return new MEDFileField1TS(*this);
5972 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
5974 return contentNotNull()->getUndergroundDataArrayDouble();
5977 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5979 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
5982 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5983 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5985 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
5988 //= MEDFileIntField1TS
5990 MEDFileIntField1TS *MEDFileIntField1TS::New()
5992 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
5993 ret->contentNotNull();
5997 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5999 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName);
6000 ret->contentNotNull();
6004 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6006 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName);
6007 ret->contentNotNull();
6011 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6013 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order);
6014 ret->contentNotNull();
6018 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6020 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6021 ret->contentNotNull();
6025 MEDFileIntField1TS::MEDFileIntField1TS()
6027 _content=new MEDFileIntField1TSWithoutSDA;
6030 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
6031 try:MEDFileAnyTypeField1TS(fileName)
6034 catch(INTERP_KERNEL::Exception& e)
6037 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6038 try:MEDFileAnyTypeField1TS(fileName,fieldName)
6041 catch(INTERP_KERNEL::Exception& e)
6044 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6045 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
6048 catch(INTERP_KERNEL::Exception& e)
6052 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6053 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6055 * \warning this is a shallow copy constructor
6057 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6061 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6063 return new MEDFileIntField1TS(*this);
6067 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6068 * following the given input policy.
6070 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6071 * By default (true) the globals are deeply copied.
6072 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6074 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6076 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6077 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6080 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6082 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6083 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6084 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6087 ret=MEDFileField1TS::New();
6089 ret->deepCpyGlobs(*this);
6091 ret->shallowCpyGlobs(*this);
6096 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6097 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6098 * "Sort By Type"), if not, an exception is thrown.
6099 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6100 * \param [in] field - the field to add to \a this. The field double values are ignored.
6101 * \param [in] arrOfVals - the values of the field \a field used.
6102 * \throw If the name of \a field is empty.
6103 * \throw If the data array of \a field is not set.
6104 * \throw If the data array is already allocated but has different number of components
6106 * \throw If the underlying mesh of \a field has no name.
6107 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6109 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6112 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6116 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6117 * of a given mesh are used as the support of the given field (a real support is not used).
6118 * Elements of the given mesh must be sorted suitable for writing to MED file.
6119 * Order of underlying mesh entities of the given field specified by \a profile parameter
6120 * is not prescribed; this method permutes field values to have them sorted by element
6121 * type as required for writing to MED file. A new profile is added only if no equal
6122 * profile is missing.
6123 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6124 * \param [in] field - the field to add to \a this. The field double values are ignored.
6125 * \param [in] arrOfVals - the values of the field \a field used.
6126 * \param [in] mesh - the supporting mesh of \a field.
6127 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6128 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6129 * \throw If either \a field or \a mesh or \a profile has an empty name.
6130 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6131 * \throw If the data array of \a field is not set.
6132 * \throw If the data array of \a this is already allocated but has different number of
6133 * components than \a field.
6134 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6135 * \sa setFieldNoProfileSBT()
6137 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6140 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6143 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6145 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6147 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6148 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6150 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 !");
6154 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6156 if(getFileName2().empty())
6157 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6158 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6159 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6160 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6162 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6167 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6169 if(!((DataArray *)arr))
6170 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6171 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6173 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6179 * Returns a new MEDCouplingFieldDouble of a given type lying on
6180 * the top level cells of the first mesh in MED file. If \a this field
6181 * has not been constructed via file reading, an exception is thrown.
6182 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6183 * \param [in] type - a spatial discretization of interest.
6184 * \param [out] arrOut - the DataArrayInt containing values of field.
6185 * \param [in] renumPol - specifies how to permute values of the result field according to
6186 * the optional numbers of cells and nodes, if any. The valid values are
6187 * - 0 - do not permute.
6188 * - 1 - permute cells.
6189 * - 2 - permute nodes.
6190 * - 3 - permute cells and nodes.
6192 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6193 * caller is to delete this field using decrRef() as it is no more needed.
6194 * \throw If \a this field has not been constructed via file reading.
6195 * \throw If the MED file is not readable.
6196 * \throw If there is no mesh in the MED file.
6197 * \throw If no field values of the given \a type.
6198 * \throw If no field values lying on the top level support.
6199 * \sa getFieldAtLevel()
6201 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6203 if(getFileName2().empty())
6204 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6205 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6206 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6207 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6212 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6213 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6214 * \param [in] type - a spatial discretization of the new field.
6215 * \param [in] mesh - the supporting mesh.
6216 * \param [out] arrOut - the DataArrayInt containing values of field.
6217 * \param [in] renumPol - specifies how to permute values of the result field according to
6218 * the optional numbers of cells and nodes, if any. The valid values are
6219 * - 0 - do not permute.
6220 * - 1 - permute cells.
6221 * - 2 - permute nodes.
6222 * - 3 - permute cells and nodes.
6224 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6225 * caller is to delete this field using decrRef() as it is no more needed.
6226 * \throw If no field of \a this is lying on \a mesh.
6227 * \throw If the mesh is empty.
6228 * \throw If no field values of the given \a type are available.
6229 * \sa getFieldAtLevel()
6230 * \sa getFieldOnMeshAtLevel()
6232 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6234 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6235 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6236 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6241 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6242 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6243 * \param [in] type - a spatial discretization of interest.
6244 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6245 * \param [out] arrOut - the DataArrayInt containing values of field.
6246 * \param [in] mesh - the supporting mesh.
6247 * \param [in] renumPol - specifies how to permute values of the result field according to
6248 * the optional numbers of cells and nodes, if any. The valid values are
6249 * - 0 - do not permute.
6250 * - 1 - permute cells.
6251 * - 2 - permute nodes.
6252 * - 3 - permute cells and nodes.
6254 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6255 * caller is to delete this field using decrRef() as it is no more needed.
6256 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6257 * \throw If no field of \a this is lying on \a mesh.
6258 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6259 * \sa getFieldAtLevel()
6260 * \sa getFieldOnMeshAtLevel()
6262 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6264 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6265 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6266 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6271 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6272 * This method is called "Old" because in MED3 norm a field has only one meshName
6273 * attached, so this method is for readers of MED2 files. If \a this field
6274 * has not been constructed via file reading, an exception is thrown.
6275 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6276 * \param [in] type - a spatial discretization of interest.
6277 * \param [in] mName - a name of the supporting mesh.
6278 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6279 * \param [out] arrOut - the DataArrayInt containing values of field.
6280 * \param [in] renumPol - specifies how to permute values of the result field according to
6281 * the optional numbers of cells and nodes, if any. The valid values are
6282 * - 0 - do not permute.
6283 * - 1 - permute cells.
6284 * - 2 - permute nodes.
6285 * - 3 - permute cells and nodes.
6287 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6288 * caller is to delete this field using decrRef() as it is no more needed.
6289 * \throw If the MED file is not readable.
6290 * \throw If there is no mesh named \a mName in the MED file.
6291 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6292 * \throw If \a this field has not been constructed via file reading.
6293 * \throw If no field of \a this is lying on the mesh named \a mName.
6294 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6295 * \sa getFieldAtLevel()
6297 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6299 if(getFileName2().empty())
6300 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6301 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6302 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6303 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6308 * Returns values and a profile of the field of a given type lying on a given support.
6309 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6310 * \param [in] type - a spatial discretization of the field.
6311 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6312 * \param [in] mesh - the supporting mesh.
6313 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6314 * field of interest lies on. If the field lies on all entities of the given
6315 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6316 * using decrRef() as it is no more needed.
6317 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6318 * field. The caller is to delete this array using decrRef() as it is no more needed.
6319 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6320 * \throw If no field of \a this is lying on \a mesh.
6321 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6323 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6325 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6326 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6329 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6331 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6333 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6334 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6336 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 !");
6340 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6342 return contentNotNull()->getUndergroundDataArrayInt();
6345 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6347 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6351 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6356 * \param [in] fieldId field id in C mode
6358 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
6360 med_field_type typcha;
6361 std::string dtunitOut;
6362 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6363 setDtUnit(dtunitOut.c_str());
6364 finishLoading(fid,nbOfStep,typcha);
6367 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
6368 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6370 setDtUnit(dtunit.c_str());
6371 finishLoading(fid,nbOfStep,fieldTyp);
6373 catch(INTERP_KERNEL::Exception& e)
6378 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6380 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6381 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6382 ret+=(*it).capacity();
6383 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6384 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6385 ret+=(*it)->getHeapMemorySize();
6390 * 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
6393 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6395 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6396 ret->setInfo(_infos);
6397 int sz=(int)_time_steps.size();
6398 for(const int *id=startIds;id!=endIds;id++)
6400 if(*id>=0 && *id<sz)
6402 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6403 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6407 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6409 ret->pushBackTimeStep(tse2);
6413 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6414 oss << " ! Should be in [0," << sz << ") !";
6415 throw INTERP_KERNEL::Exception(oss.str().c_str());
6418 if(ret->getNumberOfTS()>0)
6419 ret->synchronizeNameScope();
6420 ret->copyNameScope(*this);
6425 * 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
6428 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6430 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6431 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6432 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6433 ret->setInfo(_infos);
6434 int sz=(int)_time_steps.size();
6436 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6440 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6441 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6445 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6447 ret->pushBackTimeStep(tse2);
6451 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6452 oss << " ! Should be in [0," << sz << ") !";
6453 throw INTERP_KERNEL::Exception(oss.str().c_str());
6456 if(ret->getNumberOfTS()>0)
6457 ret->synchronizeNameScope();
6458 ret->copyNameScope(*this);
6462 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6465 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6466 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6468 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6471 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6472 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6473 ids->pushBackSilent(id);
6475 return buildFromTimeStepIds(ids->begin(),ids->end());
6478 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6481 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6482 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6484 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6487 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6488 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6489 ids->pushBackSilent(id);
6491 return buildFromTimeStepIds(ids->begin(),ids->end());
6494 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6499 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6504 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6509 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6510 if(pt->isDealingTS(iteration,order))
6513 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6514 std::vector< std::pair<int,int> > vp=getIterations();
6515 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6516 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6517 throw INTERP_KERNEL::Exception(oss.str().c_str());
6520 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6522 return *_time_steps[getTimeStepPos(iteration,order)];
6525 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6527 return *_time_steps[getTimeStepPos(iteration,order)];
6530 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6532 if(_time_steps.empty())
6533 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6534 return _time_steps[0]->getMeshName();
6537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6539 std::string oldName(getMeshName());
6540 std::vector< std::pair<std::string,std::string> > v(1);
6541 v[0].first=oldName; v[0].second=newMeshName;
6545 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6548 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6550 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6552 ret=cur->changeMeshNames(modifTab) || ret;
6558 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6560 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6562 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6566 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6568 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)
6570 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6573 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6574 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6577 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6579 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6581 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6586 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6588 std::string startLine(bkOffset,' ');
6589 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6591 oss << " (" << fmtsId << ")";
6592 oss << " has the following name: \"" << _name << "\"." << std::endl;
6593 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6594 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6596 oss << startLine << " - \"" << *it << "\"" << std::endl;
6599 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6601 std::string chapter(17,'0'+i);
6602 oss << startLine << chapter << std::endl;
6603 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6605 cur->simpleRepr(bkOffset+2,oss,i);
6607 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6608 oss << startLine << chapter << std::endl;
6612 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6614 std::size_t sz=_time_steps.size();
6615 std::vector< std::pair<int,int> > ret(sz);
6617 for(std::size_t i=0;i<sz;i++)
6619 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6622 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6626 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6627 throw INTERP_KERNEL::Exception(oss.str().c_str());
6633 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6635 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6637 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6638 checkCoherencyOfType(tse2);
6639 if(_time_steps.empty())
6641 setName(tse2->getName().c_str());
6642 setInfo(tse2->getInfo());
6644 checkThatComponentsMatch(tse2->getInfo());
6645 _time_steps.push_back(tse);
6648 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6650 std::size_t nbOfCompo=_infos.size();
6651 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6653 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6656 if((cur->getInfo()).size()!=nbOfCompo)
6658 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6659 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6660 throw INTERP_KERNEL::Exception(oss.str().c_str());
6662 cur->copyNameScope(*this);
6667 void MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception)
6669 _time_steps.resize(nbPdt);
6670 for(int i=0;i<nbPdt;i++)
6672 std::vector< std::pair<int,int> > ts;
6673 med_int numdt=0,numo=0;
6674 med_int meshIt=0,meshOrder=0;
6676 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6681 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6686 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6690 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading : managed field type are : FLOAT64, INT32 !");
6692 _time_steps[i]->finishLoading(fid,*this);
6696 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6698 if(_time_steps.empty())
6699 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6700 checkThatNbOfCompoOfTSMatchThis();
6701 std::vector<std::string> infos(getInfo());
6702 int nbComp=infos.size();
6703 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6704 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6705 for(int i=0;i<nbComp;i++)
6707 std::string info=infos[i];
6709 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6710 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6711 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6714 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6715 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6716 int nbOfTS=_time_steps.size();
6717 for(int i=0;i<nbOfTS;i++)
6718 _time_steps[i]->writeLL(fid,opts,*this);
6721 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6723 return _time_steps.size();
6726 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6728 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6729 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6731 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6733 newTS.push_back(*it);
6738 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6740 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6741 int maxId=(int)_time_steps.size();
6743 std::set<int> idsToDel;
6744 for(const int *id=startIds;id!=endIds;id++,ii++)
6746 if(*id>=0 && *id<maxId)
6748 idsToDel.insert(*id);
6752 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6753 throw INTERP_KERNEL::Exception(oss.str().c_str());
6756 for(int iii=0;iii<maxId;iii++)
6757 if(idsToDel.find(iii)==idsToDel.end())
6758 newTS.push_back(_time_steps[iii]);
6762 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6764 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6765 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6766 if(nbOfEntriesToKill==0)
6768 std::size_t sz=_time_steps.size();
6769 std::vector<bool> b(sz,true);
6771 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6773 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6774 for(std::size_t i=0;i<sz;i++)
6776 newTS.push_back(_time_steps[i]);
6780 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6783 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
6784 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6786 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6790 tmp->getTime(it2,ord);
6791 if(it2==iteration && order==ord)
6794 oss << "(" << it2 << "," << ord << "), ";
6797 throw INTERP_KERNEL::Exception(oss.str().c_str());
6800 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6803 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6805 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6807 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6811 double ti=tmp->getTime(it2,ord);
6812 if(fabs(time-ti)<eps)
6818 throw INTERP_KERNEL::Exception(oss.str().c_str());
6821 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6823 int lgth=_time_steps.size();
6824 std::vector< std::pair<int,int> > ret(lgth);
6825 for(int i=0;i<lgth;i++)
6826 _time_steps[i]->fillIteration(ret[i]);
6831 * 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'
6832 * This method returns two things.
6833 * - The absolute dimension of 'this' in first parameter.
6834 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
6835 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
6837 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
6838 * Only these 3 discretizations will be taken into account here.
6840 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
6841 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
6842 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
6844 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
6845 * 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'.
6847 * Let's consider the typical following case :
6848 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
6849 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
6850 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
6852 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
6854 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
6856 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
6857 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
6858 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
6859 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
6861 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
6863 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
6866 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
6868 if(pos<0 || pos>=(int)_time_steps.size())
6870 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6871 throw INTERP_KERNEL::Exception(oss.str().c_str());
6873 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6876 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6877 oss << "\nTry to use following method eraseEmptyTS !";
6878 throw INTERP_KERNEL::Exception(oss.str().c_str());
6883 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
6885 if(pos<0 || pos>=(int)_time_steps.size())
6887 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6888 throw INTERP_KERNEL::Exception(oss.str().c_str());
6890 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6893 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6894 oss << "\nTry to use following method eraseEmptyTS !";
6895 throw INTERP_KERNEL::Exception(oss.str().c_str());
6900 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
6902 std::vector<std::string> ret;
6903 std::set<std::string> ret2;
6904 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6906 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
6907 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6908 if(ret2.find(*it2)==ret2.end())
6910 ret.push_back(*it2);
6917 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
6919 std::vector<std::string> ret;
6920 std::set<std::string> ret2;
6921 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6923 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
6924 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6925 if(ret2.find(*it2)==ret2.end())
6927 ret.push_back(*it2);
6934 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
6936 std::vector<std::string> ret;
6937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6939 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
6940 ret.insert(ret.end(),tmp.begin(),tmp.end());
6945 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
6947 std::vector<std::string> ret;
6948 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6950 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
6951 ret.insert(ret.end(),tmp.begin(),tmp.end());
6956 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6959 (*it)->changePflsRefsNamesGen2(mapOfModif);
6962 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6964 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6965 (*it)->changeLocsRefsNamesGen2(mapOfModif);
6968 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
6970 int lgth=_time_steps.size();
6971 std::vector< std::vector<TypeOfField> > ret(lgth);
6972 for(int i=0;i<lgth;i++)
6973 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
6978 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
6980 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)
6982 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
6985 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
6987 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
6989 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6991 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
6992 ret->_time_steps[i]=(*it)->deepCpy();
6997 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
6999 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7000 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7001 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7002 for(std::size_t i=0;i<sz;i++)
7004 ret[i]=shallowCpy();
7005 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7007 for(std::size_t i=0;i<sz2;i++)
7009 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7012 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7013 throw INTERP_KERNEL::Exception(oss.str().c_str());
7017 for(std::size_t i=0;i<sz;i++)
7018 for(std::size_t j=0;j<sz2;j++)
7019 ret[i]->_time_steps[j]=ts[j][i];
7023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7025 _name=field->getName();
7027 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7029 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7030 _infos=arr->getInfoOnComponents();
7033 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7035 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7036 if(_name!=field->getName())
7038 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7039 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7040 throw INTERP_KERNEL::Exception(oss.str().c_str());
7043 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7044 checkThatComponentsMatch(arr->getInfoOnComponents());
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7049 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7050 if(getInfo().size()!=compos.size())
7052 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7053 oss << " number of components of element to append (" << compos.size() << ") !";
7054 throw INTERP_KERNEL::Exception(oss.str().c_str());
7058 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7059 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7060 oss << " But compo in input fields are : ";
7061 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7063 throw INTERP_KERNEL::Exception(oss.str().c_str());
7067 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7069 std::size_t sz=_infos.size();
7071 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7073 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7075 if(elt->getInfo().size()!=sz)
7077 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7078 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7079 throw INTERP_KERNEL::Exception(oss.str().c_str());
7084 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7087 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7088 if(!_time_steps.empty())
7089 checkCoherencyOfTinyInfo(field,arr);
7090 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7091 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7092 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7093 copyTinyInfoFrom(field,arr);
7094 _time_steps.push_back(obj);
7097 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7100 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7101 if(!_time_steps.empty())
7102 checkCoherencyOfTinyInfo(field,arr);
7103 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7104 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7105 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7106 copyTinyInfoFrom(field,arr);
7107 _time_steps.push_back(obj);
7110 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7112 int sz=(int)_time_steps.size();
7115 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7116 throw INTERP_KERNEL::Exception(oss.str().c_str());
7118 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7121 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7123 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7124 throw INTERP_KERNEL::Exception(oss.str().c_str());
7130 //= MEDFileFieldMultiTSWithoutSDA
7132 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) throw(INTERP_KERNEL::Exception)
7134 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7137 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7141 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7146 * \param [in] fieldId field id in C mode
7148 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7149 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7152 catch(INTERP_KERNEL::Exception& e)
7155 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7156 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7159 catch(INTERP_KERNEL::Exception& e)
7162 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7164 return new MEDFileField1TSWithoutSDA;
7167 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7170 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7171 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7173 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7176 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7178 return MEDFileField1TSWithoutSDA::TYPE_STR;
7181 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7183 return new MEDFileFieldMultiTSWithoutSDA(*this);
7186 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7188 return new MEDFileFieldMultiTSWithoutSDA;
7192 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7193 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7195 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)
7197 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7198 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7200 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7201 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7204 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7206 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7207 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7209 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7211 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7214 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7216 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7217 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7218 ret->setIteration(i,elt);
7224 //= MEDFileAnyTypeFieldMultiTS
7226 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7230 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
7231 try:MEDFileFieldGlobsReal(fileName)
7233 MEDFileUtilities::CheckFileForRead(fileName);
7234 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7235 _content=BuildContentFrom(fid,fileName);
7238 catch(INTERP_KERNEL::Exception& e)
7243 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7245 med_field_type typcha;
7246 std::vector<std::string> infos;
7249 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7250 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7255 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i);
7260 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i);
7265 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] !";
7266 throw INTERP_KERNEL::Exception(oss.str().c_str());
7269 ret->setDtUnit(dtunit.c_str());
7273 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
7275 med_field_type typcha;
7277 std::vector<std::string> infos;
7278 std::string dtunit,fieldName;
7279 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7280 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7285 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0);
7290 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0);
7295 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] !";
7296 throw INTERP_KERNEL::Exception(oss.str().c_str());
7299 ret->setDtUnit(dtunit.c_str());
7303 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7306 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7307 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7309 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7310 ret->setFileName(fileName);
7311 ret->_content=c; c->incrRef();
7314 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7316 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7317 ret->setFileName(fileName);
7318 ret->_content=c; c->incrRef();
7321 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7324 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7325 try:MEDFileFieldGlobsReal(fileName)
7327 MEDFileUtilities::CheckFileForRead(fileName);
7328 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7329 _content=BuildContentFrom(fid,fileName,fieldName);
7332 catch(INTERP_KERNEL::Exception& e)
7337 //= MEDFileIntFieldMultiTSWithoutSDA
7339 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) throw(INTERP_KERNEL::Exception)
7341 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7344 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7348 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7352 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7353 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7356 catch(INTERP_KERNEL::Exception& e)
7360 * \param [in] fieldId field id in C mode
7362 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7363 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7366 catch(INTERP_KERNEL::Exception& e)
7369 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7371 return new MEDFileIntField1TSWithoutSDA;
7374 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7377 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7378 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7380 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7383 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7385 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7388 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7390 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7393 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7395 return new MEDFileIntFieldMultiTSWithoutSDA;
7398 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7400 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7401 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7403 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7405 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7408 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7410 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7411 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7412 ret->setIteration(i,elt);
7418 //= MEDFileAnyTypeFieldMultiTS
7421 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7422 * that has been read from a specified MED file.
7423 * \param [in] fileName - the name of the MED file to read.
7424 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7425 * is to delete this field using decrRef() as it is no more needed.
7426 * \throw If reading the file fails.
7428 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7430 MEDFileUtilities::CheckFileForRead(fileName);
7431 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7432 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName);
7433 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7434 ret->loadGlobals(fid);
7439 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7440 * that has been read from a specified MED file.
7441 * \param [in] fileName - the name of the MED file to read.
7442 * \param [in] fieldName - the name of the field to read.
7443 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7444 * is to delete this field using decrRef() as it is no more needed.
7445 * \throw If reading the file fails.
7446 * \throw If there is no field named \a fieldName in the file.
7448 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7450 MEDFileUtilities::CheckFileForRead(fileName);
7451 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7452 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
7453 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7454 ret->loadGlobals(fid);
7459 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7460 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7462 * \warning this is a shallow copy constructor
7464 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7466 if(!shallowCopyOfContent)
7468 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7469 otherPtr->incrRef();
7470 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7474 _content=other.shallowCpy();
7478 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7480 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7486 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7488 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7490 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7494 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7496 return contentNotNullBase()->getPflsReallyUsed2();
7499 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7501 return contentNotNullBase()->getLocsReallyUsed2();
7504 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7506 return contentNotNullBase()->getPflsReallyUsedMulti2();
7509 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7511 return contentNotNullBase()->getLocsReallyUsedMulti2();
7514 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7516 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7519 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7521 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7524 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7526 return contentNotNullBase()->getNumberOfTS();
7529 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7531 contentNotNullBase()->eraseEmptyTS();
7534 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7536 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7539 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7541 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7544 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7546 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7547 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7552 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7554 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7555 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7560 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7562 return contentNotNullBase()->getIterations();
7565 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7567 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7568 pushBackTimeStep(*it);
7571 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7574 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7575 checkCoherencyOfType(f1ts);
7577 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7578 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7581 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7582 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7583 _content->pushBackTimeStep(cSafe);
7584 appendGlobs(*f1ts,1e-12);
7587 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7589 contentNotNullBase()->synchronizeNameScope();
7592 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7594 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7597 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7599 return contentNotNullBase()->getPosGivenTime(time,eps);
7602 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7604 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7607 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7609 return contentNotNullBase()->getTypesOfFieldAvailable();
7612 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)
7614 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7617 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7619 return contentNotNullBase()->getName();
7622 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7624 contentNotNullBase()->setName(name);
7627 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7629 return contentNotNullBase()->getDtUnit();
7632 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7634 contentNotNullBase()->setDtUnit(dtUnit);
7637 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7639 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7642 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7644 return contentNotNullBase()->getTimeSteps(ret1);
7647 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7649 return contentNotNullBase()->getMeshName();
7652 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7654 contentNotNullBase()->setMeshName(newMeshName);
7657 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7659 return contentNotNullBase()->changeMeshNames(modifTab);
7662 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7664 return contentNotNullBase()->getInfo();
7667 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7669 return contentNotNullBase()->setInfo(info);
7672 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7674 const std::vector<std::string> ret=getInfo();
7675 return (int)ret.size();
7678 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7680 writeGlobals(fid,*this);
7681 contentNotNullBase()->writeLL(fid,*this);
7685 * Writes \a this field into a MED file specified by its name.
7686 * \param [in] fileName - the MED file name.
7687 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7688 * - 2 - erase; an existing file is removed.
7689 * - 1 - append; same data should not be present in an existing file.
7690 * - 0 - overwrite; same data present in an existing file is overwritten.
7691 * \throw If the field name is not set.
7692 * \throw If no field data is set.
7693 * \throw If \a mode == 1 and the same data is present in an existing file.
7695 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7697 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7698 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7702 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7704 std::ostringstream oss;
7705 contentNotNullBase()->simpleRepr(0,oss,-1);
7706 simpleReprGlobs(oss);
7710 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7713 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7714 ret+=_content->getHeapMemorySize();
7715 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7719 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
7720 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7721 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7723 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7725 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7727 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7728 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7729 std::size_t sz(contentsSplit.size());
7730 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7731 for(std::size_t i=0;i<sz;i++)
7733 ret[i]=shallowCpy();
7734 ret[i]->_content=contentsSplit[i];
7739 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7741 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7742 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7743 ret->_content=_content->deepCpy();
7744 ret->deepCpyGlobs(*this);
7748 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7754 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7755 * \param [in] iteration - the iteration number of a required time step.
7756 * \param [in] order - the iteration order number of required time step.
7757 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7758 * delete this field using decrRef() as it is no more needed.
7759 * \throw If there is no required time step in \a this field.
7761 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7763 int pos=getPosOfTimeStep(iteration,order);
7764 return getTimeStepAtPos(pos);
7768 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7769 * \param [in] time - the time of the time step of interest.
7770 * \param [in] eps - a precision used to compare time values.
7771 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7772 * delete this field using decrRef() as it is no more needed.
7773 * \throw If there is no required time step in \a this field.
7775 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7777 int pos=getPosGivenTime(time,eps);
7778 return getTimeStepAtPos(pos);
7781 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7783 return new MEDFileAnyTypeFieldMultiTSIterator(this);
7786 //= MEDFileFieldMultiTS
7789 * Returns a new empty instance of MEDFileFieldMultiTS.
7790 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7791 * is to delete this field using decrRef() as it is no more needed.
7793 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
7795 return new MEDFileFieldMultiTS;
7799 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
7800 * that has been read from a specified MED file.
7801 * \param [in] fileName - the name of the MED file to read.
7802 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7803 * is to delete this field using decrRef() as it is no more needed.
7804 * \throw If reading the file fails.
7806 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7808 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName);
7809 ret->contentNotNull();//to check that content type matches with \a this type.
7814 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
7815 * that has been read from a specified MED file.
7816 * \param [in] fileName - the name of the MED file to read.
7817 * \param [in] fieldName - the name of the field to read.
7818 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7819 * is to delete this field using decrRef() as it is no more needed.
7820 * \throw If reading the file fails.
7821 * \throw If there is no field named \a fieldName in the file.
7823 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7825 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName);
7826 ret->contentNotNull();//to check that content type matches with \a this type.
7831 * Returns a new instance of MEDFileFieldMultiTS. 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 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
7835 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
7836 * \warning this is a shallow copy constructor
7837 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
7838 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
7839 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7840 * is to delete this field using decrRef() as it is no more needed.
7842 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7844 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
7847 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
7849 return new MEDFileFieldMultiTS(*this);
7852 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
7855 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7856 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
7858 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7862 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
7863 * following the given input policy.
7865 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7866 * By default (true) the globals are deeply copied.
7867 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
7869 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
7871 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
7872 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7875 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
7877 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
7878 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
7879 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
7882 ret=MEDFileIntFieldMultiTS::New();
7884 ret->deepCpyGlobs(*this);
7886 ret->shallowCpyGlobs(*this);
7891 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
7892 * \param [in] pos - a time step id.
7893 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7894 * delete this field using decrRef() as it is no more needed.
7895 * \throw If \a pos is not a valid time step id.
7897 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
7899 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
7902 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
7903 throw INTERP_KERNEL::Exception(oss.str().c_str());
7905 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
7908 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
7909 ret->shallowCpyGlobs(*this);
7912 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
7913 throw INTERP_KERNEL::Exception(oss.str().c_str());
7917 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7918 * mesh entities of a given dimension of the first mesh in MED file.
7919 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7920 * \param [in] type - a spatial discretization of interest.
7921 * \param [in] iteration - the iteration number of a required time step.
7922 * \param [in] order - the iteration order number of required time step.
7923 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7924 * \param [in] renumPol - specifies how to permute values of the result field according to
7925 * the optional numbers of cells and nodes, if any. The valid values are
7926 * - 0 - do not permute.
7927 * - 1 - permute cells.
7928 * - 2 - permute nodes.
7929 * - 3 - permute cells and nodes.
7931 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7932 * caller is to delete this field using decrRef() as it is no more needed.
7933 * \throw If the MED file is not readable.
7934 * \throw If there is no mesh in the MED file.
7935 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7936 * \throw If no field values of the required parameters are available.
7938 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7940 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7941 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7943 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
7944 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7945 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
7946 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7951 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7952 * the top level cells of the first mesh in MED file.
7953 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7954 * \param [in] type - a spatial discretization of interest.
7955 * \param [in] iteration - the iteration number of a required time step.
7956 * \param [in] order - the iteration order number of required time step.
7957 * \param [in] renumPol - specifies how to permute values of the result field according to
7958 * the optional numbers of cells and nodes, if any. The valid values are
7959 * - 0 - do not permute.
7960 * - 1 - permute cells.
7961 * - 2 - permute nodes.
7962 * - 3 - permute cells and nodes.
7964 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7965 * caller is to delete this field using decrRef() as it is no more needed.
7966 * \throw If the MED file is not readable.
7967 * \throw If there is no mesh in the MED file.
7968 * \throw If no field values of the required parameters are available.
7970 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
7972 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7973 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7975 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
7976 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7977 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
7978 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7983 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7985 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7986 * \param [in] type - a spatial discretization of interest.
7987 * \param [in] iteration - the iteration number of a required time step.
7988 * \param [in] order - the iteration order number of required time step.
7989 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7990 * \param [in] mesh - the supporting mesh.
7991 * \param [in] renumPol - specifies how to permute values of the result field according to
7992 * the optional numbers of cells and nodes, if any. The valid values are
7993 * - 0 - do not permute.
7994 * - 1 - permute cells.
7995 * - 2 - permute nodes.
7996 * - 3 - permute cells and nodes.
7998 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7999 * caller is to delete this field using decrRef() as it is no more needed.
8000 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8001 * \throw If no field of \a this is lying on \a mesh.
8002 * \throw If no field values of the required parameters are available.
8004 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8006 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8007 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8009 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8010 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8011 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8012 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8017 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8019 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8020 * \param [in] type - a spatial discretization of the new field.
8021 * \param [in] iteration - the iteration number of a required time step.
8022 * \param [in] order - the iteration order number of required time step.
8023 * \param [in] mesh - the supporting mesh.
8024 * \param [in] renumPol - specifies how to permute values of the result field according to
8025 * the optional numbers of cells and nodes, if any. The valid values are
8026 * - 0 - do not permute.
8027 * - 1 - permute cells.
8028 * - 2 - permute nodes.
8029 * - 3 - permute cells and nodes.
8031 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8032 * caller is to delete this field using decrRef() as it is no more needed.
8033 * \throw If no field of \a this is lying on \a mesh.
8034 * \throw If no field values of the required parameters are available.
8036 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8038 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8039 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8041 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8042 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8043 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8044 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8049 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8050 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8051 * This method is useful for MED2 file format when field on different mesh was autorized.
8053 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8055 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8056 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8059 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8060 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8061 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8066 * Returns values and a profile of the field of a given type, of a given time step,
8067 * lying on a given support.
8068 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8069 * \param [in] type - a spatial discretization of the field.
8070 * \param [in] iteration - the iteration number of a required time step.
8071 * \param [in] order - the iteration order number of required time step.
8072 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8073 * \param [in] mesh - the supporting mesh.
8074 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8075 * field of interest lies on. If the field lies on all entities of the given
8076 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8077 * using decrRef() as it is no more needed.
8078 * \param [in] glob - the global data storing profiles and localization.
8079 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8080 * field. The caller is to delete this array using decrRef() as it is no more needed.
8081 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8082 * \throw If no field of \a this is lying on \a mesh.
8083 * \throw If no field values of the required parameters are available.
8085 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8087 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8088 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8090 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8091 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8092 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8095 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8097 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8099 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8100 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8102 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 !");
8106 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8108 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8110 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8111 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8113 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 !");
8118 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8119 * the given field is checked if its elements are sorted suitable for writing to MED file
8120 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8121 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8122 * \param [in] field - the field to add to \a this.
8123 * \throw If the name of \a field is empty.
8124 * \throw If the data array of \a field is not set.
8125 * \throw If existing time steps have different name or number of components than \a field.
8126 * \throw If the underlying mesh of \a field has no name.
8127 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8129 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8131 const DataArrayDouble *arr=0;
8133 arr=field->getArray();
8134 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8138 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8139 * a given dimension of a given mesh are used as the support of the given field.
8140 * Elements of the given mesh must be sorted suitable for writing to MED file.
8141 * Order of underlying mesh entities of the given field specified by \a profile parameter
8142 * is not prescribed; this method permutes field values to have them sorted by element
8143 * type as required for writing to MED file.
8144 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8145 * \param [in] field - the field to add to \a this.
8146 * \param [in] mesh - the supporting mesh of \a field.
8147 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8148 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8149 * \throw If either \a field or \a mesh or \a profile has an empty name.
8150 * \throw If existing time steps have different name or number of components than \a field.
8151 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8152 * \throw If the data array of \a field is not set.
8153 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8155 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8157 const DataArrayDouble *arr=0;
8159 arr=field->getArray();
8160 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8163 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8165 _content=new MEDFileFieldMultiTSWithoutSDA;
8168 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8169 try:MEDFileAnyTypeFieldMultiTS(fileName)
8172 catch(INTERP_KERNEL::Exception& e)
8175 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8176 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8179 catch(INTERP_KERNEL::Exception& e)
8182 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8186 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)
8188 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8191 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8193 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8196 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)
8198 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8201 //= MEDFileAnyTypeFieldMultiTSIterator
8203 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8208 _nb_iter=fmts->getNumberOfTS();
8212 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8216 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8218 if(_iter_id<_nb_iter)
8220 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8222 return fmts->getTimeStepAtPos(_iter_id++);
8230 //= MEDFileIntFieldMultiTS
8233 * Returns a new empty instance of MEDFileFieldMultiTS.
8234 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8235 * is to delete this field using decrRef() as it is no more needed.
8237 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8239 return new MEDFileIntFieldMultiTS;
8243 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8244 * that has been read from a specified MED file.
8245 * \param [in] fileName - the name of the MED file to read.
8246 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8247 * is to delete this field using decrRef() as it is no more needed.
8248 * \throw If reading the file fails.
8250 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8252 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName);
8253 ret->contentNotNull();//to check that content type matches with \a this type.
8258 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8259 * that has been read from a specified MED file.
8260 * \param [in] fileName - the name of the MED file to read.
8261 * \param [in] fieldName - the name of the field to read.
8262 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8263 * is to delete this field using decrRef() as it is no more needed.
8264 * \throw If reading the file fails.
8265 * \throw If there is no field named \a fieldName in the file.
8267 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8269 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName);
8270 ret->contentNotNull();//to check that content type matches with \a this type.
8275 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8276 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8278 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8279 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8280 * \warning this is a shallow copy constructor
8281 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8282 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8283 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8284 * is to delete this field using decrRef() as it is no more needed.
8286 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8288 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8292 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8293 * following the given input policy.
8295 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8296 * By default (true) the globals are deeply copied.
8297 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8299 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8301 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8302 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8305 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8307 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8308 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8309 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8312 ret=MEDFileFieldMultiTS::New();
8314 ret->deepCpyGlobs(*this);
8316 ret->shallowCpyGlobs(*this);
8320 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8322 return new MEDFileIntFieldMultiTS(*this);
8325 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8328 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8329 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8331 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8335 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8336 * mesh entities of a given dimension of the first mesh in MED file.
8337 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8338 * \param [in] type - a spatial discretization of interest.
8339 * \param [in] iteration - the iteration number of a required time step.
8340 * \param [in] order - the iteration order number of required time step.
8341 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8342 * \param [out] arrOut - the DataArrayInt containing values of field.
8343 * \param [in] renumPol - specifies how to permute values of the result field according to
8344 * the optional numbers of cells and nodes, if any. The valid values are
8345 * - 0 - do not permute.
8346 * - 1 - permute cells.
8347 * - 2 - permute nodes.
8348 * - 3 - permute cells and nodes.
8350 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8351 * caller is to delete this field using decrRef() as it is no more needed.
8352 * \throw If the MED file is not readable.
8353 * \throw If there is no mesh in the MED file.
8354 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8355 * \throw If no field values of the required parameters are available.
8357 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8359 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8360 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8362 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8363 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8364 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8365 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8370 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8371 * the top level cells of the first mesh in MED file.
8372 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8373 * \param [in] type - a spatial discretization of interest.
8374 * \param [in] iteration - the iteration number of a required time step.
8375 * \param [in] order - the iteration order number of required time step.
8376 * \param [out] arrOut - the DataArrayInt containing values of field.
8377 * \param [in] renumPol - specifies how to permute values of the result field according to
8378 * the optional numbers of cells and nodes, if any. The valid values are
8379 * - 0 - do not permute.
8380 * - 1 - permute cells.
8381 * - 2 - permute nodes.
8382 * - 3 - permute cells and nodes.
8384 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8385 * caller is to delete this field using decrRef() as it is no more needed.
8386 * \throw If the MED file is not readable.
8387 * \throw If there is no mesh in the MED file.
8388 * \throw If no field values of the required parameters are available.
8390 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8392 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8393 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8395 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8396 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8397 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8398 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8403 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8405 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8406 * \param [in] type - a spatial discretization of interest.
8407 * \param [in] iteration - the iteration number of a required time step.
8408 * \param [in] order - the iteration order number of required time step.
8409 * \param [out] arrOut - the DataArrayInt containing values of field.
8410 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8411 * \param [in] mesh - the supporting mesh.
8412 * \param [in] renumPol - specifies how to permute values of the result field according to
8413 * the optional numbers of cells and nodes, if any. The valid values are
8414 * - 0 - do not permute.
8415 * - 1 - permute cells.
8416 * - 2 - permute nodes.
8417 * - 3 - permute cells and nodes.
8419 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8420 * caller is to delete this field using decrRef() as it is no more needed.
8421 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8422 * \throw If no field of \a this is lying on \a mesh.
8423 * \throw If no field values of the required parameters are available.
8425 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8427 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8428 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8430 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8431 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8432 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8433 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8438 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8440 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8441 * \param [in] type - a spatial discretization of the new field.
8442 * \param [in] iteration - the iteration number of a required time step.
8443 * \param [in] order - the iteration order number of required time step.
8444 * \param [in] mesh - the supporting mesh.
8445 * \param [out] arrOut - the DataArrayInt containing values of field.
8446 * \param [in] renumPol - specifies how to permute values of the result field according to
8447 * the optional numbers of cells and nodes, if any. The valid values are
8448 * - 0 - do not permute.
8449 * - 1 - permute cells.
8450 * - 2 - permute nodes.
8451 * - 3 - permute cells and nodes.
8453 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8454 * caller is to delete this field using decrRef() as it is no more needed.
8455 * \throw If no field of \a this is lying on \a mesh.
8456 * \throw If no field values of the required parameters are available.
8458 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8460 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8461 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8463 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8464 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8465 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8466 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8471 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8472 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8473 * This method is useful for MED2 file format when field on different mesh was autorized.
8475 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8477 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8478 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8480 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8481 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8482 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8483 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8488 * Returns values and a profile of the field of a given type, of a given time step,
8489 * lying on a given support.
8490 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8491 * \param [in] type - a spatial discretization of the field.
8492 * \param [in] iteration - the iteration number of a required time step.
8493 * \param [in] order - the iteration order number of required time step.
8494 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8495 * \param [in] mesh - the supporting mesh.
8496 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8497 * field of interest lies on. If the field lies on all entities of the given
8498 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8499 * using decrRef() as it is no more needed.
8500 * \param [in] glob - the global data storing profiles and localization.
8501 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8502 * field. The caller is to delete this array using decrRef() as it is no more needed.
8503 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8504 * \throw If no field of \a this is lying on \a mesh.
8505 * \throw If no field values of the required parameters are available.
8507 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8509 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8510 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8512 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8513 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8514 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8518 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8519 * \param [in] pos - a time step id.
8520 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8521 * delete this field using decrRef() as it is no more needed.
8522 * \throw If \a pos is not a valid time step id.
8524 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8526 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8529 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8530 throw INTERP_KERNEL::Exception(oss.str().c_str());
8532 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8535 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8536 ret->shallowCpyGlobs(*this);
8539 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8540 throw INTERP_KERNEL::Exception(oss.str().c_str());
8544 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8545 * the given field is checked if its elements are sorted suitable for writing to MED file
8546 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8547 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8548 * \param [in] field - the field to add to \a this.
8549 * \throw If the name of \a field is empty.
8550 * \throw If the data array of \a field is not set.
8551 * \throw If existing time steps have different name or number of components than \a field.
8552 * \throw If the underlying mesh of \a field has no name.
8553 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8555 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8557 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8561 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8562 * a given dimension of a given mesh are used as the support of the given field.
8563 * Elements of the given mesh must be sorted suitable for writing to MED file.
8564 * Order of underlying mesh entities of the given field specified by \a profile parameter
8565 * is not prescribed; this method permutes field values to have them sorted by element
8566 * type as required for writing to MED file.
8567 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8568 * \param [in] field - the field to add to \a this.
8569 * \param [in] mesh - the supporting mesh of \a field.
8570 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8571 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8572 * \throw If either \a field or \a mesh or \a profile has an empty name.
8573 * \throw If existing time steps have different name or number of components than \a field.
8574 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8575 * \throw If the data array of \a field is not set.
8576 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8578 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8580 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8583 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8585 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8587 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8588 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8590 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 !");
8594 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8596 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8598 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8599 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8601 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 !");
8605 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8607 _content=new MEDFileIntFieldMultiTSWithoutSDA;
8610 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8614 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8615 try:MEDFileAnyTypeFieldMultiTS(fileName)
8618 catch(INTERP_KERNEL::Exception& e)
8621 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8622 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8625 catch(INTERP_KERNEL::Exception& e)
8628 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8630 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8635 MEDFileFields *MEDFileFields::New()
8637 return new MEDFileFields;
8640 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8642 return new MEDFileFields(fileName);
8645 std::size_t MEDFileFields::getHeapMemorySize() const
8647 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8648 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8649 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8650 ret+=(*it)->getHeapMemorySize();
8651 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8654 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8656 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8658 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8660 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8661 ret->_fields[i]=(*it)->deepCpy();
8663 ret->deepCpyGlobs(*this);
8667 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8669 return new MEDFileFields(*this);
8673 * 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
8674 * 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.
8675 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8677 * \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.
8678 * \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.
8680 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8682 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8684 std::set< std::pair<int,int> > s;
8685 bool firstShot=true;
8686 areThereSomeForgottenTS=false;
8687 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8689 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8691 std::vector< std::pair<int,int> > v=(*it)->getIterations();
8692 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8694 { s=s1; firstShot=false; }
8697 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8699 areThereSomeForgottenTS=true;
8703 std::vector< std::pair<int,int> > ret;
8704 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8708 int MEDFileFields::getNumberOfFields() const
8710 return _fields.size();
8713 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8715 std::vector<std::string> ret(_fields.size());
8717 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8719 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8722 ret[i]=f->getName();
8726 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8727 throw INTERP_KERNEL::Exception(oss.str().c_str());
8733 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8735 std::vector<std::string> ret;
8736 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8738 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8740 ret.push_back(cur->getMeshName());
8745 std::string MEDFileFields::simpleRepr() const
8747 std::ostringstream oss;
8748 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8753 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8755 int nbOfFields=getNumberOfFields();
8756 std::string startLine(bkOffset,' ');
8757 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8759 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8761 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8764 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8768 oss << startLine << " - not defined !" << std::endl;
8772 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8774 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8775 std::string chapter(17,'0'+i);
8776 oss << startLine << chapter << std::endl;
8779 cur->simpleRepr(bkOffset+2,oss,i);
8783 oss << startLine << " - not defined !" << std::endl;
8785 oss << startLine << chapter << std::endl;
8787 simpleReprGlobs(oss);
8790 MEDFileFields::MEDFileFields()
8794 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
8795 try:MEDFileFieldGlobsReal(fileName)
8797 MEDFileUtilities::CheckFileForRead(fileName);
8798 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
8799 int nbFields=MEDnField(fid);
8800 _fields.resize(nbFields);
8801 med_field_type typcha;
8802 for(int i=0;i<nbFields;i++)
8804 std::vector<std::string> infos;
8805 std::string fieldName,dtunit;
8806 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
8811 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8816 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8821 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] !";
8822 throw INTERP_KERNEL::Exception(oss.str().c_str());
8826 loadAllGlobals(fid);
8828 catch(INTERP_KERNEL::Exception& e)
8833 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8836 writeGlobals(fid,*this);
8837 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8839 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
8842 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
8843 throw INTERP_KERNEL::Exception(oss.str().c_str());
8845 elt->writeLL(fid,*this);
8849 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8851 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8852 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8856 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
8858 std::vector<std::string> ret;
8859 std::set<std::string> ret2;
8860 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8862 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8863 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8864 if(ret2.find(*it2)==ret2.end())
8866 ret.push_back(*it2);
8873 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
8875 std::vector<std::string> ret;
8876 std::set<std::string> ret2;
8877 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8879 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8880 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8881 if(ret2.find(*it2)==ret2.end())
8883 ret.push_back(*it2);
8890 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
8892 std::vector<std::string> ret;
8893 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8895 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8896 ret.insert(ret.end(),tmp.begin(),tmp.end());
8901 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
8903 std::vector<std::string> ret;
8904 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8906 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8907 ret.insert(ret.end(),tmp.begin(),tmp.end());
8912 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8914 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8915 (*it)->changePflsRefsNamesGen2(mapOfModif);
8918 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8920 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8921 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8924 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
8926 _fields.resize(newSize);
8929 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
8931 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
8935 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8938 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
8939 _fields.push_back(field->getContent());
8940 appendGlobs(*field,1e-12);
8943 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8946 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
8947 if(i>=(int)_fields.size())
8948 _fields.resize(i+1);
8949 _fields[i]=field->getContent();
8950 appendGlobs(*field,1e-12);
8953 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
8955 destroyFieldsAtPos(&i,&i+1);
8958 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
8960 std::vector<bool> b(_fields.size(),true);
8961 for(const int *i=startIds;i!=endIds;i++)
8963 if(*i<0 || *i>=(int)_fields.size())
8965 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
8966 throw INTERP_KERNEL::Exception(oss.str().c_str());
8970 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8972 for(std::size_t i=0;i<_fields.size();i++)
8974 fields[j++]=_fields[i];
8978 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
8980 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
8981 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8982 std::vector<bool> b(_fields.size(),true);
8984 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
8986 if(k<0 || k>=(int)_fields.size())
8988 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
8989 throw INTERP_KERNEL::Exception(oss.str().c_str());
8993 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8995 for(std::size_t i=0;i<_fields.size();i++)
8997 fields[j++]=_fields[i];
9001 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9004 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9006 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9008 ret=cur->changeMeshNames(modifTab) || ret;
9014 * \param [in] meshName the name of the mesh that will be renumbered.
9015 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9016 * This code corresponds to the distribution of types in the corresponding mesh.
9017 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9018 * \param [in] renumO2N the old to new renumber array.
9019 * \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
9022 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9025 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9027 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9030 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9036 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9038 if(i<0 || i>=(int)_fields.size())
9040 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9041 throw INTERP_KERNEL::Exception(oss.str().c_str());
9043 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9046 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9047 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9048 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9050 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9052 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9055 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9056 throw INTERP_KERNEL::Exception(oss.str().c_str());
9058 ret->shallowCpyGlobs(*this);
9063 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9064 * This method is accessible in python using __getitem__ with a list in input.
9065 * \return a new object that the caller should deal with.
9067 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9069 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9070 std::size_t sz=std::distance(startIds,endIds);
9071 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9073 for(const int *i=startIds;i!=endIds;i++,j++)
9075 if(*i<0 || *i>=(int)_fields.size())
9077 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9078 throw INTERP_KERNEL::Exception(oss.str().c_str());
9080 fields[j]=_fields[*i];
9082 ret->_fields=fields;
9086 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9088 return getFieldAtPos(getPosFromFieldName(fieldName));
9092 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9093 * This method can be seen as a filter applied on \a this, that returns an object containing
9094 * 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
9095 * shallow copied from \a this.
9097 * \param [in] meshName - the name of the mesh on w
9098 * \return a new object that the caller should deal with.
9100 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9102 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9103 ret->shallowCpyOnlyUsedGlobs(*this);
9104 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9106 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9109 if(cur->getMeshName()==meshName)
9112 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9113 ret->_fields.push_back(cur2);
9120 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9121 * Input time steps are specified using a pair of integer (iteration, order).
9122 * 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,
9123 * but for each multitimestep only the time steps in \a timeSteps are kept.
9124 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9126 * The returned object points to shallow copy of elements in \a this.
9128 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9129 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9130 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9132 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9134 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9135 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9137 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9140 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9141 ret->_fields.push_back(elt);
9143 ret->shallowCpyOnlyUsedGlobs(*this);
9148 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9150 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9152 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9153 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9155 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9158 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9159 if(elt->getNumberOfTS()!=0)
9160 ret->_fields.push_back(elt);
9162 ret->shallowCpyOnlyUsedGlobs(*this);
9166 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9168 return new MEDFileFieldsIterator(this);
9171 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9173 std::string tmp(fieldName);
9174 std::vector<std::string> poss;
9175 for(std::size_t i=0;i<_fields.size();i++)
9177 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9180 std::string fname(f->getName());
9184 poss.push_back(fname);
9187 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9188 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9190 throw INTERP_KERNEL::Exception(oss.str().c_str());
9193 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9198 _nb_iter=fs->getNumberOfFields();
9202 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9206 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9208 if(_iter_id<_nb_iter)
9210 MEDFileFields *fs(_fs);
9212 return fs->getFieldAtPos(_iter_id++);