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 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble()
592 return _father->getArrayDouble();
595 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble() const
597 const MEDFileFieldPerMeshPerType *fath=_father;
598 return fath->getArrayDouble();
601 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
603 return _father->getInfo();
606 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
611 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
616 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
618 return _localization;
621 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
623 _localization=newLocName;
626 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
628 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
630 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
632 _profile=(*it2).second;
638 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
640 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
642 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
644 _localization=(*it2).second;
650 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
654 dads.push_back(std::pair<int,int>(_start,_end));
655 geoTypes.push_back(getGeoType());
660 pfls.push_back(glob->getProfile(_profile.c_str()));
662 if(_localization.empty())
666 locs.push_back(glob->getLocalizationId(_localization.c_str()));
670 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
672 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));
676 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
678 TypeOfField type=getType();
679 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
680 med_geometry_type mgeoti;
681 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
682 const DataArray *arr=getArray();
684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
685 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
686 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
687 const unsigned char *locToWrite=0;
689 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
691 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
693 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
694 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
695 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
699 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
704 dad.first=_start; dad.second=_end;
708 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
709 * This code corresponds to the distribution of types in the corresponding mesh.
710 * \param [out] ptToFill memory zone where the output will be stored.
711 * \return the size of data pushed into output param \a ptToFill
713 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
716 std::ostringstream oss;
717 std::size_t nbOfType=codeOfMesh.size()/3;
719 for(std::size_t i=0;i<nbOfType && found==-1;i++)
720 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
724 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
725 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
726 throw INTERP_KERNEL::Exception(oss.str().c_str());
731 if(_nval!=codeOfMesh[3*found+1])
733 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
734 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
735 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
736 throw INTERP_KERNEL::Exception(oss.str().c_str());
738 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
743 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
744 if(pfl->getNumberOfTuples()!=_nval)
746 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
747 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
749 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
750 throw INTERP_KERNEL::Exception(oss.str().c_str());
752 int offset2=codeOfMesh[3*found+2];
753 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
755 if(*pflId<codeOfMesh[3*found+1])
756 *work++=offset2+*pflId;
762 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
764 for(int i=_start;i<_end;i++)
769 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
780 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
784 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
787 std::map<std::pair<std::string,TypeOfField>,int> m;
788 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
789 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
790 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
791 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
793 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
794 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
799 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
801 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
802 * \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.
803 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
804 * \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)
805 * \param [in,out] glob if necessary by the method, new profiles can be added to it
806 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
807 * \param [out] result All new entries will be appended on it.
808 * \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 !)
810 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
811 const DataArrayInt *explicitIdsInMesh,
812 const std::vector<int>& newCode,
813 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
814 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
816 if(entriesOnSameDisc.empty())
818 TypeOfField type=entriesOnSameDisc[0]->getType();
819 int szEntities=0,szTuples=0;
820 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
821 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
822 int nbi=szTuples/szEntities;
823 if(szTuples%szEntities!=0)
824 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
825 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
827 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
828 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
829 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
830 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
831 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
833 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
835 int startOfEltIdOfChunk=(*it)->_start;
836 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
840 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
841 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
843 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
844 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
846 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
847 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
851 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
853 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
854 arrPart->renumberInPlace(renumTupleIds->begin());
855 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
857 const int *idIt=diffVals->begin();
858 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
860 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
862 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
864 int nbEntityElts=subIds->getNumberOfTuples();
866 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
867 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
871 result.push_back(eltToAdd);
872 offset2+=nbEntityElts*nbi;
874 ret=ret || li.empty();
879 * \param [in] typeF type of field of new chunk
880 * \param [in] geoType the geometric type of the chunk
881 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
882 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
883 * \param [in] nbi number of integration points
884 * \param [in] offset The offset in the **global array of data**.
885 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
886 * to the new chunk to create.
887 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
888 * \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
889 * and corresponding entry erased from \a entriesOnSameDisc.
890 * \return a newly allocated chunk
892 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
893 bool isPfl, int nbi, int offset,
894 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
895 MEDFileFieldGlobsReal& glob,
896 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
898 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
899 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
900 for(;it!=entriesOnSameDisc.end();it++)
902 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
906 if((*it)->_profile.empty())
909 if(!(*it)->_profile.empty())
911 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
912 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
918 if(it==entriesOnSameDisc.end())
921 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
923 ret->_loc_id=(int)geoType;
924 ret->_nval=nbMeshEntities;
926 ret->_end=ret->_start+ret->_nval*nbi;
929 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
930 glob.appendProfile(idsOfMeshElt);
931 ret->_profile=idsOfMeshElt->getName();
933 //tony treatment of localization
939 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
940 ret->_loc_id=(int)geoType;
941 ret->setNewStart(offset);
942 entriesOnSameDisc.erase(it);
948 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
950 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
953 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
955 return new MEDFileFieldPerMeshPerType(fath,geoType);
958 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
960 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
961 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
962 ret+=(*it)->getHeapMemorySize();
966 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
968 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
971 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
973 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
974 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
979 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
981 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
982 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
983 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
987 * This method is the most general one. No optimization is done here.
988 * \param [in] multiTypePfl is the end user profile specified in high level API
989 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
990 * \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.
991 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
992 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
993 * \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.
995 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)
997 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
998 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
999 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1002 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1004 _field_pm_pt_pd.resize(1);
1005 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1006 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1009 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1011 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1013 _field_pm_pt_pd.resize(1);
1014 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1015 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1018 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1020 TypeOfField type=field->getTypeOfField();
1021 if(type!=ON_GAUSS_PT)
1023 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1024 int sz=_field_pm_pt_pd.size();
1026 for(int j=0;j<sz && !found;j++)
1028 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1030 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1036 _field_pm_pt_pd.resize(sz+1);
1037 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1039 std::vector<int> ret(1,0);
1044 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1045 int sz2=ret2.size();
1046 std::vector<int> ret3(sz2);
1048 for(int i=0;i<sz2;i++)
1050 int sz=_field_pm_pt_pd.size();
1051 int locIdToFind=ret2[i];
1053 for(int j=0;j<sz && !found;j++)
1055 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1057 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1064 _field_pm_pt_pd.resize(sz+1);
1065 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1073 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1075 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1076 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1078 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1079 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1081 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1082 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1083 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1084 if(retTmp->presenceOfValue(-1))
1085 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1086 std::vector<int> ret(retTmp->begin(),retTmp->end());
1090 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1092 TypeOfField type=field->getTypeOfField();
1093 if(type!=ON_GAUSS_PT)
1095 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1096 int sz=_field_pm_pt_pd.size();
1098 for(int j=0;j<sz && !found;j++)
1100 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1102 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1108 _field_pm_pt_pd.resize(sz+1);
1109 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1111 std::vector<int> ret(1,0);
1116 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1117 int sz2=ret2.size();
1118 std::vector<int> ret3(sz2);
1120 for(int i=0;i<sz2;i++)
1122 int sz=_field_pm_pt_pd.size();
1123 int locIdToFind=ret2[i];
1125 for(int j=0;j<sz && !found;j++)
1127 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1129 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136 _field_pm_pt_pd.resize(sz+1);
1137 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1147 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1148 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1150 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1151 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1153 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1154 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1155 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1156 if(retTmp->presenceOfValue(-1))
1157 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1158 std::vector<int> ret(retTmp->begin(),retTmp->end());
1162 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1167 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1169 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1170 int curDim=(int)cm.getDimension();
1171 dim=std::max(dim,curDim);
1174 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1178 (*it)->fillTypesOfFieldAvailable(types);
1182 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)
1184 int sz=_field_pm_pt_pd.size();
1185 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1186 for(int i=0;i<sz;i++)
1188 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1192 int MEDFileFieldPerMeshPerType::getIteration() const
1194 return _father->getIteration();
1197 int MEDFileFieldPerMeshPerType::getOrder() const
1199 return _father->getOrder();
1202 double MEDFileFieldPerMeshPerType::getTime() const
1204 return _father->getTime();
1207 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1209 return _father->getMeshName();
1212 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1214 const char startLine[]=" ## ";
1215 std::string startLine2(bkOffset,' ');
1216 std::string startLine3(startLine2);
1217 startLine3+=startLine;
1218 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1220 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1221 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1224 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1225 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1227 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1229 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1231 cur->simpleRepr(bkOffset,oss,i);
1234 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1239 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1241 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1243 globalSz+=(*it)->getNumberOfTuples();
1245 nbOfEntries+=(int)_field_pm_pt_pd.size();
1248 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1254 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1256 return _father->getNumberOfComponents();
1259 DataArray *MEDFileFieldPerMeshPerType::getArray()
1261 return _father->getArray();
1264 const DataArray *MEDFileFieldPerMeshPerType::getArray() const
1266 const MEDFileFieldPerMesh *fath=_father;
1267 return fath->getArray();
1270 DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble()
1272 return _father->getArrayDouble();
1275 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble() const
1277 const MEDFileFieldPerMesh *fath=_father;
1278 return fath->getArrayDouble();
1281 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1283 return _father->getInfo();
1286 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1288 std::vector<std::string> ret;
1289 std::set<std::string> ret2;
1290 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1292 std::string tmp=(*it1)->getProfile();
1294 if(ret2.find(tmp)==ret2.end())
1303 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1305 std::vector<std::string> ret;
1306 std::set<std::string> ret2;
1307 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1309 std::string tmp=(*it1)->getLocalization();
1310 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1311 if(ret2.find(tmp)==ret2.end())
1320 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1322 std::vector<std::string> ret;
1323 std::set<std::string> ret2;
1324 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1326 std::string tmp=(*it1)->getProfile();
1333 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1335 std::vector<std::string> ret;
1336 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1338 std::string tmp=(*it1)->getLocalization();
1339 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1345 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1347 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1348 (*it1)->changePflsRefsNamesGen(mapOfModif);
1351 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1353 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1354 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1357 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1359 if(_field_pm_pt_pd.empty())
1361 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1362 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1363 throw INTERP_KERNEL::Exception(oss.str().c_str());
1365 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1366 return _field_pm_pt_pd[locId];
1367 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1368 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1369 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1370 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1371 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1374 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1376 if(_field_pm_pt_pd.empty())
1378 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1379 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1380 throw INTERP_KERNEL::Exception(oss.str().c_str());
1382 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1383 return _field_pm_pt_pd[locId];
1384 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1385 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1386 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1387 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1388 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1391 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
1393 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1395 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1396 if(meshDim!=(int)cm.getDimension())
1399 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1400 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1403 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1406 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1408 (*it)->fillValues(i,startEntryId,entries);
1412 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1414 _field_pm_pt_pd=leaves;
1415 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1416 (*it)->setFather(this);
1419 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1423 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)
1425 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1426 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1427 med_geometry_type mgeoti;
1428 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1429 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1430 _field_pm_pt_pd.resize(nbProfiles);
1431 for(int i=0;i<nbProfiles;i++)
1433 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1437 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1440 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1442 (*it)->prepareLoading(fid,pflId+1,start,nasc);//tony
1446 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1449 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1451 (*it)->finishLoading(fid,pflId+1,nasc);//tony
1455 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1457 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1459 (*it)->copyOptionsFrom(*this);
1460 (*it)->writeLL(fid,nasc);
1464 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1469 medfGeoType=typmai3[(int)ikGeoType];
1472 medfGeoType=MED_NONE;
1475 medfGeoType=typmai3[(int)ikGeoType];
1476 return MED_NODE_ELEMENT;
1478 medfGeoType=typmai3[(int)ikGeoType];
1481 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1483 return MED_UNDEF_ENTITY_TYPE;
1486 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1488 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1491 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1493 return new MEDFileFieldPerMesh(fath,mesh);
1496 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1498 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1499 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1500 if((const MEDFileFieldPerMeshPerType *)*it)
1501 ret+=(*it)->getHeapMemorySize();
1505 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1507 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1508 ret->_father=father;
1510 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1512 if((const MEDFileFieldPerMeshPerType *)*it)
1513 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1518 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1520 std::string startLine(bkOffset,' ');
1521 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1522 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1524 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1526 const MEDFileFieldPerMeshPerType *cur=*it;
1528 cur->simpleRepr(bkOffset,oss,i);
1531 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1536 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1538 _mesh_name=mesh->getName();
1539 mesh->getTime(_mesh_iteration,_mesh_order);
1542 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)
1544 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 nbOfCells=code[3*i+1];
1550 int pos=addNewEntryIfNecessary(type);
1551 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1557 * This method is the most general one. No optimization is done here.
1558 * \param [in] multiTypePfl is the end user profile specified in high level API
1559 * \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].
1560 * \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.
1561 * \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.
1562 * \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.
1563 * \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.
1565 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)
1567 int nbOfTypes=code.size()/3;
1568 for(int i=0;i<nbOfTypes;i++)
1570 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1571 int pos=addNewEntryIfNecessary(type);
1572 DataArrayInt *pfl=0;
1574 pfl=idsPerType[code[3*i+2]];
1575 int nbOfTupes2=code2.size()/3;
1577 for(;found<nbOfTupes2;found++)
1578 if(code[3*i]==code2[3*found])
1580 if(found==nbOfTupes2)
1581 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1582 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1586 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1588 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1589 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1592 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1594 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1595 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1598 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1600 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1601 (*it)->prepareLoading(fid,start,nasc);
1604 void MEDFileFieldPerMesh::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1606 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1607 (*it)->finishLoading(fid,nasc);
1610 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1612 int nbOfTypes=_field_pm_pt.size();
1613 for(int i=0;i<nbOfTypes;i++)
1615 _field_pm_pt[i]->copyOptionsFrom(*this);
1616 _field_pm_pt[i]->writeLL(fid,nasc);
1620 void MEDFileFieldPerMesh::getDimension(int& dim) const
1622 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1623 (*it)->getDimension(dim);
1626 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1628 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1629 (*it)->fillTypesOfFieldAvailable(types);
1632 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)
1634 int sz=_field_pm_pt.size();
1635 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1636 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1637 for(int i=0;i<sz;i++)
1639 types[i]=_field_pm_pt[i]->getGeoType();
1640 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1645 double MEDFileFieldPerMesh::getTime() const
1648 return _father->getTime(tmp1,tmp2);
1651 int MEDFileFieldPerMesh::getIteration() const
1653 return _father->getIteration();
1656 int MEDFileFieldPerMesh::getOrder() const
1658 return _father->getOrder();
1661 int MEDFileFieldPerMesh::getNumberOfComponents() const
1663 return _father->getNumberOfComponents();
1666 DataArray *MEDFileFieldPerMesh::getArray()
1669 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1670 return _father->getOrCreateAndGetArray();
1673 const DataArray *MEDFileFieldPerMesh::getArray() const
1676 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1677 return _father->getOrCreateAndGetArray();
1680 DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble()
1682 MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<MEDFileField1TSWithoutSDA *>(_father);
1684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
1685 return fatherC->getOrCreateAndGetArrayDouble();
1688 const DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble() const
1690 const MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(_father);
1692 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
1693 return fatherC->getOrCreateAndGetArrayDouble();
1696 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1698 return _father->getInfo();
1702 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1703 * 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.
1704 * It returns 2 output vectors :
1705 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1706 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1707 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1709 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)
1711 int notNullPflsSz=0;
1712 int nbOfArrs=geoTypes.size();
1713 for(int i=0;i<nbOfArrs;i++)
1716 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1717 int nbOfDiffGeoTypes=geoTypes3.size();
1718 code.resize(3*nbOfDiffGeoTypes);
1719 notNullPfls.resize(notNullPflsSz);
1722 for(int i=0;i<nbOfDiffGeoTypes;i++)
1725 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1726 std::vector<const DataArrayInt *> notNullTmp;
1728 notNullTmp.push_back(pfls[j]);
1730 for(;j<nbOfArrs;j++)
1731 if(geoTypes[j]==refType)
1734 notNullTmp.push_back(pfls[j]);
1738 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1739 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1740 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1741 code[3*i]=(int)refType;
1742 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1743 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1744 if(notNullTmp.empty())
1748 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1749 code[3*i+2]=notNullPflsSz++;
1755 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1757 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)
1761 for(int i=0;i<sz;i++)
1765 if(type!=ON_GAUSS_NE)
1766 ret+=dads[i].second-dads[i].first;
1769 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1770 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1775 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1776 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1782 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1784 std::vector<std::string> ret;
1785 std::set<std::string> ret2;
1786 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1788 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1789 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1790 if(ret2.find(*it2)==ret2.end())
1792 ret.push_back(*it2);
1799 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1801 std::vector<std::string> ret;
1802 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1805 ret.insert(ret.end(),tmp.begin(),tmp.end());
1810 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1812 std::vector<std::string> ret;
1813 std::set<std::string> ret2;
1814 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1816 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1817 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1818 if(ret2.find(*it2)==ret2.end())
1820 ret.push_back(*it2);
1827 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1829 std::vector<std::string> ret;
1830 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1832 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1833 ret.insert(ret.end(),tmp.begin(),tmp.end());
1838 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1840 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1842 if((*it).first==_mesh_name)
1844 _mesh_name=(*it).second;
1851 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1852 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1854 if(_mesh_name!=meshName)
1856 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1857 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1858 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1859 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1860 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1861 getUndergroundDataArrayExt(entries);
1862 DataArrayDouble *arr=getArrayDouble();
1865 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1866 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1868 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1870 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1871 sz+=(*it).second.second-(*it).second.first;
1874 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1876 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1877 ////////////////////
1878 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1879 int *workI2=explicitIdsOldInMesh->getPointer();
1880 int sz1=0,sz2=0,sid=1;
1881 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1882 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1883 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1885 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1886 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1887 int *workI=explicitIdsOldInArr->getPointer();
1888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1890 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1891 (*itL2)->setLocId(sz2);
1892 (*itL2)->_tmp_work1=(*itL2)->getStart();
1893 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1895 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1897 explicitIdsOldInMesh->reAlloc(sz2);
1898 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1899 ////////////////////
1900 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1901 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1902 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1903 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1905 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1906 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1907 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1909 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1910 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1911 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1913 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1914 int newStart=elt->getLocId();
1915 elt->setLocId((*it)->getGeoType());
1916 elt->setNewStart(newStart);
1917 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1918 entriesKeptNew.push_back(elt);
1919 entriesKeptNew2.push_back(elt);
1921 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1922 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1923 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1924 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1926 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1929 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1931 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1932 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1934 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1935 glob,arr2,otherEntriesNew) || ret;
1939 // Assign new dispatching
1940 assignNewLeaves(otherEntriesNew);
1941 arr->cpyFrom(*arr2);
1945 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1947 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1948 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1949 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1951 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1952 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1953 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1954 for(;it1!=types.end();it1++,it2++)
1956 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1957 elt->setLeaves((*it1).second);
1960 _field_pm_pt=fieldPmPt;
1963 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1965 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1966 (*it)->changePflsRefsNamesGen(mapOfModif);
1969 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1971 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1972 (*it)->changeLocsRefsNamesGen(mapOfModif);
1976 * \param [in] mesh is the whole mesh
1978 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1980 if(_field_pm_pt.empty())
1981 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1983 std::vector< std::pair<int,int> > dads;
1984 std::vector<const DataArrayInt *> pfls;
1985 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1986 std::vector<int> locs,code;
1987 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1988 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1989 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1991 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1994 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1995 throw INTERP_KERNEL::Exception(oss.str().c_str());
1998 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1999 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2002 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2004 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2007 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2008 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2014 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2018 if(nb!=mesh->getNumberOfNodes())
2020 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2021 oss << " nodes in mesh !";
2022 throw INTERP_KERNEL::Exception(oss.str().c_str());
2024 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2027 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2031 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2033 if(_field_pm_pt.empty())
2034 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2036 std::vector<std::pair<int,int> > dads;
2037 std::vector<const DataArrayInt *> pfls;
2038 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2039 std::vector<int> locs,code;
2040 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2041 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2042 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2044 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2047 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2048 throw INTERP_KERNEL::Exception(oss.str().c_str());
2050 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2051 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2054 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2055 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2060 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2064 if(nb!=mesh->getNumberOfNodes())
2066 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2067 oss << " nodes in mesh !";
2068 throw INTERP_KERNEL::Exception(oss.str().c_str());
2071 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2077 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2081 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2083 (*it)->getSizes(globalSz,nbOfEntries);
2085 entries.resize(nbOfEntries);
2087 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2089 (*it)->fillValues(nbOfEntries,entries);
2093 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2095 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2097 if((*it)->getGeoType()==typ)
2098 return (*it)->getLeafGivenLocId(locId);
2100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2101 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2102 oss << "Possiblities are : ";
2103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2106 oss << "\"" << cm2.getRepr() << "\", ";
2108 throw INTERP_KERNEL::Exception(oss.str().c_str());
2111 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2113 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2115 if((*it)->getGeoType()==typ)
2116 return (*it)->getLeafGivenLocId(locId);
2118 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2119 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2120 oss << "Possiblities are : ";
2121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2124 oss << "\"" << cm2.getRepr() << "\", ";
2126 throw INTERP_KERNEL::Exception(oss.str().c_str());
2129 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2132 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2133 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2134 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2136 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2141 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2146 int ret=std::distance(_field_pm_pt.begin(),it2);
2147 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2152 * 'dads' and 'locs' input parameters have the same number of elements
2153 * \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
2155 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2156 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2157 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2160 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2161 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2162 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2163 const std::vector<std::string>& infos=getInfo();
2164 da->setInfoOnComponents(infos);
2166 if(type==ON_GAUSS_PT)
2169 int nbOfArrs=dads.size();
2170 for(int i=0;i<nbOfArrs;i++)
2172 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2173 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2174 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2175 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2176 di->alloc(nbOfElems,1);
2178 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2179 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2188 * 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.
2189 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2190 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2191 * The order of cells in the returned field is those imposed by the profile.
2192 * \param [in] mesh is the global mesh.
2194 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2195 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2196 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2197 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2199 if(da->isIdentity())
2201 int nbOfTuples=da->getNumberOfTuples();
2202 if(nbOfTuples==mesh->getNumberOfCells())
2203 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2205 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2206 m2->setName(mesh->getName());
2207 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2213 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2215 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2216 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2217 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2219 if(da->isIdentity())
2221 int nbOfTuples=da->getNumberOfTuples();
2222 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2223 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2225 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2226 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2229 if(meshu->getNodalConnectivity()==0)
2231 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2232 int nb=da->getNbOfElems();
2233 const int *ptr=da->getConstPointer();
2234 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2235 meshuc->allocateCells(nb);
2236 for(int i=0;i<nb;i++)
2237 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2238 meshuc->finishInsertingCells();
2239 ret->setMesh(meshuc);
2240 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2241 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2242 disc->checkCoherencyBetween(meshuc,arrOut);
2247 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2249 DataArrayInt *arr2=0;
2250 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2251 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2252 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2253 int nnodes=mesh2->getNumberOfNodes();
2254 if(nnodes==(int)da->getNbOfElems())
2256 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2257 arrOut->renumberInPlace(da3->getConstPointer());
2258 mesh2->setName(mesh->getName());
2259 ret->setMesh(mesh2);
2264 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 !!!";
2265 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2266 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2267 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2268 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2269 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2270 throw INTERP_KERNEL::Exception(oss.str().c_str());
2276 * This method is the most light method of field retrieving.
2278 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2282 pflOut=DataArrayInt::New();
2283 pflOut->alloc(nbOfElems,1);
2288 pflOut=const_cast<DataArrayInt*>(pflIn);
2291 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2292 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2293 const std::vector<std::string>& infos=getInfo();
2294 int nbOfComp=infos.size();
2295 for(int i=0;i<nbOfComp;i++)
2296 da->setInfoOnComponent(i,infos[i].c_str());
2301 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),
2302 _mesh_csit(meshCsit),_father(fath)
2304 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2305 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2306 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2307 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2309 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2312 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2313 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2315 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2318 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2319 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2322 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2325 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2326 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2330 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2332 copyTinyInfoFrom(mesh);
2335 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2337 if(id>=(int)_pfls.size())
2339 _pfls[id]=DataArrayInt::New();
2340 int lgth=MEDprofileSizeByName(fid,pflName);
2341 _pfls[id]->setName(pflName);
2342 _pfls[id]->alloc(lgth,1);
2343 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2344 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2347 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2349 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2351 MEDprofileInfo(fid,i+1,pflName,&sz);
2352 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2353 if(i>=(int)_pfls.size())
2355 _pfls[i]=DataArrayInt::New();
2356 _pfls[i]->alloc(sz,1);
2357 _pfls[i]->setName(pflCpp.c_str());
2358 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2359 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2362 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2364 int nbOfPfls=_pfls.size();
2365 for(int i=0;i<nbOfPfls;i++)
2367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2368 cpy->applyLin(1,1,0);
2369 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2370 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2371 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2374 int nbOfLocs=_locs.size();
2375 for(int i=0;i<nbOfLocs;i++)
2376 _locs[i]->writeLL(fid);
2379 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2381 std::vector<std::string> pfls=getPfls();
2382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2384 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2387 _pfls.push_back(*it);
2391 int id=std::distance(pfls.begin(),it2);
2392 if(!(*it)->isEqual(*_pfls[id]))
2394 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2395 throw INTERP_KERNEL::Exception(oss.str().c_str());
2399 std::vector<std::string> locs=getLocs();
2400 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2402 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2405 _locs.push_back(*it);
2409 int id=std::distance(locs.begin(),it2);
2410 if(!(*it)->isEqual(*_locs[id],eps))
2412 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2413 throw INTERP_KERNEL::Exception(oss.str().c_str());
2419 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2421 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2422 getProfile((*it).c_str());
2425 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2427 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2428 getLocalization((*it).c_str());
2431 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2433 std::vector<std::string> profiles=real.getPflsReallyUsed();
2434 int sz=profiles.size();
2436 for(int i=0;i<sz;i++)
2437 loadProfileInFile(fid,i,profiles[i].c_str());
2439 std::vector<std::string> locs=real.getLocsReallyUsed();
2442 for(int i=0;i<sz;i++)
2443 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2446 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2448 int nProfil=MEDnProfile(fid);
2449 for(int i=0;i<nProfil;i++)
2450 loadProfileInFile(fid,i);
2451 int sz=MEDnLocalization(fid);
2453 for(int i=0;i<sz;i++)
2455 _locs[i]=MEDFileFieldLoc::New(fid,i);
2459 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2461 return new MEDFileFieldGlobs(fname);
2464 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2466 return new MEDFileFieldGlobs;
2469 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2471 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2472 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2473 ret+=(*it)->getHeapMemorySize();
2474 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2475 ret+=(*it)->getHeapMemorySize();
2479 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2481 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2483 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2485 if((const DataArrayInt *)*it)
2486 ret->_pfls[i]=(*it)->deepCpy();
2489 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2491 if((const MEDFileFieldLoc*)*it)
2492 ret->_locs[i]=(*it)->deepCpy();
2498 * \throw if a profile in \a pfls in not in \a this.
2499 * \throw if a localization in \a locs in not in \a this.
2500 * \sa MEDFileFieldGlobs::deepCpyPart
2502 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2504 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2505 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2507 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2509 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2511 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2512 ret->_pfls.push_back(pfl2);
2514 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2516 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2518 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2520 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2521 ret->_locs.push_back(loc2);
2523 ret->setFileName(getFileName());
2528 * \throw if a profile in \a pfls in not in \a this.
2529 * \throw if a localization in \a locs in not in \a this.
2530 * \sa MEDFileFieldGlobs::shallowCpyPart
2532 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2534 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2535 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2537 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2539 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2540 ret->_pfls.push_back(pfl->deepCpy());
2542 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2544 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2546 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2547 ret->_locs.push_back(loc->deepCpy());
2549 ret->setFileName(getFileName());
2553 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2557 MEDFileFieldGlobs::MEDFileFieldGlobs()
2561 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2565 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2567 oss << "Profiles :\n";
2568 std::size_t n=_pfls.size();
2569 for(std::size_t i=0;i<n;i++)
2571 oss << " - #" << i << " ";
2572 const DataArrayInt *pfl=_pfls[i];
2574 oss << "\"" << pfl->getName() << "\"\n";
2579 oss << "Localizations :\n";
2580 for(std::size_t i=0;i<n;i++)
2582 oss << " - #" << i << " ";
2583 const MEDFileFieldLoc *loc=_locs[i];
2585 loc->simpleRepr(oss);
2591 void MEDFileFieldGlobs::setFileName(const char *fileName)
2593 _file_name=fileName;
2596 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2598 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2600 DataArrayInt *elt(*it);
2603 std::string name(elt->getName());
2604 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2606 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2608 elt->setName((*it2).second.c_str());
2616 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2618 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2620 MEDFileFieldLoc *elt(*it);
2623 std::string name(elt->getName());
2624 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2626 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2628 elt->setName((*it2).second.c_str());
2636 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2638 if(locId<0 || locId>=(int)_locs.size())
2639 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2640 return _locs[locId]->getNbOfGaussPtPerCell();
2643 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2645 return getLocalizationFromId(getLocalizationId(locName));
2648 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2650 if(locId<0 || locId>=(int)_locs.size())
2651 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2652 return *_locs[locId];
2655 namespace ParaMEDMEMImpl
2660 LocFinder(const char *loc):_loc(loc) { }
2661 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2669 PflFinder(const std::string& pfl):_pfl(pfl) { }
2670 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2672 const std::string& _pfl;
2676 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2678 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2681 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2682 for(it=_locs.begin();it!=_locs.end();it++)
2683 oss << "\"" << (*it)->getName() << "\", ";
2684 throw INTERP_KERNEL::Exception(oss.str().c_str());
2686 return std::distance(_locs.begin(),it);
2690 * The returned value is never null.
2692 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2694 std::string pflNameCpp(pflName);
2695 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2698 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2699 for(it=_pfls.begin();it!=_pfls.end();it++)
2700 oss << "\"" << (*it)->getName() << "\", ";
2701 throw INTERP_KERNEL::Exception(oss.str().c_str());
2706 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2708 if(pflId<0 || pflId>=(int)_pfls.size())
2709 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2710 return _pfls[pflId];
2713 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2715 if(locId<0 || locId>=(int)_locs.size())
2716 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2717 return *_locs[locId];
2720 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2722 return getLocalizationFromId(getLocalizationId(locName));
2726 * The returned value is never null.
2728 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2730 std::string pflNameCpp(pflName);
2731 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2734 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2735 for(it=_pfls.begin();it!=_pfls.end();it++)
2736 oss << "\"" << (*it)->getName() << "\", ";
2737 throw INTERP_KERNEL::Exception(oss.str().c_str());
2742 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2744 if(pflId<0 || pflId>=(int)_pfls.size())
2745 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2746 return _pfls[pflId];
2749 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2751 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2753 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2755 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2756 newPfls.push_back(*it);
2761 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2763 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2765 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2767 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2768 newLocs.push_back(*it);
2773 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2775 int sz=_pfls.size();
2776 std::vector<std::string> ret(sz);
2777 for(int i=0;i<sz;i++)
2778 ret[i]=_pfls[i]->getName();
2782 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2784 int sz=_locs.size();
2785 std::vector<std::string> ret(sz);
2786 for(int i=0;i<sz;i++)
2787 ret[i]=_locs[i]->getName();
2791 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2793 std::vector<std::string> v=getPfls();
2794 std::string s(pflName);
2795 return std::find(v.begin(),v.end(),s)!=v.end();
2798 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2800 std::vector<std::string> v=getLocs();
2801 std::string s(locName);
2802 return std::find(v.begin(),v.end(),s)!=v.end();
2805 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2807 std::map<int,std::vector<int> > m;
2809 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2811 const DataArrayInt *tmp=(*it);
2814 m[tmp->getHashCode()].push_back(i);
2817 std::vector< std::vector<int> > ret;
2818 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2820 if((*it2).second.size()>1)
2822 std::vector<int> ret0;
2823 bool equalityOrNot=false;
2824 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2826 std::vector<int>::const_iterator it4=it3; it4++;
2827 for(;it4!=(*it2).second.end();it4++)
2829 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2832 ret0.push_back(*it3);
2833 ret0.push_back(*it4);
2839 ret.push_back(ret0);
2845 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2847 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2850 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2852 std::string name(pfl->getName());
2854 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2855 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2856 if(name==(*it)->getName())
2858 if(!pfl->isEqual(*(*it)))
2860 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2861 throw INTERP_KERNEL::Exception(oss.str().c_str());
2865 _pfls.push_back(pfl);
2868 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)
2870 std::string name(locName);
2872 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2873 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2874 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2875 if((*it)->isName(locName))
2877 if(!(*it)->isEqual(*obj,1e-12))
2879 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2880 throw INTERP_KERNEL::Exception(oss.str().c_str());
2883 _locs.push_back(obj);
2886 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2888 std::vector<std::string> names=getPfls();
2889 return CreateNewNameNotIn("NewPfl_",names);
2892 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2894 std::vector<std::string> names=getLocs();
2895 return CreateNewNameNotIn("NewLoc_",names);
2898 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2900 for(std::size_t sz=0;sz<100000;sz++)
2902 std::ostringstream tryName;
2903 tryName << prefix << sz;
2904 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2905 return tryName.str();
2907 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2911 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2912 * \param [in] fname - the file name.
2914 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2919 * Creates an empty MEDFileFieldGlobsReal.
2921 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2925 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2928 if((const MEDFileFieldGlobs *)_globals)
2929 ret+=_globals->getHeapMemorySize();
2934 * Returns a string describing profiles and Gauss points held in \a this.
2935 * \return std::string - the description string.
2937 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2939 const MEDFileFieldGlobs *glob=_globals;
2940 std::ostringstream oss2; oss2 << glob;
2941 std::string stars(oss2.str().length(),'*');
2942 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2944 glob->simpleRepr(oss);
2946 oss << "NO GLOBAL INFORMATION !\n";
2949 void MEDFileFieldGlobsReal::resetContent()
2951 _globals=MEDFileFieldGlobs::New();
2954 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2959 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2960 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2962 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2964 _globals=other._globals;
2968 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2969 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2971 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2973 const MEDFileFieldGlobs *otherg(other._globals);
2976 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2980 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2981 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2983 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2985 const MEDFileFieldGlobs *otherg(other._globals);
2988 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2991 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2993 _globals=other._globals;
2994 if((const MEDFileFieldGlobs *)_globals)
2995 _globals=other._globals->deepCpy();
2999 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3000 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3001 * \param [in] eps - a precision used to compare Gauss points with same name held by
3002 * \a this and \a other MEDFileFieldGlobsReal.
3003 * \throw If \a this and \a other hold profiles with equal names but different ids.
3004 * \throw If \a this and \a other hold different Gauss points with equal names.
3006 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3008 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3009 if(thisGlobals==otherGlobals)
3013 _globals=other._globals;
3016 _globals->appendGlobs(*other._globals,eps);
3019 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3021 checkGlobsPflsPartCoherency();
3022 checkGlobsLocsPartCoherency();
3025 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3027 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3030 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3032 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3035 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3037 contentNotNull()->loadProfileInFile(fid,id,pflName);
3040 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3042 contentNotNull()->loadProfileInFile(fid,id);
3045 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3047 contentNotNull()->loadGlobals(fid,*this);
3050 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3052 contentNotNull()->loadAllGlobals(fid);
3055 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3057 contentNotNull()->writeGlobals(fid,opt);
3061 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3062 * or getPflsReallyUsedMulti().
3063 * \return std::vector<std::string> - a sequence of names of all profiles.
3065 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3067 return contentNotNull()->getPfls();
3071 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3072 * or getLocsReallyUsedMulti().
3073 * \return std::vector<std::string> - a sequence of names of all localizations.
3075 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3077 return contentNotNull()->getLocs();
3081 * Checks if the profile with a given name exists.
3082 * \param [in] pflName - the profile name of interest.
3083 * \return bool - \c true if the profile named \a pflName exists.
3085 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3087 return contentNotNull()->existsPfl(pflName);
3091 * Checks if the localization with a given name exists.
3092 * \param [in] locName - the localization name of interest.
3093 * \return bool - \c true if the localization named \a locName exists.
3095 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3097 return contentNotNull()->existsLoc(locName);
3100 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3102 return contentNotNull()->createNewNameOfPfl();
3105 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3107 return contentNotNull()->createNewNameOfLoc();
3111 * Sets the name of a MED file.
3112 * \param [inout] fileName - the file name.
3114 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3116 contentNotNull()->setFileName(fileName);
3120 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3121 * in the same order.
3122 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3123 * Each item of this sequence is a vector containing ids of equal profiles.
3125 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3127 return contentNotNull()->whichAreEqualProfiles();
3131 * Finds equal localizations.
3132 * \param [in] eps - a precision used to compare real values of the localizations.
3133 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3134 * Each item of this sequence is a vector containing ids of equal localizations.
3136 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3138 return contentNotNull()->whichAreEqualLocs(eps);
3142 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3143 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3144 * this sequence is a pair whose
3145 * - the first item is a vector of profile names to replace by the second item,
3146 * - the second item is a profile name to replace every profile name of the first item.
3148 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3150 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3154 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3155 * \param [in] mapOfModif - a sequence describing required renaming. 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 name of the first item.
3160 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3162 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3166 * Replaces references to some profiles (a reference is a profile name) by references
3167 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3168 * them-selves accordingly. <br>
3169 * This method is a generalization of changePflName().
3170 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3171 * this sequence is a pair whose
3172 * - the first item is a vector of profile names to replace by the second item,
3173 * - the second item is a profile name to replace every profile of the first item.
3174 * \sa changePflsRefsNamesGen()
3175 * \sa changePflName()
3177 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3179 changePflsRefsNamesGen(mapOfModif);
3180 changePflsNamesInStruct(mapOfModif);
3184 * Replaces references to some localizations (a reference is a localization name) by references
3185 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3186 * them-selves accordingly. <br>
3187 * This method is a generalization of changeLocName().
3188 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3189 * this sequence is a pair whose
3190 * - the first item is a vector of localization names to replace by the second item,
3191 * - the second item is a localization name to replace every localization of the first item.
3192 * \sa changeLocsRefsNamesGen()
3193 * \sa changeLocName()
3195 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3197 changeLocsRefsNamesGen(mapOfModif);
3198 changeLocsNamesInStruct(mapOfModif);
3202 * Renames the profile having a given name and updates references to this profile.
3203 * \param [in] oldName - the name of the profile to rename.
3204 * \param [in] newName - a new name of the profile.
3205 * \sa changePflsNames().
3207 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3209 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3210 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3212 changePflsNames(mapOfModif);
3216 * Renames the localization having a given name and updates references to this localization.
3217 * \param [in] oldName - the name of the localization to rename.
3218 * \param [in] newName - a new name of the localization.
3219 * \sa changeLocsNames().
3221 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3223 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3224 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3226 changeLocsNames(mapOfModif);
3230 * Removes duplicated profiles. Returns a map used to update references to removed
3231 * profiles via changePflsRefsNamesGen().
3232 * Equal profiles are found using whichAreEqualProfiles().
3233 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3234 * a sequence describing the performed replacements of profiles. Each element of
3235 * this sequence is a pair whose
3236 * - the first item is a vector of profile names replaced by the second item,
3237 * - the second item is a profile name replacing every profile of the first item.
3239 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3241 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3242 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3244 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3246 std::vector< std::string > tmp((*it).size());
3248 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3249 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3250 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3252 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3253 killProfileIds(tmp2);
3255 changePflsRefsNamesGen(ret);
3260 * Removes duplicated localizations. Returns a map used to update references to removed
3261 * localizations via changeLocsRefsNamesGen().
3262 * Equal localizations are found using whichAreEqualLocs().
3263 * \param [in] eps - a precision used to compare real values of the localizations.
3264 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3265 * a sequence describing the performed replacements of localizations. Each element of
3266 * this sequence is a pair whose
3267 * - the first item is a vector of localization names replaced by the second item,
3268 * - the second item is a localization name replacing every localization of the first item.
3270 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3272 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3273 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3275 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3277 std::vector< std::string > tmp((*it).size());
3279 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3280 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3281 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3283 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3284 killLocalizationIds(tmp2);
3286 changeLocsRefsNamesGen(ret);
3291 * Returns number of Gauss points per cell in a given localization.
3292 * \param [in] locId - an id of the localization of interest.
3293 * \return int - the number of the Gauss points per cell.
3295 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3297 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3301 * Returns an id of a localization by its name.
3302 * \param [in] loc - the localization name of interest.
3303 * \return int - the id of the localization.
3304 * \throw If there is no a localization named \a loc.
3306 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3308 return contentNotNull()->getLocalizationId(loc);
3312 * Returns the name of the MED file.
3313 * \return const char * - the MED file name.
3315 const char *MEDFileFieldGlobsReal::getFileName() const
3317 return contentNotNull()->getFileName();
3320 std::string MEDFileFieldGlobsReal::getFileName2() const
3322 return contentNotNull()->getFileName2();
3326 * Returns a localization object by its name.
3327 * \param [in] locName - the name of the localization of interest.
3328 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3329 * \throw If there is no a localization named \a locName.
3331 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3333 return contentNotNull()->getLocalization(locName);
3337 * Returns a localization object by its id.
3338 * \param [in] locId - the id of the localization of interest.
3339 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3340 * \throw If there is no a localization with id \a locId.
3342 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3344 return contentNotNull()->getLocalizationFromId(locId);
3348 * Returns a profile array by its name.
3349 * \param [in] pflName - the name of the profile of interest.
3350 * \return const DataArrayInt * - the profile array having the name \a pflName.
3351 * \throw If there is no a profile named \a pflName.
3353 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3355 return contentNotNull()->getProfile(pflName);
3359 * Returns a profile array by its id.
3360 * \param [in] pflId - the id of the profile of interest.
3361 * \return const DataArrayInt * - the profile array having the id \a pflId.
3362 * \throw If there is no a profile with id \a pflId.
3364 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3366 return contentNotNull()->getProfileFromId(pflId);
3370 * Returns a localization object, apt for modification, by its id.
3371 * \param [in] locId - the id of the localization of interest.
3372 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3373 * having the id \a locId.
3374 * \throw If there is no a localization with id \a locId.
3376 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3378 return contentNotNull()->getLocalizationFromId(locId);
3382 * Returns a localization object, apt for modification, by its name.
3383 * \param [in] locName - the name of the localization of interest.
3384 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3385 * having the name \a locName.
3386 * \throw If there is no a localization named \a locName.
3388 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3390 return contentNotNull()->getLocalization(locName);
3394 * Returns a profile array, apt for modification, by its name.
3395 * \param [in] pflName - the name of the profile of interest.
3396 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3397 * \throw If there is no a profile named \a pflName.
3399 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3401 return contentNotNull()->getProfile(pflName);
3405 * Returns a profile array, apt for modification, by its id.
3406 * \param [in] pflId - the id of the profile of interest.
3407 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3408 * \throw If there is no a profile with id \a pflId.
3410 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3412 return contentNotNull()->getProfileFromId(pflId);
3416 * Removes profiles given by their ids. No data is updated to track this removal.
3417 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3419 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3421 contentNotNull()->killProfileIds(pflIds);
3425 * Removes localizations given by their ids. No data is updated to track this removal.
3426 * \param [in] locIds - a sequence of ids of the localizations to remove.
3428 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3430 contentNotNull()->killLocalizationIds(locIds);
3434 * Stores a profile array.
3435 * \param [in] pfl - the profile array to store.
3436 * \throw If the name of \a pfl is empty.
3437 * \throw If a profile with the same name as that of \a pfl already exists but contains
3440 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3442 contentNotNull()->appendProfile(pfl);
3446 * Adds a new localization of Gauss points.
3447 * \param [in] locName - the name of the new localization.
3448 * \param [in] geoType - a geometrical type of the reference cell.
3449 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3450 * must be \c nbOfNodesPerCell * \c dimOfType.
3451 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3452 * must be _wg_.size() * \c dimOfType.
3453 * \param [in] w - the weights of Gauss points.
3454 * \throw If \a locName is empty.
3455 * \throw If a localization with the name \a locName already exists but is
3456 * different form the new one.
3458 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)
3460 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3463 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3465 MEDFileFieldGlobs *g(_globals);
3467 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3471 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3473 const MEDFileFieldGlobs *g(_globals);
3475 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3479 //= MEDFileFieldNameScope
3481 MEDFileFieldNameScope::MEDFileFieldNameScope()
3485 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3490 * Returns the name of \a this field.
3491 * \return std::string - a string containing the field name.
3493 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3499 * Sets name of \a this field
3500 * \param [in] name - the new field name.
3502 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3507 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3512 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3517 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3520 _dt_unit=other._dt_unit;
3523 //= MEDFileAnyTypeField1TSWithoutSDA
3525 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3527 _field_per_mesh.resize(other._field_per_mesh.size());
3529 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3531 if((const MEDFileFieldPerMesh *)*it)
3532 _field_per_mesh[i]=(*it)->deepCpy(this);
3537 * Prints a string describing \a this field into a stream. This string is outputted
3538 * by \c print Python command.
3539 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3540 * \param [in,out] oss - the out stream.
3541 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3542 * info id printed, else, not.
3544 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3546 std::string startOfLine(bkOffset,' ');
3547 oss << startOfLine << "Field ";
3549 oss << "[Type=" << getTypeStr() << "] ";
3550 oss << "on One time Step ";
3552 oss << "(" << f1tsId << ") ";
3553 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3554 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3555 const DataArray *arr=getUndergroundDataArray();
3558 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3561 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3562 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3563 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3564 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3566 if(arr->isAllocated())
3568 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3571 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3575 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3577 oss << startOfLine << "----------------------" << std::endl;
3578 if(!_field_per_mesh.empty())
3581 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3583 const MEDFileFieldPerMesh *cur=(*it2);
3585 cur->simpleRepr(bkOffset,oss,i);
3587 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3592 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3594 oss << startOfLine << "----------------------" << std::endl;
3597 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3599 const DataArray *arr(getUndergroundDataArray());
3601 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3602 int nbOfCompo=arr->getNumberOfComponents();
3603 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3604 for(int i=0;i<nbOfCompo;i++)
3607 std::vector<int> v(1,i);
3608 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3609 ret[i]->setArray(arr2);
3614 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit)
3618 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1)
3623 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3624 * empty. Returns -1 if this in on nodes.
3625 * \return int - the dimension of \a this.
3627 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3630 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3631 (*it)->getDimension(ret);
3636 * Returns the mesh name.
3637 * \return std::string - a string holding the mesh name.
3638 * \throw If \c _field_per_mesh.empty()
3640 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3642 if(_field_per_mesh.empty())
3643 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3644 return _field_per_mesh[0]->getMeshName();
3647 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3649 std::string oldName(getMeshName());
3650 std::vector< std::pair<std::string,std::string> > v(1);
3651 v[0].first=oldName; v[0].second=newMeshName;
3655 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3658 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3660 MEDFileFieldPerMesh *cur(*it);
3662 ret=cur->changeMeshNames(modifTab) || ret;
3668 * Returns the number of iteration of the state of underlying mesh.
3669 * \return int - the iteration number.
3670 * \throw If \c _field_per_mesh.empty()
3672 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3674 if(_field_per_mesh.empty())
3675 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3676 return _field_per_mesh[0]->getMeshIteration();
3680 * Returns the order number of iteration of the state of underlying mesh.
3681 * \return int - the order number.
3682 * \throw If \c _field_per_mesh.empty()
3684 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3686 if(_field_per_mesh.empty())
3687 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3688 return _field_per_mesh[0]->getMeshOrder();
3692 * Checks if \a this field is tagged by a given iteration number and a given
3693 * iteration order number.
3694 * \param [in] iteration - the iteration number of interest.
3695 * \param [in] order - the iteration order number of interest.
3696 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3697 * \a this->getOrder() == \a order.
3699 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3701 return iteration==_iteration && order==_order;
3705 * Returns number of iteration and order number of iteration when
3706 * \a this field has been calculated.
3707 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3710 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3712 std::pair<int,int> p;
3718 * Returns number of iteration and order number of iteration when
3719 * \a this field has been calculated.
3720 * \param [in,out] p - a pair returning the iteration number and the iteration
3723 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3730 * Returns all types of spatial discretization of \a this field.
3731 * \param [in,out] types - a sequence of types of \a this field.
3733 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3735 std::set<TypeOfField> types2;
3736 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3738 (*it)->fillTypesOfFieldAvailable(types2);
3740 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3741 std::copy(types2.begin(),types2.end(),bi);
3745 * Returns all types of spatial discretization of \a this field.
3746 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3749 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3751 std::vector<TypeOfField> ret;
3752 fillTypesOfFieldAvailable(ret);
3756 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3758 std::vector<std::string> ret;
3759 std::set<std::string> ret2;
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)->getPflsReallyUsed();
3763 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3764 if(ret2.find(*it2)==ret2.end())
3766 ret.push_back(*it2);
3773 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3775 std::vector<std::string> ret;
3776 std::set<std::string> ret2;
3777 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3779 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3780 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3781 if(ret2.find(*it2)==ret2.end())
3783 ret.push_back(*it2);
3790 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3792 std::vector<std::string> ret;
3793 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3795 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3796 ret.insert(ret.end(),tmp.begin(),tmp.end());
3801 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3803 std::vector<std::string> ret;
3804 std::set<std::string> ret2;
3805 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3807 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3808 ret.insert(ret.end(),tmp.begin(),tmp.end());
3813 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3815 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3816 (*it)->changePflsRefsNamesGen(mapOfModif);
3819 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3821 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3822 (*it)->changeLocsRefsNamesGen(mapOfModif);
3826 * Returns all attributes of parts of \a this field lying on a given mesh.
3827 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3828 * item of every of returned sequences refers to the _i_-th part of \a this field.
3829 * Thus all sequences returned by this method are of the same length equal to number
3830 * of different types of supporting entities.<br>
3831 * A field part can include sub-parts with several different spatial discretizations,
3832 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3833 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3834 * of a nested sequence corresponds to a type of spatial discretization.<br>
3835 * This method allows for iteration over MEDFile DataStructure without any overhead.
3836 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3837 * for the case with only one underlying mesh. (Actually, the number of meshes is
3838 * not checked if \a mname == \c NULL).
3839 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3840 * a field part is returned.
3841 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3842 * This sequence is of the same length as \a types.
3843 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3844 * discretization. A profile name can be empty.
3845 * Length of this and of nested sequences is the same as that of \a typesF.
3846 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3847 * discretization. A localization name can be empty.
3848 * Length of this and of nested sequences is the same as that of \a typesF.
3849 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3850 * of ids of tuples within the data array, per each type of spatial
3851 * discretization within one mesh entity type.
3852 * Length of this and of nested sequences is the same as that of \a typesF.
3853 * \throw If no field is lying on \a mname.
3855 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)
3859 meshId=getMeshIdFromMeshName(mname);
3861 if(_field_per_mesh.empty())
3862 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3863 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3867 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3868 * maximal absolute dimension and values returned via the out parameter \a levs are
3869 * dimensions relative to the maximal absolute dimension. <br>
3870 * This method is designed for MEDFileField1TS instances that have a discretization
3871 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3872 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3873 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3874 * Only these 3 discretizations will be taken into account here. If \a this is
3875 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3876 * This method is useful to make the link between the dimension of the underlying mesh
3877 * and the levels of \a this, because it is possible that the highest dimension of \a this
3878 * field is not equal to the dimension of the underlying mesh.
3880 * Let's consider the following case:
3881 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3882 * TETRA4, HEXA8, TRI3 and SEG2.
3883 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3884 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3886 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3887 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3888 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3889 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3890 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3891 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3893 * to retrieve the highest level of
3894 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3895 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3896 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3897 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3898 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3899 * for the case with only one underlying mesh. (Actually, the number of meshes is
3900 * not checked if \a mname == \c NULL).
3901 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3902 * absolute one. They are in decreasing order. This sequence is cleared before
3904 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3905 * \throw If no field is lying on \a mname.
3907 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3910 int meshId=getMeshIdFromMeshName(mname);
3911 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3912 std::vector< std::vector<TypeOfField> > typesF;
3913 std::vector< std::vector<std::string> > pfls, locs;
3914 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3916 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3917 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3918 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3920 st.erase(INTERP_KERNEL::NORM_ERROR);
3922 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3924 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3925 ret1.insert((int)cm.getDimension());
3927 int ret=*std::max_element(ret1.begin(),ret1.end());
3928 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3929 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3934 * \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.
3935 * \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.
3936 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3937 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3939 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3941 int mid=getMeshIdFromMeshName(mName);
3942 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3946 * \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.
3947 * \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.
3948 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3949 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3951 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3953 int mid=getMeshIdFromMeshName(mName);
3954 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3958 * \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.
3960 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3962 if(_field_per_mesh.empty())
3963 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3966 std::string mName2(mName);
3968 std::vector<std::string> msg;
3969 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3970 if(mName2==(*it)->getMeshName())
3973 msg.push_back((*it)->getMeshName());
3974 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3975 oss << "Possible meshes are : ";
3976 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3977 oss << "\"" << (*it2) << "\" ";
3978 throw INTERP_KERNEL::Exception(oss.str().c_str());
3981 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3984 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3985 std::string tmp(mesh->getName());
3987 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3988 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3990 for(;it!=_field_per_mesh.end();it++,i++)
3992 if((*it)->getMeshName()==tmp)
3995 int sz=_field_per_mesh.size();
3996 _field_per_mesh.resize(sz+1);
3997 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4001 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4002 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4005 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4007 MEDFileFieldPerMesh *fpm(*it);
4009 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4014 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4016 if(_field_per_mesh.empty())
4017 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4018 if(_field_per_mesh.size()>1)
4019 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4020 _field_per_mesh[0]->copyOptionsFrom(opts);
4021 _field_per_mesh[0]->writeLL(fid,nasc);
4024 void MEDFileAnyTypeField1TSWithoutSDA::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4026 med_int numdt,numit;
4030 med_int meshnumdt,meshnumit;
4031 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4032 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4033 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4034 if(_iteration!=numdt || _order!=numit)
4035 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
4036 _field_per_mesh.resize(nmesh);
4037 for(int i=0;i<nmesh;i++)
4038 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4040 for(int i=0;i<nmesh;i++)
4042 _field_per_mesh[i]->prepareLoading(fid,start,nasc);
4044 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
4045 for(int i=0;i<nmesh;i++)
4047 _field_per_mesh[i]->finishLoading(fid,nasc);
4051 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4053 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4054 if(getUndergroundDataArray())
4055 ret+=getUndergroundDataArray()->getHeapMemorySize();
4056 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4057 ret+=(*it)->getHeapMemorySize();
4062 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4063 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4064 * "Sort By Type"), if not, an exception is thrown.
4065 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4066 * \param [in] arr - the array of values.
4067 * \param [in,out] glob - the global data where profiles and localization present in
4068 * \a field, if any, are added.
4069 * \throw If the name of \a field is empty.
4070 * \throw If the data array of \a field is not set.
4071 * \throw If \a this->_arr is already allocated but has different number of components
4073 * \throw If the underlying mesh of \a field has no name.
4074 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4076 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4078 const MEDCouplingMesh *mesh=field->getMesh();
4080 TypeOfField type=field->getTypeOfField();
4081 std::vector<DataArrayInt *> dummy;
4082 int start=copyTinyInfoFrom(field,arr);
4083 int pos=addNewEntryIfNecessary(mesh);
4086 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4087 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4090 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4094 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4095 * of a given mesh are used as the support of the given field (a real support is not used).
4096 * Elements of the given mesh must be sorted suitable for writing to MED file.
4097 * Order of underlying mesh entities of the given field specified by \a profile parameter
4098 * is not prescribed; this method permutes field values to have them sorted by element
4099 * type as required for writing to MED file. A new profile is added only if no equal
4100 * profile is missing.
4101 * \param [in] field - the field to add to \a this. The field double values are ignored.
4102 * \param [in] arrOfVals - the values of the field \a field used.
4103 * \param [in] mesh - the supporting mesh of \a field.
4104 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4105 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4106 * \param [in,out] glob - the global data where profiles and localization present in
4107 * \a field, if any, are added.
4108 * \throw If either \a field or \a mesh or \a profile has an empty name.
4109 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4110 * \throw If the data array of \a field is not set.
4111 * \throw If \a this->_arr is already allocated but has different number of components
4113 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4114 * \sa setFieldNoProfileSBT()
4116 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)
4118 TypeOfField type=field->getTypeOfField();
4119 int start=copyTinyInfoFrom(field,arrOfVals);
4120 std::vector<DataArrayInt *> idsInPflPerType;
4121 std::vector<DataArrayInt *> idsPerType;
4122 std::vector<int> code,code2;
4123 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4126 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4127 code2=m->getDistributionOfTypes();
4129 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4130 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4131 idsInPflPerType2[i]=idsInPflPerType[i];
4132 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4133 for(std::size_t i=0;i<idsPerType.size();i++)
4134 idsPerType2[i]=idsPerType[i];
4136 int pos=addNewEntryIfNecessary(m);
4137 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4141 int pos=addNewEntryIfNecessary(m);
4142 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4147 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4148 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4149 * larger by the size of \a field. Returns an id of the first not filled
4150 * tuple of \a this->_arr.
4151 * \param [in] field - the field to copy the info on components and the name from.
4152 * \return int - the id of first not initialized tuple of \a this->_arr.
4153 * \throw If the name of \a field is empty.
4154 * \throw If the data array of \a field is not set.
4155 * \throw If \a this->_arr is already allocated but has different number of components
4158 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4161 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4162 std::string name(field->getName());
4163 setName(name.c_str());
4164 setDtUnit(field->getTimeUnit());
4166 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4168 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4169 _dt=field->getTime(_iteration,_order);
4170 int nbOfComponents=arr->getNumberOfComponents();
4171 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4172 if(!getOrCreateAndGetArray()->isAllocated())
4174 getOrCreateAndGetArray()->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
4179 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4180 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4181 MEDCouplingAutoRefCountObjectPtr<DataArray> tmp=createNewEmptyDataArrayInstance();
4182 tmp->alloc(newNbOfTuples,nbOfComponents);
4183 tmp->copyStringInfoFrom(*getOrCreateAndGetArray());
4184 DataArray *arrr=getOrCreateAndGetArray();
4185 tmp->setContigPartOfSelectedValues2(0,arrr,0,oldNbOfTuples,1);
4187 return oldNbOfTuples;
4192 * Returns number of components in \a this field
4193 * \return int - the number of components.
4195 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4197 return getOrCreateAndGetArray()->getNumberOfComponents();
4201 * Change info on components in \a this.
4202 * \throw If size of \a infos is not equal to the number of components already in \a this.
4204 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4206 DataArray *arr=getOrCreateAndGetArray();
4207 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4211 * Returns info on components of \a this field.
4212 * \return const std::vector<std::string>& - a sequence of strings each being an
4213 * information on _i_-th component.
4215 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4217 const DataArray *arr=getOrCreateAndGetArray();
4218 return arr->getInfoOnComponents();
4222 * Returns a mutable info on components of \a this field.
4223 * \return std::vector<std::string>& - a sequence of strings each being an
4224 * information on _i_-th component.
4226 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4228 DataArray *arr=getOrCreateAndGetArray();
4229 return arr->getInfoOnComponents();
4233 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4234 * \param [in] type - a spatial discretization of the new field.
4235 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4236 * \param [in] mName - a name of the supporting mesh.
4237 * \param [in] renumPol - specifies how to permute values of the result field according to
4238 * the optional numbers of cells and nodes, if any. The valid values are
4239 * - 0 - do not permute.
4240 * - 1 - permute cells.
4241 * - 2 - permute nodes.
4242 * - 3 - permute cells and nodes.
4244 * \param [in] glob - the global data storing profiles and localization.
4245 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4246 * caller is to delete this field using decrRef() as it is no more needed.
4247 * \throw If the MED file is not readable.
4248 * \throw If there is no mesh named \a mName in the MED file.
4249 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4250 * \throw If no field of \a this is lying on the mesh \a mName.
4251 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4253 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)
4255 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4257 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4259 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4260 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4264 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4265 * \param [in] type - a spatial discretization of the new field.
4266 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4267 * \param [in] renumPol - specifies how to permute values of the result field according to
4268 * the optional numbers of cells and nodes, if any. The valid values are
4269 * - 0 - do not permute.
4270 * - 1 - permute cells.
4271 * - 2 - permute nodes.
4272 * - 3 - permute cells and nodes.
4274 * \param [in] glob - the global data storing profiles and localization.
4275 * \param [in] mesh - the supporting mesh.
4276 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4277 * caller is to delete this field using decrRef() as it is no more needed.
4278 * \throw If the MED file is not readable.
4279 * \throw If no field of \a this is lying on \a mesh.
4280 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4281 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4283 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)
4285 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4286 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4287 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4288 if(meshDimRelToMax==1)
4289 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4290 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4294 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4296 * \param [in] type - a spatial discretization of the new field.
4297 * \param [in] mName - a name of the supporting mesh.
4298 * \param [in] renumPol - specifies how to permute values of the result field according to
4299 * the optional numbers of cells and nodes, if any. The valid values are
4300 * - 0 - do not permute.
4301 * - 1 - permute cells.
4302 * - 2 - permute nodes.
4303 * - 3 - permute cells and nodes.
4305 * \param [in] glob - the global data storing profiles and localization.
4306 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4307 * caller is to delete this field using decrRef() as it is no more needed.
4308 * \throw If the MED file is not readable.
4309 * \throw If there is no mesh named \a mName in the MED file.
4310 * \throw If there are no mesh entities in the mesh.
4311 * \throw If no field values of the given \a type are available.
4313 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4315 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4317 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4319 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4320 int absDim=getDimension();
4321 int meshDimRelToMax=absDim-mm->getMeshDimension();
4322 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4326 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4327 * \param [in] type - a spatial discretization of the new field.
4328 * \param [in] renumPol - specifies how to permute values of the result field according to
4329 * the optional numbers of cells and nodes, if any. The valid values are
4330 * - 0 - do not permute.
4331 * - 1 - permute cells.
4332 * - 2 - permute nodes.
4333 * - 3 - permute cells and nodes.
4335 * \param [in] glob - the global data storing profiles and localization.
4336 * \param [in] mesh - the supporting mesh.
4337 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4338 * field according to \a renumPol.
4339 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4340 * field according to \a renumPol.
4341 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4342 * caller is to delete this field using decrRef() as it is no more needed.
4343 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4344 * \throw If no field of \a this is lying on \a mesh.
4345 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4347 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)
4349 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4350 int meshId=getMeshIdFromMeshName(mesh->getName());
4352 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4357 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4364 throw INTERP_KERNEL::Exception(msg1);
4365 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4368 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4370 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4371 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4372 throw INTERP_KERNEL::Exception(oss.str().c_str());
4374 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4375 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4376 std::vector<DataArray *> arrOut2(1,arrOut);
4377 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4378 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4379 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4386 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4388 throw INTERP_KERNEL::Exception(msg1);
4391 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4393 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4394 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4395 throw INTERP_KERNEL::Exception(oss.str().c_str());
4397 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4398 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4399 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4400 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4405 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4410 * Returns values and a profile of the field of a given type lying on a given support.
4411 * \param [in] type - a spatial discretization of the field.
4412 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4413 * \param [in] mesh - the supporting mesh.
4414 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4415 * field of interest lies on. If the field lies on all entities of the given
4416 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4417 * using decrRef() as it is no more needed.
4418 * \param [in] glob - the global data storing profiles and localization.
4419 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4420 * field. The caller is to delete this array using decrRef() as it is no more needed.
4421 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4422 * \throw If no field of \a this is lying on \a mesh.
4423 * \throw If no field values of the given \a type are available.
4425 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4427 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4428 int meshId=getMeshIdFromMeshName(mesh->getName());
4429 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4430 ret->setName(nasc.getName().c_str());
4434 //= MEDFileField1TSWithoutSDA
4437 * Throws if a given value is not a valid (non-extended) relative dimension.
4438 * \param [in] meshDimRelToMax - the relative dimension value.
4439 * \throw If \a meshDimRelToMax > 0.
4441 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4443 if(meshDimRelToMax>0)
4444 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4448 * Checks if elements of a given mesh are in the order suitable for writing
4449 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4450 * vector describing types of elements and their number.
4451 * \param [in] mesh - the mesh to check.
4452 * \return std::vector<int> - a vector holding for each element type (1) item of
4453 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4454 * These values are in full-interlace mode.
4455 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4457 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4460 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4461 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4462 int nbOfTypes=geoTypes.size();
4463 std::vector<int> code(3*nbOfTypes);
4464 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4465 arr1->alloc(nbOfTypes,1);
4466 int *arrPtr=arr1->getPointer();
4467 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4468 for(int i=0;i<nbOfTypes;i++,it++)
4469 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4470 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4471 const int *arrPtr2=arr2->getConstPointer();
4473 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4476 int nbCells=mesh->getNumberOfCellsWithType(*it);
4477 code[3*pos]=(int)(*it);
4478 code[3*pos+1]=nbCells;
4479 code[3*pos+2]=-1;//no profiles
4481 std::vector<const DataArrayInt *> idsPerType;//no profiles
4482 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4486 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4491 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4493 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4497 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4498 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4499 * item of every of returned sequences refers to the _i_-th part of \a this field.
4500 * Thus all sequences returned by this method are of the same length equal to number
4501 * of different types of supporting entities.<br>
4502 * A field part can include sub-parts with several different spatial discretizations,
4503 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4504 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4505 * of a nested sequence corresponds to a type of spatial discretization.<br>
4506 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4507 * The overhead is due to selecting values into new instances of DataArrayDouble.
4508 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4509 * for the case with only one underlying mesh. (Actually, the number of meshes is
4510 * not checked if \a mname == \c NULL).
4511 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4512 * a field part is returned.
4513 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4514 * A field part can include sub-parts with several different spatial discretizations,
4515 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4516 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4517 * This sequence is of the same length as \a types.
4518 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4519 * discretization. A profile name can be empty.
4520 * Length of this and of nested sequences is the same as that of \a typesF.
4521 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4522 * discretization. A localization name can be empty.
4523 * Length of this and of nested sequences is the same as that of \a typesF.
4524 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4525 * per each type of spatial discretization within one mesh entity type.
4526 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4527 * Length of this and of nested sequences is the same as that of \a typesF.
4528 * \throw If no field is lying on \a mname.
4530 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)
4534 meshId=getMeshIdFromMeshName(mname);
4536 if(_field_per_mesh.empty())
4537 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4538 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4539 int nbOfRet=ret0.size();
4540 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4541 for(int i=0;i<nbOfRet;i++)
4543 const std::vector< std::pair<int,int> >& p=ret0[i];
4544 int nbOfRet1=p.size();
4545 ret[i].resize(nbOfRet1);
4546 for(int j=0;j<nbOfRet1;j++)
4548 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4556 * Returns a pointer to the underground DataArrayDouble instance. So the
4557 * caller should not decrRef() it. This method allows for a direct access to the field
4558 * values. This method is quite unusable if there is more than a nodal field or a cell
4559 * field on single geometric cell type.
4560 * \return DataArrayDouble * - the pointer to the field values array.
4562 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4564 const DataArrayDouble *ret=_arr;
4566 return const_cast<DataArrayDouble *>(ret);
4571 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4576 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4578 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4579 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4580 ret->deepCpyLeavesFrom(*this);
4581 const DataArrayDouble *arr(_arr);
4584 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4585 ret->setArray(arr2);
4591 * Returns a pointer to the underground DataArrayDouble instance. So the
4592 * caller should not decrRef() it. This method allows for a direct access to the field
4593 * values. This method is quite unusable if there is more than a nodal field or a cell
4594 * field on single geometric cell type.
4595 * \return DataArrayDouble * - the pointer to the field values array.
4597 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4599 return getUndergroundDataArrayDouble();
4603 * Returns a pointer to the underground DataArrayDouble instance and a
4604 * sequence describing parameters of a support of each part of \a this field. The
4605 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4606 * direct access to the field values. This method is intended for the field lying on one
4608 * \param [in,out] entries - the sequence describing parameters of a support of each
4609 * part of \a this field. Each item of this sequence consists of two parts. The
4610 * first part describes a type of mesh entity and an id of discretization of a
4611 * current field part. The second part describes a range of values [begin,end)
4612 * within the returned array relating to the current field part.
4613 * \return DataArrayDouble * - the pointer to the field values array.
4614 * \throw If the number of underlying meshes is not equal to 1.
4615 * \throw If no field values are available.
4616 * \sa getUndergroundDataArray()
4618 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4620 if(_field_per_mesh.size()!=1)
4621 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4622 if(_field_per_mesh[0]==0)
4623 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4624 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4625 return getUndergroundDataArrayDouble();
4629 * Returns a pointer to the underground DataArrayDouble instance and a
4630 * sequence describing parameters of a support of each part of \a this field. The
4631 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4632 * direct access to the field values. This method is intended for the field lying on one
4634 * \param [in,out] entries - the sequence describing parameters of a support of each
4635 * part of \a this field. Each item of this sequence consists of two parts. The
4636 * first part describes a type of mesh entity and an id of discretization of a
4637 * current field part. The second part describes a range of values [begin,end)
4638 * within the returned array relating to the current field part.
4639 * \return DataArrayDouble * - the pointer to the field values array.
4640 * \throw If the number of underlying meshes is not equal to 1.
4641 * \throw If no field values are available.
4642 * \sa getUndergroundDataArray()
4644 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4646 return getUndergroundDataArrayDoubleExt(entries);
4649 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4650 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4652 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4653 arr->setInfoAndChangeNbOfCompo(infos);
4656 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4660 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4662 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4663 ret->deepCpyLeavesFrom(*this);
4667 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4669 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4670 if((const DataArrayDouble *)_arr)
4671 ret->_arr=_arr->deepCpy();
4675 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4679 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4681 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4686 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4688 return DataArrayDouble::New();
4691 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4693 DataArrayDouble *ret=_arr;
4696 _arr=DataArrayDouble::New();
4700 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4702 return getOrCreateAndGetArrayDouble();
4705 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4707 const DataArrayDouble *ret=_arr;
4710 DataArrayDouble *ret2=DataArrayDouble::New();
4711 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4715 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4717 return getOrCreateAndGetArrayDouble();
4720 //= MEDFileIntField1TSWithoutSDA
4722 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4723 const std::vector<std::string>& infos)
4725 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4728 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4732 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4733 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4735 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4736 arr->setInfoAndChangeNbOfCompo(infos);
4739 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4744 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4746 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4747 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4748 ret->deepCpyLeavesFrom(*this);
4749 const DataArrayInt *arr(_arr);
4752 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4753 ret->setArray(arr2);
4759 * Returns a pointer to the underground DataArrayInt instance. So the
4760 * caller should not decrRef() it. This method allows for a direct access to the field
4761 * values. This method is quite unusable if there is more than a nodal field or a cell
4762 * field on single geometric cell type.
4763 * \return DataArrayInt * - the pointer to the field values array.
4765 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4767 return getUndergroundDataArrayInt();
4771 * Returns a pointer to the underground DataArrayInt instance. So the
4772 * caller should not decrRef() it. This method allows for a direct access to the field
4773 * values. This method is quite unusable if there is more than a nodal field or a cell
4774 * field on single geometric cell type.
4775 * \return DataArrayInt * - the pointer to the field values array.
4777 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4779 const DataArrayInt *ret=_arr;
4781 return const_cast<DataArrayInt *>(ret);
4787 * Returns a pointer to the underground DataArrayInt instance and a
4788 * sequence describing parameters of a support of each part of \a this field. The
4789 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4790 * direct access to the field values. This method is intended for the field lying on one
4792 * \param [in,out] entries - the sequence describing parameters of a support of each
4793 * part of \a this field. Each item of this sequence consists of two parts. The
4794 * first part describes a type of mesh entity and an id of discretization of a
4795 * current field part. The second part describes a range of values [begin,end)
4796 * within the returned array relating to the current field part.
4797 * \return DataArrayInt * - the pointer to the field values array.
4798 * \throw If the number of underlying meshes is not equal to 1.
4799 * \throw If no field values are available.
4800 * \sa getUndergroundDataArray()
4802 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4804 return getUndergroundDataArrayIntExt(entries);
4808 * Returns a pointer to the underground DataArrayInt instance and a
4809 * sequence describing parameters of a support of each part of \a this field. The
4810 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4811 * direct access to the field values. This method is intended for the field lying on one
4813 * \param [in,out] entries - the sequence describing parameters of a support of each
4814 * part of \a this field. Each item of this sequence consists of two parts. The
4815 * first part describes a type of mesh entity and an id of discretization of a
4816 * current field part. The second part describes a range of values [begin,end)
4817 * within the returned array relating to the current field part.
4818 * \return DataArrayInt * - the pointer to the field values array.
4819 * \throw If the number of underlying meshes is not equal to 1.
4820 * \throw If no field values are available.
4821 * \sa getUndergroundDataArray()
4823 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4825 if(_field_per_mesh.size()!=1)
4826 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4827 if(_field_per_mesh[0]==0)
4828 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4829 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4830 return getUndergroundDataArrayInt();
4833 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4835 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4836 ret->deepCpyLeavesFrom(*this);
4840 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4842 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4843 if((const DataArrayInt *)_arr)
4844 ret->_arr=_arr->deepCpy();
4848 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4852 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4854 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4859 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4861 return DataArrayInt::New();
4864 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4866 DataArrayInt *ret=_arr;
4869 _arr=DataArrayInt::New();
4873 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4875 return getOrCreateAndGetArrayInt();
4878 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4880 const DataArrayInt *ret=_arr;
4883 DataArrayInt *ret2=DataArrayInt::New();
4884 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4888 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4890 return getOrCreateAndGetArrayInt();
4893 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4897 //= MEDFileAnyTypeField1TS
4899 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
4901 med_field_type typcha;
4903 std::vector<std::string> infos;
4904 std::string dtunit,fieldName;
4905 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4906 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4911 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4916 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4921 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] !";
4922 throw INTERP_KERNEL::Exception(oss.str().c_str());
4925 ret->setDtUnit(dtunit.c_str());
4926 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4928 med_int numdt,numit;
4930 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4931 ret->setTime(numdt,numit,dt);
4933 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4937 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
4938 try:MEDFileFieldGlobsReal(fileName)
4940 MEDFileUtilities::CheckFileForRead(fileName);
4941 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4942 _content=BuildContentFrom(fid,fileName);
4945 catch(INTERP_KERNEL::Exception& e)
4950 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4952 med_field_type typcha;
4953 std::vector<std::string> infos;
4956 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
4957 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4962 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4967 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4972 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] !";
4973 throw INTERP_KERNEL::Exception(oss.str().c_str());
4976 ret->setDtUnit(dtunit.c_str());
4977 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4981 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
4982 throw INTERP_KERNEL::Exception(oss.str().c_str());
4985 med_int numdt,numit;
4987 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
4988 ret->setTime(numdt,numit,dt);
4990 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4994 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4995 try:MEDFileFieldGlobsReal(fileName)
4997 MEDFileUtilities::CheckFileForRead(fileName);
4998 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4999 _content=BuildContentFrom(fid,fileName,fieldName);
5002 catch(INTERP_KERNEL::Exception& e)
5007 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5010 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5011 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5013 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5014 ret->setFileName(fileName);
5015 ret->_content=c; c->incrRef();
5018 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5020 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5021 ret->setFileName(fileName);
5022 ret->_content=c; c->incrRef();
5025 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5028 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5030 MEDFileUtilities::CheckFileForRead(fileName);
5031 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5032 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName);
5033 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5034 ret->loadGlobals(fid);
5038 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5040 MEDFileUtilities::CheckFileForRead(fileName);
5041 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5042 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
5043 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5044 ret->loadGlobals(fid);
5048 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5050 MEDFileUtilities::CheckFileForRead(fileName);
5051 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5052 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5053 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5054 ret->loadGlobals(fid);
5058 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5060 med_field_type typcha;
5061 std::vector<std::string> infos;
5064 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5065 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5070 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5075 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5080 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] !";
5081 throw INTERP_KERNEL::Exception(oss.str().c_str());
5084 ret->setDtUnit(dtunit.c_str());
5085 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5088 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5089 for(int i=0;i<nbOfStep2 && !found;i++)
5091 med_int numdt,numit;
5093 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5094 if(numdt==iteration && numit==order)
5100 dtits[i]=std::pair<int,int>(numdt,numit);
5104 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5105 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5106 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5107 throw INTERP_KERNEL::Exception(oss.str().c_str());
5109 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5113 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5114 try:MEDFileFieldGlobsReal(fileName)
5116 MEDFileUtilities::CheckFileForRead(fileName);
5117 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5118 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5121 catch(INTERP_KERNEL::Exception& e)
5127 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5128 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5130 * \warning this is a shallow copy constructor
5132 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5134 if(!shallowCopyOfContent)
5136 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5137 otherPtr->incrRef();
5138 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5142 _content=other.shallowCpy();
5146 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)
5150 int nbFields=MEDnField(fid);
5151 if(fieldIdCFormat>=nbFields)
5153 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5154 throw INTERP_KERNEL::Exception(oss.str().c_str());
5157 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5158 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5159 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5160 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5161 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5162 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5165 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5166 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5167 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5168 infos.clear(); infos.resize(ncomp);
5169 for(int j=0;j<ncomp;j++)
5170 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5175 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5178 * \return in case of success the number of time steps available for the field with name \a fieldName.
5180 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)
5182 int nbFields=MEDnField(fid);
5184 std::vector<std::string> fns(nbFields);
5186 for(int i=0;i<nbFields && !found;i++)
5189 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5191 found=(tmp==fieldName);
5197 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5198 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5199 oss << "\"" << *it << "\" ";
5200 throw INTERP_KERNEL::Exception(oss.str().c_str());
5206 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5207 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5208 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5209 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5210 * to keep a valid instance.
5211 * 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.
5212 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5213 * 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.
5215 * \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.
5216 * \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.
5217 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5218 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5219 * \param [in] newLocName is the new localization name.
5220 * \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.
5221 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5223 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5225 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5226 std::string oldPflName=disc->getProfile();
5227 std::vector<std::string> vv=getPflsReallyUsedMulti();
5228 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5229 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5231 disc->setProfile(newPflName);
5232 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5233 pfl->setName(newPflName);
5237 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5238 throw INTERP_KERNEL::Exception(oss.str().c_str());
5243 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5244 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5245 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5246 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5247 * to keep a valid instance.
5248 * 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.
5249 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5250 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5251 * 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.
5253 * \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.
5254 * \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.
5255 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5256 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5257 * \param [in] newLocName is the new localization name.
5258 * \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.
5259 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5261 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5263 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5264 std::string oldLocName=disc->getLocalization();
5265 std::vector<std::string> vv=getLocsReallyUsedMulti();
5266 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5267 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5269 disc->setLocalization(newLocName);
5270 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5271 loc.setName(newLocName);
5275 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5276 throw INTERP_KERNEL::Exception(oss.str().c_str());
5280 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5282 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5284 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5288 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5290 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5292 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5297 * Writes \a this field into a MED file specified by its name.
5298 * \param [in] fileName - the MED file name.
5299 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5300 * - 2 - erase; an existing file is removed.
5301 * - 1 - append; same data should not be present in an existing file.
5302 * - 0 - overwrite; same data present in an existing file is overwritten.
5303 * \throw If the field name is not set.
5304 * \throw If no field data is set.
5305 * \throw If \a mode == 1 and the same data is present in an existing file.
5307 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5309 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5310 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5314 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5316 int nbComp=getNumberOfComponents();
5317 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5318 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5319 for(int i=0;i<nbComp;i++)
5321 std::string info=getInfo()[i];
5323 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5324 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5325 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5327 if(getName().empty())
5328 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5329 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5330 writeGlobals(fid,*this);
5331 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5334 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5337 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5338 ret+=_content->getHeapMemorySize();
5339 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5343 * Returns a string describing \a this field. This string is outputted
5344 * by \c print Python command.
5346 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5348 std::ostringstream oss;
5349 contentNotNullBase()->simpleRepr(0,oss,-1);
5350 simpleReprGlobs(oss);
5355 * This method returns all profiles whose name is non empty used.
5356 * \b WARNING If profile is used several times it will be reported \b only \b once.
5357 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5359 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5361 return contentNotNullBase()->getPflsReallyUsed2();
5365 * This method returns all localizations whose name is non empty used.
5366 * \b WARNING If localization is used several times it will be reported \b only \b once.
5368 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5370 return contentNotNullBase()->getLocsReallyUsed2();
5374 * This method returns all profiles whose name is non empty used.
5375 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5377 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5379 return contentNotNullBase()->getPflsReallyUsedMulti2();
5383 * This method returns all localizations whose name is non empty used.
5384 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5386 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5388 return contentNotNullBase()->getLocsReallyUsedMulti2();
5391 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5393 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5396 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5398 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5401 int MEDFileAnyTypeField1TS::getDimension() const
5403 return contentNotNullBase()->getDimension();
5406 int MEDFileAnyTypeField1TS::getIteration() const
5408 return contentNotNullBase()->getIteration();
5411 int MEDFileAnyTypeField1TS::getOrder() const
5413 return contentNotNullBase()->getOrder();
5416 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5418 return contentNotNullBase()->getTime(iteration,order);
5421 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5423 contentNotNullBase()->setTime(iteration,order,val);
5426 std::string MEDFileAnyTypeField1TS::getName() const
5428 return contentNotNullBase()->getName();
5431 void MEDFileAnyTypeField1TS::setName(const char *name)
5433 contentNotNullBase()->setName(name);
5436 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5438 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5441 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5443 return contentNotNullBase()->getDtUnit();
5446 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5448 contentNotNullBase()->setDtUnit(dtUnit);
5451 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5453 return contentNotNullBase()->getMeshName();
5456 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5458 contentNotNullBase()->setMeshName(newMeshName);
5461 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5463 return contentNotNullBase()->changeMeshNames(modifTab);
5466 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5468 return contentNotNullBase()->getMeshIteration();
5471 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5473 return contentNotNullBase()->getMeshOrder();
5476 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5478 return contentNotNullBase()->getNumberOfComponents();
5481 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5483 return contentNotNullBase()->isDealingTS(iteration,order);
5486 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5488 return contentNotNullBase()->getDtIt();
5491 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5493 contentNotNullBase()->fillIteration(p);
5496 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5498 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5501 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5503 contentNotNullBase()->setInfo(infos);
5506 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5508 return contentNotNullBase()->getInfo();
5510 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5512 return contentNotNullBase()->getInfo();
5515 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5517 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5520 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5522 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5525 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5527 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5530 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5532 return contentNotNullBase()->getTypesOfFieldAvailable();
5535 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,
5536 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5538 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5542 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5543 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5544 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5546 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5548 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5550 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5551 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5552 std::size_t sz(contentsSplit.size());
5553 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5554 for(std::size_t i=0;i<sz;i++)
5556 ret[i]=shallowCpy();
5557 ret[i]->_content=contentsSplit[i];
5562 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5564 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5565 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5566 ret->_content=_content->deepCpy();
5567 ret->deepCpyGlobs(*this);
5571 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5573 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5579 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5580 * the first field that has been read from a specified MED file.
5581 * \param [in] fileName - the name of the MED file to read.
5582 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5583 * is to delete this field using decrRef() as it is no more needed.
5584 * \throw If reading the file fails.
5586 MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5588 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName);
5589 ret->contentNotNull();
5594 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5595 * a given field that has been read from a specified MED file.
5596 * \param [in] fileName - the name of the MED file to read.
5597 * \param [in] fieldName - the name of the field to read.
5598 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5599 * is to delete this field using decrRef() as it is no more needed.
5600 * \throw If reading the file fails.
5601 * \throw If there is no field named \a fieldName in the file.
5603 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5605 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName);
5606 ret->contentNotNull();
5611 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5612 * a given field that has been read from a specified MED file.
5613 * \param [in] fileName - the name of the MED file to read.
5614 * \param [in] fieldName - the name of the field to read.
5615 * \param [in] iteration - the iteration number of a required time step.
5616 * \param [in] order - the iteration order number of required time step.
5617 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5618 * is to delete this field using decrRef() as it is no more needed.
5619 * \throw If reading the file fails.
5620 * \throw If there is no field named \a fieldName in the file.
5621 * \throw If the required time step is missing from the file.
5623 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5625 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order);
5626 ret->contentNotNull();
5631 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5632 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5634 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5635 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5636 * \warning this is a shallow copy constructor
5637 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5638 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5639 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5640 * is to delete this field using decrRef() as it is no more needed.
5642 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5644 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5645 ret->contentNotNull();
5650 * Returns a new empty instance of MEDFileField1TS.
5651 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5652 * is to delete this field using decrRef() as it is no more needed.
5654 MEDFileField1TS *MEDFileField1TS::New()
5656 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5657 ret->contentNotNull();
5662 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5663 * following the given input policy.
5665 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5666 * By default (true) the globals are deeply copied.
5667 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5669 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5671 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5672 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5675 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5677 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5678 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5679 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5682 ret=MEDFileIntField1TS::New();
5684 ret->deepCpyGlobs(*this);
5686 ret->shallowCpyGlobs(*this);
5690 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5692 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5694 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5695 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5697 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 !");
5701 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5703 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5705 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5706 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5708 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 !");
5712 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5715 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5716 if(!((DataArray*)arr))
5717 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5718 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5720 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5721 f->setArray(arrOutC);
5724 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5726 if(!((DataArray*)arr))
5727 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5728 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5730 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5735 MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
5736 try:MEDFileAnyTypeField1TS(fileName)
5739 catch(INTERP_KERNEL::Exception& e)
5742 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5743 try:MEDFileAnyTypeField1TS(fileName,fieldName)
5746 catch(INTERP_KERNEL::Exception& e)
5749 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5750 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
5753 catch(INTERP_KERNEL::Exception& e)
5757 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5758 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5760 * \warning this is a shallow copy constructor
5762 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5763 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5766 catch(INTERP_KERNEL::Exception& e)
5769 MEDFileField1TS::MEDFileField1TS()
5771 _content=new MEDFileField1TSWithoutSDA;
5775 * Returns a new MEDCouplingFieldDouble of a given type lying on
5776 * mesh entities of a given dimension 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] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5781 * \param [in] renumPol - specifies how to permute values of the result field according to
5782 * the optional numbers of cells and nodes, if any. The valid values are
5783 * - 0 - do not permute.
5784 * - 1 - permute cells.
5785 * - 2 - permute nodes.
5786 * - 3 - permute cells and nodes.
5788 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5789 * caller is to delete this field using decrRef() as it is no more needed.
5790 * \throw If \a this field has not been constructed via file reading.
5791 * \throw If the MED file is not readable.
5792 * \throw If there is no mesh in the MED file.
5793 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5794 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5795 * \sa getFieldOnMeshAtLevel()
5797 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5799 if(getFileName2().empty())
5800 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5801 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5802 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5803 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5808 * Returns a new MEDCouplingFieldDouble of a given type lying on
5809 * the top level cells of the first mesh in MED file. If \a this field
5810 * has not been constructed via file reading, an exception is thrown.
5811 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5812 * \param [in] type - a spatial discretization of interest.
5813 * \param [in] renumPol - specifies how to permute values of the result field according to
5814 * the optional numbers of cells and nodes, if any. The valid values are
5815 * - 0 - do not permute.
5816 * - 1 - permute cells.
5817 * - 2 - permute nodes.
5818 * - 3 - permute cells and nodes.
5820 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5821 * caller is to delete this field using decrRef() as it is no more needed.
5822 * \throw If \a this field has not been constructed via file reading.
5823 * \throw If the MED file is not readable.
5824 * \throw If there is no mesh in the MED file.
5825 * \throw If no field values of the given \a type.
5826 * \throw If no field values lying on the top level support.
5827 * \sa getFieldAtLevel()
5829 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5831 if(getFileName2().empty())
5832 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5833 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5834 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5835 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5840 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5841 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5842 * \param [in] type - a spatial discretization of the new field.
5843 * \param [in] mesh - the supporting mesh.
5844 * \param [in] renumPol - specifies how to permute values of the result field according to
5845 * the optional numbers of cells and nodes, if any. The valid values are
5846 * - 0 - do not permute.
5847 * - 1 - permute cells.
5848 * - 2 - permute nodes.
5849 * - 3 - permute cells and nodes.
5851 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5852 * caller is to delete this field using decrRef() as it is no more needed.
5853 * \throw If no field of \a this is lying on \a mesh.
5854 * \throw If the mesh is empty.
5855 * \throw If no field values of the given \a type are available.
5856 * \sa getFieldAtLevel()
5857 * \sa getFieldOnMeshAtLevel()
5859 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5861 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5862 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5863 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5868 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5869 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5870 * \param [in] type - a spatial discretization of interest.
5871 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5872 * \param [in] mesh - the supporting mesh.
5873 * \param [in] renumPol - specifies how to permute values of the result field according to
5874 * the optional numbers of cells and nodes, if any. The valid values are
5875 * - 0 - do not permute.
5876 * - 1 - permute cells.
5877 * - 2 - permute nodes.
5878 * - 3 - permute cells and nodes.
5880 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5881 * caller is to delete this field using decrRef() as it is no more needed.
5882 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5883 * \throw If no field of \a this is lying on \a mesh.
5884 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5885 * \sa getFieldAtLevel()
5886 * \sa getFieldOnMeshAtLevel()
5888 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5890 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5891 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5892 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5897 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5898 * This method is called "Old" because in MED3 norm a field has only one meshName
5899 * attached, so this method is for readers of MED2 files. If \a this field
5900 * has not been constructed via file reading, an exception is thrown.
5901 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5902 * \param [in] type - a spatial discretization of interest.
5903 * \param [in] mName - a name of the supporting mesh.
5904 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5905 * \param [in] renumPol - specifies how to permute values of the result field according to
5906 * the optional numbers of cells and nodes, if any. The valid values are
5907 * - 0 - do not permute.
5908 * - 1 - permute cells.
5909 * - 2 - permute nodes.
5910 * - 3 - permute cells and nodes.
5912 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5913 * caller is to delete this field using decrRef() as it is no more needed.
5914 * \throw If the MED file is not readable.
5915 * \throw If there is no mesh named \a mName in the MED file.
5916 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5917 * \throw If \a this field has not been constructed via file reading.
5918 * \throw If no field of \a this is lying on the mesh named \a mName.
5919 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5920 * \sa getFieldAtLevel()
5922 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5924 if(getFileName2().empty())
5925 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5926 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5927 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
5928 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5933 * Returns values and a profile of the field of a given type lying on a given support.
5934 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5935 * \param [in] type - a spatial discretization of the field.
5936 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5937 * \param [in] mesh - the supporting mesh.
5938 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5939 * field of interest lies on. If the field lies on all entities of the given
5940 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5941 * using decrRef() as it is no more needed.
5942 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5943 * field. The caller is to delete this array using decrRef() as it is no more needed.
5944 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5945 * \throw If no field of \a this is lying on \a mesh.
5946 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5948 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5950 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
5951 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
5955 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5956 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5957 * "Sort By Type"), if not, an exception is thrown.
5958 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5959 * \param [in] field - the field to add to \a this.
5960 * \throw If the name of \a field is empty.
5961 * \throw If the data array of \a field is not set.
5962 * \throw If the data array is already allocated but has different number of components
5964 * \throw If the underlying mesh of \a field has no name.
5965 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5967 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5970 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
5974 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5975 * of a given mesh are used as the support of the given field (a real support is not used).
5976 * Elements of the given mesh must be sorted suitable for writing to MED file.
5977 * Order of underlying mesh entities of the given field specified by \a profile parameter
5978 * is not prescribed; this method permutes field values to have them sorted by element
5979 * type as required for writing to MED file. A new profile is added only if no equal
5980 * profile is missing.
5981 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5982 * \param [in] field - the field to add to \a this.
5983 * \param [in] mesh - the supporting mesh of \a field.
5984 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5985 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5986 * \throw If either \a field or \a mesh or \a profile has an empty name.
5987 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5988 * \throw If the data array of \a field is not set.
5989 * \throw If the data array of \a this is already allocated but has different number of
5990 * components than \a field.
5991 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5992 * \sa setFieldNoProfileSBT()
5994 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
5997 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6000 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6002 return new MEDFileField1TS(*this);
6005 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6007 return contentNotNull()->getUndergroundDataArrayDouble();
6010 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6012 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6015 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6016 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6018 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6021 //= MEDFileIntField1TS
6023 MEDFileIntField1TS *MEDFileIntField1TS::New()
6025 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6026 ret->contentNotNull();
6030 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
6032 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName);
6033 ret->contentNotNull();
6037 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6039 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName);
6040 ret->contentNotNull();
6044 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6046 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order);
6047 ret->contentNotNull();
6051 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6053 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6054 ret->contentNotNull();
6058 MEDFileIntField1TS::MEDFileIntField1TS()
6060 _content=new MEDFileIntField1TSWithoutSDA;
6063 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
6064 try:MEDFileAnyTypeField1TS(fileName)
6067 catch(INTERP_KERNEL::Exception& e)
6070 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6071 try:MEDFileAnyTypeField1TS(fileName,fieldName)
6074 catch(INTERP_KERNEL::Exception& e)
6077 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6078 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
6081 catch(INTERP_KERNEL::Exception& e)
6085 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6086 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6088 * \warning this is a shallow copy constructor
6090 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6094 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6096 return new MEDFileIntField1TS(*this);
6100 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6101 * following the given input policy.
6103 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6104 * By default (true) the globals are deeply copied.
6105 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6107 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6109 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6110 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6113 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6115 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6116 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6117 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6120 ret=MEDFileField1TS::New();
6122 ret->deepCpyGlobs(*this);
6124 ret->shallowCpyGlobs(*this);
6129 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6130 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6131 * "Sort By Type"), if not, an exception is thrown.
6132 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6133 * \param [in] field - the field to add to \a this. The field double values are ignored.
6134 * \param [in] arrOfVals - the values of the field \a field used.
6135 * \throw If the name of \a field is empty.
6136 * \throw If the data array of \a field is not set.
6137 * \throw If the data array is already allocated but has different number of components
6139 * \throw If the underlying mesh of \a field has no name.
6140 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6142 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6145 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6149 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6150 * of a given mesh are used as the support of the given field (a real support is not used).
6151 * Elements of the given mesh must be sorted suitable for writing to MED file.
6152 * Order of underlying mesh entities of the given field specified by \a profile parameter
6153 * is not prescribed; this method permutes field values to have them sorted by element
6154 * type as required for writing to MED file. A new profile is added only if no equal
6155 * profile is missing.
6156 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6157 * \param [in] field - the field to add to \a this. The field double values are ignored.
6158 * \param [in] arrOfVals - the values of the field \a field used.
6159 * \param [in] mesh - the supporting mesh of \a field.
6160 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6161 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6162 * \throw If either \a field or \a mesh or \a profile has an empty name.
6163 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6164 * \throw If the data array of \a field is not set.
6165 * \throw If the data array of \a this is already allocated but has different number of
6166 * components than \a field.
6167 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6168 * \sa setFieldNoProfileSBT()
6170 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6173 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6176 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6178 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6180 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6181 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6183 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 !");
6187 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6189 if(getFileName2().empty())
6190 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6191 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6192 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6193 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6195 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6200 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6202 if(!((DataArray *)arr))
6203 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6204 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6206 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6212 * Returns a new MEDCouplingFieldDouble of a given type lying on
6213 * the top level cells of the first mesh in MED file. If \a this field
6214 * has not been constructed via file reading, an exception is thrown.
6215 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6216 * \param [in] type - a spatial discretization of interest.
6217 * \param [out] arrOut - the DataArrayInt containing values of field.
6218 * \param [in] renumPol - specifies how to permute values of the result field according to
6219 * the optional numbers of cells and nodes, if any. The valid values are
6220 * - 0 - do not permute.
6221 * - 1 - permute cells.
6222 * - 2 - permute nodes.
6223 * - 3 - permute cells and nodes.
6225 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6226 * caller is to delete this field using decrRef() as it is no more needed.
6227 * \throw If \a this field has not been constructed via file reading.
6228 * \throw If the MED file is not readable.
6229 * \throw If there is no mesh in the MED file.
6230 * \throw If no field values of the given \a type.
6231 * \throw If no field values lying on the top level support.
6232 * \sa getFieldAtLevel()
6234 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6236 if(getFileName2().empty())
6237 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6238 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6239 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6240 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6245 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6246 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6247 * \param [in] type - a spatial discretization of the new field.
6248 * \param [in] mesh - the supporting mesh.
6249 * \param [out] arrOut - the DataArrayInt containing values of field.
6250 * \param [in] renumPol - specifies how to permute values of the result field according to
6251 * the optional numbers of cells and nodes, if any. The valid values are
6252 * - 0 - do not permute.
6253 * - 1 - permute cells.
6254 * - 2 - permute nodes.
6255 * - 3 - permute cells and nodes.
6257 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6258 * caller is to delete this field using decrRef() as it is no more needed.
6259 * \throw If no field of \a this is lying on \a mesh.
6260 * \throw If the mesh is empty.
6261 * \throw If no field values of the given \a type are available.
6262 * \sa getFieldAtLevel()
6263 * \sa getFieldOnMeshAtLevel()
6265 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6267 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6268 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6269 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6274 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6275 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6276 * \param [in] type - a spatial discretization of interest.
6277 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6278 * \param [out] arrOut - the DataArrayInt containing values of field.
6279 * \param [in] mesh - the supporting mesh.
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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6290 * \throw If no field of \a this is lying on \a mesh.
6291 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6292 * \sa getFieldAtLevel()
6293 * \sa getFieldOnMeshAtLevel()
6295 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6297 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6298 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6299 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6304 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6305 * This method is called "Old" because in MED3 norm a field has only one meshName
6306 * attached, so this method is for readers of MED2 files. If \a this field
6307 * has not been constructed via file reading, an exception is thrown.
6308 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6309 * \param [in] type - a spatial discretization of interest.
6310 * \param [in] mName - a name of the supporting mesh.
6311 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6312 * \param [out] arrOut - the DataArrayInt containing values of field.
6313 * \param [in] renumPol - specifies how to permute values of the result field according to
6314 * the optional numbers of cells and nodes, if any. The valid values are
6315 * - 0 - do not permute.
6316 * - 1 - permute cells.
6317 * - 2 - permute nodes.
6318 * - 3 - permute cells and nodes.
6320 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6321 * caller is to delete this field using decrRef() as it is no more needed.
6322 * \throw If the MED file is not readable.
6323 * \throw If there is no mesh named \a mName in the MED file.
6324 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6325 * \throw If \a this field has not been constructed via file reading.
6326 * \throw If no field of \a this is lying on the mesh named \a mName.
6327 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6328 * \sa getFieldAtLevel()
6330 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6332 if(getFileName2().empty())
6333 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6334 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6335 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6336 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6341 * Returns values and a profile of the field of a given type lying on a given support.
6342 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6343 * \param [in] type - a spatial discretization of the field.
6344 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6345 * \param [in] mesh - the supporting mesh.
6346 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6347 * field of interest lies on. If the field lies on all entities of the given
6348 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6349 * using decrRef() as it is no more needed.
6350 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6351 * field. The caller is to delete this array using decrRef() as it is no more needed.
6352 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6353 * \throw If no field of \a this is lying on \a mesh.
6354 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6356 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6358 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6359 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6362 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6364 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6366 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6367 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6369 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 !");
6373 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6375 return contentNotNull()->getUndergroundDataArrayInt();
6378 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6380 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6384 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6389 * \param [in] fieldId field id in C mode
6391 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
6393 med_field_type typcha;
6394 std::string dtunitOut;
6395 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6396 setDtUnit(dtunitOut.c_str());
6397 finishLoading(fid,nbOfStep,typcha);
6400 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)
6401 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6403 setDtUnit(dtunit.c_str());
6404 finishLoading(fid,nbOfStep,fieldTyp);
6406 catch(INTERP_KERNEL::Exception& e)
6411 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6413 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6414 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6415 ret+=(*it).capacity();
6416 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6417 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6418 ret+=(*it)->getHeapMemorySize();
6423 * 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
6426 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6428 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6429 ret->setInfo(_infos);
6430 int sz=(int)_time_steps.size();
6431 for(const int *id=startIds;id!=endIds;id++)
6433 if(*id>=0 && *id<sz)
6435 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6436 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6440 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6442 ret->pushBackTimeStep(tse2);
6446 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6447 oss << " ! Should be in [0," << sz << ") !";
6448 throw INTERP_KERNEL::Exception(oss.str().c_str());
6451 if(ret->getNumberOfTS()>0)
6452 ret->synchronizeNameScope();
6453 ret->copyNameScope(*this);
6458 * 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
6461 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6463 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6464 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6465 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6466 ret->setInfo(_infos);
6467 int sz=(int)_time_steps.size();
6469 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6473 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6474 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6478 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6480 ret->pushBackTimeStep(tse2);
6484 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6485 oss << " ! Should be in [0," << sz << ") !";
6486 throw INTERP_KERNEL::Exception(oss.str().c_str());
6489 if(ret->getNumberOfTS()>0)
6490 ret->synchronizeNameScope();
6491 ret->copyNameScope(*this);
6495 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6498 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6499 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6501 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6504 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6505 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6506 ids->pushBackSilent(id);
6508 return buildFromTimeStepIds(ids->begin(),ids->end());
6511 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6514 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6515 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6517 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6520 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6521 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6522 ids->pushBackSilent(id);
6524 return buildFromTimeStepIds(ids->begin(),ids->end());
6527 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6532 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6537 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6540 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6542 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6543 if(pt->isDealingTS(iteration,order))
6546 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6547 std::vector< std::pair<int,int> > vp=getIterations();
6548 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6549 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6550 throw INTERP_KERNEL::Exception(oss.str().c_str());
6553 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6555 return *_time_steps[getTimeStepPos(iteration,order)];
6558 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6560 return *_time_steps[getTimeStepPos(iteration,order)];
6563 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6565 if(_time_steps.empty())
6566 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6567 return _time_steps[0]->getMeshName();
6570 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6572 std::string oldName(getMeshName());
6573 std::vector< std::pair<std::string,std::string> > v(1);
6574 v[0].first=oldName; v[0].second=newMeshName;
6578 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6581 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6583 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6585 ret=cur->changeMeshNames(modifTab) || ret;
6591 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6593 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6595 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6599 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6601 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)
6603 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6606 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6607 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6610 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6612 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6614 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6619 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6621 std::string startLine(bkOffset,' ');
6622 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6624 oss << " (" << fmtsId << ")";
6625 oss << " has the following name: \"" << _name << "\"." << std::endl;
6626 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6627 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6629 oss << startLine << " - \"" << *it << "\"" << std::endl;
6632 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6634 std::string chapter(17,'0'+i);
6635 oss << startLine << chapter << std::endl;
6636 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6638 cur->simpleRepr(bkOffset+2,oss,i);
6640 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6641 oss << startLine << chapter << std::endl;
6645 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6647 std::size_t sz=_time_steps.size();
6648 std::vector< std::pair<int,int> > ret(sz);
6650 for(std::size_t i=0;i<sz;i++)
6652 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6655 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6659 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6660 throw INTERP_KERNEL::Exception(oss.str().c_str());
6666 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6668 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6670 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6671 checkCoherencyOfType(tse2);
6672 if(_time_steps.empty())
6674 setName(tse2->getName().c_str());
6675 setInfo(tse2->getInfo());
6677 checkThatComponentsMatch(tse2->getInfo());
6678 _time_steps.push_back(tse);
6681 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6683 std::size_t nbOfCompo=_infos.size();
6684 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6686 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6689 if((cur->getInfo()).size()!=nbOfCompo)
6691 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6692 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6693 throw INTERP_KERNEL::Exception(oss.str().c_str());
6695 cur->copyNameScope(*this);
6700 void MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception)
6702 _time_steps.resize(nbPdt);
6703 for(int i=0;i<nbPdt;i++)
6705 std::vector< std::pair<int,int> > ts;
6706 med_int numdt=0,numo=0;
6707 med_int meshIt=0,meshOrder=0;
6709 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6714 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6719 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6723 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading : managed field type are : FLOAT64, INT32 !");
6725 _time_steps[i]->finishLoading(fid,*this);
6729 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6731 if(_time_steps.empty())
6732 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6733 checkThatNbOfCompoOfTSMatchThis();
6734 std::vector<std::string> infos(getInfo());
6735 int nbComp=infos.size();
6736 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6737 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6738 for(int i=0;i<nbComp;i++)
6740 std::string info=infos[i];
6742 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6743 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6744 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6747 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6748 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6749 int nbOfTS=_time_steps.size();
6750 for(int i=0;i<nbOfTS;i++)
6751 _time_steps[i]->writeLL(fid,opts,*this);
6754 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6756 return _time_steps.size();
6759 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6761 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6762 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6764 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6766 newTS.push_back(*it);
6771 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6773 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6774 int maxId=(int)_time_steps.size();
6776 std::set<int> idsToDel;
6777 for(const int *id=startIds;id!=endIds;id++,ii++)
6779 if(*id>=0 && *id<maxId)
6781 idsToDel.insert(*id);
6785 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6786 throw INTERP_KERNEL::Exception(oss.str().c_str());
6789 for(int iii=0;iii<maxId;iii++)
6790 if(idsToDel.find(iii)==idsToDel.end())
6791 newTS.push_back(_time_steps[iii]);
6795 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6797 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6798 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6799 if(nbOfEntriesToKill==0)
6801 std::size_t sz=_time_steps.size();
6802 std::vector<bool> b(sz,true);
6804 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6806 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6807 for(std::size_t i=0;i<sz;i++)
6809 newTS.push_back(_time_steps[i]);
6813 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6816 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
6817 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6819 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6823 tmp->getTime(it2,ord);
6824 if(it2==iteration && order==ord)
6827 oss << "(" << it2 << "," << ord << "), ";
6830 throw INTERP_KERNEL::Exception(oss.str().c_str());
6833 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6836 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6838 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6840 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6844 double ti=tmp->getTime(it2,ord);
6845 if(fabs(time-ti)<eps)
6851 throw INTERP_KERNEL::Exception(oss.str().c_str());
6854 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6856 int lgth=_time_steps.size();
6857 std::vector< std::pair<int,int> > ret(lgth);
6858 for(int i=0;i<lgth;i++)
6859 _time_steps[i]->fillIteration(ret[i]);
6864 * 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'
6865 * This method returns two things.
6866 * - The absolute dimension of 'this' in first parameter.
6867 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
6868 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
6870 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
6871 * Only these 3 discretizations will be taken into account here.
6873 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
6874 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
6875 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
6877 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
6878 * 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'.
6880 * Let's consider the typical following case :
6881 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
6882 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
6883 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
6885 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
6887 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
6889 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
6890 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
6891 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
6892 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
6894 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
6896 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
6899 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
6901 if(pos<0 || pos>=(int)_time_steps.size())
6903 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6904 throw INTERP_KERNEL::Exception(oss.str().c_str());
6906 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6909 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6910 oss << "\nTry to use following method eraseEmptyTS !";
6911 throw INTERP_KERNEL::Exception(oss.str().c_str());
6916 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
6918 if(pos<0 || pos>=(int)_time_steps.size())
6920 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6921 throw INTERP_KERNEL::Exception(oss.str().c_str());
6923 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6926 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6927 oss << "\nTry to use following method eraseEmptyTS !";
6928 throw INTERP_KERNEL::Exception(oss.str().c_str());
6933 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
6935 std::vector<std::string> ret;
6936 std::set<std::string> ret2;
6937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6939 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
6940 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6941 if(ret2.find(*it2)==ret2.end())
6943 ret.push_back(*it2);
6950 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
6952 std::vector<std::string> ret;
6953 std::set<std::string> ret2;
6954 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6956 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
6957 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6958 if(ret2.find(*it2)==ret2.end())
6960 ret.push_back(*it2);
6967 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
6969 std::vector<std::string> ret;
6970 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6972 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
6973 ret.insert(ret.end(),tmp.begin(),tmp.end());
6978 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
6980 std::vector<std::string> ret;
6981 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6983 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
6984 ret.insert(ret.end(),tmp.begin(),tmp.end());
6989 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6991 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6992 (*it)->changePflsRefsNamesGen2(mapOfModif);
6995 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6997 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6998 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7001 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7003 int lgth=_time_steps.size();
7004 std::vector< std::vector<TypeOfField> > ret(lgth);
7005 for(int i=0;i<lgth;i++)
7006 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7011 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7013 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)
7015 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7018 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7020 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7022 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7024 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7025 ret->_time_steps[i]=(*it)->deepCpy();
7030 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7032 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7033 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7034 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7035 for(std::size_t i=0;i<sz;i++)
7037 ret[i]=shallowCpy();
7038 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7040 for(std::size_t i=0;i<sz2;i++)
7042 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7045 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7046 throw INTERP_KERNEL::Exception(oss.str().c_str());
7050 for(std::size_t i=0;i<sz;i++)
7051 for(std::size_t j=0;j<sz2;j++)
7052 ret[i]->_time_steps[j]=ts[j][i];
7056 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7058 _name=field->getName();
7060 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7062 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7063 _infos=arr->getInfoOnComponents();
7066 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7068 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7069 if(_name!=field->getName())
7071 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7072 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7073 throw INTERP_KERNEL::Exception(oss.str().c_str());
7076 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7077 checkThatComponentsMatch(arr->getInfoOnComponents());
7080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7082 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7083 if(getInfo().size()!=compos.size())
7085 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7086 oss << " number of components of element to append (" << compos.size() << ") !";
7087 throw INTERP_KERNEL::Exception(oss.str().c_str());
7091 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7092 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7093 oss << " But compo in input fields are : ";
7094 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7096 throw INTERP_KERNEL::Exception(oss.str().c_str());
7100 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7102 std::size_t sz=_infos.size();
7104 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7106 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7108 if(elt->getInfo().size()!=sz)
7110 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7111 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7112 throw INTERP_KERNEL::Exception(oss.str().c_str());
7117 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7120 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7121 if(!_time_steps.empty())
7122 checkCoherencyOfTinyInfo(field,arr);
7123 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7124 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7125 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7126 copyTinyInfoFrom(field,arr);
7127 _time_steps.push_back(obj);
7130 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7133 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7134 if(!_time_steps.empty())
7135 checkCoherencyOfTinyInfo(field,arr);
7136 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7137 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7138 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7139 copyTinyInfoFrom(field,arr);
7140 _time_steps.push_back(obj);
7143 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7145 int sz=(int)_time_steps.size();
7148 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7149 throw INTERP_KERNEL::Exception(oss.str().c_str());
7151 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7154 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7156 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7157 throw INTERP_KERNEL::Exception(oss.str().c_str());
7163 //= MEDFileFieldMultiTSWithoutSDA
7165 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)
7167 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7170 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7174 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7179 * \param [in] fieldId field id in C mode
7181 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7182 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7185 catch(INTERP_KERNEL::Exception& e)
7188 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)
7189 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7192 catch(INTERP_KERNEL::Exception& e)
7195 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7197 return new MEDFileField1TSWithoutSDA;
7200 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7203 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7204 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7206 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7209 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7211 return MEDFileField1TSWithoutSDA::TYPE_STR;
7214 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7216 return new MEDFileFieldMultiTSWithoutSDA(*this);
7219 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7221 return new MEDFileFieldMultiTSWithoutSDA;
7225 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7226 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7228 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)
7230 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7231 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7233 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7234 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7237 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7239 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7240 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7242 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7244 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7247 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7249 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7250 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7251 ret->setIteration(i,elt);
7257 //= MEDFileAnyTypeFieldMultiTS
7259 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7263 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
7264 try:MEDFileFieldGlobsReal(fileName)
7266 MEDFileUtilities::CheckFileForRead(fileName);
7267 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7268 _content=BuildContentFrom(fid,fileName);
7271 catch(INTERP_KERNEL::Exception& e)
7276 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7278 med_field_type typcha;
7279 std::vector<std::string> infos;
7282 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7283 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7288 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i);
7293 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i);
7298 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] !";
7299 throw INTERP_KERNEL::Exception(oss.str().c_str());
7302 ret->setDtUnit(dtunit.c_str());
7306 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
7308 med_field_type typcha;
7310 std::vector<std::string> infos;
7311 std::string dtunit,fieldName;
7312 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7313 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7318 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0);
7323 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0);
7328 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] !";
7329 throw INTERP_KERNEL::Exception(oss.str().c_str());
7332 ret->setDtUnit(dtunit.c_str());
7336 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7339 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7340 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7342 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7343 ret->setFileName(fileName);
7344 ret->_content=c; c->incrRef();
7347 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7349 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7350 ret->setFileName(fileName);
7351 ret->_content=c; c->incrRef();
7354 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7357 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7358 try:MEDFileFieldGlobsReal(fileName)
7360 MEDFileUtilities::CheckFileForRead(fileName);
7361 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7362 _content=BuildContentFrom(fid,fileName,fieldName);
7365 catch(INTERP_KERNEL::Exception& e)
7370 //= MEDFileIntFieldMultiTSWithoutSDA
7372 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)
7374 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7377 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7381 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7385 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)
7386 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7389 catch(INTERP_KERNEL::Exception& e)
7393 * \param [in] fieldId field id in C mode
7395 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7396 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7399 catch(INTERP_KERNEL::Exception& e)
7402 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7404 return new MEDFileIntField1TSWithoutSDA;
7407 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7410 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7411 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7413 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7416 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7418 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7421 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7423 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7426 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7428 return new MEDFileIntFieldMultiTSWithoutSDA;
7431 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7433 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7434 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7436 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7438 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7441 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7443 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7444 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7445 ret->setIteration(i,elt);
7451 //= MEDFileAnyTypeFieldMultiTS
7454 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7455 * that has been read from a specified MED file.
7456 * \param [in] fileName - the name of the MED file to read.
7457 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7458 * is to delete this field using decrRef() as it is no more needed.
7459 * \throw If reading the file fails.
7461 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7463 MEDFileUtilities::CheckFileForRead(fileName);
7464 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7465 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName);
7466 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7467 ret->loadGlobals(fid);
7472 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7473 * that has been read from a specified MED file.
7474 * \param [in] fileName - the name of the MED file to read.
7475 * \param [in] fieldName - the name of the field to read.
7476 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7477 * is to delete this field using decrRef() as it is no more needed.
7478 * \throw If reading the file fails.
7479 * \throw If there is no field named \a fieldName in the file.
7481 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7483 MEDFileUtilities::CheckFileForRead(fileName);
7484 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7485 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
7486 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7487 ret->loadGlobals(fid);
7492 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7493 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7495 * \warning this is a shallow copy constructor
7497 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7499 if(!shallowCopyOfContent)
7501 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7502 otherPtr->incrRef();
7503 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7507 _content=other.shallowCpy();
7511 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7513 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7515 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7519 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7521 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7523 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7527 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7529 return contentNotNullBase()->getPflsReallyUsed2();
7532 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7534 return contentNotNullBase()->getLocsReallyUsed2();
7537 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7539 return contentNotNullBase()->getPflsReallyUsedMulti2();
7542 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7544 return contentNotNullBase()->getLocsReallyUsedMulti2();
7547 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7549 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7552 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7554 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7557 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7559 return contentNotNullBase()->getNumberOfTS();
7562 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7564 contentNotNullBase()->eraseEmptyTS();
7567 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7569 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7572 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7574 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7577 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7579 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7585 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7587 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7588 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7593 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7595 return contentNotNullBase()->getIterations();
7598 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7600 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7601 pushBackTimeStep(*it);
7604 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7607 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7608 checkCoherencyOfType(f1ts);
7610 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7611 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7613 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7614 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7615 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7616 _content->pushBackTimeStep(cSafe);
7617 appendGlobs(*f1ts,1e-12);
7620 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7622 contentNotNullBase()->synchronizeNameScope();
7625 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7627 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7630 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7632 return contentNotNullBase()->getPosGivenTime(time,eps);
7635 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7637 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7640 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7642 return contentNotNullBase()->getTypesOfFieldAvailable();
7645 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)
7647 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7650 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7652 return contentNotNullBase()->getName();
7655 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7657 contentNotNullBase()->setName(name);
7660 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7662 return contentNotNullBase()->getDtUnit();
7665 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7667 contentNotNullBase()->setDtUnit(dtUnit);
7670 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7672 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7675 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7677 return contentNotNullBase()->getTimeSteps(ret1);
7680 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7682 return contentNotNullBase()->getMeshName();
7685 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7687 contentNotNullBase()->setMeshName(newMeshName);
7690 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7692 return contentNotNullBase()->changeMeshNames(modifTab);
7695 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7697 return contentNotNullBase()->getInfo();
7700 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7702 return contentNotNullBase()->setInfo(info);
7705 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7707 const std::vector<std::string> ret=getInfo();
7708 return (int)ret.size();
7711 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7713 writeGlobals(fid,*this);
7714 contentNotNullBase()->writeLL(fid,*this);
7718 * Writes \a this field into a MED file specified by its name.
7719 * \param [in] fileName - the MED file name.
7720 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7721 * - 2 - erase; an existing file is removed.
7722 * - 1 - append; same data should not be present in an existing file.
7723 * - 0 - overwrite; same data present in an existing file is overwritten.
7724 * \throw If the field name is not set.
7725 * \throw If no field data is set.
7726 * \throw If \a mode == 1 and the same data is present in an existing file.
7728 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7730 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7731 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7735 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7737 std::ostringstream oss;
7738 contentNotNullBase()->simpleRepr(0,oss,-1);
7739 simpleReprGlobs(oss);
7743 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7746 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7747 ret+=_content->getHeapMemorySize();
7748 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7752 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
7753 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7754 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7756 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7758 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7760 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7761 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7762 std::size_t sz(contentsSplit.size());
7763 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7764 for(std::size_t i=0;i<sz;i++)
7766 ret[i]=shallowCpy();
7767 ret[i]->_content=contentsSplit[i];
7772 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7774 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7775 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7776 ret->_content=_content->deepCpy();
7777 ret->deepCpyGlobs(*this);
7781 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7787 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7788 * \param [in] iteration - the iteration number of a required time step.
7789 * \param [in] order - the iteration order number of required time step.
7790 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7791 * delete this field using decrRef() as it is no more needed.
7792 * \throw If there is no required time step in \a this field.
7794 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7796 int pos=getPosOfTimeStep(iteration,order);
7797 return getTimeStepAtPos(pos);
7801 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7802 * \param [in] time - the time of the time step of interest.
7803 * \param [in] eps - a precision used to compare time values.
7804 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7805 * delete this field using decrRef() as it is no more needed.
7806 * \throw If there is no required time step in \a this field.
7808 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7810 int pos=getPosGivenTime(time,eps);
7811 return getTimeStepAtPos(pos);
7814 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7816 return new MEDFileAnyTypeFieldMultiTSIterator(this);
7819 //= MEDFileFieldMultiTS
7822 * Returns a new empty instance of MEDFileFieldMultiTS.
7823 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7824 * is to delete this field using decrRef() as it is no more needed.
7826 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
7828 return new MEDFileFieldMultiTS;
7832 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
7833 * that has been read from a specified MED file.
7834 * \param [in] fileName - the name of the MED file to read.
7835 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7836 * is to delete this field using decrRef() as it is no more needed.
7837 * \throw If reading the file fails.
7839 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7841 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName);
7842 ret->contentNotNull();//to check that content type matches with \a this type.
7847 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
7848 * that has been read from a specified MED file.
7849 * \param [in] fileName - the name of the MED file to read.
7850 * \param [in] fieldName - the name of the field to read.
7851 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7852 * is to delete this field using decrRef() as it is no more needed.
7853 * \throw If reading the file fails.
7854 * \throw If there is no field named \a fieldName in the file.
7856 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7858 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName);
7859 ret->contentNotNull();//to check that content type matches with \a this type.
7864 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7865 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7867 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
7868 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
7869 * \warning this is a shallow copy constructor
7870 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
7871 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
7872 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7873 * is to delete this field using decrRef() as it is no more needed.
7875 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7877 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
7880 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
7882 return new MEDFileFieldMultiTS(*this);
7885 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
7888 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7889 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
7891 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7895 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
7896 * following the given input policy.
7898 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7899 * By default (true) the globals are deeply copied.
7900 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
7902 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
7904 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
7905 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7908 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
7910 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
7911 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
7912 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
7915 ret=MEDFileIntFieldMultiTS::New();
7917 ret->deepCpyGlobs(*this);
7919 ret->shallowCpyGlobs(*this);
7924 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
7925 * \param [in] pos - a time step id.
7926 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7927 * delete this field using decrRef() as it is no more needed.
7928 * \throw If \a pos is not a valid time step id.
7930 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
7932 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
7935 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
7936 throw INTERP_KERNEL::Exception(oss.str().c_str());
7938 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
7941 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
7942 ret->shallowCpyGlobs(*this);
7945 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
7946 throw INTERP_KERNEL::Exception(oss.str().c_str());
7950 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7951 * mesh entities of a given dimension of the first mesh in MED file.
7952 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7953 * \param [in] type - a spatial discretization of interest.
7954 * \param [in] iteration - the iteration number of a required time step.
7955 * \param [in] order - the iteration order number of required time step.
7956 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7969 * \throw If no field values of the required parameters are available.
7971 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7973 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7974 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7976 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
7977 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7978 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
7979 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7984 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7985 * the top level cells of the first mesh in MED file.
7986 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7987 * \param [in] type - a spatial discretization of interest.
7988 * \param [in] iteration - the iteration number of a required time step.
7989 * \param [in] order - the iteration order number of required time step.
7990 * \param [in] renumPol - specifies how to permute values of the result field according to
7991 * the optional numbers of cells and nodes, if any. The valid values are
7992 * - 0 - do not permute.
7993 * - 1 - permute cells.
7994 * - 2 - permute nodes.
7995 * - 3 - permute cells and nodes.
7997 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7998 * caller is to delete this field using decrRef() as it is no more needed.
7999 * \throw If the MED file is not readable.
8000 * \throw If there is no mesh in the MED file.
8001 * \throw If no field values of the required parameters are available.
8003 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8005 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8006 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8008 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8009 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8010 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8011 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8016 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8018 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8019 * \param [in] type - a spatial discretization of interest.
8020 * \param [in] iteration - the iteration number of a required time step.
8021 * \param [in] order - the iteration order number of required time step.
8022 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8034 * \throw If no field of \a this is lying on \a mesh.
8035 * \throw If no field values of the required parameters are available.
8037 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8039 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8040 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8042 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8043 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8044 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8045 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8050 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8052 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8053 * \param [in] type - a spatial discretization of the new field.
8054 * \param [in] iteration - the iteration number of a required time step.
8055 * \param [in] order - the iteration order number of required time step.
8056 * \param [in] mesh - the supporting mesh.
8057 * \param [in] renumPol - specifies how to permute values of the result field according to
8058 * the optional numbers of cells and nodes, if any. The valid values are
8059 * - 0 - do not permute.
8060 * - 1 - permute cells.
8061 * - 2 - permute nodes.
8062 * - 3 - permute cells and nodes.
8064 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8065 * caller is to delete this field using decrRef() as it is no more needed.
8066 * \throw If no field of \a this is lying on \a mesh.
8067 * \throw If no field values of the required parameters are available.
8069 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8071 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8072 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8075 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8076 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8077 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8082 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8083 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8084 * This method is useful for MED2 file format when field on different mesh was autorized.
8086 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8088 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8089 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8091 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8092 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8093 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8094 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8099 * Returns values and a profile of the field of a given type, of a given time step,
8100 * lying on a given support.
8101 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8102 * \param [in] type - a spatial discretization of the field.
8103 * \param [in] iteration - the iteration number of a required time step.
8104 * \param [in] order - the iteration order number of required time step.
8105 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8106 * \param [in] mesh - the supporting mesh.
8107 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8108 * field of interest lies on. If the field lies on all entities of the given
8109 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8110 * using decrRef() as it is no more needed.
8111 * \param [in] glob - the global data storing profiles and localization.
8112 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8113 * field. The caller is to delete this array using decrRef() as it is no more needed.
8114 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8115 * \throw If no field of \a this is lying on \a mesh.
8116 * \throw If no field values of the required parameters are available.
8118 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8120 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8121 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8123 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8124 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8125 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8128 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8130 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8132 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8133 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8135 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 !");
8139 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8141 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8143 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8144 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8146 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 !");
8151 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8152 * the given field is checked if its elements are sorted suitable for writing to MED file
8153 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8154 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8155 * \param [in] field - the field to add to \a this.
8156 * \throw If the name of \a field is empty.
8157 * \throw If the data array of \a field is not set.
8158 * \throw If existing time steps have different name or number of components than \a field.
8159 * \throw If the underlying mesh of \a field has no name.
8160 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8162 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8164 const DataArrayDouble *arr=0;
8166 arr=field->getArray();
8167 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8171 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8172 * a given dimension of a given mesh are used as the support of the given field.
8173 * Elements of the given mesh must be sorted suitable for writing to MED file.
8174 * Order of underlying mesh entities of the given field specified by \a profile parameter
8175 * is not prescribed; this method permutes field values to have them sorted by element
8176 * type as required for writing to MED file.
8177 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8178 * \param [in] field - the field to add to \a this.
8179 * \param [in] mesh - the supporting mesh of \a field.
8180 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8181 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8182 * \throw If either \a field or \a mesh or \a profile has an empty name.
8183 * \throw If existing time steps have different name or number of components than \a field.
8184 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8185 * \throw If the data array of \a field is not set.
8186 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8188 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8190 const DataArrayDouble *arr=0;
8192 arr=field->getArray();
8193 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8196 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8198 _content=new MEDFileFieldMultiTSWithoutSDA;
8201 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8202 try:MEDFileAnyTypeFieldMultiTS(fileName)
8205 catch(INTERP_KERNEL::Exception& e)
8208 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8209 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8212 catch(INTERP_KERNEL::Exception& e)
8215 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8219 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)
8221 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8224 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8226 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8229 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)
8231 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8234 //= MEDFileAnyTypeFieldMultiTSIterator
8236 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8241 _nb_iter=fmts->getNumberOfTS();
8245 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8249 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8251 if(_iter_id<_nb_iter)
8253 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8255 return fmts->getTimeStepAtPos(_iter_id++);
8263 //= MEDFileIntFieldMultiTS
8266 * Returns a new empty instance of MEDFileFieldMultiTS.
8267 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8268 * is to delete this field using decrRef() as it is no more needed.
8270 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8272 return new MEDFileIntFieldMultiTS;
8276 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8277 * that has been read from a specified MED file.
8278 * \param [in] fileName - the name of the MED file to read.
8279 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8280 * is to delete this field using decrRef() as it is no more needed.
8281 * \throw If reading the file fails.
8283 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8285 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName);
8286 ret->contentNotNull();//to check that content type matches with \a this type.
8291 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8292 * that has been read from a specified MED file.
8293 * \param [in] fileName - the name of the MED file to read.
8294 * \param [in] fieldName - the name of the field to read.
8295 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8296 * is to delete this field using decrRef() as it is no more needed.
8297 * \throw If reading the file fails.
8298 * \throw If there is no field named \a fieldName in the file.
8300 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8302 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName);
8303 ret->contentNotNull();//to check that content type matches with \a this type.
8308 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8309 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8311 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8312 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8313 * \warning this is a shallow copy constructor
8314 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8315 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8316 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8317 * is to delete this field using decrRef() as it is no more needed.
8319 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8321 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8325 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8326 * following the given input policy.
8328 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8329 * By default (true) the globals are deeply copied.
8330 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8332 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8334 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8335 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8338 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8340 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8341 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8342 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8345 ret=MEDFileFieldMultiTS::New();
8347 ret->deepCpyGlobs(*this);
8349 ret->shallowCpyGlobs(*this);
8353 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8355 return new MEDFileIntFieldMultiTS(*this);
8358 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8361 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8362 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8364 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8368 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8369 * mesh entities of a given dimension of the first mesh in MED file.
8370 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8371 * \param [in] type - a spatial discretization of interest.
8372 * \param [in] iteration - the iteration number of a required time step.
8373 * \param [in] order - the iteration order number of required time step.
8374 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8375 * \param [out] arrOut - the DataArrayInt containing values of field.
8376 * \param [in] renumPol - specifies how to permute values of the result field according to
8377 * the optional numbers of cells and nodes, if any. The valid values are
8378 * - 0 - do not permute.
8379 * - 1 - permute cells.
8380 * - 2 - permute nodes.
8381 * - 3 - permute cells and nodes.
8383 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8384 * caller is to delete this field using decrRef() as it is no more needed.
8385 * \throw If the MED file is not readable.
8386 * \throw If there is no mesh in the MED file.
8387 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8388 * \throw If no field values of the required parameters are available.
8390 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, 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::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8396 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8397 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,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
8404 * the top level cells of the first mesh in MED file.
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] renumPol - specifies how to permute values of the result field according to
8411 * the optional numbers of cells and nodes, if any. The valid values are
8412 * - 0 - do not permute.
8413 * - 1 - permute cells.
8414 * - 2 - permute nodes.
8415 * - 3 - permute cells and nodes.
8417 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8418 * caller is to delete this field using decrRef() as it is no more needed.
8419 * \throw If the MED file is not readable.
8420 * \throw If there is no mesh in the MED file.
8421 * \throw If no field values of the required parameters are available.
8423 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8425 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8426 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8428 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8429 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8430 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8431 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8436 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8438 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8439 * \param [in] type - a spatial discretization of interest.
8440 * \param [in] iteration - the iteration number of a required time step.
8441 * \param [in] order - the iteration order number of required time step.
8442 * \param [out] arrOut - the DataArrayInt containing values of field.
8443 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8444 * \param [in] mesh - the supporting mesh.
8445 * \param [in] renumPol - specifies how to permute values of the result field according to
8446 * the optional numbers of cells and nodes, if any. The valid values are
8447 * - 0 - do not permute.
8448 * - 1 - permute cells.
8449 * - 2 - permute nodes.
8450 * - 3 - permute cells and nodes.
8452 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8453 * caller is to delete this field using decrRef() as it is no more needed.
8454 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
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, int meshDimRelToMax, const MEDFileMesh *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("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8464 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8465 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8466 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8471 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8473 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8474 * \param [in] type - a spatial discretization of the new field.
8475 * \param [in] iteration - the iteration number of a required time step.
8476 * \param [in] order - the iteration order number of required time step.
8477 * \param [in] mesh - the supporting mesh.
8478 * \param [out] arrOut - the DataArrayInt containing values of field.
8479 * \param [in] renumPol - specifies how to permute values of the result field according to
8480 * the optional numbers of cells and nodes, if any. The valid values are
8481 * - 0 - do not permute.
8482 * - 1 - permute cells.
8483 * - 2 - permute nodes.
8484 * - 3 - permute cells and nodes.
8486 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8487 * caller is to delete this field using decrRef() as it is no more needed.
8488 * \throw If no field of \a this is lying on \a mesh.
8489 * \throw If no field values of the required parameters are available.
8491 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8493 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8494 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8496 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8497 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8498 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8499 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8504 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8505 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8506 * This method is useful for MED2 file format when field on different mesh was autorized.
8508 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8510 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8511 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8513 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8514 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8515 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8516 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8521 * Returns values and a profile of the field of a given type, of a given time step,
8522 * lying on a given support.
8523 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8524 * \param [in] type - a spatial discretization of the field.
8525 * \param [in] iteration - the iteration number of a required time step.
8526 * \param [in] order - the iteration order number of required time step.
8527 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8528 * \param [in] mesh - the supporting mesh.
8529 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8530 * field of interest lies on. If the field lies on all entities of the given
8531 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8532 * using decrRef() as it is no more needed.
8533 * \param [in] glob - the global data storing profiles and localization.
8534 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8535 * field. The caller is to delete this array using decrRef() as it is no more needed.
8536 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8537 * \throw If no field of \a this is lying on \a mesh.
8538 * \throw If no field values of the required parameters are available.
8540 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8542 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8543 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8545 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8546 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8547 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8551 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8552 * \param [in] pos - a time step id.
8553 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8554 * delete this field using decrRef() as it is no more needed.
8555 * \throw If \a pos is not a valid time step id.
8557 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8559 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8562 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8563 throw INTERP_KERNEL::Exception(oss.str().c_str());
8565 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8568 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8569 ret->shallowCpyGlobs(*this);
8572 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8573 throw INTERP_KERNEL::Exception(oss.str().c_str());
8577 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8578 * the given field is checked if its elements are sorted suitable for writing to MED file
8579 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8580 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8581 * \param [in] field - the field to add to \a this.
8582 * \throw If the name of \a field is empty.
8583 * \throw If the data array of \a field is not set.
8584 * \throw If existing time steps have different name or number of components than \a field.
8585 * \throw If the underlying mesh of \a field has no name.
8586 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8588 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8590 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8594 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8595 * a given dimension of a given mesh are used as the support of the given field.
8596 * Elements of the given mesh must be sorted suitable for writing to MED file.
8597 * Order of underlying mesh entities of the given field specified by \a profile parameter
8598 * is not prescribed; this method permutes field values to have them sorted by element
8599 * type as required for writing to MED file.
8600 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8601 * \param [in] field - the field to add to \a this.
8602 * \param [in] mesh - the supporting mesh of \a field.
8603 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8604 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8605 * \throw If either \a field or \a mesh or \a profile has an empty name.
8606 * \throw If existing time steps have different name or number of components than \a field.
8607 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8608 * \throw If the data array of \a field is not set.
8609 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8611 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8613 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8616 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8618 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8620 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8621 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8623 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 !");
8627 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8629 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8631 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8632 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8634 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 !");
8638 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8640 _content=new MEDFileIntFieldMultiTSWithoutSDA;
8643 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8647 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8648 try:MEDFileAnyTypeFieldMultiTS(fileName)
8651 catch(INTERP_KERNEL::Exception& e)
8654 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8655 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8658 catch(INTERP_KERNEL::Exception& e)
8661 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8663 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8668 MEDFileFields *MEDFileFields::New()
8670 return new MEDFileFields;
8673 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8675 return new MEDFileFields(fileName);
8678 std::size_t MEDFileFields::getHeapMemorySize() const
8680 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8681 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8682 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8683 ret+=(*it)->getHeapMemorySize();
8684 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8687 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8689 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8691 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8693 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8694 ret->_fields[i]=(*it)->deepCpy();
8696 ret->deepCpyGlobs(*this);
8700 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8702 return new MEDFileFields(*this);
8706 * 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
8707 * 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.
8708 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8710 * \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.
8711 * \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.
8713 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8715 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8717 std::set< std::pair<int,int> > s;
8718 bool firstShot=true;
8719 areThereSomeForgottenTS=false;
8720 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8722 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8724 std::vector< std::pair<int,int> > v=(*it)->getIterations();
8725 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8727 { s=s1; firstShot=false; }
8730 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8732 areThereSomeForgottenTS=true;
8736 std::vector< std::pair<int,int> > ret;
8737 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8741 int MEDFileFields::getNumberOfFields() const
8743 return _fields.size();
8746 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8748 std::vector<std::string> ret(_fields.size());
8750 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8752 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8755 ret[i]=f->getName();
8759 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8760 throw INTERP_KERNEL::Exception(oss.str().c_str());
8766 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8768 std::vector<std::string> ret;
8769 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8771 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8773 ret.push_back(cur->getMeshName());
8778 std::string MEDFileFields::simpleRepr() const
8780 std::ostringstream oss;
8781 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8786 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8788 int nbOfFields=getNumberOfFields();
8789 std::string startLine(bkOffset,' ');
8790 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8792 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8794 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8797 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8801 oss << startLine << " - not defined !" << std::endl;
8805 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8807 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8808 std::string chapter(17,'0'+i);
8809 oss << startLine << chapter << std::endl;
8812 cur->simpleRepr(bkOffset+2,oss,i);
8816 oss << startLine << " - not defined !" << std::endl;
8818 oss << startLine << chapter << std::endl;
8820 simpleReprGlobs(oss);
8823 MEDFileFields::MEDFileFields()
8827 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
8828 try:MEDFileFieldGlobsReal(fileName)
8830 MEDFileUtilities::CheckFileForRead(fileName);
8831 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
8832 int nbFields=MEDnField(fid);
8833 _fields.resize(nbFields);
8834 med_field_type typcha;
8835 for(int i=0;i<nbFields;i++)
8837 std::vector<std::string> infos;
8838 std::string fieldName,dtunit;
8839 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
8844 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8849 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8854 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] !";
8855 throw INTERP_KERNEL::Exception(oss.str().c_str());
8859 loadAllGlobals(fid);
8861 catch(INTERP_KERNEL::Exception& e)
8866 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8869 writeGlobals(fid,*this);
8870 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8872 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
8875 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
8876 throw INTERP_KERNEL::Exception(oss.str().c_str());
8878 elt->writeLL(fid,*this);
8882 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8884 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8885 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8889 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
8891 std::vector<std::string> ret;
8892 std::set<std::string> ret2;
8893 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8895 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8896 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8897 if(ret2.find(*it2)==ret2.end())
8899 ret.push_back(*it2);
8906 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
8908 std::vector<std::string> ret;
8909 std::set<std::string> ret2;
8910 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8912 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8913 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8914 if(ret2.find(*it2)==ret2.end())
8916 ret.push_back(*it2);
8923 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
8925 std::vector<std::string> ret;
8926 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8928 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8929 ret.insert(ret.end(),tmp.begin(),tmp.end());
8934 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
8936 std::vector<std::string> ret;
8937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8939 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8940 ret.insert(ret.end(),tmp.begin(),tmp.end());
8945 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8947 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8948 (*it)->changePflsRefsNamesGen2(mapOfModif);
8951 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8953 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8954 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8957 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
8959 _fields.resize(newSize);
8962 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
8964 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
8968 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8971 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
8972 _fields.push_back(field->getContent());
8973 appendGlobs(*field,1e-12);
8976 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8979 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
8980 if(i>=(int)_fields.size())
8981 _fields.resize(i+1);
8982 _fields[i]=field->getContent();
8983 appendGlobs(*field,1e-12);
8986 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
8988 destroyFieldsAtPos(&i,&i+1);
8991 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
8993 std::vector<bool> b(_fields.size(),true);
8994 for(const int *i=startIds;i!=endIds;i++)
8996 if(*i<0 || *i>=(int)_fields.size())
8998 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
8999 throw INTERP_KERNEL::Exception(oss.str().c_str());
9003 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9005 for(std::size_t i=0;i<_fields.size();i++)
9007 fields[j++]=_fields[i];
9011 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9013 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9014 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9015 std::vector<bool> b(_fields.size(),true);
9017 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9019 if(k<0 || k>=(int)_fields.size())
9021 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9022 throw INTERP_KERNEL::Exception(oss.str().c_str());
9026 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9028 for(std::size_t i=0;i<_fields.size();i++)
9030 fields[j++]=_fields[i];
9034 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9037 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9039 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9041 ret=cur->changeMeshNames(modifTab) || ret;
9047 * \param [in] meshName the name of the mesh that will be renumbered.
9048 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9049 * This code corresponds to the distribution of types in the corresponding mesh.
9050 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9051 * \param [in] renumO2N the old to new renumber array.
9052 * \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
9055 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9058 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9060 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9063 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9069 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9071 if(i<0 || i>=(int)_fields.size())
9073 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9074 throw INTERP_KERNEL::Exception(oss.str().c_str());
9076 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9079 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9080 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9081 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9083 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9085 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9088 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9089 throw INTERP_KERNEL::Exception(oss.str().c_str());
9091 ret->shallowCpyGlobs(*this);
9096 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9097 * This method is accessible in python using __getitem__ with a list in input.
9098 * \return a new object that the caller should deal with.
9100 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9102 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9103 std::size_t sz=std::distance(startIds,endIds);
9104 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9106 for(const int *i=startIds;i!=endIds;i++,j++)
9108 if(*i<0 || *i>=(int)_fields.size())
9110 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9111 throw INTERP_KERNEL::Exception(oss.str().c_str());
9113 fields[j]=_fields[*i];
9115 ret->_fields=fields;
9119 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9121 return getFieldAtPos(getPosFromFieldName(fieldName));
9125 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9126 * This method can be seen as a filter applied on \a this, that returns an object containing
9127 * 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
9128 * shallow copied from \a this.
9130 * \param [in] meshName - the name of the mesh on w
9131 * \return a new object that the caller should deal with.
9133 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9135 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9136 ret->shallowCpyOnlyUsedGlobs(*this);
9137 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9139 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9142 if(cur->getMeshName()==meshName)
9145 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9146 ret->_fields.push_back(cur2);
9153 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9154 * Input time steps are specified using a pair of integer (iteration, order).
9155 * 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,
9156 * but for each multitimestep only the time steps in \a timeSteps are kept.
9157 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9159 * The returned object points to shallow copy of elements in \a this.
9161 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9162 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9163 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9165 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9167 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9168 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9170 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9173 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9174 ret->_fields.push_back(elt);
9176 ret->shallowCpyOnlyUsedGlobs(*this);
9181 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9183 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9185 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9186 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9188 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9191 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9192 if(elt->getNumberOfTS()!=0)
9193 ret->_fields.push_back(elt);
9195 ret->shallowCpyOnlyUsedGlobs(*this);
9199 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9201 return new MEDFileFieldsIterator(this);
9204 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9206 std::string tmp(fieldName);
9207 std::vector<std::string> poss;
9208 for(std::size_t i=0;i<_fields.size();i++)
9210 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9213 std::string fname(f->getName());
9217 poss.push_back(fname);
9220 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9221 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9223 throw INTERP_KERNEL::Exception(oss.str().c_str());
9226 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9231 _nb_iter=fs->getNumberOfFields();
9235 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9239 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9241 if(_iter_id<_nb_iter)
9243 MEDFileFields *fs(_fs);
9245 return fs->getFieldAtPos(_iter_id++);