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
20 #include "MEDFileField.hxx"
21 #include "MEDFileMesh.hxx"
22 #include "MEDLoaderBase.hxx"
23 #include "MEDFileUtilities.hxx"
25 #include "MEDCouplingFieldDouble.hxx"
26 #include "MEDCouplingFieldDiscretization.hxx"
28 #include "InterpKernelAutoPtr.hxx"
29 #include "CellModel.hxx"
34 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
35 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
36 extern med_geometry_type typmainoeud[1];
37 extern med_geometry_type typmai3[32];
39 using namespace ParaMEDMEM;
41 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
43 return new MEDFileFieldLoc(fid,locName);
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
48 return new MEDFileFieldLoc(fid,id);
51 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)
53 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
56 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
58 med_geometry_type geotype;
59 med_geometry_type sectiongeotype;
61 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
62 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
63 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
64 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
65 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
66 _nb_node_per_cell=cm.getNumberOfNodes();
67 _ref_coo.resize(_dim*_nb_node_per_cell);
68 _gs_coo.resize(_dim*_nb_gauss_pt);
69 _w.resize(_nb_gauss_pt);
70 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
73 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
75 med_geometry_type geotype;
76 med_geometry_type sectiongeotype;
78 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
79 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
80 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
81 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
83 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
84 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
85 _nb_node_per_cell=cm.getNumberOfNodes();
86 _ref_coo.resize(_dim*_nb_node_per_cell);
87 _gs_coo.resize(_dim*_nb_gauss_pt);
88 _w.resize(_nb_gauss_pt);
89 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
92 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
93 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),
96 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
97 _dim=cm.getDimension();
98 _nb_node_per_cell=cm.getNumberOfNodes();
99 _nb_gauss_pt=_w.size();
102 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
104 static const char OFF7[]="\n ";
105 oss << "\"" << _name << "\"" << OFF7;
106 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
107 oss << "Dimension=" << _dim << OFF7;
108 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
109 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
110 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
111 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
112 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
115 void MEDFileFieldLoc::setName(const char *name)
120 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
122 if(_name!=other._name)
126 if(_nb_gauss_pt!=other._nb_gauss_pt)
128 if(_nb_node_per_cell!=other._nb_node_per_cell)
130 if(_geo_type!=other._geo_type)
132 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
134 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
136 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
142 void MEDFileFieldLoc::writeLL(med_idt fid) const
144 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);
147 std::string MEDFileFieldLoc::repr() const
149 std::ostringstream oss; oss.precision(15);
150 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
151 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
152 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
153 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
154 oss << "\n - Ref coords are : ";
155 int sz=_ref_coo.size();
158 int nbOfTuples=sz/_dim;
159 for(int i=0;i<nbOfTuples;i++)
162 for(int j=0;j<_dim;j++)
163 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
168 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
169 oss << "\n - Gauss coords in reference element : ";
173 int nbOfTuples=sz/_dim;
174 for(int i=0;i<nbOfTuples;i++)
177 for(int j=0;j<_dim;j++)
178 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
183 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
184 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
188 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
190 _type=field->getTypeOfField();
191 const DataArrayDouble *da=field->getArray();
197 getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
198 _end=_start+nbOfCells;
204 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
205 const int *arrPtr=arr->getConstPointer();
206 getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
207 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
213 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
214 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
215 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
217 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
218 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
219 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
220 const int *dai2Ptr=dai2->getConstPointer();
221 int nbi=gsLoc.getWeights().size();
222 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
224 const int *da3Ptr=da3->getConstPointer();
225 if(da3->getNumberOfTuples()!=nbOfCells)
226 {//profile : for gauss even in NoProfile !!!
227 std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
229 da3->setName(_profile.c_str());
230 glob.appendProfile(da3);
232 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
233 _nval=da3->getNbOfElems();
234 da4->alloc(_nval*nbi,1);
235 int *da4Ptr=da4->getPointer();
236 for(int i=0;i<_nval;i++)
238 int ref=dai2Ptr[offset+da3Ptr[i]];
239 for(int j=0;j<nbi;j++)
242 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
243 _localization=oss2.str();
244 getArray()->setContigPartOfSelectedValues(_start,da,da4);
245 _end=_start+_nval*nbi;
246 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
250 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
256 * Leaf method of field with profile assignement.
257 * @param pflName input containing name of profile if any. 0 if no profile.
258 * @param multiTypePfl input containing the profile array \b including \b all \b types. This array is usefull only for GAUSS_NE.
259 * @param idsInPfl input containing the ids in the profile 'multiTypePfl' concerning the current geo type.
261 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)
267 _type=field->getTypeOfField();
268 const DataArrayDouble *da=field->getArray();
274 _nval=idsInPfl->getNumberOfTuples();
275 getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
281 _nval=idsInPfl->getNumberOfTuples();
282 getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
288 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
289 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
290 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples());
291 arr3->computeOffsets2();
292 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
293 int trueNval=tmp->getNumberOfTuples();
294 _nval=idsInPfl->getNumberOfTuples();
295 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
296 _end=_start+trueNval;
301 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for profiles on gauss points !");
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
309 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
312 _nval=field->getArray()->getNumberOfTuples();
313 getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
318 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
320 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
323 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
325 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
328 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
330 return new MEDFileFieldPerMeshPerTypePerDisc(other);
333 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
334 try:_type(atype),_father(fath)
337 catch(INTERP_KERNEL::Exception& e)
342 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
346 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)
350 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
351 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
355 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
360 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
362 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
363 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
364 std::string fieldName=getName();
365 std::string meshName=getMeshName();
366 int iteration=getIteration();
367 int order=getOrder();
368 TypeOfField type=getType();
369 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
371 med_geometry_type mgeoti;
372 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
373 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
374 pflname,&profilesize,locname,&nbi);
375 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
376 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
378 _end=start+_nval*nbi;
380 if(type==ON_CELLS && !_localization.empty())
382 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
383 setType(ON_GAUSS_PT);
386 setType(ON_GAUSS_NE);
387 _localization.clear();
392 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
394 std::string fieldName=getName();
395 std::string meshName=getMeshName();
396 int iteration=getIteration();
397 int order=getOrder();
398 TypeOfField type=getType();
399 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
400 med_geometry_type mgeoti;
401 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
402 DataArrayDouble *arr=getArray();
403 double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
408 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
409 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
414 INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
415 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
416 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
417 std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
421 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
426 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
428 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
430 int delta=_end-_start;
431 _start=newValueOfStart;
435 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
437 return _father->getIteration();
440 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
442 return _father->getOrder();
445 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
447 return _father->getTime();
450 std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
452 return _father->getName();
455 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
457 return _father->getMeshName();
460 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
462 const char startLine[]=" ## ";
463 std::string startLine2(bkOffset,' ');
464 startLine2+=startLine;
465 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
466 oss << startLine2 << "Localization #" << id << "." << std::endl;
467 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
469 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
470 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
471 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
474 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
479 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
484 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
489 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
491 return _father->getGeoType();
494 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
496 return _father->getNumberOfComponents();
499 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
504 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
506 return _father->getArray();
509 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
511 const MEDFileFieldPerMeshPerType *fath=_father;
512 return fath->getArray();
515 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
517 return _father->getInfo();
520 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
525 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
530 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
532 return _localization;
535 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
537 _localization=newLocName;
540 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
542 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
544 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
546 _profile=(*it2).second;
552 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
554 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
556 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
558 _localization=(*it2).second;
564 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
568 dads.push_back(std::pair<int,int>(_start,_end));
569 geoTypes.push_back(getGeoType());
574 pfls.push_back(glob->getProfile(_profile.c_str()));
576 if(_localization.empty())
580 locs.push_back(glob->getLocalizationId(_localization.c_str()));
584 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
586 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));
590 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
592 TypeOfField type=getType();
593 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
594 med_geometry_type mgeoti;
595 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
596 const DataArrayDouble *arr=getArray();
597 const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
598 MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
599 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
600 reinterpret_cast<const unsigned char*>(locToWrite));
603 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
608 dad.first=_start; dad.second=_end;
612 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
613 * This code corresponds to the distribution of types in the corresponding mesh.
614 * \param [out] ptToFill memory zone where the output will be stored.
615 * \return the size of data pushed into output param \a ptToFill
617 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
620 std::ostringstream oss;
621 std::size_t nbOfType=codeOfMesh.size()/3;
622 std::size_t found=-1;
623 for(std::size_t i=0;i<nbOfType && found==-1;i++)
624 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
628 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
629 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
630 throw INTERP_KERNEL::Exception(oss.str().c_str());
635 if(_nval!=codeOfMesh[3*found+1])
637 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
638 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
639 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
640 throw INTERP_KERNEL::Exception(oss.str().c_str());
642 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
647 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
648 if(pfl->getNumberOfTuples()!=_nval)
650 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
651 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
653 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
654 throw INTERP_KERNEL::Exception(oss.str().c_str());
656 int offset=codeOfMesh[3*found+2];
657 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
659 if(*pflId<codeOfMesh[3*found+1])
660 *work++=offset+*pflId;
666 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
668 for(int i=_start;i<_end;i++)
673 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
688 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
691 std::map<std::pair<std::string,TypeOfField>,int> m;
692 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
693 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
694 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
695 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
697 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
698 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
703 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
705 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
706 * \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.
707 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
708 * \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)
709 * \param [in,out] glob if necessary by the method, new profiles can be added to it
710 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
711 * \param [out] result All new entries will be appended on it.
712 * \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 !)
714 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
715 const DataArrayInt *explicitIdsInMesh,
716 const std::vector<int>& newCode,
717 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
718 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
720 if(entriesOnSameDisc.empty())
722 TypeOfField type=entriesOnSameDisc[0]->getType();
723 int szEntities=0,szTuples=0;
724 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
725 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
726 int nbi=szTuples/szEntities;
727 if(szTuples%szEntities!=0)
728 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
729 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
730 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
731 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
732 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
733 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
734 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
735 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
737 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
739 int startOfEltIdOfChunk=(*it)->_start;
740 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
741 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
742 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
744 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
745 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
747 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
748 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
750 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
751 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
752 std::set<int> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
753 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
755 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
757 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
758 arrPart->renumberInPlace(renumTupleIds->begin());
759 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
761 std::set<int>::const_iterator idIt=diffVals.begin();
762 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
764 for(std::size_t i=0;i<diffVals.size();i++,idIt++)
766 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
767 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
768 int nbEntityElts=subIds->getNumberOfTuples();
770 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
771 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
775 result.push_back(eltToAdd);
776 offset2+=nbEntityElts*nbi;
778 ret=ret || li.empty();
783 * \param [in] typeF type of field of new chunk
784 * \param [in] geoType the geometric type of the chunk
785 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
786 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
787 * \param [in] nbi number of integration points
788 * \param [in] offset The offset in the **global array of data**.
789 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
790 * to the new chunk to create.
791 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
792 * \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
793 * and corresponding entry erased from \a entriesOnSameDisc.
794 * \return a newly allocated chunk
796 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
797 bool isPfl, int nbi, int offset,
798 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
799 MEDFileFieldGlobsReal& glob,
800 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
802 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
803 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
804 for(;it!=entriesOnSameDisc.end();it++)
806 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
809 if((*it)->_profile.empty())
812 if(!(*it)->_profile.empty())
814 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
815 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
820 if(it==entriesOnSameDisc.end())
823 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
825 ret->_loc_id=(int)geoType;
826 ret->_nval=nbMeshEntities;
828 ret->_end=ret->_start+ret->_nval*nbi;
831 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
832 glob.appendProfile(idsOfMeshElt);
833 ret->_profile=idsOfMeshElt->getName();
835 //tony treatment of localization
841 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
842 ret->_loc_id=(int)geoType;
843 ret->setNewStart(offset);
844 entriesOnSameDisc.erase(it);
850 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
852 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
855 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
857 return new MEDFileFieldPerMeshPerType(fath,geoType);
860 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
862 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
863 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
864 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
867 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)
869 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
873 std::string pflName(locIds->getName());
875 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignFieldProfile : existing profile with empty name !");
876 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
877 std::ostringstream oss; oss << pflName << "_" << cm.getRepr();
878 locIds->setName(oss.str().c_str());
879 glob.appendProfile(locIds);
881 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
882 _field_pm_pt_pd[*it]->assignFieldProfile(start,oss.str().c_str(),multiTypePfl,idsInPfl,field,mesh,glob);
886 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
887 _field_pm_pt_pd[*it]->assignFieldProfile(start,0,multiTypePfl,idsInPfl,field,mesh,glob);
891 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
893 _field_pm_pt_pd.resize(1);
894 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
895 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
898 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
900 std::string pflName(pfl->getName());
902 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : existing profile with empty name !");
903 std::ostringstream oss; oss << pflName << "_NODE";
904 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
905 pfl2->setName(oss.str().c_str());
906 glob.appendProfile(pfl2);
908 _field_pm_pt_pd.resize(1);
909 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
910 _field_pm_pt_pd[0]->assignFieldProfile(start,oss.str().c_str(),pfl,pfl2,field,0,glob);//mesh is not requested so 0 is send.
913 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
915 TypeOfField type=field->getTypeOfField();
916 if(type!=ON_GAUSS_PT)
918 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
919 int sz=_field_pm_pt_pd.size();
921 for(int j=0;j<sz && !found;j++)
923 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
925 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
931 _field_pm_pt_pd.resize(sz+1);
932 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
934 std::vector<int> ret(1,0);
939 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
941 std::vector<int> ret3(sz2);
943 for(int i=0;i<sz2;i++)
945 int sz=_field_pm_pt_pd.size();
946 int locIdToFind=ret2[i];
948 for(int j=0;j<sz && !found;j++)
950 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
952 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
959 _field_pm_pt_pd.resize(sz+1);
960 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
968 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
970 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
971 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
973 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
974 const DataArrayInt *da=disc2->getArrayOfDiscIds();
975 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
976 std::set<int> retTmp=da2->getDifferentValues();
977 if(retTmp.find(-1)!=retTmp.end())
978 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
979 std::vector<int> ret(retTmp.begin(),retTmp.end());
983 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
985 TypeOfField type=field->getTypeOfField();
986 if(type!=ON_GAUSS_PT)
988 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
989 int sz=_field_pm_pt_pd.size();
991 for(int j=0;j<sz && !found;j++)
993 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
995 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1001 _field_pm_pt_pd.resize(sz+1);
1002 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1004 std::vector<int> ret(1,0);
1009 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1010 int sz2=ret2.size();
1011 std::vector<int> ret3(sz2);
1013 for(int i=0;i<sz2;i++)
1015 int sz=_field_pm_pt_pd.size();
1016 int locIdToFind=ret2[i];
1018 for(int j=0;j<sz && !found;j++)
1020 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1022 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1029 _field_pm_pt_pd.resize(sz+1);
1030 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1038 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1040 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1041 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1043 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1044 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1045 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1046 std::set<int> retTmp=da2->getDifferentValues();
1047 if(retTmp.find(-1)!=retTmp.end())
1048 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1049 std::vector<int> ret(retTmp.begin(),retTmp.end());
1053 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1058 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1060 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1061 int curDim=(int)cm.getDimension();
1062 dim=std::max(dim,curDim);
1065 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1067 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1069 (*it)->fillTypesOfFieldAvailable(types);
1073 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)
1075 int sz=_field_pm_pt_pd.size();
1076 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1077 for(int i=0;i<sz;i++)
1079 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1083 int MEDFileFieldPerMeshPerType::getIteration() const
1085 return _father->getIteration();
1088 int MEDFileFieldPerMeshPerType::getOrder() const
1090 return _father->getOrder();
1093 double MEDFileFieldPerMeshPerType::getTime() const
1095 return _father->getTime();
1098 std::string MEDFileFieldPerMeshPerType::getName() const
1100 return _father->getName();
1103 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1105 return _father->getMeshName();
1108 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1110 const char startLine[]=" ## ";
1111 std::string startLine2(bkOffset,' ');
1112 std::string startLine3(startLine2);
1113 startLine3+=startLine;
1114 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1116 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1117 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1120 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1121 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1123 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1125 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1127 cur->simpleRepr(bkOffset,oss,i);
1130 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1135 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1137 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1139 globalSz+=(*it)->getNumberOfTuples();
1141 nbOfEntries+=(int)_field_pm_pt_pd.size();
1144 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1150 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1152 return _father->getNumberOfComponents();
1155 DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
1157 return _father->getArray();
1160 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
1162 const MEDFileFieldPerMesh *fath=_father;
1163 return fath->getArray();
1166 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1168 return _father->getInfo();
1171 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1173 std::vector<std::string> ret;
1174 std::set<std::string> ret2;
1175 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1177 std::string tmp=(*it1)->getProfile();
1179 if(ret2.find(tmp)==ret2.end())
1188 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1190 std::vector<std::string> ret;
1191 std::set<std::string> ret2;
1192 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1194 std::string tmp=(*it1)->getLocalization();
1195 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1196 if(ret2.find(tmp)==ret2.end())
1205 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1207 std::vector<std::string> ret;
1208 std::set<std::string> ret2;
1209 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1211 std::string tmp=(*it1)->getProfile();
1218 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1220 std::vector<std::string> ret;
1221 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1223 std::string tmp=(*it1)->getLocalization();
1224 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1230 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1232 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1233 (*it1)->changePflsRefsNamesGen(mapOfModif);
1236 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1238 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1239 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1242 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1244 if(_field_pm_pt_pd.empty())
1246 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1247 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1248 throw INTERP_KERNEL::Exception(oss.str().c_str());
1250 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1251 return _field_pm_pt_pd[locId];
1252 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1253 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1254 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1255 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1256 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1259 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1261 if(_field_pm_pt_pd.empty())
1263 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1264 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1265 throw INTERP_KERNEL::Exception(oss.str().c_str());
1267 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1268 return _field_pm_pt_pd[locId];
1269 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1270 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1271 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1272 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1273 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1276 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
1278 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1280 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1281 if(meshDim!=(int)cm.getDimension())
1284 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1285 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1288 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1291 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1293 (*it)->fillValues(i,startEntryId,entries);
1297 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1299 _field_pm_pt_pd=leaves;
1300 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1301 (*it)->setFather(this);
1304 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1308 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1310 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1311 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1312 med_geometry_type mgeoti;
1313 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1314 int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1315 _field_pm_pt_pd.resize(nbProfiles);
1316 for(int i=0;i<nbProfiles;i++)
1318 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1322 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
1325 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1327 (*it)->prepareLoading(fid,pflId+1,start);
1331 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1334 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1336 (*it)->finishLoading(fid,pflId+1,ft);
1340 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1342 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 (*it)->copyOptionsFrom(*this);
1345 (*it)->writeLL(fid);
1349 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1354 medfGeoType=typmai3[(int)ikGeoType];
1357 medfGeoType=MED_NONE;
1360 medfGeoType=typmai3[(int)ikGeoType];
1361 return MED_NODE_ELEMENT;
1363 medfGeoType=typmai3[(int)ikGeoType];
1366 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1368 return MED_UNDEF_ENTITY_TYPE;
1371 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
1373 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
1376 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1378 return new MEDFileFieldPerMesh(fath,mesh);
1381 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1383 std::string startLine(bkOffset,' ');
1384 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1385 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1387 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1389 const MEDFileFieldPerMeshPerType *cur=*it;
1391 cur->simpleRepr(bkOffset,oss,i);
1394 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1399 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1401 _mesh_name=mesh->getName();
1402 mesh->getTime(_mesh_iteration,_mesh_order);
1405 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)
1407 int nbOfTypes=code.size()/3;
1408 bool isProfile=false;
1409 for(int i=0;i<nbOfTypes;i++)
1414 if(idsInPflPerType.empty())
1415 assignFieldNoProfileNoRenum(start,code,field,glob);
1417 assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
1420 assignFieldProfileGeneral(start,multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
1423 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1425 int nbOfTypes=code.size()/3;
1427 for(int i=0;i<nbOfTypes;i++)
1429 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1430 int nbOfCells=code[3*i+1];
1431 int pos=addNewEntryIfNecessary(type);
1432 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
1438 * This method is the most general one. No optimization is done here.
1440 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)
1442 int nbOfTypes=code.size()/3;
1443 for(int i=0;i<nbOfTypes;i++)
1445 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1446 int pos=addNewEntryIfNecessary(type);
1447 DataArrayInt *pfl=0;
1449 pfl=idsPerType[code[3*i+2]];
1450 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,field,mesh,glob);
1454 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1456 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1457 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
1460 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1462 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1463 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
1466 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
1468 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1469 (*it)->prepareLoading(fid,start);
1472 void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1474 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1475 (*it)->finishLoading(fid,ft);
1478 void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1480 int nbOfTypes=_field_pm_pt.size();
1481 for(int i=0;i<nbOfTypes;i++)
1483 _field_pm_pt[i]->copyOptionsFrom(*this);
1484 _field_pm_pt[i]->writeLL(fid);
1488 void MEDFileFieldPerMesh::getDimension(int& dim) const
1490 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1491 (*it)->getDimension(dim);
1494 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1496 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1497 (*it)->fillTypesOfFieldAvailable(types);
1500 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)
1502 int sz=_field_pm_pt.size();
1503 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1504 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1505 for(int i=0;i<sz;i++)
1507 types[i]=_field_pm_pt[i]->getGeoType();
1508 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1513 double MEDFileFieldPerMesh::getTime() const
1516 return _father->getTime(tmp1,tmp2);
1519 int MEDFileFieldPerMesh::getIteration() const
1521 return _father->getIteration();
1524 const std::string& MEDFileFieldPerMesh::getDtUnit() const
1526 return _father->getDtUnit();
1529 int MEDFileFieldPerMesh::getOrder() const
1531 return _father->getOrder();
1534 std::string MEDFileFieldPerMesh::getName() const
1536 return _father->getName();
1539 int MEDFileFieldPerMesh::getNumberOfComponents() const
1541 return _father->getNumberOfComponents();
1544 DataArrayDouble *MEDFileFieldPerMesh::getArray()
1546 return _father->getOrCreateAndGetArray();
1549 const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
1551 const MEDFileField1TSWithoutSDA *fath=_father;
1552 return fath->getOrCreateAndGetArray();
1555 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1557 return _father->getInfo();
1561 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1562 * 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.
1563 * It returns 2 output vectors :
1564 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1565 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1566 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1568 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)
1570 int notNullPflsSz=0;
1571 int nbOfArrs=geoTypes.size();
1572 for(int i=0;i<nbOfArrs;i++)
1575 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1576 int nbOfDiffGeoTypes=geoTypes3.size();
1577 code.resize(3*nbOfDiffGeoTypes);
1578 notNullPfls.resize(notNullPflsSz);
1581 for(int i=0;i<nbOfDiffGeoTypes;i++)
1584 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1585 std::vector<const DataArrayInt *> notNullTmp;
1587 notNullTmp.push_back(pfls[j]);
1589 for(;j<nbOfArrs;j++)
1590 if(geoTypes[j]==refType)
1593 notNullTmp.push_back(pfls[j]);
1597 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1598 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1599 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1600 code[3*i]=(int)refType;
1601 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1602 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1603 if(notNullTmp.empty())
1607 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1608 code[3*i+2]=notNullPflsSz++;
1614 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1616 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)
1620 for(int i=0;i<sz;i++)
1624 if(type!=ON_GAUSS_NE)
1625 ret+=dads[i].second-dads[i].first;
1628 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1629 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1634 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1635 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1641 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1643 std::vector<std::string> ret;
1644 std::set<std::string> ret2;
1645 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1647 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1648 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1649 if(ret2.find(*it2)==ret2.end())
1651 ret.push_back(*it2);
1658 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1660 std::vector<std::string> ret;
1661 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1663 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1664 ret.insert(ret.end(),tmp.begin(),tmp.end());
1669 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1671 std::vector<std::string> ret;
1672 std::set<std::string> ret2;
1673 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1675 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1676 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1677 if(ret2.find(*it2)==ret2.end())
1679 ret.push_back(*it2);
1686 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1688 std::vector<std::string> ret;
1689 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1691 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1692 ret.insert(ret.end(),tmp.begin(),tmp.end());
1697 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1699 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1701 if((*it).first==_mesh_name)
1703 _mesh_name=(*it).second;
1710 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1711 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1713 if(_mesh_name!=meshName)
1715 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1716 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1717 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1718 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1719 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1720 DataArrayDouble *arr=getUndergroundDataArrayExt(entries);
1723 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1724 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1726 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1728 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1729 sz+=(*it).second.second-(*it).second.first;
1732 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1734 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1735 ////////////////////
1736 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1737 int *workI2=explicitIdsOldInMesh->getPointer();
1738 int sz1=0,sz2=0,sid=1;
1739 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1740 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1741 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1743 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1744 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1745 int *workI=explicitIdsOldInArr->getPointer();
1746 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1748 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1749 (*itL2)->setLocId(sz2);
1750 (*itL2)->_tmp_work1=(*itL2)->getStart();
1751 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1753 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1755 explicitIdsOldInMesh->reAlloc(sz2);
1756 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1757 ////////////////////
1758 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1759 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1760 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1761 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1763 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1764 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1765 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1767 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1768 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1769 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1771 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1772 int newStart=elt->getLocId();
1773 elt->setLocId((*it)->getGeoType());
1774 elt->setNewStart(newStart);
1775 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1776 entriesKeptNew.push_back(elt);
1777 entriesKeptNew2.push_back(elt);
1779 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1780 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1781 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1782 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1784 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1787 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1789 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1790 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1792 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1793 glob,arr2,otherEntriesNew) || ret;
1797 // Assign new dispatching
1798 assignNewLeaves(otherEntriesNew);
1799 arr->cpyFrom(*arr2);
1803 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1805 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1806 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1807 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1809 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1810 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1811 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1812 for(;it1!=types.end();it1++,it2++)
1814 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1815 elt->setLeaves((*it1).second);
1818 _field_pm_pt=fieldPmPt;
1821 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1823 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1824 (*it)->changePflsRefsNamesGen(mapOfModif);
1827 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1829 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1830 (*it)->changeLocsRefsNamesGen(mapOfModif);
1833 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
1835 if(_field_pm_pt.empty())
1836 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1838 std::vector< std::pair<int,int> > dads;
1839 std::vector<const DataArrayInt *> pfls;
1840 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1841 std::vector<int> locs,code;
1842 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1843 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1846 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1849 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1850 throw INTERP_KERNEL::Exception(oss.str().c_str());
1853 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1854 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1857 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1859 return finishField(type,glob,dads,locs,mesh,isPfl);
1862 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1863 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
1869 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1873 if(nb!=mesh->getNumberOfNodes())
1875 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1876 oss << " nodes in mesh !";
1877 throw INTERP_KERNEL::Exception(oss.str().c_str());
1879 return finishField(type,glob,dads,locs,mesh,isPfl);
1882 return finishField3(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
1886 DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
1888 if(_field_pm_pt.empty())
1889 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1891 std::vector<std::pair<int,int> > dads;
1892 std::vector<const DataArrayInt *> pfls;
1893 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1894 std::vector<int> locs,code;
1895 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1896 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1897 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1899 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1902 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1903 throw INTERP_KERNEL::Exception(oss.str().c_str());
1905 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1906 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1909 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1910 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
1915 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1919 if(nb!=mesh->getNumberOfNodes())
1921 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1922 oss << " nodes in mesh !";
1923 throw INTERP_KERNEL::Exception(oss.str().c_str());
1926 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
1932 DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
1936 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1938 (*it)->getSizes(globalSz,nbOfEntries);
1940 entries.resize(nbOfEntries);
1942 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1944 (*it)->fillValues(nbOfEntries,entries);
1946 return _father->getUndergroundDataArray();
1949 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
1951 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1953 if((*it)->getGeoType()==typ)
1954 return (*it)->getLeafGivenLocId(locId);
1956 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
1957 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
1958 oss << "Possiblities are : ";
1959 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1961 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
1962 oss << "\"" << cm2.getRepr() << "\", ";
1964 throw INTERP_KERNEL::Exception(oss.str().c_str());
1967 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
1969 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1971 if((*it)->getGeoType()==typ)
1972 return (*it)->getLeafGivenLocId(locId);
1974 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
1975 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
1976 oss << "Possiblities are : ";
1977 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1979 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
1980 oss << "\"" << cm2.getRepr() << "\", ";
1982 throw INTERP_KERNEL::Exception(oss.str().c_str());
1985 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
1988 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
1989 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
1990 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1992 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
1997 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2002 int ret=std::distance(_field_pm_pt.begin(),it2);
2003 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2008 * 'dads' and 'locs' input parameters have the same number of elements.
2010 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2011 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2012 const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2015 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2016 ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
2017 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2018 const std::vector<std::string>& infos=getInfo();
2019 da->setInfoOnComponents(infos);
2022 if(type==ON_GAUSS_PT)
2025 int nbOfArrs=dads.size();
2026 for(int i=0;i<nbOfArrs;i++)
2028 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2029 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2030 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2031 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2032 di->alloc(nbOfElems,1);
2034 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2035 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2045 * 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.
2046 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2047 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2048 * The order of cells in the returned field is those imposed by the profile.
2050 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2051 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2052 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2053 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2055 if(da->isIdentity())
2057 int nbOfTuples=da->getNumberOfTuples();
2058 if(nbOfTuples==mesh->getNumberOfCells())
2059 return finishField(type,glob,dads,locs,mesh,isPfl);
2061 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,mesh,isPfl);
2063 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2064 m2->setName(mesh->getName());
2071 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2073 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFileFieldGlobsReal *glob,
2074 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2075 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2077 if(da->isIdentity())
2079 int nbOfTuples=da->getNumberOfTuples();
2080 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2081 if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,geoTypes2,dads,locs))//No problem for NORM_ERROR because it is in context of node
2082 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2084 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2085 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2088 if(meshu->getNodalConnectivity()==0)
2090 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
2091 int nb=da->getNbOfElems();
2092 const int *ptr=da->getConstPointer();
2093 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2094 meshuc->allocateCells(nb);
2095 for(int i=0;i<nb;i++)
2096 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2097 meshuc->finishInsertingCells();
2098 ret->setMesh(meshuc);
2099 ret->checkCoherency();
2105 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2107 DataArrayInt *arr2=0;
2108 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2109 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2110 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2111 int nnodes=mesh2->getNumberOfNodes();
2112 if(nnodes==da->getNbOfElems())
2114 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->getConstPointer(),arr2->getConstPointer()+arr2->getNbOfElems());
2115 ret->getArray()->renumberInPlace(da3->getConstPointer());
2116 mesh2->setName(mesh->getName());
2117 ret->setMesh(mesh2);
2123 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 !!!";
2124 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2125 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2126 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2127 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2128 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2129 throw INTERP_KERNEL::Exception(oss.str().c_str());
2135 * This method is the most light method of field retrieving.
2137 DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2141 pflOut=DataArrayInt::New();
2142 pflOut->alloc(nbOfElems,1);
2147 pflOut=const_cast<DataArrayInt*>(pflIn);
2150 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2151 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2152 const std::vector<std::string>& infos=getInfo();
2153 int nbOfComp=infos.size();
2154 for(int i=0;i<nbOfComp;i++)
2155 da->setInfoOnComponent(i,infos[i].c_str());
2161 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2162 _mesh_csit(meshCsit),_father(fath)
2164 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2165 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2166 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2167 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2169 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2172 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
2173 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2175 nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2178 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
2179 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2182 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2185 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
2186 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2190 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2192 copyTinyInfoFrom(mesh);
2195 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2197 if(id>=(int)_pfls.size())
2199 _pfls[id]=DataArrayInt::New();
2200 int lgth=MEDprofileSizeByName(fid,pflName);
2201 _pfls[id]->setName(pflName);
2202 _pfls[id]->alloc(lgth,1);
2203 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2204 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2207 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2209 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2211 MEDprofileInfo(fid,i+1,pflName,&sz);
2212 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2213 if(i>=(int)_pfls.size())
2215 _pfls[i]=DataArrayInt::New();
2216 _pfls[i]->alloc(sz,1);
2217 _pfls[i]->setName(pflCpp.c_str());
2218 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2219 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2222 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2224 int nbOfPfls=_pfls.size();
2225 for(int i=0;i<nbOfPfls;i++)
2227 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2228 cpy->applyLin(1,1,0);
2229 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2230 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2231 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2234 int nbOfLocs=_locs.size();
2235 for(int i=0;i<nbOfLocs;i++)
2236 _locs[i]->writeLL(fid);
2239 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2241 std::vector<std::string> pfls=getPfls();
2242 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2244 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2247 _pfls.push_back(*it);
2251 int id=std::distance(pfls.begin(),it2);
2252 if(!(*it)->isEqual(*_pfls[id]))
2254 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2255 throw INTERP_KERNEL::Exception(oss.str().c_str());
2259 std::vector<std::string> locs=getLocs();
2260 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2262 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2265 _locs.push_back(*it);
2269 int id=std::distance(locs.begin(),it2);
2270 if(!(*it)->isEqual(*_locs[id],eps))
2272 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2273 throw INTERP_KERNEL::Exception(oss.str().c_str());
2279 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2281 std::vector<std::string> profiles=real.getPflsReallyUsed();
2282 int sz=profiles.size();
2284 for(int i=0;i<sz;i++)
2285 loadProfileInFile(fid,i,profiles[i].c_str());
2287 std::vector<std::string> locs=real.getLocsReallyUsed();
2290 for(int i=0;i<sz;i++)
2291 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2294 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2296 int nProfil=MEDnProfile(fid);
2297 for(int i=0;i<nProfil;i++)
2298 loadProfileInFile(fid,i);
2299 int sz=MEDnLocalization(fid);
2301 for(int i=0;i<sz;i++)
2303 _locs[i]=MEDFileFieldLoc::New(fid,i);
2307 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2309 return new MEDFileFieldGlobs(fname);
2312 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2314 return new MEDFileFieldGlobs;
2317 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2321 MEDFileFieldGlobs::MEDFileFieldGlobs()
2325 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2329 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2331 oss << "Profiles :\n";
2332 std::size_t n=_pfls.size();
2333 for(std::size_t i=0;i<n;i++)
2335 oss << " - #" << i << " ";
2336 const DataArrayInt *pfl=_pfls[i];
2338 oss << "\"" << pfl->getName() << "\"\n";
2343 oss << "Localizations :\n";
2344 for(std::size_t i=0;i<n;i++)
2346 oss << " - #" << i << " ";
2347 const MEDFileFieldLoc *loc=_locs[i];
2349 loc->simpleRepr(oss);
2355 void MEDFileFieldGlobs::setFileName(const char *fileName)
2357 _file_name=fileName;
2360 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2362 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2364 DataArrayInt *elt(*it);
2367 std::string name(elt->getName());
2368 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2370 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2372 elt->setName((*it2).second.c_str());
2380 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2384 MEDFileFieldLoc *elt(*it);
2387 std::string name(elt->getName());
2388 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2390 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2392 elt->setName((*it2).second.c_str());
2400 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2402 if(locId<0 || locId>=(int)_locs.size())
2403 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2404 return _locs[locId]->getNbOfGaussPtPerCell();
2407 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2409 return getLocalizationFromId(getLocalizationId(locName));
2412 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2414 if(locId<0 || locId>=(int)_locs.size())
2415 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2416 return *_locs[locId];
2419 namespace ParaMEDMEMImpl
2424 LocFinder(const char *loc):_loc(loc) { }
2425 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2433 PflFinder(const std::string& pfl):_pfl(pfl) { }
2434 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2436 const std::string& _pfl;
2440 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2442 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2445 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2446 for(it=_locs.begin();it!=_locs.end();it++)
2447 oss << "\"" << (*it)->getName() << "\", ";
2448 throw INTERP_KERNEL::Exception(oss.str().c_str());
2450 return std::distance(_locs.begin(),it);
2453 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2455 std::string pflNameCpp(pflName);
2456 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2459 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2460 for(it=_pfls.begin();it!=_pfls.end();it++)
2461 oss << "\"" << (*it)->getName() << "\", ";
2462 throw INTERP_KERNEL::Exception(oss.str().c_str());
2467 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2469 if(pflId<0 || pflId>=(int)_pfls.size())
2470 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2471 return _pfls[pflId];
2474 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2476 if(locId<0 || locId>=(int)_locs.size())
2477 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2478 return *_locs[locId];
2481 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2483 return getLocalizationFromId(getLocalizationId(locName));
2486 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2488 std::string pflNameCpp(pflName);
2489 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2492 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2493 for(it=_pfls.begin();it!=_pfls.end();it++)
2494 oss << "\"" << (*it)->getName() << "\", ";
2495 throw INTERP_KERNEL::Exception(oss.str().c_str());
2500 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2502 if(pflId<0 || pflId>=(int)_pfls.size())
2503 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2504 return _pfls[pflId];
2507 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2509 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2511 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2513 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2514 newPfls.push_back(*it);
2519 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2521 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2523 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2525 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2526 newLocs.push_back(*it);
2531 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2533 int sz=_pfls.size();
2534 std::vector<std::string> ret(sz);
2535 for(int i=0;i<sz;i++)
2536 ret[i]=_pfls[i]->getName();
2540 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2542 int sz=_locs.size();
2543 std::vector<std::string> ret(sz);
2544 for(int i=0;i<sz;i++)
2545 ret[i]=_locs[i]->getName();
2549 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2551 std::vector<std::string> v=getPfls();
2552 std::string s(pflName);
2553 return std::find(v.begin(),v.end(),s)!=v.end();
2556 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2558 std::vector<std::string> v=getLocs();
2559 std::string s(locName);
2560 return std::find(v.begin(),v.end(),s)!=v.end();
2563 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2565 std::map<int,std::vector<int> > m;
2567 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2569 const DataArrayInt *tmp=(*it);
2572 m[tmp->getHashCode()].push_back(i);
2575 std::vector< std::vector<int> > ret;
2576 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2578 if((*it2).second.size()>1)
2580 std::vector<int> ret0;
2581 bool equalityOrNot=false;
2582 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2584 std::vector<int>::const_iterator it4=it3; it4++;
2585 for(;it4!=(*it2).second.end();it4++)
2587 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2590 ret0.push_back(*it3);
2591 ret0.push_back(*it4);
2597 ret.push_back(ret0);
2603 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2605 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2608 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2610 std::string name(pfl->getName());
2612 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2613 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2614 if(name==(*it)->getName())
2616 if(!pfl->isEqual(*(*it)))
2618 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2619 throw INTERP_KERNEL::Exception(oss.str().c_str());
2623 _pfls.push_back(pfl);
2626 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)
2628 std::string name(locName);
2630 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2631 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2632 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2633 if((*it)->isName(locName))
2635 if(!(*it)->isEqual(*obj,1e-12))
2637 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2638 throw INTERP_KERNEL::Exception(oss.str().c_str());
2641 _locs.push_back(obj);
2644 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2646 std::vector<std::string> names=getPfls();
2647 return CreateNewNameNotIn("NewPfl_",names);
2650 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2652 std::vector<std::string> names=getLocs();
2653 return CreateNewNameNotIn("NewLoc_",names);
2656 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2658 for(std::size_t sz=0;sz<100000;sz++)
2660 std::ostringstream tryName;
2661 tryName << prefix << sz;
2662 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2663 return tryName.str();
2665 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2668 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2672 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2676 void MEDFileFieldGlobsReal::simpleRepr(std::ostream& oss) const
2678 oss << "Globals information on fields :" << "\n*******************************\n\n";
2679 const MEDFileFieldGlobs *glob=_globals;
2681 glob->simpleRepr(oss);
2683 oss << "NO GLOBAL INFORMATION !\n";
2686 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2690 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2692 _globals=other._globals;
2695 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2697 _globals->appendGlobs(*other._globals,eps);
2700 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2702 _globals->loadProfileInFile(fid,id,pflName);
2705 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
2707 _globals->loadProfileInFile(fid,id);
2710 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2712 _globals->loadGlobals(fid,*this);
2715 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2717 _globals->loadAllGlobals(fid);
2720 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2722 _globals->writeGlobals(fid,opt);
2725 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
2727 return _globals->getPfls();
2730 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
2732 return _globals->getLocs();
2735 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
2737 return _globals->existsPfl(pflName);
2740 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
2742 return _globals->existsLoc(locName);
2745 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2747 return _globals->createNewNameOfPfl();
2750 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2752 return _globals->createNewNameOfLoc();
2755 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
2757 _globals->setFileName(fileName);
2760 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
2762 return _globals->whichAreEqualProfiles();
2765 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
2767 return _globals->whichAreEqualLocs(eps);
2770 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2772 _globals->changePflsNamesInStruct(mapOfModif);
2775 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2777 _globals->changeLocsNamesInStruct(mapOfModif);
2781 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2782 * This method contrary to abstract method MEDFileFieldGlobsReal::changePflsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changePflsRefsNamesGen,
2783 * the profiles themselves and not only leaves of field.
2785 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2787 changePflsRefsNamesGen(mapOfModif);
2788 changePflsNamesInStruct(mapOfModif);
2792 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2793 * This method contrary to abstract method MEDFileFieldGlobsReal::changeLocsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changeLocsRefsNamesGen,
2794 * the localizations themselves and not only leaves of field.
2796 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2798 changeLocsRefsNamesGen(mapOfModif);
2799 changeLocsNamesInStruct(mapOfModif);
2803 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changePflsNames.
2805 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2807 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2808 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2810 changePflsNames(mapOfModif);
2814 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changeLocsNames.
2816 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2818 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2819 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2821 changeLocsNames(mapOfModif);
2824 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
2826 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
2827 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2829 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2831 std::vector< std::string > tmp((*it).size());
2833 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2834 tmp[j]=std::string(getProfileFromId(*it2)->getName());
2835 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2837 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2838 killProfileIds(tmp2);
2840 changePflsRefsNamesGen(ret);
2844 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
2846 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
2847 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2849 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2851 std::vector< std::string > tmp((*it).size());
2853 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2854 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
2855 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2857 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2858 killLocalizationIds(tmp2);
2860 changeLocsRefsNamesGen(ret);
2864 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2866 return _globals->getNbOfGaussPtPerCell(locId);
2869 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2871 return _globals->getLocalizationId(loc);
2874 const char *MEDFileFieldGlobsReal::getFileName() const
2876 return _globals->getFileName();
2879 std::string MEDFileFieldGlobsReal::getFileName2() const
2881 return _globals->getFileName2();
2884 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2886 return _globals->getLocalization(locName);
2889 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2891 return _globals->getLocalizationFromId(locId);
2894 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2896 return _globals->getProfile(pflName);
2899 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2901 return _globals->getProfileFromId(pflId);
2904 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2906 return _globals->getLocalizationFromId(locId);
2909 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2911 return _globals->getLocalization(locName);
2914 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2916 return _globals->getProfile(pflName);
2919 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2921 return _globals->getProfileFromId(pflId);
2924 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2926 _globals->killProfileIds(pflIds);
2929 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2931 _globals->killLocalizationIds(locIds);
2934 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2936 _globals->appendProfile(pfl);
2939 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)
2941 _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
2945 * This method returns the max dimension of 'this'.
2946 * This method returns -2 if 'this' is empty, -1 if only nodes are defined.
2948 int MEDFileField1TSWithoutSDA::getDimension() const
2951 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
2952 (*it)->getDimension(ret);
2956 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
2958 if(meshDimRelToMax>0)
2959 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
2962 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
2965 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
2966 int nbOfTypes=geoTypes.size();
2967 std::vector<int> code(3*nbOfTypes);
2968 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
2969 arr1->alloc(nbOfTypes,1);
2970 int *arrPtr=arr1->getPointer();
2971 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
2972 for(int i=0;i<nbOfTypes;i++,it++)
2973 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
2974 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
2975 const int *arrPtr2=arr2->getConstPointer();
2977 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
2980 int nbCells=mesh->getNumberOfCellsWithType(*it);
2981 code[3*pos]=(int)(*it);
2982 code[3*pos+1]=nbCells;
2983 code[3*pos+2]=-1;//no profiles
2985 std::vector<const DataArrayInt *> idsPerType;//no profiles
2986 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
2990 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
2995 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
2997 return new MEDFileField1TSWithoutSDA(fieldName,csit,fieldtype,iteration,order,infos);
3001 * This method copyies tiny info but also preallocated the DataArrayDouble instance in this->_arr.
3002 * This not allocated it allocates to the size of 'field' array. If already allocated it grows the array to
3003 * the previous size + the size of the array of the input 'field'.
3004 * This method returns the position (in tuple id) where to start to feed 'this->_arr'
3006 int MEDFileField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3008 std::string name(field->getName());
3009 getOrCreateAndGetArray()->setName(name.c_str());
3011 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
3012 const DataArrayDouble *arr=field->getArray();
3014 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
3015 _dt=field->getTime(_iteration,_order);
3016 int nbOfComponents=arr->getNumberOfComponents();
3017 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
3018 if(!getOrCreateAndGetArray()->isAllocated())
3020 _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
3025 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
3026 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
3027 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
3028 tmp->alloc(newNbOfTuples,nbOfComponents);
3029 tmp->copyStringInfoFrom(*_arr);
3030 std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
3032 return oldNbOfTuples;
3036 std::string MEDFileField1TSWithoutSDA::getName() const
3038 const DataArrayDouble *arr=getOrCreateAndGetArray();
3039 return arr->getName();
3042 void MEDFileField1TSWithoutSDA::setName(const char *name)
3044 DataArrayDouble *arr=getOrCreateAndGetArray();
3048 void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3050 std::string startOfLine(bkOffset,' ');
3051 oss << startOfLine << "Field on One time Step ";
3053 oss << "(" << f1tsId << ") ";
3054 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3055 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3056 const DataArrayDouble *arr=_arr;
3059 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3062 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3063 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3064 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3065 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3067 if(arr->isAllocated())
3069 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3072 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3076 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3078 oss << startOfLine << "----------------------" << std::endl;
3079 if(!_field_per_mesh.empty())
3082 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3084 const MEDFileFieldPerMesh *cur=(*it2);
3086 cur->simpleRepr(bkOffset,oss,i);
3088 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3093 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3095 oss << startOfLine << "----------------------" << std::endl;
3098 std::string MEDFileField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3100 if(_field_per_mesh.empty())
3101 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3102 return _field_per_mesh[0]->getMeshName();
3105 void MEDFileField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3107 std::string oldName(getMeshName());
3108 std::vector< std::pair<std::string,std::string> > v(1);
3109 v[0].first=oldName; v[0].second=newMeshName;
3113 bool MEDFileField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3116 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3118 MEDFileFieldPerMesh *cur(*it);
3120 ret=cur->changeMeshNames(modifTab) || ret;
3125 bool MEDFileField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3126 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3129 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3131 MEDFileFieldPerMesh *fpm(*it);
3133 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3138 int MEDFileField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3140 if(_field_per_mesh.empty())
3141 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3142 return _field_per_mesh[0]->getMeshIteration();
3145 int MEDFileField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3147 if(_field_per_mesh.empty())
3148 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3149 return _field_per_mesh[0]->getMeshOrder();
3152 int MEDFileField1TSWithoutSDA::getNumberOfComponents() const
3154 return getOrCreateAndGetArray()->getNumberOfComponents();
3157 bool MEDFileField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3159 return iteration==_iteration && order==_order;
3162 std::pair<int,int> MEDFileField1TSWithoutSDA::getDtIt() const
3164 std::pair<int,int> p;
3169 void MEDFileField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3175 void MEDFileField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3177 std::set<TypeOfField> types2;
3178 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3180 (*it)->fillTypesOfFieldAvailable(types2);
3182 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3183 std::copy(types2.begin(),types2.end(),bi);
3186 const std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo() const
3188 const DataArrayDouble *arr=getOrCreateAndGetArray();
3189 return arr->getInfoOnComponents();
3192 std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo()
3194 DataArrayDouble *arr=getOrCreateAndGetArray();
3195 return arr->getInfoOnComponents();
3199 * 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'
3200 * This method returns two things.
3201 * - The absolute dimension of 'this' in first parameter.
3202 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
3203 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
3205 * This method is designed for MEDFileField1TS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
3206 * Only these 3 discretizations will be taken into account here.
3208 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
3209 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
3210 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
3212 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
3213 * 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'.
3215 * Let's consider the typical following case :
3216 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
3217 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
3218 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
3220 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
3222 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
3224 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
3225 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
3226 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
3227 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
3229 int MEDFileField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3232 int meshId=getMeshIdFromMeshName(mname);
3233 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3234 std::vector< std::vector<TypeOfField> > typesF;
3235 std::vector< std::vector<std::string> > pfls, locs;
3236 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3238 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3239 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3240 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3242 st.erase(INTERP_KERNEL::NORM_ERROR);
3244 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3246 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3247 ret1.insert((int)cm.getDimension());
3249 int ret=*std::max_element(ret1.begin(),ret1.end());
3250 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3251 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3255 std::vector<TypeOfField> MEDFileField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3257 std::vector<TypeOfField> ret;
3258 fillTypesOfFieldAvailable(ret);
3263 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
3265 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)
3269 meshId=getMeshIdFromMeshName(mname);
3271 if(_field_per_mesh.empty())
3272 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3273 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3277 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
3278 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
3280 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)
3284 meshId=getMeshIdFromMeshName(mname);
3286 if(_field_per_mesh.empty())
3287 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3288 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3289 int nbOfRet=ret0.size();
3290 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
3291 for(int i=0;i<nbOfRet;i++)
3293 const std::vector< std::pair<int,int> >& p=ret0[i];
3294 int nbOfRet1=p.size();
3295 ret[i].resize(nbOfRet1);
3296 for(int j=0;j<nbOfRet1;j++)
3298 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
3305 void MEDFileField1TSWithoutSDA::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
3307 med_int numdt,numit;
3311 med_int meshnumdt,meshnumit;
3312 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3313 MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
3314 MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
3315 if(_iteration!=numdt || _order!=numit)
3316 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
3317 _field_per_mesh.resize(nmesh);
3318 for(int i=0;i<nmesh;i++)
3319 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
3321 for(int i=0;i<nmesh;i++)
3323 _field_per_mesh[i]->prepareLoading(fid,start);
3325 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
3326 for(int i=0;i<nmesh;i++)
3328 _field_per_mesh[i]->finishLoading(fid,_field_type);
3332 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsed2() const
3334 std::vector<std::string> ret;
3335 std::set<std::string> ret2;
3336 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3338 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3339 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3340 if(ret2.find(*it2)==ret2.end())
3342 ret.push_back(*it2);
3349 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsed2() const
3351 std::vector<std::string> ret;
3352 std::set<std::string> ret2;
3353 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3355 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3356 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3357 if(ret2.find(*it2)==ret2.end())
3359 ret.push_back(*it2);
3366 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3368 std::vector<std::string> ret;
3369 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3371 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3372 ret.insert(ret.end(),tmp.begin(),tmp.end());
3377 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3379 std::vector<std::string> ret;
3380 std::set<std::string> ret2;
3381 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3383 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3384 ret.insert(ret.end(),tmp.begin(),tmp.end());
3389 void MEDFileField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3391 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3392 (*it)->changePflsRefsNamesGen(mapOfModif);
3395 void MEDFileField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3397 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3398 (*it)->changeLocsRefsNamesGen(mapOfModif);
3401 void MEDFileField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
3403 if(_field_per_mesh.empty())
3404 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3405 if(_field_per_mesh.size()>1)
3406 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3407 _field_per_mesh[0]->copyOptionsFrom(opts);
3408 _field_per_mesh[0]->writeLL(fid);
3412 * SBT means Sort By Type.
3413 * 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.
3415 void MEDFileField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3417 const MEDCouplingMesh *mesh=field->getMesh();
3419 TypeOfField type=field->getTypeOfField();
3420 std::vector<DataArrayInt *> dummy;
3421 int start=copyTinyInfoFrom(field);
3424 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
3426 int pos=addNewEntryIfNecessary(mesh);
3427 _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.
3431 int pos=addNewEntryIfNecessary(mesh);
3432 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
3437 * Generalization of MEDFileField1TSWithoutSDA::setFieldNoProfileSBT method.
3439 void MEDFileField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3441 TypeOfField type=field->getTypeOfField();
3442 int start=copyTinyInfoFrom(field);
3443 std::vector<DataArrayInt *> idsInPflPerType;
3444 std::vector<DataArrayInt *> idsPerType;
3445 std::vector<int> code;
3446 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3449 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
3451 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
3452 for(std::size_t i=0;i<idsInPflPerType.size();i++)
3453 idsInPflPerType2[i]=idsInPflPerType[i];
3454 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
3455 for(std::size_t i=0;i<idsPerType.size();i++)
3456 idsPerType2[i]=idsPerType[i];
3458 int pos=addNewEntryIfNecessary(m);
3459 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,idsInPflPerType,idsPerType,field,m,glob);
3463 int pos=addNewEntryIfNecessary(m);
3464 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
3468 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3470 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3472 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3474 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3475 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3478 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
3480 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
3481 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
3482 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
3483 if(meshDimRelToMax==1)
3484 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
3485 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
3488 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3490 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3492 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3494 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3495 int absDim=getDimension();
3496 int meshDimRelToMax=absDim-mm->getMeshDimension();
3497 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3500 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
3502 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
3503 int meshId=getMeshIdFromMeshName(mesh->getName());
3505 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
3510 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3518 throw INTERP_KERNEL::Exception(msg1);
3519 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3522 if(cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
3524 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3525 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
3526 throw INTERP_KERNEL::Exception(oss.str().c_str());
3528 ret->renumberCells(cellRenum->getConstPointer(),true);
3538 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3540 throw INTERP_KERNEL::Exception(msg1);
3543 if(nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
3545 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3546 oss << "\"" << getName() << "\" not defined on all nodes !";
3547 throw INTERP_KERNEL::Exception(oss.str().c_str());
3549 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
3550 ret->renumberNodes(nodeRenumSafe->getConstPointer());
3556 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
3560 DataArrayDouble *MEDFileField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3562 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3563 int meshId=getMeshIdFromMeshName(mesh->getName());
3564 return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
3568 * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance. The returned array is not a newly
3569 * created array so it should \b not be dealed by the caller.
3570 * This method allows to the user a direct access to the values.
3571 * This method is quite unusable if there is more than a nodal field or a cell field on single geometric cell type.
3573 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
3575 const DataArrayDouble *ret=_arr;
3577 return const_cast<DataArrayDouble *>(ret);
3583 * This method returns an array that the caller must deal with (contrary to those returned by MEDFileField1TSWithoutSDA::getUndergroundDataArray method).
3584 * 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
3585 * '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
3586 * id attached to it. The second pair of pair precise the range [begin,end) into the returned array.
3587 * This method makes the hypothesis that the field lies only on one mesh. If it is not the case an exception will be thrown.
3589 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
3591 if(_field_per_mesh.size()!=1)
3592 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
3593 if(_field_per_mesh[0]==0)
3594 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
3595 return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
3598 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order,
3599 const std::vector<std::string>& infos):_csit(csit),_field_type(fieldtype),_iteration(iteration),_order(order)
3601 DataArrayDouble *arr=getOrCreateAndGetArray();
3602 arr->setName(fieldName);
3603 arr->setInfoAndChangeNbOfCompo(infos);
3606 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():_csit(-1),_field_type(-1)
3610 int MEDFileField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3612 std::string tmp(mesh->getName());
3614 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3615 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3617 for(;it!=_field_per_mesh.end();it++,i++)
3619 if((*it)->getMeshName()==tmp)
3622 int sz=_field_per_mesh.size();
3623 _field_per_mesh.resize(sz+1);
3624 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3629 * \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.
3631 int MEDFileField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3633 if(_field_per_mesh.empty())
3634 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3637 std::string mName2(mName);
3639 std::vector<std::string> msg;
3640 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3641 if(mName2==(*it)->getMeshName())
3644 msg.push_back((*it)->getMeshName());
3645 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3646 oss << "Possible meshes are : ";
3647 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3648 oss << "\"" << (*it2) << "\" ";
3649 throw INTERP_KERNEL::Exception(oss.str().c_str());
3653 * \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.
3654 * \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.
3655 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3656 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3658 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3660 int mid=getMeshIdFromMeshName(mName);
3661 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3665 * \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.
3666 * \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.
3667 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3668 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3670 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3672 int mid=getMeshIdFromMeshName(mName);
3673 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3676 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
3678 DataArrayDouble *ret=_arr;
3681 _arr=DataArrayDouble::New();
3685 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
3687 const DataArrayDouble *ret=_arr;
3690 DataArrayDouble *ret2=DataArrayDouble::New();
3691 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
3695 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3697 return new MEDFileField1TS(fileName,fieldName,iteration,order);
3701 * \warning this is a shallow copy constructor
3703 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3705 return new MEDFileField1TS(other,deepCpy);
3708 MEDFileField1TS *MEDFileField1TS::New()
3710 return new MEDFileField1TS;
3713 std::string MEDFileField1TS::simpleRepr() const
3715 std::ostringstream oss;
3716 _content->simpleRepr(0,oss,-1);
3717 MEDFileFieldGlobsReal::simpleRepr(oss);
3721 void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
3723 int nbComp=getNumberOfComponents();
3724 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3725 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3726 for(int i=0;i<nbComp;i++)
3728 std::string info=getInfo()[i];
3730 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
3731 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
3732 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
3734 if(getName().empty())
3735 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
3736 MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
3737 writeGlobals(fid,*this);
3738 _content->writeLL(fid,*this);
3741 void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
3743 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
3744 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
3748 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3749 try:_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,iteration,order,std::vector<std::string>())),MEDFileFieldGlobsReal(fileName)
3751 MEDFileUtilities::CheckFileForRead(fileName);
3752 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
3753 int nbFields=MEDnField(fid);
3754 med_field_type typcha;
3756 std::vector<std::string> fns(nbFields);
3758 for(int i=0;i<nbFields && !found;i++)
3760 int ncomp=MEDfieldnComponent(fid,i+1);
3761 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3762 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3763 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
3764 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3765 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3768 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
3769 std::string tmp(nomcha);
3771 found=(tmp==fieldName);
3775 std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
3776 std::vector<std::string> infos(ncomp);
3777 for(int j=0;j<ncomp;j++)
3778 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
3779 _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
3784 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
3785 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
3786 throw INTERP_KERNEL::Exception(oss.str().c_str());
3789 std::vector< std::pair<int,int> > dtits(nbOfStep2);
3790 for(int i=0;i<nbOfStep2 && !found;i++)
3792 med_int numdt,numit;
3794 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
3795 if(numdt==iteration && numit==order)
3798 _content->_csit=i+1;
3799 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
3802 dtits[i]=std::pair<int,int>(numdt,numit);
3806 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
3807 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
3808 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
3809 throw INTERP_KERNEL::Exception(oss.str().c_str());
3811 _content->finishLoading(fid);
3815 catch(INTERP_KERNEL::Exception& e)
3821 * \warning this is a shallow copy constructor
3823 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3827 const MEDFileField1TSWithoutSDA *otherPtr(&other);
3828 otherPtr->incrRef();
3829 _content=const_cast<MEDFileField1TSWithoutSDA *>(otherPtr);
3833 _content=new MEDFileField1TSWithoutSDA(other);
3837 MEDFileField1TS::MEDFileField1TS():_content(new MEDFileField1TSWithoutSDA)
3842 * This method returns all profiles whose name is non empty used.
3843 * \b WARNING If profile is used several times it will be reported \b only \b once.
3844 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
3846 std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
3848 return _content->getPflsReallyUsed2();
3852 * This method returns all localizations whose name is non empty used.
3853 * \b WARNING If localization is used several times it will be reported \b only \b once.
3855 std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
3857 return _content->getLocsReallyUsed2();
3861 * This method returns all profiles whose name is non empty used.
3862 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
3864 std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
3866 return _content->getPflsReallyUsedMulti2();
3870 * This method returns all localizations whose name is non empty used.
3871 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
3873 std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
3875 return _content->getLocsReallyUsedMulti2();
3878 void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3880 _content->changePflsRefsNamesGen2(mapOfModif);
3883 void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3885 _content->changeLocsRefsNamesGen2(mapOfModif);
3889 * 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
3890 * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead.
3891 * \b WARNING ! Parameter 'meshDimRelToMax' is relative from read mesh in file that can be different from the field in MED file !
3892 * It leads that the returned field of this method is always coherent.
3894 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3896 if(getFileName2().empty())
3897 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3898 return _content->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
3902 * This method is close to MEDFileField1TS::getFieldAtLevel except that here the 'meshDimRelToMax' param is ignored and the maximal dimension is taken
3903 * automatically. If the field lies on different level and that an another level than the maximal is requested MEDFileField1TS::getFieldAtLevel
3904 * should be called instead.
3906 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
3908 if(getFileName2().empty())
3909 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
3910 return _content->getFieldAtTopLevel(type,0,renumPol,this);
3914 * \b WARNING, there is a main difference with the two close methods (MEDFileField1TS::getFieldAtLevel and MEDFileField1TS::getFieldOnMeshAtLevel method) !
3915 * Here the mesh-dimension of 'mesh' is used by this to automatically request the right geoTypes regarding 'type'.
3916 * If no such element fufilled the deduced dimension and 'type' an exception will be thrown.
3917 * It leads that the returned field of this method is always coherent.
3919 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3921 return _content->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
3925 * This method can be called whatever the mode of instance feeding of this (MED file or from scratch).
3926 * 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' !
3927 * It leads that the returned field of this method is always coherent.
3929 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3931 return _content->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
3935 * This method is identical to MEDFileField1TS::getFieldAtLevel method except that meshName 'mname' should be specified.
3936 * 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.
3937 * See MEDFileField1TS::getFieldAtLevel for more information.
3939 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3941 if(getFileName2().empty())
3942 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3943 return _content->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
3946 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
3948 return _content->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
3952 * SBT means Sort By Type.
3953 * 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.
3956 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3959 _content->setFieldNoProfileSBT(field,*this);
3963 * This method is a generalization of MEDFileField1TS::setFieldNoProfileSBT method. Here a profile array is given in input.
3964 * The support of field 'field' is \b not used by this method, so it can be null or incoherent with field.
3965 * 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,
3966 * an exception will be thrown.
3967 * 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'.
3968 * In this case, if this profile name is empty an exception will be thrown.
3970 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
3973 _content->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
3977 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
3978 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
3979 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
3980 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
3981 * to keep a valid instance.
3982 * 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.
3983 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
3984 * 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.
3986 * \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.
3987 * \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.
3988 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3989 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3990 * \param [in] newLocName is the new localization name.
3991 * \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.
3992 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
3994 void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
3996 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
3997 std::string oldPflName=disc->getProfile();
3998 std::vector<std::string> vv=getPflsReallyUsedMulti();
3999 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
4000 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
4002 disc->setProfile(newPflName);
4003 DataArrayInt *pfl=getProfile(oldPflName.c_str());
4004 pfl->setName(newPflName);
4008 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
4009 throw INTERP_KERNEL::Exception(oss.str().c_str());
4014 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4015 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4016 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4017 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4018 * to keep a valid instance.
4019 * 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.
4020 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
4021 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
4022 * 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.
4024 * \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.
4025 * \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.
4026 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4027 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4028 * \param [in] newLocName is the new localization name.
4029 * \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.
4030 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
4032 void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4034 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4035 std::string oldLocName=disc->getLocalization();
4036 std::vector<std::string> vv=getLocsReallyUsedMulti();
4037 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
4038 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
4040 disc->setLocalization(newLocName);
4041 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
4042 loc.setName(newLocName);
4046 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
4047 throw INTERP_KERNEL::Exception(oss.str().c_str());
4051 int MEDFileField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4053 return _content->copyTinyInfoFrom(field);
4056 int MEDFileField1TS::getDimension() const
4058 return _content->getDimension();
4061 int MEDFileField1TS::getIteration() const
4063 return _content->getIteration();
4066 int MEDFileField1TS::getOrder() const
4068 return _content->getOrder();
4071 double MEDFileField1TS::getTime(int& iteration, int& order) const
4073 return _content->getTime(iteration,order);
4076 void MEDFileField1TS::setTime(int iteration, int order, double val)
4078 _content->setTime(iteration,order,val);
4081 std::string MEDFileField1TS::getName() const
4083 return _content->getName();
4086 void MEDFileField1TS::setName(const char *name)
4088 _content->setName(name);
4091 void MEDFileField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4093 _content->simpleRepr(bkOffset,oss,f1tsId);
4096 const std::string& MEDFileField1TS::getDtUnit() const
4098 return _content->getDtUnit();
4101 std::string MEDFileField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
4103 return _content->getMeshName();
4106 void MEDFileField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4108 _content->setMeshName(newMeshName);
4111 bool MEDFileField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4113 return _content->changeMeshNames(modifTab);
4116 int MEDFileField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
4118 return _content->getMeshIteration();
4121 int MEDFileField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
4123 return _content->getMeshOrder();
4126 int MEDFileField1TS::getNumberOfComponents() const
4128 return _content->getNumberOfComponents();
4131 bool MEDFileField1TS::isDealingTS(int iteration, int order) const
4133 return _content->isDealingTS(iteration,order);
4136 std::pair<int,int> MEDFileField1TS::getDtIt() const
4138 return _content->getDtIt();
4141 void MEDFileField1TS::fillIteration(std::pair<int,int>& p) const
4143 _content->fillIteration(p);
4145 void MEDFileField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
4147 _content->fillTypesOfFieldAvailable(types);
4150 const std::vector<std::string>& MEDFileField1TS::getInfo() const
4152 return _content->getInfo();
4154 std::vector<std::string>& MEDFileField1TS::getInfo()
4156 return _content->getInfo();
4159 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4161 return _content->getUndergroundDataArray();
4164 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4166 return _content->getUndergroundDataArrayExt(entries);
4169 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
4171 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4174 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
4176 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4179 int MEDFileField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4181 return _content->getNonEmptyLevels(mname,levs);
4184 std::vector<TypeOfField> MEDFileField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4186 return _content->getTypesOfFieldAvailable();
4189 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,
4190 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4192 return _content->getFieldSplitedByType(mname,types,typesF,pfls,locs);
4194 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
4195 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4197 return _content->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4200 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)
4202 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,id,ft,infos,nbOfStep);
4205 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA():_field_type(-1)
4209 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):_name(fieldName),_field_type(-1)
4214 * \param [in] fieldId field id in C mode
4216 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
4219 med_field_type typcha;
4222 int ncomp=MEDfieldnComponent(fid,1);
4223 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4224 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4225 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4226 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4227 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4230 MEDfieldInfo(fid,fieldId+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4231 _name=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
4232 _field_type=MEDFileUtilities::TraduceFieldType(typcha);
4233 _infos.resize(ncomp);
4234 for(int j=0;j<ncomp;j++)
4235 _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
4237 finishLoading(fid,nbOfStep);
4239 catch(INTERP_KERNEL::Exception& e)
4244 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
4245 try:_name(fieldName),_infos(infos),_field_type(ft)
4247 finishLoading(fid,nbOfStep);
4249 catch(INTERP_KERNEL::Exception& e)
4254 const std::vector<std::string>& MEDFileFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
4256 if(_time_steps.empty())
4257 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getInfos : not time steps !");
4258 return _time_steps[0]->getInfo();
4262 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
4264 DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4266 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
4270 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
4272 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)
4274 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
4277 std::string MEDFileFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
4279 if(_time_steps.empty())
4280 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4281 return _time_steps[0]->getMeshName();
4284 void MEDFileFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4286 std::string oldName(getMeshName());
4287 std::vector< std::pair<std::string,std::string> > v(1);
4288 v[0].first=oldName; v[0].second=newMeshName;
4292 bool MEDFileFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4295 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4297 MEDFileField1TSWithoutSDA *cur(*it);
4299 ret=cur->changeMeshNames(modifTab) || ret;
4304 bool MEDFileFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4305 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4310 MEDFileField1TSWithoutSDA *f1ts(*it);
4312 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4317 void MEDFileFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4319 if(_time_steps.empty())
4321 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4322 obj->setFieldNoProfileSBT(field,glob);
4323 copyTinyInfoFrom(field);
4324 _time_steps.push_back(obj);
4328 checkCoherencyOfTinyInfo(field);
4329 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4330 obj->setFieldNoProfileSBT(field,glob);
4331 _time_steps.push_back(obj);
4335 void MEDFileFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4337 if(_time_steps.empty())
4339 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4340 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4341 copyTinyInfoFrom(field);
4342 _time_steps.push_back(obj);
4346 checkCoherencyOfTinyInfo(field);
4347 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4348 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4349 _time_steps.push_back(obj);
4353 std::string MEDFileFieldMultiTSWithoutSDA::getDtUnit() const throw(INTERP_KERNEL::Exception)
4355 if(_time_steps.empty())
4356 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4357 return _time_steps[0]->getDtUnit();
4360 std::string MEDFileFieldMultiTSWithoutSDA::getName() const
4365 void MEDFileFieldMultiTSWithoutSDA::setName(const char *name)
4370 void MEDFileFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
4372 std::string startLine(bkOffset,' ');
4373 oss << startLine << "Field multi time steps";
4375 oss << " (" << fmtsId << ")";
4376 oss << " has the following name: \"" << _name << "\"." << std::endl;
4377 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
4378 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
4380 oss << startLine << " - \"" << *it << "\"" << std::endl;
4383 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
4385 std::string chapter(17,'0'+i);
4386 oss << startLine << chapter << std::endl;
4387 const MEDFileField1TSWithoutSDA *cur=(*it);
4389 cur->simpleRepr(bkOffset+2,oss,i);
4391 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
4392 oss << startLine << chapter << std::endl;
4396 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
4398 std::size_t sz=_time_steps.size();
4399 std::vector< std::pair<int,int> > ret(sz);
4401 for(std::size_t i=0;i<sz;i++)
4403 const MEDFileField1TSWithoutSDA *f1ts=_time_steps[i];
4406 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
4410 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
4411 throw INTERP_KERNEL::Exception(oss.str().c_str());
4417 void MEDFileFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
4419 _time_steps.resize(nbPdt);
4420 for(int i=0;i<nbPdt;i++)
4422 std::vector< std::pair<int,int> > ts;
4423 med_int numdt=0,numo=0;
4424 med_int meshIt=0,meshOrder=0;
4426 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
4427 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
4428 _time_steps[i]->finishLoading(fid);
4432 void MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4434 _name=field->getName();
4436 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4437 const DataArrayDouble *arr=field->getArray();
4439 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
4440 _infos=arr->getInfoOnComponents();
4443 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
4445 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
4446 if(_name!=field->getName())
4448 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
4449 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
4450 throw INTERP_KERNEL::Exception(oss.str().c_str());
4452 const DataArrayDouble *arr=field->getArray();
4454 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
4455 if(_infos!=arr->getInfoOnComponents())
4457 std::ostringstream oss; oss << MSG << "components ! should be \"";
4458 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
4459 oss << " But compo in input fields are : ";
4460 std::vector<std::string> tmp=arr->getInfoOnComponents();
4461 std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
4463 throw INTERP_KERNEL::Exception(oss.str().c_str());
4467 void MEDFileFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
4469 if(_time_steps.empty())
4470 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
4471 std::vector<std::string> infos(getInfo());
4472 int nbComp=infos.size();
4473 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4474 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4475 for(int i=0;i<nbComp;i++)
4477 std::string info=infos[i];
4479 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
4480 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4481 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4484 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
4485 MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
4486 int nbOfTS=_time_steps.size();
4487 for(int i=0;i<nbOfTS;i++)
4488 _time_steps[i]->writeLL(fid,opts);
4491 int MEDFileFieldMultiTSWithoutSDA::getNumberOfTS() const
4493 return _time_steps.size();
4496 void MEDFileFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
4498 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4499 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4501 const MEDFileField1TSWithoutSDA *tmp=(*it);
4503 newTS.push_back(*it);
4508 void MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
4510 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4511 int maxId=(int)_time_steps.size();
4513 std::set<int> idsToDel;
4514 for(const int *id=startIds;id!=endIds;id++,ii++)
4516 if(*id>=0 && *id<maxId)
4518 idsToDel.insert(*id);
4522 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
4523 throw INTERP_KERNEL::Exception(oss.str().c_str());
4526 for(int iii=0;iii<maxId;iii++)
4527 if(idsToDel.find(iii)==idsToDel.end())
4528 newTS.push_back(_time_steps[iii]);
4532 int MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4535 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
4536 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4538 const MEDFileField1TSWithoutSDA *tmp(*it);
4542 tmp->getTime(it,ord);
4543 if(it==iteration && order==ord)
4546 oss << "(" << it << "," << ord << "), ";
4549 throw INTERP_KERNEL::Exception(oss.str().c_str());
4552 int MEDFileFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4555 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
4557 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4559 const MEDFileField1TSWithoutSDA *tmp(*it);
4563 double ti=tmp->getTime(it,ord);
4564 if(fabs(time-ti)<eps)
4570 throw INTERP_KERNEL::Exception(oss.str().c_str());
4573 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getIterations() const
4575 int lgth=_time_steps.size();
4576 std::vector< std::pair<int,int> > ret(lgth);
4577 for(int i=0;i<lgth;i++)
4578 _time_steps[i]->fillIteration(ret[i]);
4583 * 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'
4584 * This method returns two things.
4585 * - The absolute dimension of 'this' in first parameter.
4586 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
4587 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
4589 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
4590 * Only these 3 discretizations will be taken into account here.
4592 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
4593 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
4594 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
4596 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
4597 * 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'.
4599 * Let's consider the typical following case :
4600 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
4601 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
4602 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
4604 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
4606 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
4608 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
4609 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
4610 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
4611 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
4613 int MEDFileFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4615 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
4618 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4620 int lgth=_time_steps.size();
4621 std::vector< std::vector<TypeOfField> > ret(lgth);
4622 for(int i=0;i<lgth;i++)
4623 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
4628 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
4630 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)
4632 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
4636 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
4637 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
4639 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)
4641 return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4644 const MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4646 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4647 if((*it)->isDealingTS(iteration,order))
4649 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4650 std::vector< std::pair<int,int> > vp=getIterations();
4651 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4652 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4653 throw INTERP_KERNEL::Exception(oss.str().c_str());
4656 MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
4658 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4659 if((*it)->isDealingTS(iteration,order))
4661 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4662 std::vector< std::pair<int,int> > vp=getIterations();
4663 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4664 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4665 throw INTERP_KERNEL::Exception(oss.str().c_str());
4668 const MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
4670 if(pos<0 || pos>=(int)_time_steps.size())
4672 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4673 throw INTERP_KERNEL::Exception(oss.str().c_str());
4675 const MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4678 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4679 oss << "\nTry to use following method eraseEmptyTS !";
4680 throw INTERP_KERNEL::Exception(oss.str().c_str());
4685 MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
4687 if(pos<0 || pos>=(int)_time_steps.size())
4689 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4690 throw INTERP_KERNEL::Exception(oss.str().c_str());
4692 MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4695 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4696 oss << "\nTry to use following method eraseEmptyTS !";
4697 throw INTERP_KERNEL::Exception(oss.str().c_str());
4702 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
4704 std::vector<std::string> ret;
4705 std::set<std::string> ret2;
4706 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4708 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
4709 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4710 if(ret2.find(*it2)==ret2.end())
4712 ret.push_back(*it2);
4719 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
4721 std::vector<std::string> ret;
4722 std::set<std::string> ret2;
4723 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4725 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
4726 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4727 if(ret2.find(*it2)==ret2.end())
4729 ret.push_back(*it2);
4736 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
4738 std::vector<std::string> ret;
4739 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4741 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
4742 ret.insert(ret.end(),tmp.begin(),tmp.end());
4747 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
4749 std::vector<std::string> ret;
4750 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4752 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
4753 ret.insert(ret.end(),tmp.begin(),tmp.end());
4758 void MEDFileFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4760 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4761 (*it)->changePflsRefsNamesGen2(mapOfModif);
4764 void MEDFileFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4766 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4767 (*it)->changeLocsRefsNamesGen2(mapOfModif);
4770 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
4772 return new MEDFileFieldMultiTS;
4775 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4777 return new MEDFileFieldMultiTS(fileName);
4780 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4782 return new MEDFileFieldMultiTS(fileName,fieldName);
4785 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
4787 return new MEDFileFieldMultiTS(other,deepCpy);
4790 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
4792 const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
4793 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item,false);
4794 ret->shallowCpyGlobs(*this);
4799 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4801 int pos=getPosOfTimeStep(iteration,order);
4802 return getTimeStepAtPos(pos);
4805 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4807 int pos=getPosGivenTime(time,eps);
4808 return getTimeStepAtPos(pos);
4811 MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
4813 return new MEDFileFieldMultiTSIterator(this);
4816 std::string MEDFileFieldMultiTS::simpleRepr() const
4818 std::ostringstream oss;
4819 _content->simpleRepr(0,oss,-1);
4820 MEDFileFieldGlobsReal::simpleRepr(oss);
4824 void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
4826 writeGlobals(fid,*this);
4827 _content->writeLL(fid,*this);
4830 void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
4832 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
4833 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
4838 * Performs the job than MEDFileField1TS::getFieldAtLevel except that (iteration,order) couple should be specified !
4839 * If such couple does not exist an exception is thrown.
4841 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4843 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4844 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
4847 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
4849 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4850 return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
4854 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4855 * If such couple does not exist an exception is thrown.
4857 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4859 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4860 return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
4864 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4865 * If such couple does not exist an exception is thrown.
4867 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4869 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4870 return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
4874 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
4875 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
4876 * This method is useful for MED2 file format when field on different mesh was autorized.
4878 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4880 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4881 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
4884 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
4886 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4887 return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
4890 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4892 _content->appendFieldNoProfileSBT(field,*this);
4895 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
4897 _content->appendFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
4900 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> MEDFileFieldMultiTS::getContent()
4905 MEDFileFieldMultiTS::MEDFileFieldMultiTS():_content(new MEDFileFieldMultiTSWithoutSDA)
4911 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
4912 try:MEDFileFieldGlobsReal(fileName)
4914 MEDFileUtilities::CheckFileForRead(fileName);
4915 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4916 int nbFields=MEDnField(fid);
4919 std::ostringstream oss; oss << "MEDFileFieldMultiTS(const char *fileName) constructor : no fields in file \"" << fileName << "\" !";
4920 throw INTERP_KERNEL::Exception(oss.str().c_str());
4922 _content=new MEDFileFieldMultiTSWithoutSDA(fid,0);
4926 catch(INTERP_KERNEL::Exception& e)
4931 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4932 try:MEDFileFieldGlobsReal(fileName)
4934 MEDFileUtilities::CheckFileForRead(fileName);
4935 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4936 int nbFields=MEDnField(fid);
4937 med_field_type typcha;
4939 std::vector<std::string> fns(nbFields);
4940 for(int i=0;i<nbFields && !found;i++)
4942 int ncomp=MEDfieldnComponent(fid,i+1);
4943 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4944 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4945 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4946 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4947 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4950 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4951 std::string tmp(nomcha);
4953 found=(tmp==fieldName);
4955 _content=new MEDFileFieldMultiTSWithoutSDA(fid,i);
4959 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
4960 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
4961 throw INTERP_KERNEL::Exception(oss.str().c_str());
4966 catch(INTERP_KERNEL::Exception& e)
4971 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
4975 const MEDFileFieldMultiTSWithoutSDA *otherPtr(&other);
4976 otherPtr->incrRef();
4977 _content=const_cast<MEDFileFieldMultiTSWithoutSDA *>(otherPtr);
4981 _content=new MEDFileFieldMultiTSWithoutSDA(other);
4985 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
4987 return _content->getPflsReallyUsed2();
4990 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
4992 return _content->getLocsReallyUsed2();
4995 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
4997 return _content->getPflsReallyUsedMulti2();
5000 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
5002 return _content->getLocsReallyUsedMulti2();
5005 void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5007 _content->changePflsRefsNamesGen2(mapOfModif);
5010 void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5012 _content->changeLocsRefsNamesGen2(mapOfModif);
5015 int MEDFileFieldMultiTS::getNumberOfTS() const
5017 return _content->getNumberOfTS();
5020 void MEDFileFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
5022 _content->eraseEmptyTS();
5025 void MEDFileFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
5027 _content->eraseTimeStepIds(startIds,endIds);
5030 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getIterations() const
5032 return _content->getIterations();
5035 int MEDFileFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5037 return _content->getPosOfTimeStep(iteration,order);
5040 int MEDFileFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
5042 return _content->getPosGivenTime(time,eps);
5045 int MEDFileFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5047 return _content->getNonEmptyLevels(iteration,order,mname,levs);
5050 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5052 return _content->getTypesOfFieldAvailable();
5055 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)
5057 return _content->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
5060 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)
5062 return _content->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
5065 std::string MEDFileFieldMultiTS::getName() const
5067 return _content->getName();
5070 void MEDFileFieldMultiTS::setName(const char *name)
5072 _content->setName(name);
5075 void MEDFileFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
5077 _content->simpleRepr(bkOffset,oss,fmtsId);
5080 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
5082 return _content->getTimeSteps(ret1);
5085 std::string MEDFileFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
5087 return _content->getMeshName();
5090 void MEDFileFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5092 _content->setMeshName(newMeshName);
5095 bool MEDFileFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5097 return _content->changeMeshNames(modifTab);
5100 const std::vector<std::string>& MEDFileFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
5102 return _content->getInfo();
5105 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5107 return _content->getUndergroundDataArray(iteration,order);
5110 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)
5112 return _content->getUndergroundDataArrayExt(iteration,order,entries);
5115 MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
5120 _nb_iter=fmts->getNumberOfTS();
5124 MEDFileFieldMultiTSIterator::~MEDFileFieldMultiTSIterator()
5128 MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
5130 if(_iter_id<_nb_iter)
5132 MEDFileFieldMultiTS *fmts(_fmts);
5134 return fmts->getTimeStepAtPos(_iter_id++);
5142 MEDFileFields *MEDFileFields::New()
5144 return new MEDFileFields;
5147 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5149 return new MEDFileFields(fileName);
5152 int MEDFileFields::getNumberOfFields() const
5154 return _fields.size();
5157 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
5159 std::vector<std::string> ret(_fields.size());
5161 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5163 const MEDFileFieldMultiTSWithoutSDA *f=(*it);
5166 ret[i]=f->getName();
5170 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
5171 throw INTERP_KERNEL::Exception(oss.str().c_str());
5177 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
5179 std::vector<std::string> ret;
5180 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5182 const MEDFileFieldMultiTSWithoutSDA *cur(*it);
5184 ret.push_back(cur->getMeshName());
5189 std::string MEDFileFields::simpleRepr() const
5191 std::ostringstream oss;
5192 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
5197 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
5199 int nbOfFields=getNumberOfFields();
5200 std::string startLine(bkOffset,' ');
5201 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
5203 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5205 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5208 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
5212 oss << startLine << " - not defined !" << std::endl;
5216 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5218 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5219 std::string chapter(17,'0'+i);
5220 oss << startLine << chapter << std::endl;
5223 cur->simpleRepr(bkOffset+2,oss,i);
5227 oss << startLine << " - not defined !" << std::endl;
5229 oss << startLine << chapter << std::endl;
5231 MEDFileFieldGlobsReal::simpleRepr(oss);
5234 MEDFileFields::MEDFileFields()
5238 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
5239 try:MEDFileFieldGlobsReal(fileName)
5241 MEDFileUtilities::CheckFileForRead(fileName);
5242 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5243 int nbFields=MEDnField(fid);
5244 _fields.resize(nbFields);
5245 med_field_type typcha;
5246 for(int i=0;i<nbFields;i++)
5248 int ncomp=MEDfieldnComponent(fid,i+1);
5249 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5250 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5251 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5252 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5253 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5256 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5257 int ft=MEDFileUtilities::TraduceFieldType(typcha);
5258 std::vector<std::string> infos(ncomp);
5259 for(int j=0;j<ncomp;j++)
5260 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5261 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,nomcha,i+1,ft,infos,nbOfStep);
5263 loadAllGlobals(fid);
5265 catch(INTERP_KERNEL::Exception& e)
5270 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5273 writeGlobals(fid,*this);
5274 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5276 const MEDFileFieldMultiTSWithoutSDA *elt=*it;
5279 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
5280 throw INTERP_KERNEL::Exception(oss.str().c_str());
5282 elt->writeLL(fid,*this);
5286 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5288 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5289 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5293 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
5295 std::vector<std::string> ret;
5296 std::set<std::string> ret2;
5297 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5299 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
5300 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5301 if(ret2.find(*it2)==ret2.end())
5303 ret.push_back(*it2);
5310 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
5312 std::vector<std::string> ret;
5313 std::set<std::string> ret2;
5314 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5316 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5317 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5318 if(ret2.find(*it2)==ret2.end())
5320 ret.push_back(*it2);
5327 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
5329 std::vector<std::string> ret;
5330 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5332 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
5333 ret.insert(ret.end(),tmp.begin(),tmp.end());
5338 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
5340 std::vector<std::string> ret;
5341 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5343 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5344 ret.insert(ret.end(),tmp.begin(),tmp.end());
5349 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5351 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5352 (*it)->changePflsRefsNamesGen2(mapOfModif);
5355 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5357 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5358 (*it)->changeLocsRefsNamesGen2(mapOfModif);
5361 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
5363 _fields.resize(newSize);
5366 void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5369 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
5370 _fields.push_back(field->getContent());
5371 appendGlobs(*field,1e-12);
5374 void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5377 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
5378 if(i>=(int)_fields.size())
5379 _fields.resize(i+1);
5380 _fields[i]=field->getContent();
5381 appendGlobs(*field,1e-12);
5384 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
5386 if(i<0 || i>=(int)_fields.size())
5388 std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5389 throw INTERP_KERNEL::Exception(oss.str().c_str());
5391 _fields.erase(_fields.begin()+i);
5394 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5397 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5399 MEDFileFieldMultiTSWithoutSDA *cur(*it);
5401 ret=cur->changeMeshNames(modifTab) || ret;
5407 * \param [in] meshName the name of the mesh that will be renumbered.
5408 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
5409 * This code corresponds to the distribution of types in the corresponding mesh.
5410 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
5411 * \param [in] renumO2N the old to new renumber array.
5412 * \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
5415 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
5418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5420 MEDFileFieldMultiTSWithoutSDA *fmts(*it);
5423 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
5429 MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
5431 if(i<0 || i>=(int)_fields.size())
5433 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5434 throw INTERP_KERNEL::Exception(oss.str().c_str());
5436 const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i];
5437 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts,false);
5438 ret->shallowCpyGlobs(*this);
5443 MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5445 return getFieldAtPos(getPosFromFieldName(fieldName));
5448 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
5450 return new MEDFileFieldsIterator(this);
5453 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5455 std::string tmp(fieldName);
5456 std::vector<std::string> poss;
5457 for(std::size_t i=0;i<_fields.size();i++)
5459 const MEDFileFieldMultiTSWithoutSDA *f=_fields[i];
5462 std::string fname(f->getName());
5466 poss.push_back(fname);
5469 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
5470 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
5472 throw INTERP_KERNEL::Exception(oss.str().c_str());
5475 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
5480 _nb_iter=fs->getNumberOfFields();
5484 MEDFileFieldsIterator::~MEDFileFieldsIterator()
5488 MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
5490 if(_iter_id<_nb_iter)
5492 MEDFileFields *fs(_fs);
5494 return fs->getFieldAtPos(_iter_id++);