1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
44 return new MEDFileFieldLoc(fid,locName);
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
49 return new MEDFileFieldLoc(fid,id);
52 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
54 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
57 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
59 med_geometry_type geotype;
60 med_geometry_type sectiongeotype;
62 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
63 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
64 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
65 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
66 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
67 _nb_node_per_cell=cm.getNumberOfNodes();
68 _ref_coo.resize(_dim*_nb_node_per_cell);
69 _gs_coo.resize(_dim*_nb_gauss_pt);
70 _w.resize(_nb_gauss_pt);
71 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
74 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
76 med_geometry_type geotype;
77 med_geometry_type sectiongeotype;
79 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
80 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
81 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
82 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
84 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
85 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
86 _nb_node_per_cell=cm.getNumberOfNodes();
87 _ref_coo.resize(_dim*_nb_node_per_cell);
88 _gs_coo.resize(_dim*_nb_gauss_pt);
89 _w.resize(_nb_gauss_pt);
90 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
93 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
94 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
97 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
98 _dim=cm.getDimension();
99 _nb_node_per_cell=cm.getNumberOfNodes();
100 _nb_gauss_pt=_w.size();
103 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
105 static const char OFF7[]="\n ";
106 oss << "\"" << _name << "\"" << OFF7;
107 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
108 oss << "Dimension=" << _dim << OFF7;
109 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
110 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
111 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
112 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
113 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
116 void MEDFileFieldLoc::setName(const char *name)
121 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
123 if(_name!=other._name)
127 if(_nb_gauss_pt!=other._nb_gauss_pt)
129 if(_nb_node_per_cell!=other._nb_node_per_cell)
131 if(_geo_type!=other._geo_type)
133 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
135 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
137 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
143 void MEDFileFieldLoc::writeLL(med_idt fid) const
145 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
148 std::string MEDFileFieldLoc::repr() const
150 std::ostringstream oss; oss.precision(15);
151 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
152 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
153 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
154 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
155 oss << "\n - Ref coords are : ";
156 int sz=_ref_coo.size();
159 int nbOfTuples=sz/_dim;
160 for(int i=0;i<nbOfTuples;i++)
163 for(int j=0;j<_dim;j++)
164 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
169 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
170 oss << "\n - Gauss coords in reference element : ";
174 int nbOfTuples=sz/_dim;
175 for(int i=0;i<nbOfTuples;i++)
178 for(int j=0;j<_dim;j++)
179 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
184 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
185 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
189 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
191 _type=field->getTypeOfField();
192 const DataArrayDouble *da=field->getArray();
198 getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
199 _end=_start+nbOfCells;
205 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
206 const int *arrPtr=arr->getConstPointer();
207 getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
208 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
214 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
215 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
216 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
218 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
219 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
220 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
221 const int *dai2Ptr=dai2->getConstPointer();
222 int nbi=gsLoc.getWeights().size();
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
224 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
225 const int *da3Ptr=da3->getConstPointer();
226 if(da3->getNumberOfTuples()!=nbOfCells)
227 {//profile : for gauss even in NoProfile !!!
228 std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
230 da3->setName(_profile.c_str());
231 glob.appendProfile(da3);
233 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
234 _nval=da3->getNbOfElems();
235 da4->alloc(_nval*nbi,1);
236 int *da4Ptr=da4->getPointer();
237 for(int i=0;i<_nval;i++)
239 int ref=dai2Ptr[offset+da3Ptr[i]];
240 for(int j=0;j<nbi;j++)
243 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
244 _localization=oss2.str();
245 getArray()->setContigPartOfSelectedValues(_start,da,da4);
246 _end=_start+_nval*nbi;
247 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
251 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
257 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
258 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
259 * \param [in] multiTypePfl is the end user profile specified in high level API
260 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
261 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
262 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
263 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
265 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
268 _type=field->getTypeOfField();
269 std::string pflName(multiTypePfl->getName());
270 std::ostringstream oss; oss << pflName;
271 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
275 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
276 if(_type!=ON_GAUSS_PT)
278 locIds->setName(oss.str().c_str());
279 glob.appendProfile(locIds);
283 const DataArrayDouble *da=field->getArray();
289 _nval=idsInPfl->getNumberOfTuples();
290 getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
296 _nval=idsInPfl->getNumberOfTuples();
297 getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
303 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
304 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
305 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
306 arr3->computeOffsets2();
307 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
308 int trueNval=tmp->getNumberOfTuples();
309 _nval=idsInPfl->getNumberOfTuples();
310 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
311 _end=_start+trueNval;
316 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
318 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
319 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
320 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
321 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
322 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
323 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
325 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
330 for(const int *pt=da4->begin();pt!=da4->end();pt++)
331 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
332 tmp->alloc(trueNval,1);
333 int *tmpPtr=tmp->getPointer();
334 for(const int *pt=da4->begin();pt!=da4->end();pt++)
335 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
338 _nval=da4->getNumberOfTuples();
339 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
340 _end=_start+trueNval;
341 oss << "_loc_" << _loc_id;
344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
345 da5->setName(oss.str().c_str());
346 glob.appendProfile(da5);
351 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
353 da3->setName(oss.str().c_str());
354 glob.appendProfile(da3);
358 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
359 _localization=oss2.str();
360 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
364 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
369 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
372 _nval=field->getArray()->getNumberOfTuples();
373 getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
378 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
380 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
383 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
385 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
388 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
390 return new MEDFileFieldPerMeshPerTypePerDisc(other);
393 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
394 try:_type(atype),_father(fath)
397 catch(INTERP_KERNEL::Exception& e)
402 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
406 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)
410 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
411 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
415 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
420 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
422 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
423 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
424 std::string fieldName=getName();
425 std::string meshName=getMeshName();
426 int iteration=getIteration();
427 int order=getOrder();
428 TypeOfField type=getType();
429 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
431 med_geometry_type mgeoti;
432 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
433 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
434 pflname,&profilesize,locname,&nbi);
435 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
436 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
438 _end=start+_nval*nbi;
440 if(type==ON_CELLS && !_localization.empty())
442 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
443 setType(ON_GAUSS_PT);
446 setType(ON_GAUSS_NE);
447 _localization.clear();
452 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
454 std::string fieldName=getName();
455 std::string meshName=getMeshName();
456 int iteration=getIteration();
457 int order=getOrder();
458 TypeOfField type=getType();
459 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
460 med_geometry_type mgeoti;
461 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
462 DataArrayDouble *arr=getArray();
463 double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
468 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
469 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
474 INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
475 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
476 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
477 std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
481 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
486 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
488 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
490 int delta=_end-_start;
491 _start=newValueOfStart;
495 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
497 return _father->getIteration();
500 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
502 return _father->getOrder();
505 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
507 return _father->getTime();
510 std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
512 return _father->getName();
515 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
517 return _father->getMeshName();
520 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
522 const char startLine[]=" ## ";
523 std::string startLine2(bkOffset,' ');
524 startLine2+=startLine;
525 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
526 oss << startLine2 << "Localization #" << id << "." << std::endl;
527 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
529 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
530 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
531 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
534 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
539 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
544 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
549 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
551 return _father->getGeoType();
554 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
556 return _father->getNumberOfComponents();
559 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
564 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
566 return _father->getArray();
569 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
571 const MEDFileFieldPerMeshPerType *fath=_father;
572 return fath->getArray();
575 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
577 return _father->getInfo();
580 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
585 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
590 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
592 return _localization;
595 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
597 _localization=newLocName;
600 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
602 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
604 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
606 _profile=(*it2).second;
612 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
614 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
616 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
618 _localization=(*it2).second;
624 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
628 dads.push_back(std::pair<int,int>(_start,_end));
629 geoTypes.push_back(getGeoType());
634 pfls.push_back(glob->getProfile(_profile.c_str()));
636 if(_localization.empty())
640 locs.push_back(glob->getLocalizationId(_localization.c_str()));
644 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
646 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));
650 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
652 TypeOfField type=getType();
653 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
654 med_geometry_type mgeoti;
655 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
656 const DataArrayDouble *arr=getArray();
657 const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
658 MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
659 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
660 reinterpret_cast<const unsigned char*>(locToWrite));
663 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
668 dad.first=_start; dad.second=_end;
672 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
673 * This code corresponds to the distribution of types in the corresponding mesh.
674 * \param [out] ptToFill memory zone where the output will be stored.
675 * \return the size of data pushed into output param \a ptToFill
677 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
680 std::ostringstream oss;
681 std::size_t nbOfType=codeOfMesh.size()/3;
683 for(std::size_t i=0;i<nbOfType && found==-1;i++)
684 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
688 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
689 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
690 throw INTERP_KERNEL::Exception(oss.str().c_str());
695 if(_nval!=codeOfMesh[3*found+1])
697 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
698 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
699 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
700 throw INTERP_KERNEL::Exception(oss.str().c_str());
702 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
707 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
708 if(pfl->getNumberOfTuples()!=_nval)
710 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
711 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
713 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
714 throw INTERP_KERNEL::Exception(oss.str().c_str());
716 int offset2=codeOfMesh[3*found+2];
717 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
719 if(*pflId<codeOfMesh[3*found+1])
720 *work++=offset2+*pflId;
726 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
728 for(int i=_start;i<_end;i++)
733 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
744 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
748 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
751 std::map<std::pair<std::string,TypeOfField>,int> m;
752 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
753 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
754 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
755 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
757 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
758 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
763 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
765 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
766 * \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.
767 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
768 * \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)
769 * \param [in,out] glob if necessary by the method, new profiles can be added to it
770 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
771 * \param [out] result All new entries will be appended on it.
772 * \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 !)
774 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
775 const DataArrayInt *explicitIdsInMesh,
776 const std::vector<int>& newCode,
777 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
778 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
780 if(entriesOnSameDisc.empty())
782 TypeOfField type=entriesOnSameDisc[0]->getType();
783 int szEntities=0,szTuples=0;
784 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
785 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
786 int nbi=szTuples/szEntities;
787 if(szTuples%szEntities!=0)
788 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
789 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
790 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
791 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
792 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
793 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
794 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
795 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
797 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
799 int startOfEltIdOfChunk=(*it)->_start;
800 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
801 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
802 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
804 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
805 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
807 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
808 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
810 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
811 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
812 std::set<int> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
813 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
815 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
817 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
818 arrPart->renumberInPlace(renumTupleIds->begin());
819 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
821 std::set<int>::const_iterator idIt=diffVals.begin();
822 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
824 for(std::size_t i=0;i<diffVals.size();i++,idIt++)
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
827 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
828 int nbEntityElts=subIds->getNumberOfTuples();
830 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
831 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
835 result.push_back(eltToAdd);
836 offset2+=nbEntityElts*nbi;
838 ret=ret || li.empty();
843 * \param [in] typeF type of field of new chunk
844 * \param [in] geoType the geometric type of the chunk
845 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
846 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
847 * \param [in] nbi number of integration points
848 * \param [in] offset The offset in the **global array of data**.
849 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
850 * to the new chunk to create.
851 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
852 * \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
853 * and corresponding entry erased from \a entriesOnSameDisc.
854 * \return a newly allocated chunk
856 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
857 bool isPfl, int nbi, int offset,
858 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
859 MEDFileFieldGlobsReal& glob,
860 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
862 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
863 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
864 for(;it!=entriesOnSameDisc.end();it++)
866 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
870 if((*it)->_profile.empty())
873 if(!(*it)->_profile.empty())
875 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
876 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
882 if(it==entriesOnSameDisc.end())
885 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
887 ret->_loc_id=(int)geoType;
888 ret->_nval=nbMeshEntities;
890 ret->_end=ret->_start+ret->_nval*nbi;
893 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
894 glob.appendProfile(idsOfMeshElt);
895 ret->_profile=idsOfMeshElt->getName();
897 //tony treatment of localization
903 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
904 ret->_loc_id=(int)geoType;
905 ret->setNewStart(offset);
906 entriesOnSameDisc.erase(it);
912 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
914 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
917 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
919 return new MEDFileFieldPerMeshPerType(fath,geoType);
922 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
924 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
925 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
926 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
930 * This method is the most general one. No optimization is done here.
931 * \param [in] multiTypePfl is the end user profile specified in high level API
932 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
933 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
934 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
935 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
936 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
938 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
940 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
941 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
942 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,mesh,glob);
945 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
947 _field_pm_pt_pd.resize(1);
948 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
949 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
952 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
954 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
956 _field_pm_pt_pd.resize(1);
957 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
958 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,0,glob);//mesh is not requested so 0 is send.
961 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
963 TypeOfField type=field->getTypeOfField();
964 if(type!=ON_GAUSS_PT)
966 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
967 int sz=_field_pm_pt_pd.size();
969 for(int j=0;j<sz && !found;j++)
971 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
973 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
979 _field_pm_pt_pd.resize(sz+1);
980 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
982 std::vector<int> ret(1,0);
987 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
989 std::vector<int> ret3(sz2);
991 for(int i=0;i<sz2;i++)
993 int sz=_field_pm_pt_pd.size();
994 int locIdToFind=ret2[i];
996 for(int j=0;j<sz && !found;j++)
998 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1000 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1007 _field_pm_pt_pd.resize(sz+1);
1008 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1016 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1018 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1019 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1021 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1022 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1023 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1024 std::set<int> retTmp=da2->getDifferentValues();
1025 if(retTmp.find(-1)!=retTmp.end())
1026 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1027 std::vector<int> ret(retTmp.begin(),retTmp.end());
1031 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1033 TypeOfField type=field->getTypeOfField();
1034 if(type!=ON_GAUSS_PT)
1036 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1037 int sz=_field_pm_pt_pd.size();
1039 for(int j=0;j<sz && !found;j++)
1041 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1043 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1049 _field_pm_pt_pd.resize(sz+1);
1050 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1052 std::vector<int> ret(1,0);
1057 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1058 int sz2=ret2.size();
1059 std::vector<int> ret3(sz2);
1061 for(int i=0;i<sz2;i++)
1063 int sz=_field_pm_pt_pd.size();
1064 int locIdToFind=ret2[i];
1066 for(int j=0;j<sz && !found;j++)
1068 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1070 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1077 _field_pm_pt_pd.resize(sz+1);
1078 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1086 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1088 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1089 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1091 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1092 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1093 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1094 std::set<int> retTmp=da2->getDifferentValues();
1095 if(retTmp.find(-1)!=retTmp.end())
1096 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1097 std::vector<int> ret(retTmp.begin(),retTmp.end());
1101 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1106 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1108 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1109 int curDim=(int)cm.getDimension();
1110 dim=std::max(dim,curDim);
1113 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1115 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1117 (*it)->fillTypesOfFieldAvailable(types);
1121 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)
1123 int sz=_field_pm_pt_pd.size();
1124 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1125 for(int i=0;i<sz;i++)
1127 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1131 int MEDFileFieldPerMeshPerType::getIteration() const
1133 return _father->getIteration();
1136 int MEDFileFieldPerMeshPerType::getOrder() const
1138 return _father->getOrder();
1141 double MEDFileFieldPerMeshPerType::getTime() const
1143 return _father->getTime();
1146 std::string MEDFileFieldPerMeshPerType::getName() const
1148 return _father->getName();
1151 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1153 return _father->getMeshName();
1156 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1158 const char startLine[]=" ## ";
1159 std::string startLine2(bkOffset,' ');
1160 std::string startLine3(startLine2);
1161 startLine3+=startLine;
1162 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1164 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1165 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1168 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1169 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1171 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1173 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1175 cur->simpleRepr(bkOffset,oss,i);
1178 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1183 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1185 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1187 globalSz+=(*it)->getNumberOfTuples();
1189 nbOfEntries+=(int)_field_pm_pt_pd.size();
1192 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1198 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1200 return _father->getNumberOfComponents();
1203 DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
1205 return _father->getArray();
1208 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
1210 const MEDFileFieldPerMesh *fath=_father;
1211 return fath->getArray();
1214 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1216 return _father->getInfo();
1219 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1221 std::vector<std::string> ret;
1222 std::set<std::string> ret2;
1223 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1225 std::string tmp=(*it1)->getProfile();
1227 if(ret2.find(tmp)==ret2.end())
1236 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1238 std::vector<std::string> ret;
1239 std::set<std::string> ret2;
1240 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1242 std::string tmp=(*it1)->getLocalization();
1243 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1244 if(ret2.find(tmp)==ret2.end())
1253 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1255 std::vector<std::string> ret;
1256 std::set<std::string> ret2;
1257 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1259 std::string tmp=(*it1)->getProfile();
1266 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1268 std::vector<std::string> ret;
1269 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1271 std::string tmp=(*it1)->getLocalization();
1272 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1278 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1280 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1281 (*it1)->changePflsRefsNamesGen(mapOfModif);
1284 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1286 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1287 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1290 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1292 if(_field_pm_pt_pd.empty())
1294 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1295 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1296 throw INTERP_KERNEL::Exception(oss.str().c_str());
1298 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1299 return _field_pm_pt_pd[locId];
1300 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1301 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1302 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1303 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1304 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1307 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1309 if(_field_pm_pt_pd.empty())
1311 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1312 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1313 throw INTERP_KERNEL::Exception(oss.str().c_str());
1315 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1316 return _field_pm_pt_pd[locId];
1317 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1318 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1319 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1320 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1321 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1324 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
1326 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1328 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1329 if(meshDim!=(int)cm.getDimension())
1332 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1333 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1336 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1339 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1341 (*it)->fillValues(i,startEntryId,entries);
1345 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1347 _field_pm_pt_pd=leaves;
1348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1349 (*it)->setFather(this);
1352 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1356 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1358 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1359 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1360 med_geometry_type mgeoti;
1361 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1362 int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1363 _field_pm_pt_pd.resize(nbProfiles);
1364 for(int i=0;i<nbProfiles;i++)
1366 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1370 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
1373 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1375 (*it)->prepareLoading(fid,pflId+1,start);
1379 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1384 (*it)->finishLoading(fid,pflId+1,ft);
1388 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1390 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1392 (*it)->copyOptionsFrom(*this);
1393 (*it)->writeLL(fid);
1397 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1402 medfGeoType=typmai3[(int)ikGeoType];
1405 medfGeoType=MED_NONE;
1408 medfGeoType=typmai3[(int)ikGeoType];
1409 return MED_NODE_ELEMENT;
1411 medfGeoType=typmai3[(int)ikGeoType];
1414 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1416 return MED_UNDEF_ENTITY_TYPE;
1419 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
1421 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
1424 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1426 return new MEDFileFieldPerMesh(fath,mesh);
1429 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1431 std::string startLine(bkOffset,' ');
1432 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1433 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1435 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1437 const MEDFileFieldPerMeshPerType *cur=*it;
1439 cur->simpleRepr(bkOffset,oss,i);
1442 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1447 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1449 _mesh_name=mesh->getName();
1450 mesh->getTime(_mesh_iteration,_mesh_order);
1453 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1455 int nbOfTypes=code.size()/3;
1457 for(int i=0;i<nbOfTypes;i++)
1459 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1460 int nbOfCells=code[3*i+1];
1461 int pos=addNewEntryIfNecessary(type);
1462 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
1468 * This method is the most general one. No optimization is done here.
1469 * \param [in] multiTypePfl is the end user profile specified in high level API
1470 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1471 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1472 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1473 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1474 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1476 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1478 int nbOfTypes=code.size()/3;
1479 for(int i=0;i<nbOfTypes;i++)
1481 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1482 int pos=addNewEntryIfNecessary(type);
1483 DataArrayInt *pfl=0;
1485 pfl=idsPerType[code[3*i+2]];
1486 int nbOfTupes2=code2.size()/3;
1488 for(;found<nbOfTupes2;found++)
1489 if(code[3*i]==code2[3*found])
1491 if(found==nbOfTupes2)
1492 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1493 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,mesh,glob);
1497 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1499 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1500 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
1503 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1505 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1506 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
1509 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
1511 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1512 (*it)->prepareLoading(fid,start);
1515 void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1517 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1518 (*it)->finishLoading(fid,ft);
1521 void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1523 int nbOfTypes=_field_pm_pt.size();
1524 for(int i=0;i<nbOfTypes;i++)
1526 _field_pm_pt[i]->copyOptionsFrom(*this);
1527 _field_pm_pt[i]->writeLL(fid);
1531 void MEDFileFieldPerMesh::getDimension(int& dim) const
1533 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1534 (*it)->getDimension(dim);
1537 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1539 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1540 (*it)->fillTypesOfFieldAvailable(types);
1543 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)
1545 int sz=_field_pm_pt.size();
1546 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1547 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1548 for(int i=0;i<sz;i++)
1550 types[i]=_field_pm_pt[i]->getGeoType();
1551 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1556 double MEDFileFieldPerMesh::getTime() const
1559 return _father->getTime(tmp1,tmp2);
1562 int MEDFileFieldPerMesh::getIteration() const
1564 return _father->getIteration();
1567 const std::string& MEDFileFieldPerMesh::getDtUnit() const
1569 return _father->getDtUnit();
1572 int MEDFileFieldPerMesh::getOrder() const
1574 return _father->getOrder();
1577 std::string MEDFileFieldPerMesh::getName() const
1579 return _father->getName();
1582 int MEDFileFieldPerMesh::getNumberOfComponents() const
1584 return _father->getNumberOfComponents();
1587 DataArrayDouble *MEDFileFieldPerMesh::getArray()
1589 return _father->getOrCreateAndGetArray();
1592 const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
1594 const MEDFileField1TSWithoutSDA *fath=_father;
1595 return fath->getOrCreateAndGetArray();
1598 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1600 return _father->getInfo();
1604 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1605 * 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.
1606 * It returns 2 output vectors :
1607 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1608 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1609 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1611 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)
1613 int notNullPflsSz=0;
1614 int nbOfArrs=geoTypes.size();
1615 for(int i=0;i<nbOfArrs;i++)
1618 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1619 int nbOfDiffGeoTypes=geoTypes3.size();
1620 code.resize(3*nbOfDiffGeoTypes);
1621 notNullPfls.resize(notNullPflsSz);
1624 for(int i=0;i<nbOfDiffGeoTypes;i++)
1627 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1628 std::vector<const DataArrayInt *> notNullTmp;
1630 notNullTmp.push_back(pfls[j]);
1632 for(;j<nbOfArrs;j++)
1633 if(geoTypes[j]==refType)
1636 notNullTmp.push_back(pfls[j]);
1640 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1641 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1642 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1643 code[3*i]=(int)refType;
1644 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1645 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1646 if(notNullTmp.empty())
1650 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1651 code[3*i+2]=notNullPflsSz++;
1657 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1659 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)
1663 for(int i=0;i<sz;i++)
1667 if(type!=ON_GAUSS_NE)
1668 ret+=dads[i].second-dads[i].first;
1671 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1672 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1677 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1678 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1684 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1686 std::vector<std::string> ret;
1687 std::set<std::string> ret2;
1688 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1690 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1691 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1692 if(ret2.find(*it2)==ret2.end())
1694 ret.push_back(*it2);
1701 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1703 std::vector<std::string> ret;
1704 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1706 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1707 ret.insert(ret.end(),tmp.begin(),tmp.end());
1712 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1714 std::vector<std::string> ret;
1715 std::set<std::string> ret2;
1716 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1718 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1719 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1720 if(ret2.find(*it2)==ret2.end())
1722 ret.push_back(*it2);
1729 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1731 std::vector<std::string> ret;
1732 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1734 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1735 ret.insert(ret.end(),tmp.begin(),tmp.end());
1740 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1742 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1744 if((*it).first==_mesh_name)
1746 _mesh_name=(*it).second;
1753 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1754 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1756 if(_mesh_name!=meshName)
1758 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1759 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1760 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1761 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1762 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1763 DataArrayDouble *arr=getUndergroundDataArrayExt(entries);
1766 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1767 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1769 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1771 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1772 sz+=(*it).second.second-(*it).second.first;
1775 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1777 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1778 ////////////////////
1779 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1780 int *workI2=explicitIdsOldInMesh->getPointer();
1781 int sz1=0,sz2=0,sid=1;
1782 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1783 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1784 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1786 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1787 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1788 int *workI=explicitIdsOldInArr->getPointer();
1789 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1791 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1792 (*itL2)->setLocId(sz2);
1793 (*itL2)->_tmp_work1=(*itL2)->getStart();
1794 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1796 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1798 explicitIdsOldInMesh->reAlloc(sz2);
1799 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1800 ////////////////////
1801 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1802 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1803 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1804 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1806 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1807 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1808 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1810 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1811 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1812 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1814 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1815 int newStart=elt->getLocId();
1816 elt->setLocId((*it)->getGeoType());
1817 elt->setNewStart(newStart);
1818 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1819 entriesKeptNew.push_back(elt);
1820 entriesKeptNew2.push_back(elt);
1822 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1823 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1824 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1825 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1827 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1830 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1832 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1833 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1835 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1836 glob,arr2,otherEntriesNew) || ret;
1840 // Assign new dispatching
1841 assignNewLeaves(otherEntriesNew);
1842 arr->cpyFrom(*arr2);
1846 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1848 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1849 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1850 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1852 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1853 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1854 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1855 for(;it1!=types.end();it1++,it2++)
1857 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1858 elt->setLeaves((*it1).second);
1861 _field_pm_pt=fieldPmPt;
1864 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1866 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1867 (*it)->changePflsRefsNamesGen(mapOfModif);
1870 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1872 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1873 (*it)->changeLocsRefsNamesGen(mapOfModif);
1877 * \param [in] mesh is the whole mesh
1879 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
1881 if(_field_pm_pt.empty())
1882 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1884 std::vector< std::pair<int,int> > dads;
1885 std::vector<const DataArrayInt *> pfls;
1886 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1887 std::vector<int> locs,code;
1888 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1889 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1890 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1892 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1895 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1896 throw INTERP_KERNEL::Exception(oss.str().c_str());
1899 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1900 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1903 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1905 return finishField(type,glob,dads,locs,mesh,isPfl);
1908 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1909 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
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());
1925 return finishField(type,glob,dads,locs,mesh,isPfl);
1928 return finishField3(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
1932 DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
1934 if(_field_pm_pt.empty())
1935 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1937 std::vector<std::pair<int,int> > dads;
1938 std::vector<const DataArrayInt *> pfls;
1939 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1940 std::vector<int> locs,code;
1941 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1942 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1943 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1945 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1948 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1949 throw INTERP_KERNEL::Exception(oss.str().c_str());
1951 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1952 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1955 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1956 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
1961 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1965 if(nb!=mesh->getNumberOfNodes())
1967 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1968 oss << " nodes in mesh !";
1969 throw INTERP_KERNEL::Exception(oss.str().c_str());
1972 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
1978 DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
1982 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1984 (*it)->getSizes(globalSz,nbOfEntries);
1986 entries.resize(nbOfEntries);
1988 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1990 (*it)->fillValues(nbOfEntries,entries);
1992 return _father->getUndergroundDataArray();
1995 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
1997 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999 if((*it)->getGeoType()==typ)
2000 return (*it)->getLeafGivenLocId(locId);
2002 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2003 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2004 oss << "Possiblities are : ";
2005 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2007 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2008 oss << "\"" << cm2.getRepr() << "\", ";
2010 throw INTERP_KERNEL::Exception(oss.str().c_str());
2013 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2015 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2017 if((*it)->getGeoType()==typ)
2018 return (*it)->getLeafGivenLocId(locId);
2020 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2021 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2022 oss << "Possiblities are : ";
2023 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2025 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2026 oss << "\"" << cm2.getRepr() << "\", ";
2028 throw INTERP_KERNEL::Exception(oss.str().c_str());
2031 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2034 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2035 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2036 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2038 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2043 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2048 int ret=std::distance(_field_pm_pt.begin(),it2);
2049 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2054 * 'dads' and 'locs' input parameters have the same number of elements
2055 * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2057 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2058 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2059 const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2062 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2063 ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
2064 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2065 const std::vector<std::string>& infos=getInfo();
2066 da->setInfoOnComponents(infos);
2069 if(type==ON_GAUSS_PT)
2072 int nbOfArrs=dads.size();
2073 for(int i=0;i<nbOfArrs;i++)
2075 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2076 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2077 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2078 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2079 di->alloc(nbOfElems,1);
2081 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2082 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2092 * 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.
2093 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2094 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2095 * The order of cells in the returned field is those imposed by the profile.
2096 * \param [in] mesh is the global mesh.
2098 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2099 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2100 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2101 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2103 if(da->isIdentity())
2105 int nbOfTuples=da->getNumberOfTuples();
2106 if(nbOfTuples==mesh->getNumberOfCells())
2107 return finishField(type,glob,dads,locs,mesh,isPfl);
2109 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2110 m2->setName(mesh->getName());
2111 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl);
2118 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2120 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFileFieldGlobsReal *glob,
2121 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2122 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2124 if(da->isIdentity())
2126 int nbOfTuples=da->getNumberOfTuples();
2127 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2128 if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,geoTypes2,dads,locs))//No problem for NORM_ERROR because it is in context of node
2129 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2131 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2132 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2135 if(meshu->getNodalConnectivity()==0)
2137 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
2138 int nb=da->getNbOfElems();
2139 const int *ptr=da->getConstPointer();
2140 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2141 meshuc->allocateCells(nb);
2142 for(int i=0;i<nb;i++)
2143 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2144 meshuc->finishInsertingCells();
2145 ret->setMesh(meshuc);
2146 ret->checkCoherency();
2152 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2154 DataArrayInt *arr2=0;
2155 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2156 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2157 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2158 int nnodes=mesh2->getNumberOfNodes();
2159 if(nnodes==da->getNbOfElems())
2161 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->getConstPointer(),arr2->getConstPointer()+arr2->getNbOfElems());
2162 ret->getArray()->renumberInPlace(da3->getConstPointer());
2163 mesh2->setName(mesh->getName());
2164 ret->setMesh(mesh2);
2170 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 !!!";
2171 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2172 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2173 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2174 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2175 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2176 throw INTERP_KERNEL::Exception(oss.str().c_str());
2182 * This method is the most light method of field retrieving.
2184 DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2188 pflOut=DataArrayInt::New();
2189 pflOut->alloc(nbOfElems,1);
2194 pflOut=const_cast<DataArrayInt*>(pflIn);
2197 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2198 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2199 const std::vector<std::string>& infos=getInfo();
2200 int nbOfComp=infos.size();
2201 for(int i=0;i<nbOfComp;i++)
2202 da->setInfoOnComponent(i,infos[i].c_str());
2208 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2209 _mesh_csit(meshCsit),_father(fath)
2211 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2212 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2213 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2214 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2216 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2219 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
2220 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2222 nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2225 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
2226 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2229 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2232 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
2233 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2237 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2239 copyTinyInfoFrom(mesh);
2242 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2244 if(id>=(int)_pfls.size())
2246 _pfls[id]=DataArrayInt::New();
2247 int lgth=MEDprofileSizeByName(fid,pflName);
2248 _pfls[id]->setName(pflName);
2249 _pfls[id]->alloc(lgth,1);
2250 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2251 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2254 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2256 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2258 MEDprofileInfo(fid,i+1,pflName,&sz);
2259 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2260 if(i>=(int)_pfls.size())
2262 _pfls[i]=DataArrayInt::New();
2263 _pfls[i]->alloc(sz,1);
2264 _pfls[i]->setName(pflCpp.c_str());
2265 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2266 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2269 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2271 int nbOfPfls=_pfls.size();
2272 for(int i=0;i<nbOfPfls;i++)
2274 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2275 cpy->applyLin(1,1,0);
2276 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2277 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2278 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2281 int nbOfLocs=_locs.size();
2282 for(int i=0;i<nbOfLocs;i++)
2283 _locs[i]->writeLL(fid);
2286 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2288 std::vector<std::string> pfls=getPfls();
2289 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2291 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2294 _pfls.push_back(*it);
2298 int id=std::distance(pfls.begin(),it2);
2299 if(!(*it)->isEqual(*_pfls[id]))
2301 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2302 throw INTERP_KERNEL::Exception(oss.str().c_str());
2306 std::vector<std::string> locs=getLocs();
2307 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2309 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2312 _locs.push_back(*it);
2316 int id=std::distance(locs.begin(),it2);
2317 if(!(*it)->isEqual(*_locs[id],eps))
2319 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2320 throw INTERP_KERNEL::Exception(oss.str().c_str());
2326 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2328 std::vector<std::string> profiles=real.getPflsReallyUsed();
2329 int sz=profiles.size();
2331 for(int i=0;i<sz;i++)
2332 loadProfileInFile(fid,i,profiles[i].c_str());
2334 std::vector<std::string> locs=real.getLocsReallyUsed();
2337 for(int i=0;i<sz;i++)
2338 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2341 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2343 int nProfil=MEDnProfile(fid);
2344 for(int i=0;i<nProfil;i++)
2345 loadProfileInFile(fid,i);
2346 int sz=MEDnLocalization(fid);
2348 for(int i=0;i<sz;i++)
2350 _locs[i]=MEDFileFieldLoc::New(fid,i);
2354 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2356 return new MEDFileFieldGlobs(fname);
2359 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2361 return new MEDFileFieldGlobs;
2364 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2368 MEDFileFieldGlobs::MEDFileFieldGlobs()
2372 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2376 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2378 oss << "Profiles :\n";
2379 std::size_t n=_pfls.size();
2380 for(std::size_t i=0;i<n;i++)
2382 oss << " - #" << i << " ";
2383 const DataArrayInt *pfl=_pfls[i];
2385 oss << "\"" << pfl->getName() << "\"\n";
2390 oss << "Localizations :\n";
2391 for(std::size_t i=0;i<n;i++)
2393 oss << " - #" << i << " ";
2394 const MEDFileFieldLoc *loc=_locs[i];
2396 loc->simpleRepr(oss);
2402 void MEDFileFieldGlobs::setFileName(const char *fileName)
2404 _file_name=fileName;
2407 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2409 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2411 DataArrayInt *elt(*it);
2414 std::string name(elt->getName());
2415 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2417 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2419 elt->setName((*it2).second.c_str());
2427 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2431 MEDFileFieldLoc *elt(*it);
2434 std::string name(elt->getName());
2435 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2437 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2439 elt->setName((*it2).second.c_str());
2447 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2449 if(locId<0 || locId>=(int)_locs.size())
2450 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2451 return _locs[locId]->getNbOfGaussPtPerCell();
2454 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2456 return getLocalizationFromId(getLocalizationId(locName));
2459 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2461 if(locId<0 || locId>=(int)_locs.size())
2462 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2463 return *_locs[locId];
2466 namespace ParaMEDMEMImpl
2471 LocFinder(const char *loc):_loc(loc) { }
2472 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2480 PflFinder(const std::string& pfl):_pfl(pfl) { }
2481 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2483 const std::string& _pfl;
2487 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2489 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2492 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2493 for(it=_locs.begin();it!=_locs.end();it++)
2494 oss << "\"" << (*it)->getName() << "\", ";
2495 throw INTERP_KERNEL::Exception(oss.str().c_str());
2497 return std::distance(_locs.begin(),it);
2500 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2502 std::string pflNameCpp(pflName);
2503 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2506 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2507 for(it=_pfls.begin();it!=_pfls.end();it++)
2508 oss << "\"" << (*it)->getName() << "\", ";
2509 throw INTERP_KERNEL::Exception(oss.str().c_str());
2514 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2516 if(pflId<0 || pflId>=(int)_pfls.size())
2517 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2518 return _pfls[pflId];
2521 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2523 if(locId<0 || locId>=(int)_locs.size())
2524 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2525 return *_locs[locId];
2528 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2530 return getLocalizationFromId(getLocalizationId(locName));
2533 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2535 std::string pflNameCpp(pflName);
2536 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2539 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2540 for(it=_pfls.begin();it!=_pfls.end();it++)
2541 oss << "\"" << (*it)->getName() << "\", ";
2542 throw INTERP_KERNEL::Exception(oss.str().c_str());
2547 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2549 if(pflId<0 || pflId>=(int)_pfls.size())
2550 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2551 return _pfls[pflId];
2554 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2556 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2558 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2560 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2561 newPfls.push_back(*it);
2566 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2568 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2570 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2572 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2573 newLocs.push_back(*it);
2578 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2580 int sz=_pfls.size();
2581 std::vector<std::string> ret(sz);
2582 for(int i=0;i<sz;i++)
2583 ret[i]=_pfls[i]->getName();
2587 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2589 int sz=_locs.size();
2590 std::vector<std::string> ret(sz);
2591 for(int i=0;i<sz;i++)
2592 ret[i]=_locs[i]->getName();
2596 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2598 std::vector<std::string> v=getPfls();
2599 std::string s(pflName);
2600 return std::find(v.begin(),v.end(),s)!=v.end();
2603 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2605 std::vector<std::string> v=getLocs();
2606 std::string s(locName);
2607 return std::find(v.begin(),v.end(),s)!=v.end();
2610 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2612 std::map<int,std::vector<int> > m;
2614 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2616 const DataArrayInt *tmp=(*it);
2619 m[tmp->getHashCode()].push_back(i);
2622 std::vector< std::vector<int> > ret;
2623 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2625 if((*it2).second.size()>1)
2627 std::vector<int> ret0;
2628 bool equalityOrNot=false;
2629 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2631 std::vector<int>::const_iterator it4=it3; it4++;
2632 for(;it4!=(*it2).second.end();it4++)
2634 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2637 ret0.push_back(*it3);
2638 ret0.push_back(*it4);
2644 ret.push_back(ret0);
2650 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2652 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2655 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2657 std::string name(pfl->getName());
2659 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2660 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2661 if(name==(*it)->getName())
2663 if(!pfl->isEqual(*(*it)))
2665 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2666 throw INTERP_KERNEL::Exception(oss.str().c_str());
2670 _pfls.push_back(pfl);
2673 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)
2675 std::string name(locName);
2677 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2678 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2679 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2680 if((*it)->isName(locName))
2682 if(!(*it)->isEqual(*obj,1e-12))
2684 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2685 throw INTERP_KERNEL::Exception(oss.str().c_str());
2688 _locs.push_back(obj);
2691 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2693 std::vector<std::string> names=getPfls();
2694 return CreateNewNameNotIn("NewPfl_",names);
2697 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2699 std::vector<std::string> names=getLocs();
2700 return CreateNewNameNotIn("NewLoc_",names);
2703 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2705 for(std::size_t sz=0;sz<100000;sz++)
2707 std::ostringstream tryName;
2708 tryName << prefix << sz;
2709 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2710 return tryName.str();
2712 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2715 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2719 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2723 void MEDFileFieldGlobsReal::simpleRepr(std::ostream& oss) const
2725 oss << "Globals information on fields :" << "\n*******************************\n\n";
2726 const MEDFileFieldGlobs *glob=_globals;
2728 glob->simpleRepr(oss);
2730 oss << "NO GLOBAL INFORMATION !\n";
2733 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2737 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2739 _globals=other._globals;
2742 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2744 _globals->appendGlobs(*other._globals,eps);
2747 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2749 _globals->loadProfileInFile(fid,id,pflName);
2752 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
2754 _globals->loadProfileInFile(fid,id);
2757 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2759 _globals->loadGlobals(fid,*this);
2762 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2764 _globals->loadAllGlobals(fid);
2767 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2769 _globals->writeGlobals(fid,opt);
2772 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
2774 return _globals->getPfls();
2777 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
2779 return _globals->getLocs();
2782 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
2784 return _globals->existsPfl(pflName);
2787 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
2789 return _globals->existsLoc(locName);
2792 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2794 return _globals->createNewNameOfPfl();
2797 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2799 return _globals->createNewNameOfLoc();
2802 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
2804 _globals->setFileName(fileName);
2807 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
2809 return _globals->whichAreEqualProfiles();
2812 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
2814 return _globals->whichAreEqualLocs(eps);
2817 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2819 _globals->changePflsNamesInStruct(mapOfModif);
2822 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2824 _globals->changeLocsNamesInStruct(mapOfModif);
2828 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2829 * This method contrary to abstract method MEDFileFieldGlobsReal::changePflsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changePflsRefsNamesGen,
2830 * the profiles themselves and not only leaves of field.
2832 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2834 changePflsRefsNamesGen(mapOfModif);
2835 changePflsNamesInStruct(mapOfModif);
2839 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2840 * This method contrary to abstract method MEDFileFieldGlobsReal::changeLocsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changeLocsRefsNamesGen,
2841 * the localizations themselves and not only leaves of field.
2843 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2845 changeLocsRefsNamesGen(mapOfModif);
2846 changeLocsNamesInStruct(mapOfModif);
2850 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changePflsNames.
2852 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2854 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2855 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2857 changePflsNames(mapOfModif);
2861 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changeLocsNames.
2863 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2865 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2866 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2868 changeLocsNames(mapOfModif);
2871 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
2873 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
2874 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2876 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2878 std::vector< std::string > tmp((*it).size());
2880 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2881 tmp[j]=std::string(getProfileFromId(*it2)->getName());
2882 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2884 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2885 killProfileIds(tmp2);
2887 changePflsRefsNamesGen(ret);
2891 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
2893 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
2894 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2896 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2898 std::vector< std::string > tmp((*it).size());
2900 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2901 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
2902 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2904 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2905 killLocalizationIds(tmp2);
2907 changeLocsRefsNamesGen(ret);
2911 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2913 return _globals->getNbOfGaussPtPerCell(locId);
2916 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2918 return _globals->getLocalizationId(loc);
2921 const char *MEDFileFieldGlobsReal::getFileName() const
2923 return _globals->getFileName();
2926 std::string MEDFileFieldGlobsReal::getFileName2() const
2928 return _globals->getFileName2();
2931 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2933 return _globals->getLocalization(locName);
2936 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2938 return _globals->getLocalizationFromId(locId);
2941 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2943 return _globals->getProfile(pflName);
2946 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2948 return _globals->getProfileFromId(pflId);
2951 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2953 return _globals->getLocalizationFromId(locId);
2956 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2958 return _globals->getLocalization(locName);
2961 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2963 return _globals->getProfile(pflName);
2966 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2968 return _globals->getProfileFromId(pflId);
2971 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2973 _globals->killProfileIds(pflIds);
2976 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2978 _globals->killLocalizationIds(locIds);
2981 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2983 _globals->appendProfile(pfl);
2986 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)
2988 _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
2992 * This method returns the max dimension of 'this'.
2993 * This method returns -2 if 'this' is empty, -1 if only nodes are defined.
2995 int MEDFileField1TSWithoutSDA::getDimension() const
2998 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
2999 (*it)->getDimension(ret);
3003 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
3005 if(meshDimRelToMax>0)
3006 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
3009 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3012 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
3013 int nbOfTypes=geoTypes.size();
3014 std::vector<int> code(3*nbOfTypes);
3015 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
3016 arr1->alloc(nbOfTypes,1);
3017 int *arrPtr=arr1->getPointer();
3018 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
3019 for(int i=0;i<nbOfTypes;i++,it++)
3020 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
3021 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
3022 const int *arrPtr2=arr2->getConstPointer();
3024 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
3027 int nbCells=mesh->getNumberOfCellsWithType(*it);
3028 code[3*pos]=(int)(*it);
3029 code[3*pos+1]=nbCells;
3030 code[3*pos+2]=-1;//no profiles
3032 std::vector<const DataArrayInt *> idsPerType;//no profiles
3033 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
3037 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
3042 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
3044 return new MEDFileField1TSWithoutSDA(fieldName,csit,fieldtype,iteration,order,infos);
3048 * This method copyies tiny info but also preallocated the DataArrayDouble instance in this->_arr.
3049 * This not allocated it allocates to the size of 'field' array. If already allocated it grows the array to
3050 * the previous size + the size of the array of the input 'field'.
3051 * This method returns the position (in tuple id) where to start to feed 'this->_arr'
3053 int MEDFileField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3055 std::string name(field->getName());
3056 getOrCreateAndGetArray()->setName(name.c_str());
3058 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
3059 const DataArrayDouble *arr=field->getArray();
3061 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
3062 _dt=field->getTime(_iteration,_order);
3063 int nbOfComponents=arr->getNumberOfComponents();
3064 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
3065 if(!getOrCreateAndGetArray()->isAllocated())
3067 _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
3072 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
3073 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
3074 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
3075 tmp->alloc(newNbOfTuples,nbOfComponents);
3076 tmp->copyStringInfoFrom(*_arr);
3077 std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
3079 return oldNbOfTuples;
3083 std::string MEDFileField1TSWithoutSDA::getName() const
3085 const DataArrayDouble *arr=getOrCreateAndGetArray();
3086 return arr->getName();
3089 void MEDFileField1TSWithoutSDA::setName(const char *name)
3091 DataArrayDouble *arr=getOrCreateAndGetArray();
3095 void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3097 std::string startOfLine(bkOffset,' ');
3098 oss << startOfLine << "Field on One time Step ";
3100 oss << "(" << f1tsId << ") ";
3101 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3102 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3103 const DataArrayDouble *arr=_arr;
3106 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3109 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3110 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3111 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3112 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3114 if(arr->isAllocated())
3116 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3119 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3123 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3125 oss << startOfLine << "----------------------" << std::endl;
3126 if(!_field_per_mesh.empty())
3129 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3131 const MEDFileFieldPerMesh *cur=(*it2);
3133 cur->simpleRepr(bkOffset,oss,i);
3135 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3140 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3142 oss << startOfLine << "----------------------" << std::endl;
3145 std::string MEDFileField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3147 if(_field_per_mesh.empty())
3148 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3149 return _field_per_mesh[0]->getMeshName();
3152 void MEDFileField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3154 std::string oldName(getMeshName());
3155 std::vector< std::pair<std::string,std::string> > v(1);
3156 v[0].first=oldName; v[0].second=newMeshName;
3160 bool MEDFileField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3163 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3165 MEDFileFieldPerMesh *cur(*it);
3167 ret=cur->changeMeshNames(modifTab) || ret;
3172 bool MEDFileField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3173 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3176 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3178 MEDFileFieldPerMesh *fpm(*it);
3180 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3185 int MEDFileField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3187 if(_field_per_mesh.empty())
3188 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3189 return _field_per_mesh[0]->getMeshIteration();
3192 int MEDFileField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3194 if(_field_per_mesh.empty())
3195 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3196 return _field_per_mesh[0]->getMeshOrder();
3199 int MEDFileField1TSWithoutSDA::getNumberOfComponents() const
3201 return getOrCreateAndGetArray()->getNumberOfComponents();
3204 bool MEDFileField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3206 return iteration==_iteration && order==_order;
3209 std::pair<int,int> MEDFileField1TSWithoutSDA::getDtIt() const
3211 std::pair<int,int> p;
3216 void MEDFileField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3222 void MEDFileField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3224 std::set<TypeOfField> types2;
3225 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3227 (*it)->fillTypesOfFieldAvailable(types2);
3229 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3230 std::copy(types2.begin(),types2.end(),bi);
3233 const std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo() const
3235 const DataArrayDouble *arr=getOrCreateAndGetArray();
3236 return arr->getInfoOnComponents();
3239 std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo()
3241 DataArrayDouble *arr=getOrCreateAndGetArray();
3242 return arr->getInfoOnComponents();
3246 * 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'
3247 * This method returns two things.
3248 * - The absolute dimension of 'this' in first parameter.
3249 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
3250 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
3252 * This method is designed for MEDFileField1TS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
3253 * Only these 3 discretizations will be taken into account here.
3255 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
3256 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
3257 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
3259 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
3260 * 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'.
3262 * Let's consider the typical following case :
3263 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
3264 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
3265 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
3267 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
3269 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
3271 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
3272 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
3273 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
3274 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
3276 int MEDFileField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3279 int meshId=getMeshIdFromMeshName(mname);
3280 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3281 std::vector< std::vector<TypeOfField> > typesF;
3282 std::vector< std::vector<std::string> > pfls, locs;
3283 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3285 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3286 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3287 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3289 st.erase(INTERP_KERNEL::NORM_ERROR);
3291 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3293 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3294 ret1.insert((int)cm.getDimension());
3296 int ret=*std::max_element(ret1.begin(),ret1.end());
3297 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3298 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3302 std::vector<TypeOfField> MEDFileField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3304 std::vector<TypeOfField> ret;
3305 fillTypesOfFieldAvailable(ret);
3310 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
3312 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)
3316 meshId=getMeshIdFromMeshName(mname);
3318 if(_field_per_mesh.empty())
3319 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3320 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3324 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
3325 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
3327 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)
3331 meshId=getMeshIdFromMeshName(mname);
3333 if(_field_per_mesh.empty())
3334 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3335 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3336 int nbOfRet=ret0.size();
3337 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
3338 for(int i=0;i<nbOfRet;i++)
3340 const std::vector< std::pair<int,int> >& p=ret0[i];
3341 int nbOfRet1=p.size();
3342 ret[i].resize(nbOfRet1);
3343 for(int j=0;j<nbOfRet1;j++)
3345 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
3352 void MEDFileField1TSWithoutSDA::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
3354 med_int numdt,numit;
3358 med_int meshnumdt,meshnumit;
3359 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3360 MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
3361 MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
3362 if(_iteration!=numdt || _order!=numit)
3363 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
3364 _field_per_mesh.resize(nmesh);
3365 for(int i=0;i<nmesh;i++)
3366 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
3368 for(int i=0;i<nmesh;i++)
3370 _field_per_mesh[i]->prepareLoading(fid,start);
3372 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
3373 for(int i=0;i<nmesh;i++)
3375 _field_per_mesh[i]->finishLoading(fid,_field_type);
3379 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsed2() const
3381 std::vector<std::string> ret;
3382 std::set<std::string> ret2;
3383 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3385 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3386 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3387 if(ret2.find(*it2)==ret2.end())
3389 ret.push_back(*it2);
3396 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsed2() const
3398 std::vector<std::string> ret;
3399 std::set<std::string> ret2;
3400 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3402 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3403 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3404 if(ret2.find(*it2)==ret2.end())
3406 ret.push_back(*it2);
3413 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3415 std::vector<std::string> ret;
3416 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3418 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3419 ret.insert(ret.end(),tmp.begin(),tmp.end());
3424 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3426 std::vector<std::string> ret;
3427 std::set<std::string> ret2;
3428 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3430 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3431 ret.insert(ret.end(),tmp.begin(),tmp.end());
3436 void MEDFileField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3438 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3439 (*it)->changePflsRefsNamesGen(mapOfModif);
3442 void MEDFileField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3444 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3445 (*it)->changeLocsRefsNamesGen(mapOfModif);
3448 void MEDFileField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
3450 if(_field_per_mesh.empty())
3451 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3452 if(_field_per_mesh.size()>1)
3453 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3454 _field_per_mesh[0]->copyOptionsFrom(opts);
3455 _field_per_mesh[0]->writeLL(fid);
3459 * SBT means Sort By Type.
3460 * 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.
3462 void MEDFileField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3464 const MEDCouplingMesh *mesh=field->getMesh();
3466 TypeOfField type=field->getTypeOfField();
3467 std::vector<DataArrayInt *> dummy;
3468 int start=copyTinyInfoFrom(field);
3469 int pos=addNewEntryIfNecessary(mesh);
3472 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
3473 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,glob);
3476 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
3480 * Generalization of MEDFileField1TSWithoutSDA::setFieldNoProfileSBT method.
3482 void MEDFileField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3484 TypeOfField type=field->getTypeOfField();
3485 int start=copyTinyInfoFrom(field);
3486 std::vector<DataArrayInt *> idsInPflPerType;
3487 std::vector<DataArrayInt *> idsPerType;
3488 std::vector<int> code,code2;
3489 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3492 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
3493 code2=m->getDistributionOfTypes();
3495 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
3496 for(std::size_t i=0;i<idsInPflPerType.size();i++)
3497 idsInPflPerType2[i]=idsInPflPerType[i];
3498 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
3499 for(std::size_t i=0;i<idsPerType.size();i++)
3500 idsPerType2[i]=idsPerType[i];
3502 int pos=addNewEntryIfNecessary(m);
3503 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,m,glob);
3507 int pos=addNewEntryIfNecessary(m);
3508 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
3512 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3514 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3516 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3518 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3519 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3522 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
3524 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
3525 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
3526 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
3527 if(meshDimRelToMax==1)
3528 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
3529 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
3532 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3534 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3536 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3538 mm=MEDFileMesh::New(glob->getFileName(),mName,-1,-1);
3539 int absDim=getDimension();
3540 int meshDimRelToMax=absDim-mm->getMeshDimension();
3541 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3545 * \param [in] mesh is the whole mesh.
3547 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
3549 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
3550 int meshId=getMeshIdFromMeshName(mesh->getName());
3552 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
3557 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3565 throw INTERP_KERNEL::Exception(msg1);
3566 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3569 if(cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
3571 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3572 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
3573 throw INTERP_KERNEL::Exception(oss.str().c_str());
3575 ret->renumberCells(cellRenum->getConstPointer(),true);
3585 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3587 throw INTERP_KERNEL::Exception(msg1);
3590 if(nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
3592 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3593 oss << "\"" << getName() << "\" not defined on all nodes !";
3594 throw INTERP_KERNEL::Exception(oss.str().c_str());
3596 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
3597 ret->renumberNodes(nodeRenumSafe->getConstPointer());
3603 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
3607 DataArrayDouble *MEDFileField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3609 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3610 int meshId=getMeshIdFromMeshName(mesh->getName());
3611 return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
3615 * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance. The returned array is not a newly
3616 * created array so it should \b not be dealed by the caller.
3617 * This method allows to the user a direct access to the values.
3618 * This method is quite unusable if there is more than a nodal field or a cell field on single geometric cell type.
3620 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
3622 const DataArrayDouble *ret=_arr;
3624 return const_cast<DataArrayDouble *>(ret);
3630 * This method returns an array that the caller must deal with (contrary to those returned by MEDFileField1TSWithoutSDA::getUndergroundDataArray method).
3631 * 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
3632 * '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
3633 * id attached to it. The second pair of pair precise the range [begin,end) into the returned array.
3634 * This method makes the hypothesis that the field lies only on one mesh. If it is not the case an exception will be thrown.
3636 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
3638 if(_field_per_mesh.size()!=1)
3639 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
3640 if(_field_per_mesh[0]==0)
3641 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
3642 return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
3645 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order,
3646 const std::vector<std::string>& infos):_iteration(iteration),_order(order),_csit(csit),_field_type(fieldtype)
3648 DataArrayDouble *arr=getOrCreateAndGetArray();
3649 arr->setName(fieldName);
3650 arr->setInfoAndChangeNbOfCompo(infos);
3653 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():_csit(-1),_field_type(-1)
3657 int MEDFileField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3659 std::string tmp(mesh->getName());
3661 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3662 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3664 for(;it!=_field_per_mesh.end();it++,i++)
3666 if((*it)->getMeshName()==tmp)
3669 int sz=_field_per_mesh.size();
3670 _field_per_mesh.resize(sz+1);
3671 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3676 * \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.
3678 int MEDFileField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3680 if(_field_per_mesh.empty())
3681 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3684 std::string mName2(mName);
3686 std::vector<std::string> msg;
3687 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3688 if(mName2==(*it)->getMeshName())
3691 msg.push_back((*it)->getMeshName());
3692 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3693 oss << "Possible meshes are : ";
3694 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3695 oss << "\"" << (*it2) << "\" ";
3696 throw INTERP_KERNEL::Exception(oss.str().c_str());
3700 * \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.
3701 * \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.
3702 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3703 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3705 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3707 int mid=getMeshIdFromMeshName(mName);
3708 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3712 * \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.
3713 * \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.
3714 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3715 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3717 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3719 int mid=getMeshIdFromMeshName(mName);
3720 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3723 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
3725 DataArrayDouble *ret=_arr;
3728 _arr=DataArrayDouble::New();
3732 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
3734 const DataArrayDouble *ret=_arr;
3737 DataArrayDouble *ret2=DataArrayDouble::New();
3738 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
3742 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3744 return new MEDFileField1TS(fileName,fieldName,iteration,order);
3748 * \warning this is a shallow copy constructor
3750 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3752 return new MEDFileField1TS(other,deepCpy);
3755 MEDFileField1TS *MEDFileField1TS::New()
3757 return new MEDFileField1TS;
3760 std::string MEDFileField1TS::simpleRepr() const
3762 std::ostringstream oss;
3763 _content->simpleRepr(0,oss,-1);
3764 MEDFileFieldGlobsReal::simpleRepr(oss);
3768 void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
3770 int nbComp=getNumberOfComponents();
3771 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3772 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3773 for(int i=0;i<nbComp;i++)
3775 std::string info=getInfo()[i];
3777 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
3778 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
3779 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
3781 if(getName().empty())
3782 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
3783 MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
3784 writeGlobals(fid,*this);
3785 _content->writeLL(fid,*this);
3788 void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
3790 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
3791 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
3795 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3796 try:MEDFileFieldGlobsReal(fileName),_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,iteration,order,std::vector<std::string>()))
3798 MEDFileUtilities::CheckFileForRead(fileName);
3799 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
3800 int nbFields=MEDnField(fid);
3801 med_field_type typcha;
3803 std::vector<std::string> fns(nbFields);
3805 for(int i=0;i<nbFields && !found;i++)
3807 int ncomp=MEDfieldnComponent(fid,i+1);
3808 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3809 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3810 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
3811 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3812 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3815 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
3816 std::string tmp(nomcha);
3818 found=(tmp==fieldName);
3822 std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
3823 std::vector<std::string> infos(ncomp);
3824 for(int j=0;j<ncomp;j++)
3825 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
3826 _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
3831 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
3832 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
3833 throw INTERP_KERNEL::Exception(oss.str().c_str());
3836 std::vector< std::pair<int,int> > dtits(nbOfStep2);
3837 for(int i=0;i<nbOfStep2 && !found;i++)
3839 med_int numdt,numit;
3841 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
3842 if(numdt==iteration && numit==order)
3845 _content->_csit=i+1;
3846 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
3849 dtits[i]=std::pair<int,int>(numdt,numit);
3853 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
3854 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
3855 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
3856 throw INTERP_KERNEL::Exception(oss.str().c_str());
3858 _content->finishLoading(fid);
3862 catch(INTERP_KERNEL::Exception& e)
3868 * \warning this is a shallow copy constructor
3870 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool deepCpy)
3874 const MEDFileField1TSWithoutSDA *otherPtr(&other);
3875 otherPtr->incrRef();
3876 _content=const_cast<MEDFileField1TSWithoutSDA *>(otherPtr);
3880 _content=new MEDFileField1TSWithoutSDA(other);
3884 MEDFileField1TS::MEDFileField1TS():_content(new MEDFileField1TSWithoutSDA)
3889 * This method returns all profiles whose name is non empty used.
3890 * \b WARNING If profile is used several times it will be reported \b only \b once.
3891 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
3893 std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
3895 return _content->getPflsReallyUsed2();
3899 * This method returns all localizations whose name is non empty used.
3900 * \b WARNING If localization is used several times it will be reported \b only \b once.
3902 std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
3904 return _content->getLocsReallyUsed2();
3908 * This method returns all profiles whose name is non empty used.
3909 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
3911 std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
3913 return _content->getPflsReallyUsedMulti2();
3917 * This method returns all localizations whose name is non empty used.
3918 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
3920 std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
3922 return _content->getLocsReallyUsedMulti2();
3925 void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3927 _content->changePflsRefsNamesGen2(mapOfModif);
3930 void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3932 _content->changeLocsRefsNamesGen2(mapOfModif);
3936 * 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
3937 * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead.
3938 * \b WARNING ! Parameter 'meshDimRelToMax' is relative from read mesh in file that can be different from the field in MED file !
3939 * It leads that the returned field of this method is always coherent.
3941 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3943 if(getFileName2().empty())
3944 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3945 return _content->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
3949 * This method is close to MEDFileField1TS::getFieldAtLevel except that here the 'meshDimRelToMax' param is ignored and the maximal dimension is taken
3950 * automatically. If the field lies on different level and that an another level than the maximal is requested MEDFileField1TS::getFieldAtLevel
3951 * should be called instead.
3953 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
3955 if(getFileName2().empty())
3956 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
3957 return _content->getFieldAtTopLevel(type,0,renumPol,this);
3961 * \b WARNING, there is a main difference with the two close methods (MEDFileField1TS::getFieldAtLevel and MEDFileField1TS::getFieldOnMeshAtLevel method) !
3962 * Here the mesh-dimension of 'mesh' is used by this to automatically request the right geoTypes regarding 'type'.
3963 * If no such element fufilled the deduced dimension and 'type' an exception will be thrown.
3964 * It leads that the returned field of this method is always coherent.
3966 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3968 return _content->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
3972 * This method can be called whatever the mode of instance feeding of this (MED file or from scratch).
3973 * 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' !
3974 * It leads that the returned field of this method is always coherent.
3976 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
3978 return _content->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
3982 * This method is identical to MEDFileField1TS::getFieldAtLevel method except that meshName 'mname' should be specified.
3983 * 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.
3984 * See MEDFileField1TS::getFieldAtLevel for more information.
3986 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
3988 if(getFileName2().empty())
3989 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
3990 return _content->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
3993 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
3995 return _content->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
3999 * SBT means Sort By Type.
4000 * 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.
4003 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4006 _content->setFieldNoProfileSBT(field,*this);
4010 * This method is a generalization of MEDFileField1TS::setFieldNoProfileSBT method. Here a profile array is given in input.
4011 * The support of field 'field' is \b not used by this method, so it can be null or incoherent with field.
4012 * 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,
4013 * an exception will be thrown.
4014 * 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'.
4015 * In this case, if this profile name is empty an exception will be thrown.
4017 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
4020 _content->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
4024 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4025 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4026 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4027 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4028 * to keep a valid instance.
4029 * 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.
4030 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
4031 * 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.
4033 * \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.
4034 * \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.
4035 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4036 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4037 * \param [in] newLocName is the new localization name.
4038 * \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.
4039 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
4041 void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4043 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4044 std::string oldPflName=disc->getProfile();
4045 std::vector<std::string> vv=getPflsReallyUsedMulti();
4046 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
4047 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
4049 disc->setProfile(newPflName);
4050 DataArrayInt *pfl=getProfile(oldPflName.c_str());
4051 pfl->setName(newPflName);
4055 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
4056 throw INTERP_KERNEL::Exception(oss.str().c_str());
4061 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4062 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4063 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4064 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4065 * to keep a valid instance.
4066 * 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.
4067 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
4068 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
4069 * 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.
4071 * \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.
4072 * \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.
4073 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4074 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4075 * \param [in] newLocName is the new localization name.
4076 * \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.
4077 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
4079 void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4081 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4082 std::string oldLocName=disc->getLocalization();
4083 std::vector<std::string> vv=getLocsReallyUsedMulti();
4084 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
4085 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
4087 disc->setLocalization(newLocName);
4088 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
4089 loc.setName(newLocName);
4093 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
4094 throw INTERP_KERNEL::Exception(oss.str().c_str());
4098 int MEDFileField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4100 return _content->copyTinyInfoFrom(field);
4103 int MEDFileField1TS::getDimension() const
4105 return _content->getDimension();
4108 int MEDFileField1TS::getIteration() const
4110 return _content->getIteration();
4113 int MEDFileField1TS::getOrder() const
4115 return _content->getOrder();
4118 double MEDFileField1TS::getTime(int& iteration, int& order) const
4120 return _content->getTime(iteration,order);
4123 void MEDFileField1TS::setTime(int iteration, int order, double val)
4125 _content->setTime(iteration,order,val);
4128 std::string MEDFileField1TS::getName() const
4130 return _content->getName();
4133 void MEDFileField1TS::setName(const char *name)
4135 _content->setName(name);
4138 void MEDFileField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4140 _content->simpleRepr(bkOffset,oss,f1tsId);
4143 const std::string& MEDFileField1TS::getDtUnit() const
4145 return _content->getDtUnit();
4148 std::string MEDFileField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
4150 return _content->getMeshName();
4153 void MEDFileField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4155 _content->setMeshName(newMeshName);
4158 bool MEDFileField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4160 return _content->changeMeshNames(modifTab);
4163 int MEDFileField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
4165 return _content->getMeshIteration();
4168 int MEDFileField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
4170 return _content->getMeshOrder();
4173 int MEDFileField1TS::getNumberOfComponents() const
4175 return _content->getNumberOfComponents();
4178 bool MEDFileField1TS::isDealingTS(int iteration, int order) const
4180 return _content->isDealingTS(iteration,order);
4183 std::pair<int,int> MEDFileField1TS::getDtIt() const
4185 return _content->getDtIt();
4188 void MEDFileField1TS::fillIteration(std::pair<int,int>& p) const
4190 _content->fillIteration(p);
4192 void MEDFileField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
4194 _content->fillTypesOfFieldAvailable(types);
4197 const std::vector<std::string>& MEDFileField1TS::getInfo() const
4199 return _content->getInfo();
4201 std::vector<std::string>& MEDFileField1TS::getInfo()
4203 return _content->getInfo();
4206 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4208 return _content->getUndergroundDataArray();
4211 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4213 return _content->getUndergroundDataArrayExt(entries);
4216 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
4218 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4221 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
4223 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4226 int MEDFileField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4228 return _content->getNonEmptyLevels(mname,levs);
4231 std::vector<TypeOfField> MEDFileField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4233 return _content->getTypesOfFieldAvailable();
4236 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,
4237 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4239 return _content->getFieldSplitedByType(mname,types,typesF,pfls,locs);
4241 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
4242 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4244 return _content->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4247 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)
4249 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,id,ft,infos,nbOfStep);
4252 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA():_field_type(-1)
4256 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):_name(fieldName),_field_type(-1)
4261 * \param [in] fieldId field id in C mode
4263 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
4266 med_field_type typcha;
4268 int ncomp=MEDfieldnComponent(fid,fieldId+1);
4269 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4270 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4271 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4272 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4273 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4276 MEDfieldInfo(fid,fieldId+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4277 _name=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
4278 _field_type=MEDFileUtilities::TraduceFieldType(typcha);
4279 _infos.resize(ncomp);
4280 for(int j=0;j<ncomp;j++)
4281 _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
4283 finishLoading(fid,nbOfStep);
4285 catch(INTERP_KERNEL::Exception& e)
4290 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
4291 try:_name(fieldName),_infos(infos),_field_type(ft)
4293 finishLoading(fid,nbOfStep);
4295 catch(INTERP_KERNEL::Exception& e)
4300 const std::vector<std::string>& MEDFileFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
4302 if(_time_steps.empty())
4303 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getInfos : not time steps !");
4304 return _time_steps[0]->getInfo();
4308 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
4310 DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4312 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
4316 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
4318 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)
4320 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
4323 std::string MEDFileFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
4325 if(_time_steps.empty())
4326 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4327 return _time_steps[0]->getMeshName();
4330 void MEDFileFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4332 std::string oldName(getMeshName());
4333 std::vector< std::pair<std::string,std::string> > v(1);
4334 v[0].first=oldName; v[0].second=newMeshName;
4338 bool MEDFileFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4341 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4343 MEDFileField1TSWithoutSDA *cur(*it);
4345 ret=cur->changeMeshNames(modifTab) || ret;
4350 bool MEDFileFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4351 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4354 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4356 MEDFileField1TSWithoutSDA *f1ts(*it);
4358 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4363 void MEDFileFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4365 if(_time_steps.empty())
4367 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4368 obj->setFieldNoProfileSBT(field,glob);
4369 copyTinyInfoFrom(field);
4370 _time_steps.push_back(obj);
4374 checkCoherencyOfTinyInfo(field);
4375 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4376 obj->setFieldNoProfileSBT(field,glob);
4377 _time_steps.push_back(obj);
4381 void MEDFileFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4383 if(_time_steps.empty())
4385 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4386 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4387 copyTinyInfoFrom(field);
4388 _time_steps.push_back(obj);
4392 checkCoherencyOfTinyInfo(field);
4393 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4394 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4395 _time_steps.push_back(obj);
4399 std::string MEDFileFieldMultiTSWithoutSDA::getDtUnit() const throw(INTERP_KERNEL::Exception)
4401 if(_time_steps.empty())
4402 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4403 return _time_steps[0]->getDtUnit();
4406 std::string MEDFileFieldMultiTSWithoutSDA::getName() const
4411 void MEDFileFieldMultiTSWithoutSDA::setName(const char *name)
4416 void MEDFileFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
4418 std::string startLine(bkOffset,' ');
4419 oss << startLine << "Field multi time steps";
4421 oss << " (" << fmtsId << ")";
4422 oss << " has the following name: \"" << _name << "\"." << std::endl;
4423 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
4424 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
4426 oss << startLine << " - \"" << *it << "\"" << std::endl;
4429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
4431 std::string chapter(17,'0'+i);
4432 oss << startLine << chapter << std::endl;
4433 const MEDFileField1TSWithoutSDA *cur=(*it);
4435 cur->simpleRepr(bkOffset+2,oss,i);
4437 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
4438 oss << startLine << chapter << std::endl;
4442 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
4444 std::size_t sz=_time_steps.size();
4445 std::vector< std::pair<int,int> > ret(sz);
4447 for(std::size_t i=0;i<sz;i++)
4449 const MEDFileField1TSWithoutSDA *f1ts=_time_steps[i];
4452 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
4456 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
4457 throw INTERP_KERNEL::Exception(oss.str().c_str());
4463 void MEDFileFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
4465 _time_steps.resize(nbPdt);
4466 for(int i=0;i<nbPdt;i++)
4468 std::vector< std::pair<int,int> > ts;
4469 med_int numdt=0,numo=0;
4470 med_int meshIt=0,meshOrder=0;
4472 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
4473 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
4474 _time_steps[i]->finishLoading(fid);
4478 void MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4480 _name=field->getName();
4482 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4483 const DataArrayDouble *arr=field->getArray();
4485 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
4486 _infos=arr->getInfoOnComponents();
4489 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
4491 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
4492 if(_name!=field->getName())
4494 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
4495 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
4496 throw INTERP_KERNEL::Exception(oss.str().c_str());
4498 const DataArrayDouble *arr=field->getArray();
4500 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
4501 if(_infos!=arr->getInfoOnComponents())
4503 std::ostringstream oss; oss << MSG << "components ! should be \"";
4504 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
4505 oss << " But compo in input fields are : ";
4506 std::vector<std::string> tmp=arr->getInfoOnComponents();
4507 std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
4509 throw INTERP_KERNEL::Exception(oss.str().c_str());
4513 void MEDFileFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
4515 if(_time_steps.empty())
4516 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
4517 std::vector<std::string> infos(getInfo());
4518 int nbComp=infos.size();
4519 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4520 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4521 for(int i=0;i<nbComp;i++)
4523 std::string info=infos[i];
4525 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
4526 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4527 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4530 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
4531 MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
4532 int nbOfTS=_time_steps.size();
4533 for(int i=0;i<nbOfTS;i++)
4534 _time_steps[i]->writeLL(fid,opts);
4537 int MEDFileFieldMultiTSWithoutSDA::getNumberOfTS() const
4539 return _time_steps.size();
4542 void MEDFileFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
4544 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4545 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4547 const MEDFileField1TSWithoutSDA *tmp=(*it);
4549 newTS.push_back(*it);
4554 void MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
4556 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4557 int maxId=(int)_time_steps.size();
4559 std::set<int> idsToDel;
4560 for(const int *id=startIds;id!=endIds;id++,ii++)
4562 if(*id>=0 && *id<maxId)
4564 idsToDel.insert(*id);
4568 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
4569 throw INTERP_KERNEL::Exception(oss.str().c_str());
4572 for(int iii=0;iii<maxId;iii++)
4573 if(idsToDel.find(iii)==idsToDel.end())
4574 newTS.push_back(_time_steps[iii]);
4578 int MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4581 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
4582 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4584 const MEDFileField1TSWithoutSDA *tmp(*it);
4588 tmp->getTime(it2,ord);
4589 if(it2==iteration && order==ord)
4592 oss << "(" << it2 << "," << ord << "), ";
4595 throw INTERP_KERNEL::Exception(oss.str().c_str());
4598 int MEDFileFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4601 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
4603 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4605 const MEDFileField1TSWithoutSDA *tmp(*it);
4609 double ti=tmp->getTime(it2,ord);
4610 if(fabs(time-ti)<eps)
4616 throw INTERP_KERNEL::Exception(oss.str().c_str());
4619 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getIterations() const
4621 int lgth=_time_steps.size();
4622 std::vector< std::pair<int,int> > ret(lgth);
4623 for(int i=0;i<lgth;i++)
4624 _time_steps[i]->fillIteration(ret[i]);
4629 * 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'
4630 * This method returns two things.
4631 * - The absolute dimension of 'this' in first parameter.
4632 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
4633 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
4635 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
4636 * Only these 3 discretizations will be taken into account here.
4638 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
4639 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
4640 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
4642 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
4643 * 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'.
4645 * Let's consider the typical following case :
4646 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
4647 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
4648 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
4650 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
4652 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
4654 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
4655 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
4656 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
4657 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
4659 int MEDFileFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4661 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
4664 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4666 int lgth=_time_steps.size();
4667 std::vector< std::vector<TypeOfField> > ret(lgth);
4668 for(int i=0;i<lgth;i++)
4669 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
4674 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
4676 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)
4678 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
4682 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
4683 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
4685 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)
4687 return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4690 const MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4692 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4693 if((*it)->isDealingTS(iteration,order))
4695 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4696 std::vector< std::pair<int,int> > vp=getIterations();
4697 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4698 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4699 throw INTERP_KERNEL::Exception(oss.str().c_str());
4702 MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
4704 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4705 if((*it)->isDealingTS(iteration,order))
4707 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4708 std::vector< std::pair<int,int> > vp=getIterations();
4709 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4710 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4711 throw INTERP_KERNEL::Exception(oss.str().c_str());
4714 const MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
4716 if(pos<0 || pos>=(int)_time_steps.size())
4718 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4719 throw INTERP_KERNEL::Exception(oss.str().c_str());
4721 const MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4724 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4725 oss << "\nTry to use following method eraseEmptyTS !";
4726 throw INTERP_KERNEL::Exception(oss.str().c_str());
4731 MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
4733 if(pos<0 || pos>=(int)_time_steps.size())
4735 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4736 throw INTERP_KERNEL::Exception(oss.str().c_str());
4738 MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4741 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
4742 oss << "\nTry to use following method eraseEmptyTS !";
4743 throw INTERP_KERNEL::Exception(oss.str().c_str());
4748 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
4750 std::vector<std::string> ret;
4751 std::set<std::string> ret2;
4752 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4754 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
4755 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4756 if(ret2.find(*it2)==ret2.end())
4758 ret.push_back(*it2);
4765 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
4767 std::vector<std::string> ret;
4768 std::set<std::string> ret2;
4769 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4771 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
4772 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4773 if(ret2.find(*it2)==ret2.end())
4775 ret.push_back(*it2);
4782 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
4784 std::vector<std::string> ret;
4785 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4787 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
4788 ret.insert(ret.end(),tmp.begin(),tmp.end());
4793 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
4795 std::vector<std::string> ret;
4796 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4798 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
4799 ret.insert(ret.end(),tmp.begin(),tmp.end());
4804 void MEDFileFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4806 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4807 (*it)->changePflsRefsNamesGen2(mapOfModif);
4810 void MEDFileFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4812 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4813 (*it)->changeLocsRefsNamesGen2(mapOfModif);
4816 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
4818 return new MEDFileFieldMultiTS;
4821 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4823 return new MEDFileFieldMultiTS(fileName);
4826 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4828 return new MEDFileFieldMultiTS(fileName,fieldName);
4831 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
4833 return new MEDFileFieldMultiTS(other,deepCpy);
4836 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
4838 const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
4839 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item,false);
4840 ret->shallowCpyGlobs(*this);
4845 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4847 int pos=getPosOfTimeStep(iteration,order);
4848 return getTimeStepAtPos(pos);
4851 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4853 int pos=getPosGivenTime(time,eps);
4854 return getTimeStepAtPos(pos);
4857 MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
4859 return new MEDFileFieldMultiTSIterator(this);
4862 std::string MEDFileFieldMultiTS::simpleRepr() const
4864 std::ostringstream oss;
4865 _content->simpleRepr(0,oss,-1);
4866 MEDFileFieldGlobsReal::simpleRepr(oss);
4870 void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
4872 writeGlobals(fid,*this);
4873 _content->writeLL(fid,*this);
4876 void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
4878 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
4879 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
4884 * Performs the job than MEDFileField1TS::getFieldAtLevel except that (iteration,order) couple should be specified !
4885 * If such couple does not exist an exception is thrown.
4887 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4889 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4890 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
4893 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
4895 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4896 return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
4900 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4901 * If such couple does not exist an exception is thrown.
4903 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4905 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4906 return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
4910 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
4911 * If such couple does not exist an exception is thrown.
4913 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4915 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4916 return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
4920 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
4921 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
4922 * This method is useful for MED2 file format when field on different mesh was autorized.
4924 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4926 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4927 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
4930 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
4932 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
4933 return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
4936 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4938 _content->appendFieldNoProfileSBT(field,*this);
4941 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
4943 _content->appendFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
4946 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> MEDFileFieldMultiTS::getContent()
4951 MEDFileFieldMultiTS::MEDFileFieldMultiTS():_content(new MEDFileFieldMultiTSWithoutSDA)
4957 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
4958 try:MEDFileFieldGlobsReal(fileName)
4960 MEDFileUtilities::CheckFileForRead(fileName);
4961 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4962 int nbFields=MEDnField(fid);
4965 std::ostringstream oss; oss << "MEDFileFieldMultiTS(const char *fileName) constructor : no fields in file \"" << fileName << "\" !";
4966 throw INTERP_KERNEL::Exception(oss.str().c_str());
4968 _content=new MEDFileFieldMultiTSWithoutSDA(fid,0);
4972 catch(INTERP_KERNEL::Exception& e)
4977 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4978 try:MEDFileFieldGlobsReal(fileName)
4980 MEDFileUtilities::CheckFileForRead(fileName);
4981 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4982 int nbFields=MEDnField(fid);
4983 med_field_type typcha;
4985 std::vector<std::string> fns(nbFields);
4986 for(int i=0;i<nbFields && !found;i++)
4988 int ncomp=MEDfieldnComponent(fid,i+1);
4989 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4990 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4991 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4992 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4993 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4996 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4997 std::string tmp(nomcha);
4999 found=(tmp==fieldName);
5001 _content=new MEDFileFieldMultiTSWithoutSDA(fid,i);
5005 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5006 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
5007 throw INTERP_KERNEL::Exception(oss.str().c_str());
5012 catch(INTERP_KERNEL::Exception& e)
5017 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy)
5021 const MEDFileFieldMultiTSWithoutSDA *otherPtr(&other);
5022 otherPtr->incrRef();
5023 _content=const_cast<MEDFileFieldMultiTSWithoutSDA *>(otherPtr);
5027 _content=new MEDFileFieldMultiTSWithoutSDA(other);
5031 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
5033 return _content->getPflsReallyUsed2();
5036 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
5038 return _content->getLocsReallyUsed2();
5041 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
5043 return _content->getPflsReallyUsedMulti2();
5046 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
5048 return _content->getLocsReallyUsedMulti2();
5051 void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5053 _content->changePflsRefsNamesGen2(mapOfModif);
5056 void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5058 _content->changeLocsRefsNamesGen2(mapOfModif);
5061 int MEDFileFieldMultiTS::getNumberOfTS() const
5063 return _content->getNumberOfTS();
5066 void MEDFileFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
5068 _content->eraseEmptyTS();
5071 void MEDFileFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
5073 _content->eraseTimeStepIds(startIds,endIds);
5076 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getIterations() const
5078 return _content->getIterations();
5081 int MEDFileFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5083 return _content->getPosOfTimeStep(iteration,order);
5086 int MEDFileFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
5088 return _content->getPosGivenTime(time,eps);
5091 int MEDFileFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5093 return _content->getNonEmptyLevels(iteration,order,mname,levs);
5096 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5098 return _content->getTypesOfFieldAvailable();
5101 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)
5103 return _content->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
5106 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)
5108 return _content->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
5111 std::string MEDFileFieldMultiTS::getName() const
5113 return _content->getName();
5116 void MEDFileFieldMultiTS::setName(const char *name)
5118 _content->setName(name);
5121 void MEDFileFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
5123 _content->simpleRepr(bkOffset,oss,fmtsId);
5126 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
5128 return _content->getTimeSteps(ret1);
5131 std::string MEDFileFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
5133 return _content->getMeshName();
5136 void MEDFileFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5138 _content->setMeshName(newMeshName);
5141 bool MEDFileFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5143 return _content->changeMeshNames(modifTab);
5146 const std::vector<std::string>& MEDFileFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
5148 return _content->getInfo();
5151 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5153 return _content->getUndergroundDataArray(iteration,order);
5156 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)
5158 return _content->getUndergroundDataArrayExt(iteration,order,entries);
5161 MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
5166 _nb_iter=fmts->getNumberOfTS();
5170 MEDFileFieldMultiTSIterator::~MEDFileFieldMultiTSIterator()
5174 MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
5176 if(_iter_id<_nb_iter)
5178 MEDFileFieldMultiTS *fmts(_fmts);
5180 return fmts->getTimeStepAtPos(_iter_id++);
5188 MEDFileFields *MEDFileFields::New()
5190 return new MEDFileFields;
5193 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5195 return new MEDFileFields(fileName);
5198 int MEDFileFields::getNumberOfFields() const
5200 return _fields.size();
5203 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
5205 std::vector<std::string> ret(_fields.size());
5207 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5209 const MEDFileFieldMultiTSWithoutSDA *f=(*it);
5212 ret[i]=f->getName();
5216 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
5217 throw INTERP_KERNEL::Exception(oss.str().c_str());
5223 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
5225 std::vector<std::string> ret;
5226 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5228 const MEDFileFieldMultiTSWithoutSDA *cur(*it);
5230 ret.push_back(cur->getMeshName());
5235 std::string MEDFileFields::simpleRepr() const
5237 std::ostringstream oss;
5238 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
5243 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
5245 int nbOfFields=getNumberOfFields();
5246 std::string startLine(bkOffset,' ');
5247 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
5249 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5251 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5254 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
5258 oss << startLine << " - not defined !" << std::endl;
5262 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5264 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5265 std::string chapter(17,'0'+i);
5266 oss << startLine << chapter << std::endl;
5269 cur->simpleRepr(bkOffset+2,oss,i);
5273 oss << startLine << " - not defined !" << std::endl;
5275 oss << startLine << chapter << std::endl;
5277 MEDFileFieldGlobsReal::simpleRepr(oss);
5280 MEDFileFields::MEDFileFields()
5284 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
5285 try:MEDFileFieldGlobsReal(fileName)
5287 MEDFileUtilities::CheckFileForRead(fileName);
5288 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5289 int nbFields=MEDnField(fid);
5290 _fields.resize(nbFields);
5291 med_field_type typcha;
5292 for(int i=0;i<nbFields;i++)
5294 int ncomp=MEDfieldnComponent(fid,i+1);
5295 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5296 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5297 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5298 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5299 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5302 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5303 int ft=MEDFileUtilities::TraduceFieldType(typcha);
5304 std::vector<std::string> infos(ncomp);
5305 for(int j=0;j<ncomp;j++)
5306 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5307 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,nomcha,i+1,ft,infos,nbOfStep);
5309 loadAllGlobals(fid);
5311 catch(INTERP_KERNEL::Exception& e)
5316 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5319 writeGlobals(fid,*this);
5320 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5322 const MEDFileFieldMultiTSWithoutSDA *elt=*it;
5325 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
5326 throw INTERP_KERNEL::Exception(oss.str().c_str());
5328 elt->writeLL(fid,*this);
5332 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5334 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5335 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5339 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
5341 std::vector<std::string> ret;
5342 std::set<std::string> ret2;
5343 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5345 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
5346 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5347 if(ret2.find(*it2)==ret2.end())
5349 ret.push_back(*it2);
5356 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
5358 std::vector<std::string> ret;
5359 std::set<std::string> ret2;
5360 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5362 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5363 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5364 if(ret2.find(*it2)==ret2.end())
5366 ret.push_back(*it2);
5373 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
5375 std::vector<std::string> ret;
5376 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5378 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
5379 ret.insert(ret.end(),tmp.begin(),tmp.end());
5384 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
5386 std::vector<std::string> ret;
5387 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5389 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5390 ret.insert(ret.end(),tmp.begin(),tmp.end());
5395 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5397 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5398 (*it)->changePflsRefsNamesGen2(mapOfModif);
5401 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5403 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5404 (*it)->changeLocsRefsNamesGen2(mapOfModif);
5407 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
5409 _fields.resize(newSize);
5412 void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5415 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
5416 _fields.push_back(field->getContent());
5417 appendGlobs(*field,1e-12);
5420 void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5423 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
5424 if(i>=(int)_fields.size())
5425 _fields.resize(i+1);
5426 _fields[i]=field->getContent();
5427 appendGlobs(*field,1e-12);
5430 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
5432 if(i<0 || i>=(int)_fields.size())
5434 std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5435 throw INTERP_KERNEL::Exception(oss.str().c_str());
5437 _fields.erase(_fields.begin()+i);
5440 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5443 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5445 MEDFileFieldMultiTSWithoutSDA *cur(*it);
5447 ret=cur->changeMeshNames(modifTab) || ret;
5453 * \param [in] meshName the name of the mesh that will be renumbered.
5454 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
5455 * This code corresponds to the distribution of types in the corresponding mesh.
5456 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
5457 * \param [in] renumO2N the old to new renumber array.
5458 * \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
5461 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
5464 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5466 MEDFileFieldMultiTSWithoutSDA *fmts(*it);
5469 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
5475 MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
5477 if(i<0 || i>=(int)_fields.size())
5479 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5480 throw INTERP_KERNEL::Exception(oss.str().c_str());
5482 const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i];
5483 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts,false);
5484 ret->shallowCpyGlobs(*this);
5489 MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5491 return getFieldAtPos(getPosFromFieldName(fieldName));
5494 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
5496 return new MEDFileFieldsIterator(this);
5499 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5501 std::string tmp(fieldName);
5502 std::vector<std::string> poss;
5503 for(std::size_t i=0;i<_fields.size();i++)
5505 const MEDFileFieldMultiTSWithoutSDA *f=_fields[i];
5508 std::string fname(f->getName());
5512 poss.push_back(fname);
5515 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
5516 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
5518 throw INTERP_KERNEL::Exception(oss.str().c_str());
5521 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
5526 _nb_iter=fs->getNumberOfFields();
5530 MEDFileFieldsIterator::~MEDFileFieldsIterator()
5534 MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
5536 if(_iter_id<_nb_iter)
5538 MEDFileFields *fs(_fs);
5540 return fs->getFieldAtPos(_iter_id++);