1 // Copyright (C) 2007-2012 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 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
44 return new MEDFileFieldLoc(fid,locName);
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
49 return new MEDFileFieldLoc(fid,id);
52 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)
54 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
57 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
59 med_geometry_type geotype;
60 med_geometry_type sectiongeotype;
62 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
63 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
64 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
65 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
66 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
67 _nb_node_per_cell=cm.getNumberOfNodes();
68 _ref_coo.resize(_dim*_nb_node_per_cell);
69 _gs_coo.resize(_dim*_nb_gauss_pt);
70 _w.resize(_nb_gauss_pt);
71 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
74 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
76 med_geometry_type geotype;
77 med_geometry_type sectiongeotype;
79 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
80 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
81 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
82 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
84 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
85 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
86 _nb_node_per_cell=cm.getNumberOfNodes();
87 _ref_coo.resize(_dim*_nb_node_per_cell);
88 _gs_coo.resize(_dim*_nb_gauss_pt);
89 _w.resize(_nb_gauss_pt);
90 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
93 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
94 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),
97 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
98 _dim=cm.getDimension();
99 _nb_node_per_cell=cm.getNumberOfNodes();
100 _nb_gauss_pt=_w.size();
103 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
105 static const char OFF7[]="\n ";
106 oss << "\"" << _name << "\"" << OFF7;
107 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
108 oss << "Dimension=" << _dim << OFF7;
109 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
110 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
111 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
112 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
113 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
116 void MEDFileFieldLoc::setName(const char *name)
121 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
123 if(_name!=other._name)
127 if(_nb_gauss_pt!=other._nb_gauss_pt)
129 if(_nb_node_per_cell!=other._nb_node_per_cell)
131 if(_geo_type!=other._geo_type)
133 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
135 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
137 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
143 void MEDFileFieldLoc::writeLL(med_idt fid) const
145 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);
148 std::string MEDFileFieldLoc::repr() const
150 std::ostringstream oss; oss.precision(15);
151 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
152 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
153 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
154 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
155 oss << "\n - Ref coords are : ";
156 int sz=_ref_coo.size();
159 int nbOfTuples=sz/_dim;
160 for(int i=0;i<nbOfTuples;i++)
163 for(int j=0;j<_dim;j++)
164 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
169 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
170 oss << "\n - Gauss coords in reference element : ";
174 int nbOfTuples=sz/_dim;
175 for(int i=0;i<nbOfTuples;i++)
178 for(int j=0;j<_dim;j++)
179 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
184 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
185 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
189 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
191 _type=field->getTypeOfField();
192 const DataArrayDouble *da=field->getArray();
198 getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
199 _end=_start+nbOfCells;
205 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
206 const int *arrPtr=arr->getConstPointer();
207 getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
208 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
214 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
215 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
216 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
218 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
219 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
220 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
221 const int *dai2Ptr=dai2->getConstPointer();
222 int nbi=gsLoc.getWeights().size();
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
224 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
225 const int *da3Ptr=da3->getConstPointer();
226 if(da3->getNumberOfTuples()!=nbOfCells)
227 {//profile : for gauss even in NoProfile !!!
228 std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
230 da3->setName(_profile.c_str());
231 glob.appendProfile(da3);
233 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
234 _nval=da3->getNbOfElems();
235 da4->alloc(_nval*nbi,1);
236 int *da4Ptr=da4->getPointer();
237 for(int i=0;i<_nval;i++)
239 int ref=dai2Ptr[offset+da3Ptr[i]];
240 for(int j=0;j<nbi;j++)
243 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
244 _localization=oss2.str();
245 getArray()->setContigPartOfSelectedValues(_start,da,da4);
246 _end=_start+_nval*nbi;
247 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
251 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
257 * Leaf method of field with profile assignement.
258 * @param pflName input containing name of profile if any. 0 if no profile.
259 * @param multiTypePfl input containing the profile array \b including \b all \b types. This array is usefull only for GAUSS_NE.
260 * @param idsInPfl input containing the ids in the profile 'multiTypePfl' concerning the current geo type.
262 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
268 _type=field->getTypeOfField();
269 const DataArrayDouble *da=field->getArray();
275 _nval=idsInPfl->getNumberOfTuples();
276 getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
282 _nval=idsInPfl->getNumberOfTuples();
283 getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
289 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
290 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
291 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples());
292 arr3->computeOffsets2();
293 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
294 int trueNval=tmp->getNumberOfTuples();
295 _nval=idsInPfl->getNumberOfTuples();
296 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
297 _end=_start+trueNval;
302 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for profiles on gauss points !");
305 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
310 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
313 _nval=field->getArray()->getNumberOfTuples();
314 getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
319 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
321 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
324 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
326 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
329 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
331 return new MEDFileFieldPerMeshPerTypePerDisc(other);
334 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
335 try:_type(atype),_father(fath)
338 catch(INTERP_KERNEL::Exception& e)
343 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
347 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)
351 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
352 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
356 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
361 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
363 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
364 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
365 std::string fieldName=getName();
366 std::string meshName=getMeshName();
367 int iteration=getIteration();
368 int order=getOrder();
369 TypeOfField type=getType();
370 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
372 med_geometry_type mgeoti;
373 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
374 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
375 pflname,&profilesize,locname,&nbi);
376 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
377 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
379 _end=start+_nval*nbi;
381 if(type==ON_CELLS && !_localization.empty())
383 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
384 setType(ON_GAUSS_PT);
387 setType(ON_GAUSS_NE);
388 _localization.clear();
393 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
395 std::string fieldName=getName();
396 std::string meshName=getMeshName();
397 int iteration=getIteration();
398 int order=getOrder();
399 TypeOfField type=getType();
400 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
401 med_geometry_type mgeoti;
402 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
403 DataArrayDouble *arr=getArray();
404 double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
409 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
410 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
415 INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
416 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
417 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
418 std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
422 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
427 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
429 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
431 int delta=_end-_start;
432 _start=newValueOfStart;
436 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
438 return _father->getIteration();
441 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
443 return _father->getOrder();
446 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
448 return _father->getTime();
451 std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
453 return _father->getName();
456 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
458 return _father->getMeshName();
461 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
463 const char startLine[]=" ## ";
464 std::string startLine2(bkOffset,' ');
465 startLine2+=startLine;
466 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
467 oss << startLine2 << "Localization #" << id << "." << std::endl;
468 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
470 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
471 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
472 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
475 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
480 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
485 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
490 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
492 return _father->getGeoType();
495 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
497 return _father->getNumberOfComponents();
500 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
505 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
507 return _father->getArray();
510 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
512 const MEDFileFieldPerMeshPerType *fath=_father;
513 return fath->getArray();
516 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
518 return _father->getInfo();
521 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
526 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
531 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
533 return _localization;
536 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
538 _localization=newLocName;
541 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
543 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
545 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
547 _profile=(*it2).second;
553 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
555 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
557 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
559 _localization=(*it2).second;
565 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
569 dads.push_back(std::pair<int,int>(_start,_end));
570 geoTypes.push_back(getGeoType());
575 pfls.push_back(glob->getProfile(_profile.c_str()));
577 if(_localization.empty())
581 locs.push_back(glob->getLocalizationId(_localization.c_str()));
585 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
587 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));
591 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
593 TypeOfField type=getType();
594 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
595 med_geometry_type mgeoti;
596 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
597 const DataArrayDouble *arr=getArray();
598 const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
599 MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
600 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
601 reinterpret_cast<const unsigned char*>(locToWrite));
604 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
609 dad.first=_start; dad.second=_end;
613 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
614 * This code corresponds to the distribution of types in the corresponding mesh.
615 * \param [out] ptToFill memory zone where the output will be stored.
616 * \return the size of data pushed into output param \a ptToFill
618 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
621 std::ostringstream oss;
622 std::size_t nbOfType=codeOfMesh.size()/3;
623 std::size_t found=-1;
624 for(std::size_t i=0;i<nbOfType && found==-1;i++)
625 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
629 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
630 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
631 throw INTERP_KERNEL::Exception(oss.str().c_str());
636 if(_nval!=codeOfMesh[3*found+1])
638 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
639 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
640 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
641 throw INTERP_KERNEL::Exception(oss.str().c_str());
643 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
648 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
649 if(pfl->getNumberOfTuples()!=_nval)
651 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
652 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
654 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
655 throw INTERP_KERNEL::Exception(oss.str().c_str());
657 int offset=codeOfMesh[3*found+2];
658 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
660 if(*pflId<codeOfMesh[3*found+1])
661 *work++=offset+*pflId;
667 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
669 for(int i=_start;i<_end;i++)
674 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
685 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
689 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
692 std::map<std::pair<std::string,TypeOfField>,int> m;
693 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
694 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
695 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
696 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
698 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
699 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
704 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
706 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
707 * \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.
708 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
709 * \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)
710 * \param [in,out] glob if necessary by the method, new profiles can be added to it
711 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
712 * \param [out] result All new entries will be appended on it.
713 * \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 !)
715 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
716 const DataArrayInt *explicitIdsInMesh,
717 const std::vector<int>& newCode,
718 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
719 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
721 if(entriesOnSameDisc.empty())
723 TypeOfField type=entriesOnSameDisc[0]->getType();
724 int szEntities=0,szTuples=0;
725 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
726 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
727 int nbi=szTuples/szEntities;
728 if(szTuples%szEntities!=0)
729 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
730 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
731 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
732 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
733 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
734 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
735 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
736 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
738 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
740 int startOfEltIdOfChunk=(*it)->_start;
741 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
742 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
743 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
745 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
746 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
748 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
749 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
751 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
752 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
753 std::set<int> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
754 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
756 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
758 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
759 arrPart->renumberInPlace(renumTupleIds->begin());
760 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
762 std::set<int>::const_iterator idIt=diffVals.begin();
763 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
765 for(std::size_t i=0;i<diffVals.size();i++,idIt++)
767 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
768 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
769 int nbEntityElts=subIds->getNumberOfTuples();
771 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
772 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
776 result.push_back(eltToAdd);
777 offset2+=nbEntityElts*nbi;
779 ret=ret || li.empty();
784 * \param [in] typeF type of field of new chunk
785 * \param [in] geoType the geometric type of the chunk
786 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
787 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
788 * \param [in] nbi number of integration points
789 * \param [in] offset The offset in the **global array of data**.
790 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
791 * to the new chunk to create.
792 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
793 * \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
794 * and corresponding entry erased from \a entriesOnSameDisc.
795 * \return a newly allocated chunk
797 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
798 bool isPfl, int nbi, int offset,
799 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
800 MEDFileFieldGlobsReal& glob,
801 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
803 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
804 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
805 for(;it!=entriesOnSameDisc.end();it++)
807 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
810 if((*it)->_profile.empty())
813 if(!(*it)->_profile.empty())
815 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
816 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
821 if(it==entriesOnSameDisc.end())
824 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
826 ret->_loc_id=(int)geoType;
827 ret->_nval=nbMeshEntities;
829 ret->_end=ret->_start+ret->_nval*nbi;
832 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
833 glob.appendProfile(idsOfMeshElt);
834 ret->_profile=idsOfMeshElt->getName();
836 //tony treatment of localization
842 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
843 ret->_loc_id=(int)geoType;
844 ret->setNewStart(offset);
845 entriesOnSameDisc.erase(it);
851 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
853 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
856 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
858 return new MEDFileFieldPerMeshPerType(fath,geoType);
861 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
863 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
864 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
865 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
868 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
870 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
874 std::string pflName(locIds->getName());
876 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignFieldProfile : existing profile with empty name !");
877 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
878 std::ostringstream oss; oss << pflName << "_" << cm.getRepr();
879 locIds->setName(oss.str().c_str());
880 glob.appendProfile(locIds);
882 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
883 _field_pm_pt_pd[*it]->assignFieldProfile(start,oss.str().c_str(),multiTypePfl,idsInPfl,field,mesh,glob);
887 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
888 _field_pm_pt_pd[*it]->assignFieldProfile(start,0,multiTypePfl,idsInPfl,field,mesh,glob);
892 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
894 _field_pm_pt_pd.resize(1);
895 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
896 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
899 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
901 std::string pflName(pfl->getName());
903 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : existing profile with empty name !");
904 std::ostringstream oss; oss << pflName << "_NODE";
905 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
906 pfl2->setName(oss.str().c_str());
907 glob.appendProfile(pfl2);
909 _field_pm_pt_pd.resize(1);
910 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
911 _field_pm_pt_pd[0]->assignFieldProfile(start,oss.str().c_str(),pfl,pfl2,field,0,glob);//mesh is not requested so 0 is send.
914 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
916 TypeOfField type=field->getTypeOfField();
917 if(type!=ON_GAUSS_PT)
919 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
920 int sz=_field_pm_pt_pd.size();
922 for(int j=0;j<sz && !found;j++)
924 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
926 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
932 _field_pm_pt_pd.resize(sz+1);
933 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
935 std::vector<int> ret(1,0);
940 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
942 std::vector<int> ret3(sz2);
944 for(int i=0;i<sz2;i++)
946 int sz=_field_pm_pt_pd.size();
947 int locIdToFind=ret2[i];
949 for(int j=0;j<sz && !found;j++)
951 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
953 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
960 _field_pm_pt_pd.resize(sz+1);
961 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
969 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
971 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
972 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
974 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
975 const DataArrayInt *da=disc2->getArrayOfDiscIds();
976 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
977 std::set<int> retTmp=da2->getDifferentValues();
978 if(retTmp.find(-1)!=retTmp.end())
979 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
980 std::vector<int> ret(retTmp.begin(),retTmp.end());
984 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
986 TypeOfField type=field->getTypeOfField();
987 if(type!=ON_GAUSS_PT)
989 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
990 int sz=_field_pm_pt_pd.size();
992 for(int j=0;j<sz && !found;j++)
994 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
996 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1002 _field_pm_pt_pd.resize(sz+1);
1003 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1005 std::vector<int> ret(1,0);
1010 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1011 int sz2=ret2.size();
1012 std::vector<int> ret3(sz2);
1014 for(int i=0;i<sz2;i++)
1016 int sz=_field_pm_pt_pd.size();
1017 int locIdToFind=ret2[i];
1019 for(int j=0;j<sz && !found;j++)
1021 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1023 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1030 _field_pm_pt_pd.resize(sz+1);
1031 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1039 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1041 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1042 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1044 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1045 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1046 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1047 std::set<int> retTmp=da2->getDifferentValues();
1048 if(retTmp.find(-1)!=retTmp.end())
1049 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1050 std::vector<int> ret(retTmp.begin(),retTmp.end());
1054 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1059 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1061 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1062 int curDim=(int)cm.getDimension();
1063 dim=std::max(dim,curDim);
1066 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1068 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1070 (*it)->fillTypesOfFieldAvailable(types);
1074 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)
1076 int sz=_field_pm_pt_pd.size();
1077 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1078 for(int i=0;i<sz;i++)
1080 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1084 int MEDFileFieldPerMeshPerType::getIteration() const
1086 return _father->getIteration();
1089 int MEDFileFieldPerMeshPerType::getOrder() const
1091 return _father->getOrder();
1094 double MEDFileFieldPerMeshPerType::getTime() const
1096 return _father->getTime();
1099 std::string MEDFileFieldPerMeshPerType::getName() const
1101 return _father->getName();
1104 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1106 return _father->getMeshName();
1109 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1111 const char startLine[]=" ## ";
1112 std::string startLine2(bkOffset,' ');
1113 std::string startLine3(startLine2);
1114 startLine3+=startLine;
1115 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1117 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1118 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1121 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1122 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1124 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1126 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1128 cur->simpleRepr(bkOffset,oss,i);
1131 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1136 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1138 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1140 globalSz+=(*it)->getNumberOfTuples();
1142 nbOfEntries+=(int)_field_pm_pt_pd.size();
1145 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1151 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1153 return _father->getNumberOfComponents();
1156 DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
1158 return _father->getArray();
1161 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
1163 const MEDFileFieldPerMesh *fath=_father;
1164 return fath->getArray();
1167 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1169 return _father->getInfo();
1172 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1174 std::vector<std::string> ret;
1175 std::set<std::string> ret2;
1176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1178 std::string tmp=(*it1)->getProfile();
1180 if(ret2.find(tmp)==ret2.end())
1189 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1191 std::vector<std::string> ret;
1192 std::set<std::string> ret2;
1193 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1195 std::string tmp=(*it1)->getLocalization();
1196 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1197 if(ret2.find(tmp)==ret2.end())
1206 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1208 std::vector<std::string> ret;
1209 std::set<std::string> ret2;
1210 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1212 std::string tmp=(*it1)->getProfile();
1219 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1221 std::vector<std::string> ret;
1222 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1224 std::string tmp=(*it1)->getLocalization();
1225 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1231 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1233 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1234 (*it1)->changePflsRefsNamesGen(mapOfModif);
1237 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1239 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1240 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1243 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1245 if(_field_pm_pt_pd.empty())
1247 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1248 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1249 throw INTERP_KERNEL::Exception(oss.str().c_str());
1251 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1252 return _field_pm_pt_pd[locId];
1253 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1254 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1255 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1256 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1257 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1260 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1262 if(_field_pm_pt_pd.empty())
1264 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1265 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1266 throw INTERP_KERNEL::Exception(oss.str().c_str());
1268 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1269 return _field_pm_pt_pd[locId];
1270 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1271 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1272 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1273 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1274 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1277 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
1279 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1281 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1282 if(meshDim!=(int)cm.getDimension())
1285 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1286 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1289 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1292 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1294 (*it)->fillValues(i,startEntryId,entries);
1298 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1300 _field_pm_pt_pd=leaves;
1301 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1302 (*it)->setFather(this);
1305 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1309 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1311 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1312 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1313 med_geometry_type mgeoti;
1314 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1315 int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1316 _field_pm_pt_pd.resize(nbProfiles);
1317 for(int i=0;i<nbProfiles;i++)
1319 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1323 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
1326 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1328 (*it)->prepareLoading(fid,pflId+1,start);
1332 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1335 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1337 (*it)->finishLoading(fid,pflId+1,ft);
1341 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1343 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1345 (*it)->copyOptionsFrom(*this);
1346 (*it)->writeLL(fid);
1350 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1355 medfGeoType=typmai3[(int)ikGeoType];
1358 medfGeoType=MED_NONE;
1361 medfGeoType=typmai3[(int)ikGeoType];
1362 return MED_NODE_ELEMENT;
1364 medfGeoType=typmai3[(int)ikGeoType];
1367 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1369 return MED_UNDEF_ENTITY_TYPE;
1372 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
1374 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
1377 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1379 return new MEDFileFieldPerMesh(fath,mesh);
1382 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1384 std::string startLine(bkOffset,' ');
1385 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1386 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1388 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1390 const MEDFileFieldPerMeshPerType *cur=*it;
1392 cur->simpleRepr(bkOffset,oss,i);
1395 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1400 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1402 _mesh_name=mesh->getName();
1403 mesh->getTime(_mesh_iteration,_mesh_order);
1406 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1408 int nbOfTypes=code.size()/3;
1409 bool isProfile=false;
1410 for(int i=0;i<nbOfTypes;i++)
1415 if(idsInPflPerType.empty())
1416 assignFieldNoProfileNoRenum(start,code,field,glob);
1418 assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
1421 assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
1424 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1426 int nbOfTypes=code.size()/3;
1428 for(int i=0;i<nbOfTypes;i++)
1430 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1431 int nbOfCells=code[3*i+1];
1432 int pos=addNewEntryIfNecessary(type);
1433 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
1439 * This method is the most general one. No optimization is done here.
1441 void MEDFileFieldPerMesh::assignFieldProfileGeneral(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1443 int nbOfTypes=code.size()/3;
1444 for(int i=0;i<nbOfTypes;i++)
1446 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1447 int pos=addNewEntryIfNecessary(type);
1448 DataArrayInt *pfl=0;
1450 pfl=idsPerType[code[3*i+2]];
1451 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,field,mesh,glob);
1455 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1457 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1458 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
1461 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1463 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1464 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
1467 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
1469 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1470 (*it)->prepareLoading(fid,start);
1473 void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1475 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1476 (*it)->finishLoading(fid,ft);
1479 void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1481 int nbOfTypes=_field_pm_pt.size();
1482 for(int i=0;i<nbOfTypes;i++)
1484 _field_pm_pt[i]->copyOptionsFrom(*this);
1485 _field_pm_pt[i]->writeLL(fid);
1489 void MEDFileFieldPerMesh::getDimension(int& dim) const
1491 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1492 (*it)->getDimension(dim);
1495 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1497 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1498 (*it)->fillTypesOfFieldAvailable(types);
1501 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)
1503 int sz=_field_pm_pt.size();
1504 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1505 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1506 for(int i=0;i<sz;i++)
1508 types[i]=_field_pm_pt[i]->getGeoType();
1509 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1514 double MEDFileFieldPerMesh::getTime() const
1517 return _father->getTime(tmp1,tmp2);
1520 int MEDFileFieldPerMesh::getIteration() const
1522 return _father->getIteration();
1525 const std::string& MEDFileFieldPerMesh::getDtUnit() const
1527 return _father->getDtUnit();
1530 int MEDFileFieldPerMesh::getOrder() const
1532 return _father->getOrder();
1535 std::string MEDFileFieldPerMesh::getName() const
1537 return _father->getName();
1540 int MEDFileFieldPerMesh::getNumberOfComponents() const
1542 return _father->getNumberOfComponents();
1545 DataArrayDouble *MEDFileFieldPerMesh::getArray()
1547 return _father->getOrCreateAndGetArray();
1550 const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
1552 const MEDFileField1TSWithoutSDA *fath=_father;
1553 return fath->getOrCreateAndGetArray();
1556 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1558 return _father->getInfo();
1562 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1563 * 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.
1564 * It returns 2 output vectors :
1565 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1566 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1567 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1569 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)
1571 int notNullPflsSz=0;
1572 int nbOfArrs=geoTypes.size();
1573 for(int i=0;i<nbOfArrs;i++)
1576 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1577 int nbOfDiffGeoTypes=geoTypes3.size();
1578 code.resize(3*nbOfDiffGeoTypes);
1579 notNullPfls.resize(notNullPflsSz);
1582 for(int i=0;i<nbOfDiffGeoTypes;i++)
1585 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1586 std::vector<const DataArrayInt *> notNullTmp;
1588 notNullTmp.push_back(pfls[j]);
1590 for(;j<nbOfArrs;j++)
1591 if(geoTypes[j]==refType)
1594 notNullTmp.push_back(pfls[j]);
1598 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1599 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1600 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1601 code[3*i]=(int)refType;
1602 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1603 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1604 if(notNullTmp.empty())
1608 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1609 code[3*i+2]=notNullPflsSz++;
1615 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1617 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)
1621 for(int i=0;i<sz;i++)
1625 if(type!=ON_GAUSS_NE)
1626 ret+=dads[i].second-dads[i].first;
1629 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1630 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1635 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1636 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1642 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1644 std::vector<std::string> ret;
1645 std::set<std::string> ret2;
1646 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1648 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1649 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1650 if(ret2.find(*it2)==ret2.end())
1652 ret.push_back(*it2);
1659 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1661 std::vector<std::string> ret;
1662 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1664 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1665 ret.insert(ret.end(),tmp.begin(),tmp.end());
1670 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1672 std::vector<std::string> ret;
1673 std::set<std::string> ret2;
1674 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1676 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1677 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1678 if(ret2.find(*it2)==ret2.end())
1680 ret.push_back(*it2);
1687 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1689 std::vector<std::string> ret;
1690 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1692 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1693 ret.insert(ret.end(),tmp.begin(),tmp.end());
1698 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1700 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1702 if((*it).first==_mesh_name)
1704 _mesh_name=(*it).second;
1711 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1712 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1714 if(_mesh_name!=meshName)
1716 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1717 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1718 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1719 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1720 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1721 DataArrayDouble *arr=getUndergroundDataArrayExt(entries);
1724 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1725 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1727 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1729 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1730 sz+=(*it).second.second-(*it).second.first;
1733 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1735 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1736 ////////////////////
1737 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1738 int *workI2=explicitIdsOldInMesh->getPointer();
1739 int sz1=0,sz2=0,sid=1;
1740 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1741 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1742 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1744 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1745 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1746 int *workI=explicitIdsOldInArr->getPointer();
1747 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1749 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1750 (*itL2)->setLocId(sz2);
1751 (*itL2)->_tmp_work1=(*itL2)->getStart();
1752 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1754 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1756 explicitIdsOldInMesh->reAlloc(sz2);
1757 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1758 ////////////////////
1759 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1760 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1761 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1762 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1764 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1765 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1766 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1768 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1769 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1770 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1772 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1773 int newStart=elt->getLocId();
1774 elt->setLocId((*it)->getGeoType());
1775 elt->setNewStart(newStart);
1776 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1777 entriesKeptNew.push_back(elt);
1778 entriesKeptNew2.push_back(elt);
1780 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1781 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1782 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1783 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1785 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1788 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1790 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1791 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1793 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1794 glob,arr2,otherEntriesNew) || ret;
1798 // Assign new dispatching
1799 assignNewLeaves(otherEntriesNew);
1800 arr->cpyFrom(*arr2);
1804 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1806 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1807 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1808 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1810 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1811 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1812 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1813 for(;it1!=types.end();it1++,it2++)
1815 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1816 elt->setLeaves((*it1).second);
1819 _field_pm_pt=fieldPmPt;
1822 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1824 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1825 (*it)->changePflsRefsNamesGen(mapOfModif);
1828 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1830 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1831 (*it)->changeLocsRefsNamesGen(mapOfModif);
1834 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
1836 if(_field_pm_pt.empty())
1837 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1839 std::vector< std::pair<int,int> > dads;
1840 std::vector<const DataArrayInt *> pfls;
1841 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1842 std::vector<int> locs,code;
1843 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1844 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1845 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1847 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1850 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1851 throw INTERP_KERNEL::Exception(oss.str().c_str());
1854 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1855 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1858 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1860 return finishField(type,glob,dads,locs,mesh,isPfl);
1863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1864 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
1870 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1874 if(nb!=mesh->getNumberOfNodes())
1876 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1877 oss << " nodes in mesh !";
1878 throw INTERP_KERNEL::Exception(oss.str().c_str());
1880 return finishField(type,glob,dads,locs,mesh,isPfl);
1883 return finishField3(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
1887 DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
1889 if(_field_pm_pt.empty())
1890 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1892 std::vector<std::pair<int,int> > dads;
1893 std::vector<const DataArrayInt *> pfls;
1894 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1895 std::vector<int> locs,code;
1896 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1897 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1898 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1900 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1903 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1904 throw INTERP_KERNEL::Exception(oss.str().c_str());
1906 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1907 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1910 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1911 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
1916 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1920 if(nb!=mesh->getNumberOfNodes())
1922 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1923 oss << " nodes in mesh !";
1924 throw INTERP_KERNEL::Exception(oss.str().c_str());
1927 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
1933 DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
1937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1939 (*it)->getSizes(globalSz,nbOfEntries);
1941 entries.resize(nbOfEntries);
1943 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1945 (*it)->fillValues(nbOfEntries,entries);
1947 return _father->getUndergroundDataArray();
1950 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
1952 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1954 if((*it)->getGeoType()==typ)
1955 return (*it)->getLeafGivenLocId(locId);
1957 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
1958 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
1959 oss << "Possiblities are : ";
1960 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1962 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
1963 oss << "\"" << cm2.getRepr() << "\", ";
1965 throw INTERP_KERNEL::Exception(oss.str().c_str());
1968 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
1970 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1972 if((*it)->getGeoType()==typ)
1973 return (*it)->getLeafGivenLocId(locId);
1975 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
1976 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
1977 oss << "Possiblities are : ";
1978 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1980 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
1981 oss << "\"" << cm2.getRepr() << "\", ";
1983 throw INTERP_KERNEL::Exception(oss.str().c_str());
1986 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
1989 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
1990 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
1991 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1993 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
1998 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2003 int ret=std::distance(_field_pm_pt.begin(),it2);
2004 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2009 * 'dads' and 'locs' input parameters have the same number of elements.
2011 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2012 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2013 const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2016 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2017 ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
2018 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2019 const std::vector<std::string>& infos=getInfo();
2020 da->setInfoOnComponents(infos);
2023 if(type==ON_GAUSS_PT)
2026 int nbOfArrs=dads.size();
2027 for(int i=0;i<nbOfArrs;i++)
2029 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2030 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2031 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2032 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2033 di->alloc(nbOfElems,1);
2035 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2036 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2046 * 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.
2047 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2048 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2049 * The order of cells in the returned field is those imposed by the profile.
2051 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2052 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2053 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2054 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2056 if(da->isIdentity())
2058 int nbOfTuples=da->getNumberOfTuples();
2059 if(nbOfTuples==mesh->getNumberOfCells())
2060 return finishField(type,glob,dads,locs,mesh,isPfl);
2062 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,mesh,isPfl);
2064 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2065 m2->setName(mesh->getName());
2072 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2074 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFileFieldGlobsReal *glob,
2075 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2076 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2078 if(da->isIdentity())
2080 int nbOfTuples=da->getNumberOfTuples();
2081 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2082 if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,geoTypes2,dads,locs))//No problem for NORM_ERROR because it is in context of node
2083 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2085 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2086 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2089 if(meshu->getNodalConnectivity()==0)
2091 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
2092 int nb=da->getNbOfElems();
2093 const int *ptr=da->getConstPointer();
2094 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2095 meshuc->allocateCells(nb);
2096 for(int i=0;i<nb;i++)
2097 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2098 meshuc->finishInsertingCells();
2099 ret->setMesh(meshuc);
2100 ret->checkCoherency();
2106 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2108 DataArrayInt *arr2=0;
2109 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2110 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2111 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2112 int nnodes=mesh2->getNumberOfNodes();
2113 if(nnodes==da->getNbOfElems())
2115 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->getConstPointer(),arr2->getConstPointer()+arr2->getNbOfElems());
2116 ret->getArray()->renumberInPlace(da3->getConstPointer());
2117 mesh2->setName(mesh->getName());
2118 ret->setMesh(mesh2);
2124 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishField3 : 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 !!!";
2125 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2126 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2127 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2128 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2129 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2130 throw INTERP_KERNEL::Exception(oss.str().c_str());
2136 * This method is the most light method of field retrieving.
2138 DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2142 pflOut=DataArrayInt::New();
2143 pflOut->alloc(nbOfElems,1);
2148 pflOut=const_cast<DataArrayInt*>(pflIn);
2151 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2152 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2153 const std::vector<std::string>& infos=getInfo();
2154 int nbOfComp=infos.size();
2155 for(int i=0;i<nbOfComp;i++)
2156 da->setInfoOnComponent(i,infos[i].c_str());
2162 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2163 _mesh_csit(meshCsit),_father(fath)
2165 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2166 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2167 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2168 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2170 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2173 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
2174 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2176 nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2179 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
2180 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2183 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2186 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
2187 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2191 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2193 copyTinyInfoFrom(mesh);
2196 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2198 if(id>=(int)_pfls.size())
2200 _pfls[id]=DataArrayInt::New();
2201 int lgth=MEDprofileSizeByName(fid,pflName);
2202 _pfls[id]->setName(pflName);
2203 _pfls[id]->alloc(lgth,1);
2204 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2205 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2208 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2210 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2212 MEDprofileInfo(fid,i+1,pflName,&sz);
2213 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2214 if(i>=(int)_pfls.size())
2216 _pfls[i]=DataArrayInt::New();
2217 _pfls[i]->alloc(sz,1);
2218 _pfls[i]->setName(pflCpp.c_str());
2219 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2220 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2223 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2225 int nbOfPfls=_pfls.size();
2226 for(int i=0;i<nbOfPfls;i++)
2228 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2229 cpy->applyLin(1,1,0);
2230 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2231 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2232 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2235 int nbOfLocs=_locs.size();
2236 for(int i=0;i<nbOfLocs;i++)
2237 _locs[i]->writeLL(fid);
2240 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2242 std::vector<std::string> pfls=getPfls();
2243 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2245 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2248 _pfls.push_back(*it);
2252 int id=std::distance(pfls.begin(),it2);
2253 if(!(*it)->isEqual(*_pfls[id]))
2255 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2256 throw INTERP_KERNEL::Exception(oss.str().c_str());
2260 std::vector<std::string> locs=getLocs();
2261 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2263 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2266 _locs.push_back(*it);
2270 int id=std::distance(locs.begin(),it2);
2271 if(!(*it)->isEqual(*_locs[id],eps))
2273 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2274 throw INTERP_KERNEL::Exception(oss.str().c_str());
2280 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2282 std::vector<std::string> profiles=real.getPflsReallyUsed();
2283 int sz=profiles.size();
2285 for(int i=0;i<sz;i++)
2286 loadProfileInFile(fid,i,profiles[i].c_str());
2288 std::vector<std::string> locs=real.getLocsReallyUsed();
2291 for(int i=0;i<sz;i++)
2292 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2295 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2297 int nProfil=MEDnProfile(fid);
2298 for(int i=0;i<nProfil;i++)
2299 loadProfileInFile(fid,i);
2300 int sz=MEDnLocalization(fid);
2302 for(int i=0;i<sz;i++)
2304 _locs[i]=MEDFileFieldLoc::New(fid,i);
2308 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2310 return new MEDFileFieldGlobs(fname);
2313 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2315 return new MEDFileFieldGlobs;
2318 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2322 MEDFileFieldGlobs::MEDFileFieldGlobs()
2326 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2330 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2332 oss << "Profiles :\n";
2333 std::size_t n=_pfls.size();
2334 for(std::size_t i=0;i<n;i++)
2336 oss << " - #" << i << " ";
2337 const DataArrayInt *pfl=_pfls[i];
2339 oss << "\"" << pfl->getName() << "\"\n";
2344 oss << "Localizations :\n";
2345 for(std::size_t i=0;i<n;i++)
2347 oss << " - #" << i << " ";
2348 const MEDFileFieldLoc *loc=_locs[i];
2350 loc->simpleRepr(oss);
2356 void MEDFileFieldGlobs::setFileName(const char *fileName)
2358 _file_name=fileName;
2361 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2363 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2365 DataArrayInt *elt(*it);
2368 std::string name(elt->getName());
2369 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2371 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2373 elt->setName((*it2).second.c_str());
2381 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2383 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2385 MEDFileFieldLoc *elt(*it);
2388 std::string name(elt->getName());
2389 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2391 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2393 elt->setName((*it2).second.c_str());
2401 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2403 if(locId<0 || locId>=(int)_locs.size())
2404 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2405 return _locs[locId]->getNbOfGaussPtPerCell();
2408 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2410 return getLocalizationFromId(getLocalizationId(locName));
2413 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2415 if(locId<0 || locId>=(int)_locs.size())
2416 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2417 return *_locs[locId];
2420 namespace ParaMEDMEMImpl
2425 LocFinder(const char *loc):_loc(loc) { }
2426 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2434 PflFinder(const std::string& pfl):_pfl(pfl) { }
2435 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2437 const std::string& _pfl;
2441 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2443 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2446 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2447 for(it=_locs.begin();it!=_locs.end();it++)
2448 oss << "\"" << (*it)->getName() << "\", ";
2449 throw INTERP_KERNEL::Exception(oss.str().c_str());
2451 return std::distance(_locs.begin(),it);
2454 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2456 std::string pflNameCpp(pflName);
2457 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2460 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2461 for(it=_pfls.begin();it!=_pfls.end();it++)
2462 oss << "\"" << (*it)->getName() << "\", ";
2463 throw INTERP_KERNEL::Exception(oss.str().c_str());
2468 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2470 if(pflId<0 || pflId>=(int)_pfls.size())
2471 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2472 return _pfls[pflId];
2475 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2477 if(locId<0 || locId>=(int)_locs.size())
2478 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2479 return *_locs[locId];
2482 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2484 return getLocalizationFromId(getLocalizationId(locName));
2487 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2489 std::string pflNameCpp(pflName);
2490 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2493 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2494 for(it=_pfls.begin();it!=_pfls.end();it++)
2495 oss << "\"" << (*it)->getName() << "\", ";
2496 throw INTERP_KERNEL::Exception(oss.str().c_str());
2501 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2503 if(pflId<0 || pflId>=(int)_pfls.size())
2504 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2505 return _pfls[pflId];
2508 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2510 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2512 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2514 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2515 newPfls.push_back(*it);
2520 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2522 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2524 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2526 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2527 newLocs.push_back(*it);
2532 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2534 int sz=_pfls.size();
2535 std::vector<std::string> ret(sz);
2536 for(int i=0;i<sz;i++)
2537 ret[i]=_pfls[i]->getName();
2541 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2543 int sz=_locs.size();
2544 std::vector<std::string> ret(sz);
2545 for(int i=0;i<sz;i++)
2546 ret[i]=_locs[i]->getName();
2550 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2552 std::vector<std::string> v=getPfls();
2553 std::string s(pflName);
2554 return std::find(v.begin(),v.end(),s)!=v.end();
2557 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2559 std::vector<std::string> v=getLocs();
2560 std::string s(locName);
2561 return std::find(v.begin(),v.end(),s)!=v.end();
2564 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2566 std::map<int,std::vector<int> > m;
2568 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2570 const DataArrayInt *tmp=(*it);
2573 m[tmp->getHashCode()].push_back(i);
2576 std::vector< std::vector<int> > ret;
2577 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2579 if((*it2).second.size()>1)
2581 std::vector<int> ret0;
2582 bool equalityOrNot=false;
2583 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2585 std::vector<int>::const_iterator it4=it3; it4++;
2586 for(;it4!=(*it2).second.end();it4++)
2588 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2591 ret0.push_back(*it3);
2592 ret0.push_back(*it4);
2598 ret.push_back(ret0);
2604 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2606 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2609 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2611 std::string name(pfl->getName());
2613 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2614 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2615 if(name==(*it)->getName())
2617 if(!pfl->isEqual(*(*it)))
2619 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2620 throw INTERP_KERNEL::Exception(oss.str().c_str());
2624 _pfls.push_back(pfl);
2627 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)
2629 std::string name(locName);
2631 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2632 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2633 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2634 if((*it)->isName(locName))
2636 if(!(*it)->isEqual(*obj,1e-12))
2638 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2639 throw INTERP_KERNEL::Exception(oss.str().c_str());
2642 _locs.push_back(obj);
2645 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2647 std::vector<std::string> names=getPfls();
2648 return CreateNewNameNotIn("NewPfl_",names);
2651 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2653 std::vector<std::string> names=getLocs();
2654 return CreateNewNameNotIn("NewLoc_",names);
2657 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2659 for(std::size_t sz=0;sz<100000;sz++)
2661 std::ostringstream tryName;
2662 tryName << prefix << sz;
2663 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2664 return tryName.str();
2666 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2669 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2673 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2677 void MEDFileFieldGlobsReal::simpleRepr(std::ostream& oss) const
2679 oss << "Globals information on fields :" << "\n*******************************\n\n";
2680 const MEDFileFieldGlobs *glob=_globals;
2682 glob->simpleRepr(oss);
2684 oss << "NO GLOBAL INFORMATION !\n";
2687 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2691 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2693 _globals=other._globals;
2696 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2698 _globals->appendGlobs(*other._globals,eps);
2701 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2703 _globals->loadProfileInFile(fid,id,pflName);
2706 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
2708 _globals->loadProfileInFile(fid,id);
2711 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2713 _globals->loadGlobals(fid,*this);
2716 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2718 _globals->loadAllGlobals(fid);
2721 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2723 _globals->writeGlobals(fid,opt);
2726 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
2728 return _globals->getPfls();
2731 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
2733 return _globals->getLocs();
2736 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
2738 return _globals->existsPfl(pflName);
2741 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
2743 return _globals->existsLoc(locName);
2746 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2748 return _globals->createNewNameOfPfl();
2751 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2753 return _globals->createNewNameOfLoc();
2756 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
2758 _globals->setFileName(fileName);
2761 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
2763 return _globals->whichAreEqualProfiles();
2766 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
2768 return _globals->whichAreEqualLocs(eps);
2771 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2773 _globals->changePflsNamesInStruct(mapOfModif);
2776 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2778 _globals->changeLocsNamesInStruct(mapOfModif);
2782 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2783 * This method contrary to abstract method MEDFileFieldGlobsReal::changePflsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changePflsRefsNamesGen,
2784 * the profiles themselves and not only leaves of field.
2786 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2788 changePflsRefsNamesGen(mapOfModif);
2789 changePflsNamesInStruct(mapOfModif);
2793 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2794 * This method contrary to abstract method MEDFileFieldGlobsReal::changeLocsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changeLocsRefsNamesGen,
2795 * the localizations themselves and not only leaves of field.
2797 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2799 changeLocsRefsNamesGen(mapOfModif);
2800 changeLocsNamesInStruct(mapOfModif);
2804 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changePflsNames.
2806 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2808 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2809 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2811 changePflsNames(mapOfModif);
2815 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changeLocsNames.
2817 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2819 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2820 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2822 changeLocsNames(mapOfModif);
2825 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
2827 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
2828 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2830 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2832 std::vector< std::string > tmp((*it).size());
2834 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2835 tmp[j]=std::string(getProfileFromId(*it2)->getName());
2836 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2838 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2839 killProfileIds(tmp2);
2841 changePflsRefsNamesGen(ret);
2845 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
2847 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
2848 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2850 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2852 std::vector< std::string > tmp((*it).size());
2854 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2855 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
2856 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2858 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2859 killLocalizationIds(tmp2);
2861 changeLocsRefsNamesGen(ret);
2865 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2867 return _globals->getNbOfGaussPtPerCell(locId);
2870 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2872 return _globals->getLocalizationId(loc);
2875 const char *MEDFileFieldGlobsReal::getFileName() const
2877 return _globals->getFileName();
2880 std::string MEDFileFieldGlobsReal::getFileName2() const
2882 return _globals->getFileName2();
2885 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2887 return _globals->getLocalization(locName);
2890 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2892 return _globals->getLocalizationFromId(locId);
2895 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2897 return _globals->getProfile(pflName);
2900 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2902 return _globals->getProfileFromId(pflId);
2905 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2907 return _globals->getLocalizationFromId(locId);
2910 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2912 return _globals->getLocalization(locName);
2915 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2917 return _globals->getProfile(pflName);
2920 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2922 return _globals->getProfileFromId(pflId);
2925 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2927 _globals->killProfileIds(pflIds);
2930 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2932 _globals->killLocalizationIds(locIds);
2935 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2937 _globals->appendProfile(pfl);
2940 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)
2942 _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
2946 * This method returns the max dimension of 'this'.
2947 * This method returns -2 if 'this' is empty, -1 if only nodes are defined.
2949 int MEDFileField1TSWithoutSDA::getDimension() const
2952 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
2953 (*it)->getDimension(ret);
2957 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
2959 if(meshDimRelToMax>0)
2960 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
2963 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
2966 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
2967 int nbOfTypes=geoTypes.size();
2968 std::vector<int> code(3*nbOfTypes);
2969 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
2970 arr1->alloc(nbOfTypes,1);
2971 int *arrPtr=arr1->getPointer();
2972 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
2973 for(int i=0;i<nbOfTypes;i++,it++)
2974 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
2975 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
2976 const int *arrPtr2=arr2->getConstPointer();
2978 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
2981 int nbCells=mesh->getNumberOfCellsWithType(*it);
2982 code[3*pos]=(int)(*it);
2983 code[3*pos+1]=nbCells;
2984 code[3*pos+2]=-1;//no profiles
2986 std::vector<const DataArrayInt *> idsPerType;//no profiles
2987 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
2991 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
2996 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
2998 return new MEDFileField1TSWithoutSDA(fieldName,csit,fieldtype,iteration,order,infos);
3002 * This method copyies tiny info but also preallocated the DataArrayDouble instance in this->_arr.
3003 * This not allocated it allocates to the size of 'field' array. If already allocated it grows the array to
3004 * the previous size + the size of the array of the input 'field'.
3005 * This method returns the position (in tuple id) where to start to feed 'this->_arr'
3007 int MEDFileField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3009 std::string name(field->getName());
3010 getOrCreateAndGetArray()->setName(name.c_str());
3012 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
3013 const DataArrayDouble *arr=field->getArray();
3015 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
3016 _dt=field->getTime(_iteration,_order);
3017 int nbOfComponents=arr->getNumberOfComponents();
3018 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
3019 if(!getOrCreateAndGetArray()->isAllocated())
3021 _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
3026 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
3027 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
3028 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
3029 tmp->alloc(newNbOfTuples,nbOfComponents);
3030 tmp->copyStringInfoFrom(*_arr);
3031 std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
3033 return oldNbOfTuples;
3037 std::string MEDFileField1TSWithoutSDA::getName() const
3039 const DataArrayDouble *arr=getOrCreateAndGetArray();
3040 return arr->getName();
3043 void MEDFileField1TSWithoutSDA::setName(const char *name)
3045 DataArrayDouble *arr=getOrCreateAndGetArray();
3049 void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3051 std::string startOfLine(bkOffset,' ');
3052 oss << startOfLine << "Field on One time Step ";
3054 oss << "(" << f1tsId << ") ";
3055 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3056 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3057 const DataArrayDouble *arr=_arr;
3060 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3063 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3064 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3065 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3066 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3068 if(arr->isAllocated())
3070 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3073 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3077 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3079 oss << startOfLine << "----------------------" << std::endl;
3080 if(!_field_per_mesh.empty())
3083 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3085 const MEDFileFieldPerMesh *cur=(*it2);
3087 cur->simpleRepr(bkOffset,oss,i);
3089 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3094 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3096 oss << startOfLine << "----------------------" << std::endl;
3099 std::string MEDFileField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3101 if(_field_per_mesh.empty())
3102 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3103 return _field_per_mesh[0]->getMeshName();
3106 void MEDFileField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3108 std::string oldName(getMeshName());
3109 std::vector< std::pair<std::string,std::string> > v(1);
3110 v[0].first=oldName; v[0].second=newMeshName;
3114 bool MEDFileField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3117 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3119 MEDFileFieldPerMesh *cur(*it);
3121 ret=cur->changeMeshNames(modifTab) || ret;
3126 bool MEDFileField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3127 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3130 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3132 MEDFileFieldPerMesh *fpm(*it);
3134 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3139 int MEDFileField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3141 if(_field_per_mesh.empty())
3142 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3143 return _field_per_mesh[0]->getMeshIteration();
3146 int MEDFileField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3148 if(_field_per_mesh.empty())
3149 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3150 return _field_per_mesh[0]->getMeshOrder();
3153 int MEDFileField1TSWithoutSDA::getNumberOfComponents() const
3155 return getOrCreateAndGetArray()->getNumberOfComponents();
3158 bool MEDFileField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3160 return iteration==_iteration && order==_order;
3163 std::pair<int,int> MEDFileField1TSWithoutSDA::getDtIt() const
3165 std::pair<int,int> p;
3170 void MEDFileField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3176 void MEDFileField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3178 std::set<TypeOfField> types2;
3179 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3181 (*it)->fillTypesOfFieldAvailable(types2);
3183 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3184 std::copy(types2.begin(),types2.end(),bi);
3187 const std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo() const
3189 const DataArrayDouble *arr=getOrCreateAndGetArray();
3190 return arr->getInfoOnComponents();
3193 std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo()
3195 DataArrayDouble *arr=getOrCreateAndGetArray();
3196 return arr->getInfoOnComponents();
3200 * This method has one input 'mname'. It can be null if the user is the general case where there is only one meshName lying on 'this'
3201 * This method returns two things.
3202 * - The absolute dimension of 'this' in first parameter.
3203 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
3204 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
3206 * This method is designed for MEDFileField1TS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
3207 * Only these 3 discretizations will be taken into account here.
3209 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
3210 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
3211 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
3213 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
3214 * 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'.
3216 * Let's consider the typical following case :
3217 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
3218 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
3219 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
3221 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
3223 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
3225 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
3226 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
3227 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
3228 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
3230 int MEDFileField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3233 int meshId=getMeshIdFromMeshName(mname);
3234 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3235 std::vector< std::vector<TypeOfField> > typesF;
3236 std::vector< std::vector<std::string> > pfls, locs;
3237 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3239 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3240 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3241 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3243 st.erase(INTERP_KERNEL::NORM_ERROR);
3245 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3247 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3248 ret1.insert((int)cm.getDimension());
3250 int ret=*std::max_element(ret1.begin(),ret1.end());
3251 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3252 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3256 std::vector<TypeOfField> MEDFileField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3258 std::vector<TypeOfField> ret;
3259 fillTypesOfFieldAvailable(ret);
3264 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
3266 std::vector< std::vector< std::pair<int,int> > > MEDFileField1TSWithoutSDA::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)
3270 meshId=getMeshIdFromMeshName(mname);
3272 if(_field_per_mesh.empty())
3273 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3274 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3278 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
3279 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
3281 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)
3285 meshId=getMeshIdFromMeshName(mname);
3287 if(_field_per_mesh.empty())
3288 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3289 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3290 int nbOfRet=ret0.size();
3291 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
3292 for(int i=0;i<nbOfRet;i++)
3294 const std::vector< std::pair<int,int> >& p=ret0[i];
3295 int nbOfRet1=p.size();
3296 ret[i].resize(nbOfRet1);
3297 for(int j=0;j<nbOfRet1;j++)
3299 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
3306 void MEDFileField1TSWithoutSDA::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
3308 med_int numdt,numit;
3312 med_int meshnumdt,meshnumit;
3313 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3314 MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
3315 MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
3316 if(_iteration!=numdt || _order!=numit)
3317 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
3318 _field_per_mesh.resize(nmesh);
3319 for(int i=0;i<nmesh;i++)
3320 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
3322 for(int i=0;i<nmesh;i++)
3324 _field_per_mesh[i]->prepareLoading(fid,start);
3326 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
3327 for(int i=0;i<nmesh;i++)
3329 _field_per_mesh[i]->finishLoading(fid,_field_type);
3333 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsed2() const
3335 std::vector<std::string> ret;
3336 std::set<std::string> ret2;
3337 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3339 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3340 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3341 if(ret2.find(*it2)==ret2.end())
3343 ret.push_back(*it2);
3350 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsed2() const
3352 std::vector<std::string> ret;
3353 std::set<std::string> ret2;
3354 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3356 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3357 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3358 if(ret2.find(*it2)==ret2.end())
3360 ret.push_back(*it2);
3367 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3369 std::vector<std::string> ret;
3370 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3372 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3373 ret.insert(ret.end(),tmp.begin(),tmp.end());
3378 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3380 std::vector<std::string> ret;
3381 std::set<std::string> ret2;
3382 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3384 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3385 ret.insert(ret.end(),tmp.begin(),tmp.end());
3390 void MEDFileField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3392 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3393 (*it)->changePflsRefsNamesGen(mapOfModif);
3396 void MEDFileField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3398 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3399 (*it)->changeLocsRefsNamesGen(mapOfModif);
3402 void MEDFileField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
3404 if(_field_per_mesh.empty())
3405 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3406 if(_field_per_mesh.size()>1)
3407 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3408 _field_per_mesh[0]->copyOptionsFrom(opts);
3409 _field_per_mesh[0]->writeLL(fid);
3413 * SBT means Sort By Type.
3414 * This method is the most basic method to assign field in this. Basic in sense that no renumbering is done. Underlying mesh in 'field' is globaly ignored except for type contiguous check.
3416 void MEDFileField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3418 const MEDCouplingMesh *mesh=field->getMesh();
3420 TypeOfField type=field->getTypeOfField();
3421 std::vector<DataArrayInt *> dummy;
3422 int start=copyTinyInfoFrom(field);
3425 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
3427 int pos=addNewEntryIfNecessary(mesh);
3428 _field_per_mesh[pos]->assignFieldProfile(start,0,code,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile.
3432 int pos=addNewEntryIfNecessary(mesh);
3433 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
3438 * Generalization of MEDFileField1TSWithoutSDA::setFieldNoProfileSBT method.
3440 void MEDFileField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3442 TypeOfField type=field->getTypeOfField();
3443 int start=copyTinyInfoFrom(field);
3444 std::vector<DataArrayInt *> idsInPflPerType;
3445 std::vector<DataArrayInt *> idsPerType;
3446 std::vector<int> code;
3447 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3450 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
3452 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
3453 for(std::size_t i=0;i<idsInPflPerType.size();i++)
3454 idsInPflPerType2[i]=idsInPflPerType[i];
3455 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
3456 for(std::size_t i=0;i<idsPerType.size();i++)
3457 idsPerType2[i]=idsPerType[i];
3459 int pos=addNewEntryIfNecessary(m);
3460 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,idsInPflPerType,idsPerType,field,m,glob);
3464 int pos=addNewEntryIfNecessary(m);
3465 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
3469 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3471 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3473 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3475 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3476 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3479 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
3481 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
3482 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
3483 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
3484 if(meshDimRelToMax==1)
3485 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
3486 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
3489 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3491 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3493 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3495 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3496 int absDim=getDimension();
3497 int meshDimRelToMax=absDim-mm->getMeshDimension();
3498 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3501 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
3503 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
3504 int meshId=getMeshIdFromMeshName(mesh->getName());
3506 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
3511 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3519 throw INTERP_KERNEL::Exception(msg1);
3520 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3523 if(cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
3525 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3526 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
3527 throw INTERP_KERNEL::Exception(oss.str().c_str());
3529 ret->renumberCells(cellRenum->getConstPointer(),true);
3539 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3541 throw INTERP_KERNEL::Exception(msg1);
3544 if(nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
3546 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3547 oss << "\"" << getName() << "\" not defined on all nodes !";
3548 throw INTERP_KERNEL::Exception(oss.str().c_str());
3550 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
3551 ret->renumberNodes(nodeRenumSafe->getConstPointer());
3557 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
3561 DataArrayDouble *MEDFileField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3563 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3564 int meshId=getMeshIdFromMeshName(mesh->getName());
3565 return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
3569 * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance. The returned array is not a newly
3570 * created array so it should \b not be dealed by the caller.
3571 * This method allows to the user a direct access to the values.
3572 * This method is quite unusable if there is more than a nodal field or a cell field on single geometric cell type.
3574 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
3576 const DataArrayDouble *ret=_arr;
3578 return const_cast<DataArrayDouble *>(ret);
3584 * This method returns an array that the caller must deal with (contrary to those returned by MEDFileField1TSWithoutSDA::getUndergroundDataArray method).
3585 * The returned array is the result of the aggregation of all sub arrays stored in the MED file. So to allow the caller to select the output param
3586 * 'entries' is returned. This output param is a vector of a pair of 2 pairs. The first pair of pair informs of the geometric type it refers to and the discretization
3587 * id attached to it. The second pair of pair precise the range [begin,end) into the returned array.
3588 * This method makes the hypothesis that the field lies only on one mesh. If it is not the case an exception will be thrown.
3590 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
3592 if(_field_per_mesh.size()!=1)
3593 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
3594 if(_field_per_mesh[0]==0)
3595 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
3596 return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
3599 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order,
3600 const std::vector<std::string>& infos):_csit(csit),_field_type(fieldtype),_iteration(iteration),_order(order)
3602 DataArrayDouble *arr=getOrCreateAndGetArray();
3603 arr->setName(fieldName);
3604 arr->setInfoAndChangeNbOfCompo(infos);
3607 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():_csit(-1),_field_type(-1)
3611 int MEDFileField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3613 std::string tmp(mesh->getName());
3615 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3616 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3618 for(;it!=_field_per_mesh.end();it++,i++)
3620 if((*it)->getMeshName()==tmp)
3623 int sz=_field_per_mesh.size();
3624 _field_per_mesh.resize(sz+1);
3625 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3630 * \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.
3632 int MEDFileField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3634 if(_field_per_mesh.empty())
3635 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3638 std::string mName2(mName);
3640 std::vector<std::string> msg;
3641 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3642 if(mName2==(*it)->getMeshName())
3645 msg.push_back((*it)->getMeshName());
3646 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3647 oss << "Possible meshes are : ";
3648 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3649 oss << "\"" << (*it2) << "\" ";
3650 throw INTERP_KERNEL::Exception(oss.str().c_str());
3654 * \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.
3655 * \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.
3656 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3657 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3659 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3661 int mid=getMeshIdFromMeshName(mName);
3662 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3666 * \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.
3667 * \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.
3668 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3669 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3671 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3673 int mid=getMeshIdFromMeshName(mName);
3674 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3677 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
3679 DataArrayDouble *ret=_arr;
3682 _arr=DataArrayDouble::New();
3686 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
3688 const DataArrayDouble *ret=_arr;
3691 DataArrayDouble *ret2=DataArrayDouble::New();
3692 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
3696 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3698 return new MEDFileField1TS(fileName,fieldName,iteration,order);
3702 * \warning this is a shallow copy constructor
3704 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3706 return new MEDFileField1TS(other,deepCpy);
3709 MEDFileField1TS *MEDFileField1TS::New()
3711 return new MEDFileField1TS;
3714 std::string MEDFileField1TS::simpleRepr() const
3716 std::ostringstream oss;
3717 _content->simpleRepr(0,oss,-1);
3718 MEDFileFieldGlobsReal::simpleRepr(oss);
3722 void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
3724 int nbComp=getNumberOfComponents();
3725 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3726 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3727 for(int i=0;i<nbComp;i++)
3729 std::string info=getInfo()[i];
3731 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
3732 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
3733 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
3735 if(getName().empty())
3736 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
3737 MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
3738 writeGlobals(fid,*this);
3739 _content->writeLL(fid,*this);
3742 void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
3744 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
3745 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
3749 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3750 try:_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,iteration,order,std::vector<std::string>())),MEDFileFieldGlobsReal(fileName)
3752 MEDFileUtilities::CheckFileForRead(fileName);
3753 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
3754 int nbFields=MEDnField(fid);
3755 med_field_type typcha;
3757 std::vector<std::string> fns(nbFields);
3759 for(int i=0;i<nbFields && !found;i++)
3761 int ncomp=MEDfieldnComponent(fid,i+1);
3762 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3763 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3764 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
3765 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3766 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3769 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
3770 std::string tmp(nomcha);
3772 found=(tmp==fieldName);
3776 std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
3777 std::vector<std::string> infos(ncomp);
3778 for(int j=0;j<ncomp;j++)
3779 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
3780 _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
3785 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
3786 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
3787 throw INTERP_KERNEL::Exception(oss.str().c_str());
3790 std::vector< std::pair<int,int> > dtits(nbOfStep2);
3791 for(int i=0;i<nbOfStep2 && !found;i++)
3793 med_int numdt,numit;
3795 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
3796 if(numdt==iteration && numit==order)
3799 _content->_csit=i+1;
3800 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
3803 dtits[i]=std::pair<int,int>(numdt,numit);
3807 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
3808 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
3809 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
3810 throw INTERP_KERNEL::Exception(oss.str().c_str());
3812 _content->finishLoading(fid);
3816 catch(INTERP_KERNEL::Exception& e)
3822 * \warning this is a shallow copy constructor
3824 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3828 const MEDFileField1TSWithoutSDA *otherPtr(&other);
3829 otherPtr->incrRef();
3830 _content=const_cast<MEDFileField1TSWithoutSDA *>(otherPtr);
3834 _content=new MEDFileField1TSWithoutSDA(other);
3838 MEDFileField1TS::MEDFileField1TS():_content(new MEDFileField1TSWithoutSDA)
3843 * This method returns all profiles whose name is non empty used.
3844 * \b WARNING If profile is used several times it will be reported \b only \b once.
3845 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
3847 std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
3849 return _content->getPflsReallyUsed2();
3853 * This method returns all localizations whose name is non empty used.
3854 * \b WARNING If localization is used several times it will be reported \b only \b once.
3856 std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
3858 return _content->getLocsReallyUsed2();
3862 * This method returns all profiles whose name is non empty used.
3863 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
3865 std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
3867 return _content->getPflsReallyUsedMulti2();
3871 * This method returns all localizations whose name is non empty used.
3872 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
3874 std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
3876 return _content->getLocsReallyUsedMulti2();
3879 void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3881 _content->changePflsRefsNamesGen2(mapOfModif);
3884 void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3886 _content->changeLocsRefsNamesGen2(mapOfModif);
3890 * This method requests underlying file to perform the job, for mesh reading. If the current instance is not coming from a file and has been constructed from scratch
3891 * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead.
3892 * \b WARNING ! Parameter 'meshDimRelToMax' is relative from read mesh in file that can be different from the field in MED file !
3893 * It leads that the returned field of this method is always coherent.
3895 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3897 if(getFileName2().empty())
3898 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3899 return _content->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
3903 * This method is close to MEDFileField1TS::getFieldAtLevel except that here the 'meshDimRelToMax' param is ignored and the maximal dimension is taken
3904 * automatically. If the field lies on different level and that an another level than the maximal is requested MEDFileField1TS::getFieldAtLevel
3905 * should be called instead.
3907 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
3909 if(getFileName2().empty())
3910 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
3911 return _content->getFieldAtTopLevel(type,0,renumPol,this);
3915 * \b WARNING, there is a main difference with the two close methods (MEDFileField1TS::getFieldAtLevel and MEDFileField1TS::getFieldOnMeshAtLevel method) !
3916 * Here the mesh-dimension of 'mesh' is used by this to automatically request the right geoTypes regarding 'type'.
3917 * If no such element fufilled the deduced dimension and 'type' an exception will be thrown.
3918 * It leads that the returned field of this method is always coherent.
3920 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3922 return _content->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
3926 * This method can be called whatever the mode of instance feeding of this (MED file or from scratch).
3927 * But the parameter ''meshDimRelToMax' is applyied on 'mesh' (like MEDFileField1TS::getFieldAtLevel does). \b WARNING the dim of 'this' can be different from those in 'mesh' !
3928 * It leads that the returned field of this method is always coherent.
3930 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3932 return _content->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
3936 * This method is identical to MEDFileField1TS::getFieldAtLevel method except that meshName 'mname' should be specified.
3937 * This method is called "Old" because in MED3 norm a field has only one meshName attached. This method is only here for reader of MED2 files.
3938 * See MEDFileField1TS::getFieldAtLevel for more information.
3940 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3942 if(getFileName2().empty())
3943 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3944 return _content->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
3947 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
3949 return _content->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
3953 * SBT means Sort By Type.
3954 * This method is the most basic method to assign field in this. Basic in sense that no renumbering is done. Underlying mesh in 'field' is globaly ignored except for type contiguous check.
3957 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3960 _content->setFieldNoProfileSBT(field,*this);
3964 * This method is a generalization of MEDFileField1TS::setFieldNoProfileSBT method. Here a profile array is given in input.
3965 * The support of field 'field' is \b not used by this method, so it can be null or incoherent with field.
3966 * This method uses input parameters 'mesh', 'meshDimRelToMax' and 'profile' to determine what is really the support of field 'field'. If field is incoherent regarding this deduced support,
3967 * an exception will be thrown.
3968 * This method is trying to reduce the size of MEDfile file so profile is created only if it is absolutely necessary. If it is necessary the name of 'profile' will be used to create it in 'this'.
3969 * In this case, if this profile name is empty an exception will be thrown.
3971 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
3974 _content->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
3978 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
3979 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
3980 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
3981 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
3982 * to keep a valid instance.
3983 * 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.
3984 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
3985 * 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.
3987 * \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.
3988 * \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.
3989 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3990 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3991 * \param [in] newLocName is the new localization name.
3992 * \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.
3993 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
3995 void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
3997 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
3998 std::string oldPflName=disc->getProfile();
3999 std::vector<std::string> vv=getPflsReallyUsedMulti();
4000 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
4001 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
4003 disc->setProfile(newPflName);
4004 DataArrayInt *pfl=getProfile(oldPflName.c_str());
4005 pfl->setName(newPflName);
4009 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
4010 throw INTERP_KERNEL::Exception(oss.str().c_str());
4015 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4016 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4017 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4018 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4019 * to keep a valid instance.
4020 * 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.
4021 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
4022 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
4023 * 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.
4025 * \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.
4026 * \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.
4027 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4028 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4029 * \param [in] newLocName is the new localization name.
4030 * \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.
4031 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
4033 void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4035 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4036 std::string oldLocName=disc->getLocalization();
4037 std::vector<std::string> vv=getLocsReallyUsedMulti();
4038 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
4039 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
4041 disc->setLocalization(newLocName);
4042 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
4043 loc.setName(newLocName);
4047 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
4048 throw INTERP_KERNEL::Exception(oss.str().c_str());
4052 int MEDFileField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4054 return _content->copyTinyInfoFrom(field);
4057 int MEDFileField1TS::getDimension() const
4059 return _content->getDimension();
4062 int MEDFileField1TS::getIteration() const
4064 return _content->getIteration();
4067 int MEDFileField1TS::getOrder() const
4069 return _content->getOrder();
4072 double MEDFileField1TS::getTime(int& iteration, int& order) const
4074 return _content->getTime(iteration,order);
4077 void MEDFileField1TS::setTime(int iteration, int order, double val)
4079 _content->setTime(iteration,order,val);
4082 std::string MEDFileField1TS::getName() const
4084 return _content->getName();
4087 void MEDFileField1TS::setName(const char *name)
4089 _content->setName(name);
4092 void MEDFileField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4094 _content->simpleRepr(bkOffset,oss,f1tsId);
4097 const std::string& MEDFileField1TS::getDtUnit() const
4099 return _content->getDtUnit();
4102 std::string MEDFileField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
4104 return _content->getMeshName();
4107 void MEDFileField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4109 _content->setMeshName(newMeshName);
4112 bool MEDFileField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4114 return _content->changeMeshNames(modifTab);
4117 int MEDFileField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
4119 return _content->getMeshIteration();
4122 int MEDFileField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
4124 return _content->getMeshOrder();
4127 int MEDFileField1TS::getNumberOfComponents() const
4129 return _content->getNumberOfComponents();
4132 bool MEDFileField1TS::isDealingTS(int iteration, int order) const
4134 return _content->isDealingTS(iteration,order);
4137 std::pair<int,int> MEDFileField1TS::getDtIt() const
4139 return _content->getDtIt();
4142 void MEDFileField1TS::fillIteration(std::pair<int,int>& p) const
4144 _content->fillIteration(p);
4146 void MEDFileField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
4148 _content->fillTypesOfFieldAvailable(types);
4151 const std::vector<std::string>& MEDFileField1TS::getInfo() const
4153 return _content->getInfo();
4155 std::vector<std::string>& MEDFileField1TS::getInfo()
4157 return _content->getInfo();
4160 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4162 return _content->getUndergroundDataArray();
4165 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4167 return _content->getUndergroundDataArrayExt(entries);
4170 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
4172 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4175 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
4177 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4180 int MEDFileField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4182 return _content->getNonEmptyLevels(mname,levs);
4185 std::vector<TypeOfField> MEDFileField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4187 return _content->getTypesOfFieldAvailable();
4190 std::vector< std::vector<std::pair<int,int> > > MEDFileField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
4191 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4193 return _content->getFieldSplitedByType(mname,types,typesF,pfls,locs);
4195 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
4196 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4198 return _content->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4201 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
4203 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,id,ft,infos,nbOfStep);
4206 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA():_field_type(-1)
4210 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):_name(fieldName),_field_type(-1)
4215 * \param [in] fieldId field id in C mode
4217 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
4220 med_field_type typcha;
4223 int ncomp=MEDfieldnComponent(fid,1);
4224 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4225 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4226 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4227 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4228 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4231 MEDfieldInfo(fid,fieldId+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4232 _name=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
4233 _field_type=MEDFileUtilities::TraduceFieldType(typcha);
4234 _infos.resize(ncomp);
4235 for(int j=0;j<ncomp;j++)
4236 _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
4238 finishLoading(fid,nbOfStep);
4240 catch(INTERP_KERNEL::Exception& e)
4245 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
4246 try:_name(fieldName),_infos(infos),_field_type(ft)
4248 finishLoading(fid,nbOfStep);
4250 catch(INTERP_KERNEL::Exception& e)
4255 const std::vector<std::string>& MEDFileFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
4257 if(_time_steps.empty())
4258 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getInfos : not time steps !");
4259 return _time_steps[0]->getInfo();
4263 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
4265 DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4267 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
4271 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
4273 DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::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)
4275 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
4278 std::string MEDFileFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
4280 if(_time_steps.empty())
4281 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4282 return _time_steps[0]->getMeshName();
4285 void MEDFileFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4287 std::string oldName(getMeshName());
4288 std::vector< std::pair<std::string,std::string> > v(1);
4289 v[0].first=oldName; v[0].second=newMeshName;
4293 bool MEDFileFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4296 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4298 MEDFileField1TSWithoutSDA *cur(*it);
4300 ret=cur->changeMeshNames(modifTab) || ret;
4305 bool MEDFileFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4306 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4309 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4311 MEDFileField1TSWithoutSDA *f1ts(*it);
4313 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4318 void MEDFileFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4320 if(_time_steps.empty())
4322 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4323 obj->setFieldNoProfileSBT(field,glob);
4324 copyTinyInfoFrom(field);
4325 _time_steps.push_back(obj);
4329 checkCoherencyOfTinyInfo(field);
4330 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4331 obj->setFieldNoProfileSBT(field,glob);
4332 _time_steps.push_back(obj);
4336 void MEDFileFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4338 if(_time_steps.empty())
4340 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4341 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4342 copyTinyInfoFrom(field);
4343 _time_steps.push_back(obj);
4347 checkCoherencyOfTinyInfo(field);
4348 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4349 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4350 _time_steps.push_back(obj);
4354 std::string MEDFileFieldMultiTSWithoutSDA::getDtUnit() const throw(INTERP_KERNEL::Exception)
4356 if(_time_steps.empty())
4357 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4358 return _time_steps[0]->getDtUnit();
4361 std::string MEDFileFieldMultiTSWithoutSDA::getName() const
4366 void MEDFileFieldMultiTSWithoutSDA::setName(const char *name)
4371 void MEDFileFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
4373 std::string startLine(bkOffset,' ');
4374 oss << startLine << "Field multi time steps";
4376 oss << " (" << fmtsId << ")";
4377 oss << " has the following name: \"" << _name << "\"." << std::endl;
4378 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
4379 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
4381 oss << startLine << " - \"" << *it << "\"" << std::endl;
4384 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
4386 std::string chapter(17,'0'+i);
4387 oss << startLine << chapter << std::endl;
4388 const MEDFileField1TSWithoutSDA *cur=(*it);
4390 cur->simpleRepr(bkOffset+2,oss,i);
4392 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
4393 oss << startLine << chapter << std::endl;
4397 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
4399 std::size_t sz=_time_steps.size();
4400 std::vector< std::pair<int,int> > ret(sz);
4402 for(std::size_t i=0;i<sz;i++)
4404 const MEDFileField1TSWithoutSDA *f1ts=_time_steps[i];
4407 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
4411 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
4412 throw INTERP_KERNEL::Exception(oss.str().c_str());
4418 void MEDFileFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
4420 _time_steps.resize(nbPdt);
4421 for(int i=0;i<nbPdt;i++)
4423 std::vector< std::pair<int,int> > ts;
4424 med_int numdt=0,numo=0;
4425 med_int meshIt=0,meshOrder=0;
4427 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
4428 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
4429 _time_steps[i]->finishLoading(fid);
4433 void MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4435 _name=field->getName();
4437 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4438 const DataArrayDouble *arr=field->getArray();
4440 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
4441 _infos=arr->getInfoOnComponents();
4444 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
4446 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
4447 if(_name!=field->getName())
4449 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
4450 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
4451 throw INTERP_KERNEL::Exception(oss.str().c_str());
4453 const DataArrayDouble *arr=field->getArray();
4455 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
4456 if(_infos!=arr->getInfoOnComponents())
4458 std::ostringstream oss; oss << MSG << "components ! should be \"";
4459 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
4460 oss << " But compo in input fields are : ";
4461 std::vector<std::string> tmp=arr->getInfoOnComponents();
4462 std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
4464 throw INTERP_KERNEL::Exception(oss.str().c_str());
4468 void MEDFileFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
4470 if(_time_steps.empty())
4471 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
4472 std::vector<std::string> infos(getInfo());
4473 int nbComp=infos.size();
4474 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4475 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4476 for(int i=0;i<nbComp;i++)
4478 std::string info=infos[i];
4480 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
4481 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4482 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4485 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
4486 MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
4487 int nbOfTS=_time_steps.size();
4488 for(int i=0;i<nbOfTS;i++)
4489 _time_steps[i]->writeLL(fid,opts);
4492 int MEDFileFieldMultiTSWithoutSDA::getNumberOfTS() const
4494 return _time_steps.size();
4497 void MEDFileFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
4499 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4502 const MEDFileField1TSWithoutSDA *tmp=(*it);
4504 newTS.push_back(*it);
4509 void MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
4511 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4512 int maxId=(int)_time_steps.size();
4514 std::set<int> idsToDel;
4515 for(const int *id=startIds;id!=endIds;id++,ii++)
4517 if(*id>=0 && *id<maxId)
4519 idsToDel.insert(*id);
4523 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
4524 throw INTERP_KERNEL::Exception(oss.str().c_str());
4527 for(int iii=0;iii<maxId;iii++)
4528 if(idsToDel.find(iii)==idsToDel.end())
4529 newTS.push_back(_time_steps[iii]);
4533 int MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4536 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
4537 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4539 const MEDFileField1TSWithoutSDA *tmp(*it);
4543 tmp->getTime(it,ord);
4544 if(it==iteration && order==ord)
4547 oss << "(" << it << "," << ord << "), ";
4550 throw INTERP_KERNEL::Exception(oss.str().c_str());
4553 int MEDFileFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4556 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
4558 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4560 const MEDFileField1TSWithoutSDA *tmp(*it);
4564 double ti=tmp->getTime(it,ord);
4565 if(fabs(time-ti)<eps)
4571 throw INTERP_KERNEL::Exception(oss.str().c_str());
4574 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getIterations() const
4576 int lgth=_time_steps.size();
4577 std::vector< std::pair<int,int> > ret(lgth);
4578 for(int i=0;i<lgth;i++)
4579 _time_steps[i]->fillIteration(ret[i]);
4584 * 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'
4585 * This method returns two things.
4586 * - The absolute dimension of 'this' in first parameter.
4587 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
4588 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
4590 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
4591 * Only these 3 discretizations will be taken into account here.
4593 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
4594 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
4595 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
4597 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
4598 * 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'.
4600 * Let's consider the typical following case :
4601 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
4602 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
4603 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
4605 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
4607 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
4609 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
4610 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
4611 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
4612 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
4614 int MEDFileFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4616 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
4619 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4621 int lgth=_time_steps.size();
4622 std::vector< std::vector<TypeOfField> > ret(lgth);
4623 for(int i=0;i<lgth;i++)
4624 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
4629 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
4631 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTSWithoutSDA::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)
4633 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
4637 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
4638 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
4640 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)
4642 return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4645 const MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4647 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4648 if((*it)->isDealingTS(iteration,order))
4650 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4651 std::vector< std::pair<int,int> > vp=getIterations();
4652 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4653 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4654 throw INTERP_KERNEL::Exception(oss.str().c_str());
4657 MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
4659 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4660 if((*it)->isDealingTS(iteration,order))
4662 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4663 std::vector< std::pair<int,int> > vp=getIterations();
4664 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4665 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4666 throw INTERP_KERNEL::Exception(oss.str().c_str());
4669 const MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
4671 if(pos<0 || pos>=(int)_time_steps.size())
4673 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4674 throw INTERP_KERNEL::Exception(oss.str().c_str());
4676 const MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4679 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4680 oss << "\nTry to use following method eraseEmptyTS !";
4681 throw INTERP_KERNEL::Exception(oss.str().c_str());
4686 MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
4688 if(pos<0 || pos>=(int)_time_steps.size())
4690 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4691 throw INTERP_KERNEL::Exception(oss.str().c_str());
4693 MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4696 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4697 oss << "\nTry to use following method eraseEmptyTS !";
4698 throw INTERP_KERNEL::Exception(oss.str().c_str());
4703 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
4705 std::vector<std::string> ret;
4706 std::set<std::string> ret2;
4707 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4709 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
4710 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4711 if(ret2.find(*it2)==ret2.end())
4713 ret.push_back(*it2);
4720 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
4722 std::vector<std::string> ret;
4723 std::set<std::string> ret2;
4724 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4726 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
4727 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4728 if(ret2.find(*it2)==ret2.end())
4730 ret.push_back(*it2);
4737 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
4739 std::vector<std::string> ret;
4740 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4742 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
4743 ret.insert(ret.end(),tmp.begin(),tmp.end());
4748 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
4750 std::vector<std::string> ret;
4751 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4753 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
4754 ret.insert(ret.end(),tmp.begin(),tmp.end());
4759 void MEDFileFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4761 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4762 (*it)->changePflsRefsNamesGen2(mapOfModif);
4765 void MEDFileFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4767 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4768 (*it)->changeLocsRefsNamesGen2(mapOfModif);
4771 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
4773 return new MEDFileFieldMultiTS;
4776 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4778 return new MEDFileFieldMultiTS(fileName);
4781 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4783 return new MEDFileFieldMultiTS(fileName,fieldName);
4786 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
4788 return new MEDFileFieldMultiTS(other,deepCpy);
4791 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
4793 const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
4794 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item,false);
4795 ret->shallowCpyGlobs(*this);
4800 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4802 int pos=getPosOfTimeStep(iteration,order);
4803 return getTimeStepAtPos(pos);
4806 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4808 int pos=getPosGivenTime(time,eps);
4809 return getTimeStepAtPos(pos);
4812 MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
4814 return new MEDFileFieldMultiTSIterator(this);
4817 std::string MEDFileFieldMultiTS::simpleRepr() const
4819 std::ostringstream oss;
4820 _content->simpleRepr(0,oss,-1);
4821 MEDFileFieldGlobsReal::simpleRepr(oss);
4825 void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
4827 writeGlobals(fid,*this);
4828 _content->writeLL(fid,*this);
4831 void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
4833 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
4834 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
4839 * Performs the job than MEDFileField1TS::getFieldAtLevel except that (iteration,order) couple should be specified !
4840 * If such couple does not exist an exception is thrown.
4842 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4844 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4845 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
4848 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
4850 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4851 return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
4855 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4856 * If such couple does not exist an exception is thrown.
4858 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4860 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4861 return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
4865 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4866 * If such couple does not exist an exception is thrown.
4868 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4870 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4871 return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
4875 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
4876 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
4877 * This method is useful for MED2 file format when field on different mesh was autorized.
4879 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4881 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4882 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
4885 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
4887 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4888 return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
4891 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4893 _content->appendFieldNoProfileSBT(field,*this);
4896 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
4898 _content->appendFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
4901 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> MEDFileFieldMultiTS::getContent()
4906 MEDFileFieldMultiTS::MEDFileFieldMultiTS():_content(new MEDFileFieldMultiTSWithoutSDA)
4912 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
4913 try:MEDFileFieldGlobsReal(fileName)
4915 MEDFileUtilities::CheckFileForRead(fileName);
4916 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4917 int nbFields=MEDnField(fid);
4920 std::ostringstream oss; oss << "MEDFileFieldMultiTS(const char *fileName) constructor : no fields in file \"" << fileName << "\" !";
4921 throw INTERP_KERNEL::Exception(oss.str().c_str());
4923 _content=new MEDFileFieldMultiTSWithoutSDA(fid,0);
4927 catch(INTERP_KERNEL::Exception& e)
4932 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4933 try:MEDFileFieldGlobsReal(fileName)
4935 MEDFileUtilities::CheckFileForRead(fileName);
4936 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4937 int nbFields=MEDnField(fid);
4938 med_field_type typcha;
4940 std::vector<std::string> fns(nbFields);
4941 for(int i=0;i<nbFields && !found;i++)
4943 int ncomp=MEDfieldnComponent(fid,i+1);
4944 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4945 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4946 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4947 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4948 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4951 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4952 std::string tmp(nomcha);
4954 found=(tmp==fieldName);
4956 _content=new MEDFileFieldMultiTSWithoutSDA(fid,i);
4960 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
4961 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
4962 throw INTERP_KERNEL::Exception(oss.str().c_str());
4967 catch(INTERP_KERNEL::Exception& e)
4972 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
4976 const MEDFileFieldMultiTSWithoutSDA *otherPtr(&other);
4977 otherPtr->incrRef();
4978 _content=const_cast<MEDFileFieldMultiTSWithoutSDA *>(otherPtr);
4982 _content=new MEDFileFieldMultiTSWithoutSDA(other);
4986 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
4988 return _content->getPflsReallyUsed2();
4991 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
4993 return _content->getLocsReallyUsed2();
4996 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
4998 return _content->getPflsReallyUsedMulti2();
5001 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
5003 return _content->getLocsReallyUsedMulti2();
5006 void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5008 _content->changePflsRefsNamesGen2(mapOfModif);
5011 void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5013 _content->changeLocsRefsNamesGen2(mapOfModif);
5016 int MEDFileFieldMultiTS::getNumberOfTS() const
5018 return _content->getNumberOfTS();
5021 void MEDFileFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
5023 _content->eraseEmptyTS();
5026 void MEDFileFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
5028 _content->eraseTimeStepIds(startIds,endIds);
5031 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getIterations() const
5033 return _content->getIterations();
5036 int MEDFileFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5038 return _content->getPosOfTimeStep(iteration,order);
5041 int MEDFileFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
5043 return _content->getPosGivenTime(time,eps);
5046 int MEDFileFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5048 return _content->getNonEmptyLevels(iteration,order,mname,levs);
5051 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5053 return _content->getTypesOfFieldAvailable();
5056 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTS::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)
5058 return _content->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
5061 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)
5063 return _content->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
5066 std::string MEDFileFieldMultiTS::getName() const
5068 return _content->getName();
5071 void MEDFileFieldMultiTS::setName(const char *name)
5073 _content->setName(name);
5076 void MEDFileFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
5078 _content->simpleRepr(bkOffset,oss,fmtsId);
5081 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
5083 return _content->getTimeSteps(ret1);
5086 std::string MEDFileFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
5088 return _content->getMeshName();
5091 void MEDFileFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5093 _content->setMeshName(newMeshName);
5096 bool MEDFileFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5098 return _content->changeMeshNames(modifTab);
5101 const std::vector<std::string>& MEDFileFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
5103 return _content->getInfo();
5106 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5108 return _content->getUndergroundDataArray(iteration,order);
5111 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)
5113 return _content->getUndergroundDataArrayExt(iteration,order,entries);
5116 MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
5121 _nb_iter=fmts->getNumberOfTS();
5125 MEDFileFieldMultiTSIterator::~MEDFileFieldMultiTSIterator()
5129 MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
5131 if(_iter_id<_nb_iter)
5133 MEDFileFieldMultiTS *fmts(_fmts);
5135 return fmts->getTimeStepAtPos(_iter_id++);
5143 MEDFileFields *MEDFileFields::New()
5145 return new MEDFileFields;
5148 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5150 return new MEDFileFields(fileName);
5153 int MEDFileFields::getNumberOfFields() const
5155 return _fields.size();
5158 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
5160 std::vector<std::string> ret(_fields.size());
5162 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5164 const MEDFileFieldMultiTSWithoutSDA *f=(*it);
5167 ret[i]=f->getName();
5171 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
5172 throw INTERP_KERNEL::Exception(oss.str().c_str());
5178 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
5180 std::vector<std::string> ret;
5181 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5183 const MEDFileFieldMultiTSWithoutSDA *cur(*it);
5185 ret.push_back(cur->getMeshName());
5190 std::string MEDFileFields::simpleRepr() const
5192 std::ostringstream oss;
5193 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
5198 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
5200 int nbOfFields=getNumberOfFields();
5201 std::string startLine(bkOffset,' ');
5202 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
5204 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5206 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5209 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
5213 oss << startLine << " - not defined !" << std::endl;
5217 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5219 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5220 std::string chapter(17,'0'+i);
5221 oss << startLine << chapter << std::endl;
5224 cur->simpleRepr(bkOffset+2,oss,i);
5228 oss << startLine << " - not defined !" << std::endl;
5230 oss << startLine << chapter << std::endl;
5232 MEDFileFieldGlobsReal::simpleRepr(oss);
5235 MEDFileFields::MEDFileFields()
5239 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
5240 try:MEDFileFieldGlobsReal(fileName)
5242 MEDFileUtilities::CheckFileForRead(fileName);
5243 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5244 int nbFields=MEDnField(fid);
5245 _fields.resize(nbFields);
5246 med_field_type typcha;
5247 for(int i=0;i<nbFields;i++)
5249 int ncomp=MEDfieldnComponent(fid,i+1);
5250 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5251 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5252 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5253 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5254 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5257 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5258 int ft=MEDFileUtilities::TraduceFieldType(typcha);
5259 std::vector<std::string> infos(ncomp);
5260 for(int j=0;j<ncomp;j++)
5261 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5262 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,nomcha,i+1,ft,infos,nbOfStep);
5264 loadAllGlobals(fid);
5266 catch(INTERP_KERNEL::Exception& e)
5271 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5274 writeGlobals(fid,*this);
5275 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5277 const MEDFileFieldMultiTSWithoutSDA *elt=*it;
5280 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
5281 throw INTERP_KERNEL::Exception(oss.str().c_str());
5283 elt->writeLL(fid,*this);
5287 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5289 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5290 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5294 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
5296 std::vector<std::string> ret;
5297 std::set<std::string> ret2;
5298 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5300 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
5301 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5302 if(ret2.find(*it2)==ret2.end())
5304 ret.push_back(*it2);
5311 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
5313 std::vector<std::string> ret;
5314 std::set<std::string> ret2;
5315 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5317 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5318 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5319 if(ret2.find(*it2)==ret2.end())
5321 ret.push_back(*it2);
5328 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
5330 std::vector<std::string> ret;
5331 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5333 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
5334 ret.insert(ret.end(),tmp.begin(),tmp.end());
5339 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
5341 std::vector<std::string> ret;
5342 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5344 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5345 ret.insert(ret.end(),tmp.begin(),tmp.end());
5350 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5352 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5353 (*it)->changePflsRefsNamesGen2(mapOfModif);
5356 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5358 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5359 (*it)->changeLocsRefsNamesGen2(mapOfModif);
5362 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
5364 _fields.resize(newSize);
5367 void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5370 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
5371 _fields.push_back(field->getContent());
5372 appendGlobs(*field,1e-12);
5375 void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5378 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
5379 if(i>=(int)_fields.size())
5380 _fields.resize(i+1);
5381 _fields[i]=field->getContent();
5382 appendGlobs(*field,1e-12);
5385 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
5387 if(i<0 || i>=(int)_fields.size())
5389 std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5390 throw INTERP_KERNEL::Exception(oss.str().c_str());
5392 _fields.erase(_fields.begin()+i);
5395 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5398 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5400 MEDFileFieldMultiTSWithoutSDA *cur(*it);
5402 ret=cur->changeMeshNames(modifTab) || ret;
5408 * \param [in] meshName the name of the mesh that will be renumbered.
5409 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
5410 * This code corresponds to the distribution of types in the corresponding mesh.
5411 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
5412 * \param [in] renumO2N the old to new renumber array.
5413 * \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
5416 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
5419 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5421 MEDFileFieldMultiTSWithoutSDA *fmts(*it);
5424 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
5430 MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
5432 if(i<0 || i>=(int)_fields.size())
5434 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5435 throw INTERP_KERNEL::Exception(oss.str().c_str());
5437 const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i];
5438 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts,false);
5439 ret->shallowCpyGlobs(*this);
5444 MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5446 return getFieldAtPos(getPosFromFieldName(fieldName));
5449 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
5451 return new MEDFileFieldsIterator(this);
5454 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5456 std::string tmp(fieldName);
5457 std::vector<std::string> poss;
5458 for(std::size_t i=0;i<_fields.size();i++)
5460 const MEDFileFieldMultiTSWithoutSDA *f=_fields[i];
5463 std::string fname(f->getName());
5467 poss.push_back(fname);
5470 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
5471 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
5473 throw INTERP_KERNEL::Exception(oss.str().c_str());
5476 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
5481 _nb_iter=fs->getNumberOfFields();
5485 MEDFileFieldsIterator::~MEDFileFieldsIterator()
5489 MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
5491 if(_iter_id<_nb_iter)
5493 MEDFileFields *fs(_fs);
5495 return fs->getFieldAtPos(_iter_id++);