1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 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 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
105 return new MEDFileFieldLoc(*this);
108 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
110 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
113 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
115 static const char OFF7[]="\n ";
116 oss << "\"" << _name << "\"" << OFF7;
117 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
118 oss << "Dimension=" << _dim << OFF7;
119 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
120 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
121 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
122 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
123 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
126 void MEDFileFieldLoc::setName(const char *name)
131 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
133 if(_name!=other._name)
137 if(_nb_gauss_pt!=other._nb_gauss_pt)
139 if(_nb_node_per_cell!=other._nb_node_per_cell)
141 if(_geo_type!=other._geo_type)
143 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
145 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
147 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
153 void MEDFileFieldLoc::writeLL(med_idt fid) const
155 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);
158 std::string MEDFileFieldLoc::repr() const
160 std::ostringstream oss; oss.precision(15);
161 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
162 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
163 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
164 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
165 oss << "\n - Ref coords are : ";
166 int sz=_ref_coo.size();
169 int nbOfTuples=sz/_dim;
170 for(int i=0;i<nbOfTuples;i++)
173 for(int j=0;j<_dim;j++)
174 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
179 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
180 oss << "\n - Gauss coords in reference element : ";
184 int nbOfTuples=sz/_dim;
185 for(int i=0;i<nbOfTuples;i++)
188 for(int j=0;j<_dim;j++)
189 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
194 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
195 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
199 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
201 _type=field->getTypeOfField();
202 const DataArrayDouble *da=field->getArray();
208 getArray()->setContigPartOfSelectedValues2(_start,da,offset,offset+nbOfCells,1);
209 _end=_start+nbOfCells;
215 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
216 const int *arrPtr=arr->getConstPointer();
217 getArray()->setContigPartOfSelectedValues2(_start,da,arrPtr[offset],arrPtr[offset+nbOfCells],1);
218 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
224 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
225 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
226 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
228 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
229 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
230 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
231 const int *dai2Ptr=dai2->getConstPointer();
232 int nbi=gsLoc.getWeights().size();
233 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
234 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
235 const int *da3Ptr=da3->getConstPointer();
236 if(da3->getNumberOfTuples()!=nbOfCells)
237 {//profile : for gauss even in NoProfile !!!
238 std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
240 da3->setName(_profile.c_str());
241 glob.appendProfile(da3);
243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
244 _nval=da3->getNbOfElems();
245 da4->alloc(_nval*nbi,1);
246 int *da4Ptr=da4->getPointer();
247 for(int i=0;i<_nval;i++)
249 int ref=dai2Ptr[offset+da3Ptr[i]];
250 for(int j=0;j<nbi;j++)
253 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
254 _localization=oss2.str();
255 getArray()->setContigPartOfSelectedValues(_start,da,da4);
256 _end=_start+_nval*nbi;
257 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
261 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
267 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
268 * \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).
269 * \param [in] multiTypePfl is the end user profile specified in high level API
270 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
271 * \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.
272 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
273 * \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.
275 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)
278 _type=field->getTypeOfField();
279 std::string pflName(multiTypePfl->getName());
280 std::ostringstream oss; oss << pflName;
281 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
285 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
286 if(_type!=ON_GAUSS_PT)
288 locIds->setName(oss.str().c_str());
289 glob.appendProfile(locIds);
293 const DataArrayDouble *da=field->getArray();
299 _nval=idsInPfl->getNumberOfTuples();
300 getArray()->setContigPartOfSelectedValues2(_start,da,0,da->getNumberOfTuples(),1);
306 _nval=idsInPfl->getNumberOfTuples();
307 getArray()->setContigPartOfSelectedValues(_start,da,idsInPfl);
313 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
314 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
316 arr3->computeOffsets2();
317 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
318 int trueNval=tmp->getNumberOfTuples();
319 _nval=idsInPfl->getNumberOfTuples();
320 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
321 _end=_start+trueNval;
326 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
328 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
329 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
330 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
331 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
335 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
336 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
338 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
340 for(const int *pt=da4->begin();pt!=da4->end();pt++)
341 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
342 tmp->alloc(trueNval,1);
343 int *tmpPtr=tmp->getPointer();
344 for(const int *pt=da4->begin();pt!=da4->end();pt++)
345 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
348 _nval=da4->getNumberOfTuples();
349 getArray()->setContigPartOfSelectedValues(_start,da,tmp);
350 _end=_start+trueNval;
351 oss << "_loc_" << _loc_id;
354 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
355 da5->setName(oss.str().c_str());
356 glob.appendProfile(da5);
361 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
363 da3->setName(oss.str().c_str());
364 glob.appendProfile(da3);
368 std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
369 _localization=oss2.str();
370 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
374 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
379 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
382 _nval=field->getArray()->getNumberOfTuples();
383 getArray()->setContigPartOfSelectedValues2(_start,field->getArray(),0,_nval,1);
388 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
390 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
393 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
395 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
398 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
400 return new MEDFileFieldPerMeshPerTypePerDisc(other);
403 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
405 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
408 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
410 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
415 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
416 try:_type(atype),_father(fath)
419 catch(INTERP_KERNEL::Exception& e)
424 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
428 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)
432 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
433 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
437 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
442 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception)
444 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
445 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446 std::string fieldName=getName();
447 std::string meshName=getMeshName();
448 int iteration=getIteration();
449 int order=getOrder();
450 TypeOfField type=getType();
451 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
453 med_geometry_type mgeoti;
454 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
455 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
456 pflname,&profilesize,locname,&nbi);
457 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
458 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
460 _end=start+_nval*nbi;
462 if(type==ON_CELLS && !_localization.empty())
464 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
465 setType(ON_GAUSS_PT);
468 setType(ON_GAUSS_NE);
469 _localization.clear();
474 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
476 std::string fieldName=getName();
477 std::string meshName=getMeshName();
478 int iteration=getIteration();
479 int order=getOrder();
480 TypeOfField type=getType();
481 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
482 med_geometry_type mgeoti;
483 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
484 DataArrayDouble *arr=getArray();
485 double *startFeeding=arr->getPointer()+_start*arr->getNumberOfComponents();
490 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
491 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
496 INTERP_KERNEL::AutoPtr<int> tmpp=new int[(_end-_start)*arr->getNumberOfComponents()];
497 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
498 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
499 std::copy((const int *)tmpp,(const int *)tmpp+(_end-_start)*arr->getNumberOfComponents(),startFeeding);
503 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
508 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
510 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
512 int delta=_end-_start;
513 _start=newValueOfStart;
517 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
519 return _father->getIteration();
522 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
524 return _father->getOrder();
527 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
529 return _father->getTime();
532 std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
534 return _father->getName();
537 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
539 return _father->getMeshName();
542 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
544 const char startLine[]=" ## ";
545 std::string startLine2(bkOffset,' ');
546 startLine2+=startLine;
547 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
548 oss << startLine2 << "Localization #" << id << "." << std::endl;
549 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
551 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
552 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
553 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
556 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
561 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
566 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
571 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
573 return _father->getGeoType();
576 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
578 return _father->getNumberOfComponents();
581 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
586 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray()
588 return _father->getArray();
591 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
593 const MEDFileFieldPerMeshPerType *fath=_father;
594 return fath->getArray();
597 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
599 return _father->getInfo();
602 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
607 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
612 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
614 return _localization;
617 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
619 _localization=newLocName;
622 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
624 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
626 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
628 _profile=(*it2).second;
634 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
636 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
638 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
640 _localization=(*it2).second;
646 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
650 dads.push_back(std::pair<int,int>(_start,_end));
651 geoTypes.push_back(getGeoType());
656 pfls.push_back(glob->getProfile(_profile.c_str()));
658 if(_localization.empty())
662 locs.push_back(glob->getLocalizationId(_localization.c_str()));
666 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
668 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));
672 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
674 TypeOfField type=getType();
675 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
676 med_geometry_type mgeoti;
677 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
678 const DataArrayDouble *arr=getArray();
679 const double *locToWrite=arr->getConstPointer()+_start*arr->getNumberOfComponents();
680 MEDfieldValueWithProfileWr(fid,getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
681 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
682 reinterpret_cast<const unsigned char*>(locToWrite));
685 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
690 dad.first=_start; dad.second=_end;
694 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
695 * This code corresponds to the distribution of types in the corresponding mesh.
696 * \param [out] ptToFill memory zone where the output will be stored.
697 * \return the size of data pushed into output param \a ptToFill
699 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
702 std::ostringstream oss;
703 std::size_t nbOfType=codeOfMesh.size()/3;
705 for(std::size_t i=0;i<nbOfType && found==-1;i++)
706 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
710 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
711 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
712 throw INTERP_KERNEL::Exception(oss.str().c_str());
717 if(_nval!=codeOfMesh[3*found+1])
719 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
720 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
721 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
722 throw INTERP_KERNEL::Exception(oss.str().c_str());
724 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
729 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
730 if(pfl->getNumberOfTuples()!=_nval)
732 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
733 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
735 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
736 throw INTERP_KERNEL::Exception(oss.str().c_str());
738 int offset2=codeOfMesh[3*found+2];
739 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
741 if(*pflId<codeOfMesh[3*found+1])
742 *work++=offset2+*pflId;
748 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
750 for(int i=_start;i<_end;i++)
755 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
766 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
770 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
773 std::map<std::pair<std::string,TypeOfField>,int> m;
774 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
775 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
776 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
777 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
779 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
780 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
785 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
787 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
788 * \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.
789 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
790 * \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)
791 * \param [in,out] glob if necessary by the method, new profiles can be added to it
792 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
793 * \param [out] result All new entries will be appended on it.
794 * \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 !)
796 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
797 const DataArrayInt *explicitIdsInMesh,
798 const std::vector<int>& newCode,
799 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
800 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
802 if(entriesOnSameDisc.empty())
804 TypeOfField type=entriesOnSameDisc[0]->getType();
805 int szEntities=0,szTuples=0;
806 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
807 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
808 int nbi=szTuples/szEntities;
809 if(szTuples%szEntities!=0)
810 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
811 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
812 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
813 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
814 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
815 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
816 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
817 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
819 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
821 int startOfEltIdOfChunk=(*it)->_start;
822 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
823 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
824 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
827 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
829 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
830 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
832 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
833 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
834 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
835 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
839 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
840 arrPart->renumberInPlace(renumTupleIds->begin());
841 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
843 const int *idIt=diffVals->begin();
844 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
846 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
850 int nbEntityElts=subIds->getNumberOfTuples();
852 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
853 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
857 result.push_back(eltToAdd);
858 offset2+=nbEntityElts*nbi;
860 ret=ret || li.empty();
865 * \param [in] typeF type of field of new chunk
866 * \param [in] geoType the geometric type of the chunk
867 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
868 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
869 * \param [in] nbi number of integration points
870 * \param [in] offset The offset in the **global array of data**.
871 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
872 * to the new chunk to create.
873 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
874 * \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
875 * and corresponding entry erased from \a entriesOnSameDisc.
876 * \return a newly allocated chunk
878 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
879 bool isPfl, int nbi, int offset,
880 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
881 MEDFileFieldGlobsReal& glob,
882 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
884 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
885 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
886 for(;it!=entriesOnSameDisc.end();it++)
888 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
892 if((*it)->_profile.empty())
895 if(!(*it)->_profile.empty())
897 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
898 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
904 if(it==entriesOnSameDisc.end())
907 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
909 ret->_loc_id=(int)geoType;
910 ret->_nval=nbMeshEntities;
912 ret->_end=ret->_start+ret->_nval*nbi;
915 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
916 glob.appendProfile(idsOfMeshElt);
917 ret->_profile=idsOfMeshElt->getName();
919 //tony treatment of localization
925 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
926 ret->_loc_id=(int)geoType;
927 ret->setNewStart(offset);
928 entriesOnSameDisc.erase(it);
934 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
936 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType);
939 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
941 return new MEDFileFieldPerMeshPerType(fath,geoType);
944 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
946 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
947 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
948 ret+=(*it)->getHeapMemorySize();
952 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
954 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
957 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
959 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
960 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
965 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
967 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
968 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
969 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
973 * This method is the most general one. No optimization is done here.
974 * \param [in] multiTypePfl is the end user profile specified in high level API
975 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
976 * \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.
977 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
978 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
979 * \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.
981 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)
983 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
984 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
985 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,mesh,glob);
988 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
990 _field_pm_pt_pd.resize(1);
991 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
992 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,glob);
995 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
997 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
999 _field_pm_pt_pd.resize(1);
1000 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1001 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,0,glob);//mesh is not requested so 0 is send.
1004 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1006 TypeOfField type=field->getTypeOfField();
1007 if(type!=ON_GAUSS_PT)
1009 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1010 int sz=_field_pm_pt_pd.size();
1012 for(int j=0;j<sz && !found;j++)
1014 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1016 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1022 _field_pm_pt_pd.resize(sz+1);
1023 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1025 std::vector<int> ret(1,0);
1030 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1031 int sz2=ret2.size();
1032 std::vector<int> ret3(sz2);
1034 for(int i=0;i<sz2;i++)
1036 int sz=_field_pm_pt_pd.size();
1037 int locIdToFind=ret2[i];
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);
1050 _field_pm_pt_pd.resize(sz+1);
1051 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1059 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1061 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1062 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1064 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1065 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1067 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1068 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1069 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1070 if(retTmp->presenceOfValue(-1))
1071 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1072 std::vector<int> ret(retTmp->begin(),retTmp->end());
1076 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1078 TypeOfField type=field->getTypeOfField();
1079 if(type!=ON_GAUSS_PT)
1081 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1082 int sz=_field_pm_pt_pd.size();
1084 for(int j=0;j<sz && !found;j++)
1086 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1088 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1094 _field_pm_pt_pd.resize(sz+1);
1095 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1097 std::vector<int> ret(1,0);
1102 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1103 int sz2=ret2.size();
1104 std::vector<int> ret3(sz2);
1106 for(int i=0;i<sz2;i++)
1108 int sz=_field_pm_pt_pd.size();
1109 int locIdToFind=ret2[i];
1111 for(int j=0;j<sz && !found;j++)
1113 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1115 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1122 _field_pm_pt_pd.resize(sz+1);
1123 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1131 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1133 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1134 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1136 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1137 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1139 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1140 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1141 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1142 if(retTmp->presenceOfValue(-1))
1143 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1144 std::vector<int> ret(retTmp->begin(),retTmp->end());
1148 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1153 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1155 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1156 int curDim=(int)cm.getDimension();
1157 dim=std::max(dim,curDim);
1160 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1162 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1164 (*it)->fillTypesOfFieldAvailable(types);
1168 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)
1170 int sz=_field_pm_pt_pd.size();
1171 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1172 for(int i=0;i<sz;i++)
1174 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1178 int MEDFileFieldPerMeshPerType::getIteration() const
1180 return _father->getIteration();
1183 int MEDFileFieldPerMeshPerType::getOrder() const
1185 return _father->getOrder();
1188 double MEDFileFieldPerMeshPerType::getTime() const
1190 return _father->getTime();
1193 std::string MEDFileFieldPerMeshPerType::getName() const
1195 return _father->getName();
1198 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1200 return _father->getMeshName();
1203 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1205 const char startLine[]=" ## ";
1206 std::string startLine2(bkOffset,' ');
1207 std::string startLine3(startLine2);
1208 startLine3+=startLine;
1209 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1211 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1212 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1215 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1216 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1218 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1220 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1222 cur->simpleRepr(bkOffset,oss,i);
1225 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1230 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1232 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1234 globalSz+=(*it)->getNumberOfTuples();
1236 nbOfEntries+=(int)_field_pm_pt_pd.size();
1239 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1245 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1247 return _father->getNumberOfComponents();
1250 DataArrayDouble *MEDFileFieldPerMeshPerType::getArray()
1252 return _father->getArray();
1255 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArray() const
1257 const MEDFileFieldPerMesh *fath=_father;
1258 return fath->getArray();
1261 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1263 return _father->getInfo();
1266 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1268 std::vector<std::string> ret;
1269 std::set<std::string> ret2;
1270 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1272 std::string tmp=(*it1)->getProfile();
1274 if(ret2.find(tmp)==ret2.end())
1283 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1285 std::vector<std::string> ret;
1286 std::set<std::string> ret2;
1287 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1289 std::string tmp=(*it1)->getLocalization();
1290 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1291 if(ret2.find(tmp)==ret2.end())
1300 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1302 std::vector<std::string> ret;
1303 std::set<std::string> ret2;
1304 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1306 std::string tmp=(*it1)->getProfile();
1313 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1315 std::vector<std::string> ret;
1316 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1318 std::string tmp=(*it1)->getLocalization();
1319 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1325 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1328 (*it1)->changePflsRefsNamesGen(mapOfModif);
1331 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1333 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1334 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1337 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1339 if(_field_pm_pt_pd.empty())
1341 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1342 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1343 throw INTERP_KERNEL::Exception(oss.str().c_str());
1345 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1346 return _field_pm_pt_pd[locId];
1347 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1348 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1349 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1350 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1351 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1354 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1356 if(_field_pm_pt_pd.empty())
1358 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1359 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1360 throw INTERP_KERNEL::Exception(oss.str().c_str());
1362 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1363 return _field_pm_pt_pd[locId];
1364 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1365 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1366 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1367 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1368 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1371 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
1373 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1375 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1376 if(meshDim!=(int)cm.getDimension())
1379 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1380 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1383 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1386 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1388 (*it)->fillValues(i,startEntryId,entries);
1392 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1394 _field_pm_pt_pd=leaves;
1395 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1396 (*it)->setFather(this);
1399 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1403 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1405 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1406 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1407 med_geometry_type mgeoti;
1408 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1409 int nbProfiles=MEDfieldnProfile(fid,getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1410 _field_pm_pt_pd.resize(nbProfiles);
1411 for(int i=0;i<nbProfiles;i++)
1413 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1417 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception)
1420 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1422 (*it)->prepareLoading(fid,pflId+1,start);
1426 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1431 (*it)->finishLoading(fid,pflId+1,ft);
1435 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1437 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1439 (*it)->copyOptionsFrom(*this);
1440 (*it)->writeLL(fid);
1444 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1449 medfGeoType=typmai3[(int)ikGeoType];
1452 medfGeoType=MED_NONE;
1455 medfGeoType=typmai3[(int)ikGeoType];
1456 return MED_NODE_ELEMENT;
1458 medfGeoType=typmai3[(int)ikGeoType];
1461 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1463 return MED_UNDEF_ENTITY_TYPE;
1466 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception)
1468 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder);
1471 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1473 return new MEDFileFieldPerMesh(fath,mesh);
1476 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1478 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1479 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1480 if((const MEDFileFieldPerMeshPerType *)*it)
1481 ret+=(*it)->getHeapMemorySize();
1485 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1487 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1488 ret->_father=father;
1490 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1492 if((const MEDFileFieldPerMeshPerType *)*it)
1493 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1498 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1500 std::string startLine(bkOffset,' ');
1501 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1502 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1504 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1506 const MEDFileFieldPerMeshPerType *cur=*it;
1508 cur->simpleRepr(bkOffset,oss,i);
1511 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1516 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1518 _mesh_name=mesh->getName();
1519 mesh->getTime(_mesh_iteration,_mesh_order);
1522 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1524 int nbOfTypes=code.size()/3;
1526 for(int i=0;i<nbOfTypes;i++)
1528 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1529 int nbOfCells=code[3*i+1];
1530 int pos=addNewEntryIfNecessary(type);
1531 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,glob);
1537 * This method is the most general one. No optimization is done here.
1538 * \param [in] multiTypePfl is the end user profile specified in high level API
1539 * \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].
1540 * \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.
1541 * \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.
1542 * \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.
1543 * \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.
1545 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)
1547 int nbOfTypes=code.size()/3;
1548 for(int i=0;i<nbOfTypes;i++)
1550 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1551 int pos=addNewEntryIfNecessary(type);
1552 DataArrayInt *pfl=0;
1554 pfl=idsPerType[code[3*i+2]];
1555 int nbOfTupes2=code2.size()/3;
1557 for(;found<nbOfTupes2;found++)
1558 if(code[3*i]==code2[3*found])
1560 if(found==nbOfTupes2)
1561 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1562 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,mesh,glob);
1566 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1568 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1569 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,glob);
1572 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1574 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1575 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,glob);
1578 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start) throw(INTERP_KERNEL::Exception)
1580 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1581 (*it)->prepareLoading(fid,start);
1584 void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
1586 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1587 (*it)->finishLoading(fid,ft);
1590 void MEDFileFieldPerMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
1592 int nbOfTypes=_field_pm_pt.size();
1593 for(int i=0;i<nbOfTypes;i++)
1595 _field_pm_pt[i]->copyOptionsFrom(*this);
1596 _field_pm_pt[i]->writeLL(fid);
1600 void MEDFileFieldPerMesh::getDimension(int& dim) const
1602 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1603 (*it)->getDimension(dim);
1606 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1608 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1609 (*it)->fillTypesOfFieldAvailable(types);
1612 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)
1614 int sz=_field_pm_pt.size();
1615 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1616 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1617 for(int i=0;i<sz;i++)
1619 types[i]=_field_pm_pt[i]->getGeoType();
1620 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1625 double MEDFileFieldPerMesh::getTime() const
1628 return _father->getTime(tmp1,tmp2);
1631 int MEDFileFieldPerMesh::getIteration() const
1633 return _father->getIteration();
1636 const std::string& MEDFileFieldPerMesh::getDtUnit() const
1638 return _father->getDtUnit();
1641 int MEDFileFieldPerMesh::getOrder() const
1643 return _father->getOrder();
1646 std::string MEDFileFieldPerMesh::getName() const
1648 return _father->getName();
1651 int MEDFileFieldPerMesh::getNumberOfComponents() const
1653 return _father->getNumberOfComponents();
1656 DataArrayDouble *MEDFileFieldPerMesh::getArray()
1658 return _father->getOrCreateAndGetArray();
1661 const DataArrayDouble *MEDFileFieldPerMesh::getArray() const
1663 const MEDFileField1TSWithoutSDA *fath=_father;
1664 return fath->getOrCreateAndGetArray();
1667 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1669 return _father->getInfo();
1673 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1674 * 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.
1675 * It returns 2 output vectors :
1676 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1677 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1678 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1680 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)
1682 int notNullPflsSz=0;
1683 int nbOfArrs=geoTypes.size();
1684 for(int i=0;i<nbOfArrs;i++)
1687 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1688 int nbOfDiffGeoTypes=geoTypes3.size();
1689 code.resize(3*nbOfDiffGeoTypes);
1690 notNullPfls.resize(notNullPflsSz);
1693 for(int i=0;i<nbOfDiffGeoTypes;i++)
1696 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1697 std::vector<const DataArrayInt *> notNullTmp;
1699 notNullTmp.push_back(pfls[j]);
1701 for(;j<nbOfArrs;j++)
1702 if(geoTypes[j]==refType)
1705 notNullTmp.push_back(pfls[j]);
1709 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1710 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1711 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1712 code[3*i]=(int)refType;
1713 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1714 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1715 if(notNullTmp.empty())
1719 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1720 code[3*i+2]=notNullPflsSz++;
1726 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1728 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)
1732 for(int i=0;i<sz;i++)
1736 if(type!=ON_GAUSS_NE)
1737 ret+=dads[i].second-dads[i].first;
1740 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1741 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1746 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1747 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1753 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1755 std::vector<std::string> ret;
1756 std::set<std::string> ret2;
1757 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1759 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1760 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1761 if(ret2.find(*it2)==ret2.end())
1763 ret.push_back(*it2);
1770 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1772 std::vector<std::string> ret;
1773 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1775 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1776 ret.insert(ret.end(),tmp.begin(),tmp.end());
1781 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1783 std::vector<std::string> ret;
1784 std::set<std::string> ret2;
1785 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1787 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1788 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1789 if(ret2.find(*it2)==ret2.end())
1791 ret.push_back(*it2);
1798 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1800 std::vector<std::string> ret;
1801 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1803 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1804 ret.insert(ret.end(),tmp.begin(),tmp.end());
1809 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1811 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1813 if((*it).first==_mesh_name)
1815 _mesh_name=(*it).second;
1822 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1823 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1825 if(_mesh_name!=meshName)
1827 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1828 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1829 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1830 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1831 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1832 DataArrayDouble *arr=getUndergroundDataArrayExt(entries);
1835 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1836 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1838 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1840 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1841 sz+=(*it).second.second-(*it).second.first;
1844 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1846 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1847 ////////////////////
1848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1849 int *workI2=explicitIdsOldInMesh->getPointer();
1850 int sz1=0,sz2=0,sid=1;
1851 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1852 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1853 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1855 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1856 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1857 int *workI=explicitIdsOldInArr->getPointer();
1858 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1860 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1861 (*itL2)->setLocId(sz2);
1862 (*itL2)->_tmp_work1=(*itL2)->getStart();
1863 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1865 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1867 explicitIdsOldInMesh->reAlloc(sz2);
1868 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1869 ////////////////////
1870 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1871 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1872 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1873 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1875 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1876 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1877 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1879 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1880 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1881 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1883 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1884 int newStart=elt->getLocId();
1885 elt->setLocId((*it)->getGeoType());
1886 elt->setNewStart(newStart);
1887 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1888 entriesKeptNew.push_back(elt);
1889 entriesKeptNew2.push_back(elt);
1891 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1892 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1893 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1894 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1896 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1899 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1901 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1902 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1904 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1905 glob,arr2,otherEntriesNew) || ret;
1909 // Assign new dispatching
1910 assignNewLeaves(otherEntriesNew);
1911 arr->cpyFrom(*arr2);
1915 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1917 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1918 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1919 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1921 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1922 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1923 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1924 for(;it1!=types.end();it1++,it2++)
1926 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1927 elt->setLeaves((*it1).second);
1930 _field_pm_pt=fieldPmPt;
1933 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1935 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1936 (*it)->changePflsRefsNamesGen(mapOfModif);
1939 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1941 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1942 (*it)->changeLocsRefsNamesGen(mapOfModif);
1946 * \param [in] mesh is the whole mesh
1948 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
1950 if(_field_pm_pt.empty())
1951 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1953 std::vector< std::pair<int,int> > dads;
1954 std::vector<const DataArrayInt *> pfls;
1955 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1956 std::vector<int> locs,code;
1957 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1959 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1961 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1964 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1965 throw INTERP_KERNEL::Exception(oss.str().c_str());
1968 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1969 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1972 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1974 return finishField(type,glob,dads,locs,mesh,isPfl);
1977 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1978 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl);
1984 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1988 if(nb!=mesh->getNumberOfNodes())
1990 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1991 oss << " nodes in mesh !";
1992 throw INTERP_KERNEL::Exception(oss.str().c_str());
1994 return finishField(type,glob,dads,locs,mesh,isPfl);
1997 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl);
2001 DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
2003 if(_field_pm_pt.empty())
2004 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2006 std::vector<std::pair<int,int> > dads;
2007 std::vector<const DataArrayInt *> pfls;
2008 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2009 std::vector<int> locs,code;
2010 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2011 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2012 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2014 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2017 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2018 throw INTERP_KERNEL::Exception(oss.str().c_str());
2020 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2021 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2024 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2025 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2030 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2034 if(nb!=mesh->getNumberOfNodes())
2036 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2037 oss << " nodes in mesh !";
2038 throw INTERP_KERNEL::Exception(oss.str().c_str());
2041 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2047 DataArrayDouble *MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2051 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2053 (*it)->getSizes(globalSz,nbOfEntries);
2055 entries.resize(nbOfEntries);
2057 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2059 (*it)->fillValues(nbOfEntries,entries);
2061 return _father->getUndergroundDataArray();
2064 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2066 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2068 if((*it)->getGeoType()==typ)
2069 return (*it)->getLeafGivenLocId(locId);
2071 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2072 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2073 oss << "Possiblities are : ";
2074 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2076 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2077 oss << "\"" << cm2.getRepr() << "\", ";
2079 throw INTERP_KERNEL::Exception(oss.str().c_str());
2082 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2084 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2086 if((*it)->getGeoType()==typ)
2087 return (*it)->getLeafGivenLocId(locId);
2089 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2090 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2091 oss << "Possiblities are : ";
2092 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2094 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2095 oss << "\"" << cm2.getRepr() << "\", ";
2097 throw INTERP_KERNEL::Exception(oss.str().c_str());
2100 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2103 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2104 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2105 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2107 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2112 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2117 int ret=std::distance(_field_pm_pt.begin(),it2);
2118 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2123 * 'dads' and 'locs' input parameters have the same number of elements
2124 * \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
2126 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2127 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2128 const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2131 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2132 ret->setMesh(mesh); ret->setName(getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(getDtUnit().c_str());
2133 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2134 const std::vector<std::string>& infos=getInfo();
2135 da->setInfoOnComponents(infos);
2138 if(type==ON_GAUSS_PT)
2141 int nbOfArrs=dads.size();
2142 for(int i=0;i<nbOfArrs;i++)
2144 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2145 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2146 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2147 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2148 di->alloc(nbOfElems,1);
2150 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2151 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2160 * 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.
2161 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2162 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2163 * The order of cells in the returned field is those imposed by the profile.
2164 * \param [in] mesh is the global mesh.
2166 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2167 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2168 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2169 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2171 if(da->isIdentity())
2173 int nbOfTuples=da->getNumberOfTuples();
2174 if(nbOfTuples==mesh->getNumberOfCells())
2175 return finishField(type,glob,dads,locs,mesh,isPfl);
2177 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2178 m2->setName(mesh->getName());
2179 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl);
2185 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2187 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2188 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2189 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
2191 if(da->isIdentity())
2193 int nbOfTuples=da->getNumberOfTuples();
2194 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2195 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2197 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2198 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2201 if(meshu->getNodalConnectivity()==0)
2203 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl);
2204 int nb=da->getNbOfElems();
2205 const int *ptr=da->getConstPointer();
2206 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2207 meshuc->allocateCells(nb);
2208 for(int i=0;i<nb;i++)
2209 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2210 meshuc->finishInsertingCells();
2211 ret->setMesh(meshuc);
2212 ret->checkCoherency();
2217 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
2219 DataArrayInt *arr2=0;
2220 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2221 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2222 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2223 int nnodes=mesh2->getNumberOfNodes();
2224 if(nnodes==(int)da->getNbOfElems())
2226 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2227 ret->getArray()->renumberInPlace(da3->getConstPointer());
2228 mesh2->setName(mesh->getName());
2229 ret->setMesh(mesh2);
2234 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2235 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2236 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2237 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2238 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2239 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2240 throw INTERP_KERNEL::Exception(oss.str().c_str());
2246 * This method is the most light method of field retrieving.
2248 DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2252 pflOut=DataArrayInt::New();
2253 pflOut->alloc(nbOfElems,1);
2258 pflOut=const_cast<DataArrayInt*>(pflIn);
2261 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2262 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=getArray()->selectByTupleRanges(dads);
2263 const std::vector<std::string>& infos=getInfo();
2264 int nbOfComp=infos.size();
2265 for(int i=0;i<nbOfComp;i++)
2266 da->setInfoOnComponent(i,infos[i].c_str());
2271 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2272 _mesh_csit(meshCsit),_father(fath)
2274 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2275 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2276 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2277 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2279 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2282 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i]));
2283 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2285 nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2288 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i]));
2289 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2292 int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2295 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR));
2296 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2300 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2302 copyTinyInfoFrom(mesh);
2305 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2307 if(id>=(int)_pfls.size())
2309 _pfls[id]=DataArrayInt::New();
2310 int lgth=MEDprofileSizeByName(fid,pflName);
2311 _pfls[id]->setName(pflName);
2312 _pfls[id]->alloc(lgth,1);
2313 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2314 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2317 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2319 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2321 MEDprofileInfo(fid,i+1,pflName,&sz);
2322 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2323 if(i>=(int)_pfls.size())
2325 _pfls[i]=DataArrayInt::New();
2326 _pfls[i]->alloc(sz,1);
2327 _pfls[i]->setName(pflCpp.c_str());
2328 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2329 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2332 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2334 int nbOfPfls=_pfls.size();
2335 for(int i=0;i<nbOfPfls;i++)
2337 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2338 cpy->applyLin(1,1,0);
2339 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2340 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2341 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2344 int nbOfLocs=_locs.size();
2345 for(int i=0;i<nbOfLocs;i++)
2346 _locs[i]->writeLL(fid);
2349 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2351 std::vector<std::string> pfls=getPfls();
2352 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2354 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2357 _pfls.push_back(*it);
2361 int id=std::distance(pfls.begin(),it2);
2362 if(!(*it)->isEqual(*_pfls[id]))
2364 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2365 throw INTERP_KERNEL::Exception(oss.str().c_str());
2369 std::vector<std::string> locs=getLocs();
2370 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2372 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2375 _locs.push_back(*it);
2379 int id=std::distance(locs.begin(),it2);
2380 if(!(*it)->isEqual(*_locs[id],eps))
2382 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2383 throw INTERP_KERNEL::Exception(oss.str().c_str());
2389 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2391 std::vector<std::string> profiles=real.getPflsReallyUsed();
2392 int sz=profiles.size();
2394 for(int i=0;i<sz;i++)
2395 loadProfileInFile(fid,i,profiles[i].c_str());
2397 std::vector<std::string> locs=real.getLocsReallyUsed();
2400 for(int i=0;i<sz;i++)
2401 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2404 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2406 int nProfil=MEDnProfile(fid);
2407 for(int i=0;i<nProfil;i++)
2408 loadProfileInFile(fid,i);
2409 int sz=MEDnLocalization(fid);
2411 for(int i=0;i<sz;i++)
2413 _locs[i]=MEDFileFieldLoc::New(fid,i);
2417 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2419 return new MEDFileFieldGlobs(fname);
2422 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2424 return new MEDFileFieldGlobs;
2427 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2429 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2430 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2431 ret+=(*it)->getHeapMemorySize();
2432 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2433 ret+=(*it)->getHeapMemorySize();
2437 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2439 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2441 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2443 if((const DataArrayInt *)*it)
2444 ret->_pfls[i]=(*it)->deepCpy();
2447 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2449 if((const MEDFileFieldLoc*)*it)
2450 ret->_locs[i]=(*it)->deepCpy();
2455 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2459 MEDFileFieldGlobs::MEDFileFieldGlobs()
2463 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2467 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2469 oss << "Profiles :\n";
2470 std::size_t n=_pfls.size();
2471 for(std::size_t i=0;i<n;i++)
2473 oss << " - #" << i << " ";
2474 const DataArrayInt *pfl=_pfls[i];
2476 oss << "\"" << pfl->getName() << "\"\n";
2481 oss << "Localizations :\n";
2482 for(std::size_t i=0;i<n;i++)
2484 oss << " - #" << i << " ";
2485 const MEDFileFieldLoc *loc=_locs[i];
2487 loc->simpleRepr(oss);
2493 void MEDFileFieldGlobs::setFileName(const char *fileName)
2495 _file_name=fileName;
2498 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2502 DataArrayInt *elt(*it);
2505 std::string name(elt->getName());
2506 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2508 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2510 elt->setName((*it2).second.c_str());
2518 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2520 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2522 MEDFileFieldLoc *elt(*it);
2525 std::string name(elt->getName());
2526 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2528 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2530 elt->setName((*it2).second.c_str());
2538 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2540 if(locId<0 || locId>=(int)_locs.size())
2541 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2542 return _locs[locId]->getNbOfGaussPtPerCell();
2545 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2547 return getLocalizationFromId(getLocalizationId(locName));
2550 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2552 if(locId<0 || locId>=(int)_locs.size())
2553 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2554 return *_locs[locId];
2557 namespace ParaMEDMEMImpl
2562 LocFinder(const char *loc):_loc(loc) { }
2563 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2571 PflFinder(const std::string& pfl):_pfl(pfl) { }
2572 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2574 const std::string& _pfl;
2578 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2580 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2583 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2584 for(it=_locs.begin();it!=_locs.end();it++)
2585 oss << "\"" << (*it)->getName() << "\", ";
2586 throw INTERP_KERNEL::Exception(oss.str().c_str());
2588 return std::distance(_locs.begin(),it);
2591 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2593 std::string pflNameCpp(pflName);
2594 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2597 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2598 for(it=_pfls.begin();it!=_pfls.end();it++)
2599 oss << "\"" << (*it)->getName() << "\", ";
2600 throw INTERP_KERNEL::Exception(oss.str().c_str());
2605 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2607 if(pflId<0 || pflId>=(int)_pfls.size())
2608 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2609 return _pfls[pflId];
2612 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2614 if(locId<0 || locId>=(int)_locs.size())
2615 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2616 return *_locs[locId];
2619 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2621 return getLocalizationFromId(getLocalizationId(locName));
2624 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2626 std::string pflNameCpp(pflName);
2627 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2630 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2631 for(it=_pfls.begin();it!=_pfls.end();it++)
2632 oss << "\"" << (*it)->getName() << "\", ";
2633 throw INTERP_KERNEL::Exception(oss.str().c_str());
2638 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2640 if(pflId<0 || pflId>=(int)_pfls.size())
2641 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2642 return _pfls[pflId];
2645 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2647 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2649 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2651 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2652 newPfls.push_back(*it);
2657 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2659 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2661 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2663 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2664 newLocs.push_back(*it);
2669 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2671 int sz=_pfls.size();
2672 std::vector<std::string> ret(sz);
2673 for(int i=0;i<sz;i++)
2674 ret[i]=_pfls[i]->getName();
2678 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2680 int sz=_locs.size();
2681 std::vector<std::string> ret(sz);
2682 for(int i=0;i<sz;i++)
2683 ret[i]=_locs[i]->getName();
2687 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2689 std::vector<std::string> v=getPfls();
2690 std::string s(pflName);
2691 return std::find(v.begin(),v.end(),s)!=v.end();
2694 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2696 std::vector<std::string> v=getLocs();
2697 std::string s(locName);
2698 return std::find(v.begin(),v.end(),s)!=v.end();
2701 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2703 std::map<int,std::vector<int> > m;
2705 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2707 const DataArrayInt *tmp=(*it);
2710 m[tmp->getHashCode()].push_back(i);
2713 std::vector< std::vector<int> > ret;
2714 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2716 if((*it2).second.size()>1)
2718 std::vector<int> ret0;
2719 bool equalityOrNot=false;
2720 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2722 std::vector<int>::const_iterator it4=it3; it4++;
2723 for(;it4!=(*it2).second.end();it4++)
2725 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2728 ret0.push_back(*it3);
2729 ret0.push_back(*it4);
2735 ret.push_back(ret0);
2741 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2743 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2746 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2748 std::string name(pfl->getName());
2750 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2751 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2752 if(name==(*it)->getName())
2754 if(!pfl->isEqual(*(*it)))
2756 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2757 throw INTERP_KERNEL::Exception(oss.str().c_str());
2761 _pfls.push_back(pfl);
2764 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)
2766 std::string name(locName);
2768 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2769 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2770 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2771 if((*it)->isName(locName))
2773 if(!(*it)->isEqual(*obj,1e-12))
2775 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2776 throw INTERP_KERNEL::Exception(oss.str().c_str());
2779 _locs.push_back(obj);
2782 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2784 std::vector<std::string> names=getPfls();
2785 return CreateNewNameNotIn("NewPfl_",names);
2788 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2790 std::vector<std::string> names=getLocs();
2791 return CreateNewNameNotIn("NewLoc_",names);
2794 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2796 for(std::size_t sz=0;sz<100000;sz++)
2798 std::ostringstream tryName;
2799 tryName << prefix << sz;
2800 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2801 return tryName.str();
2803 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2806 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2810 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2814 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2817 if((const MEDFileFieldGlobs *)_globals)
2818 ret+=_globals->getHeapMemorySize();
2822 void MEDFileFieldGlobsReal::simpleRepr(std::ostream& oss) const
2824 oss << "Globals information on fields :" << "\n*******************************\n\n";
2825 const MEDFileFieldGlobs *glob=_globals;
2827 glob->simpleRepr(oss);
2829 oss << "NO GLOBAL INFORMATION !\n";
2832 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2836 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2838 _globals=other._globals;
2841 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2843 _globals=other._globals;
2844 if((const MEDFileFieldGlobs *)_globals)
2845 _globals=other._globals->deepCpy();
2848 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2850 _globals->appendGlobs(*other._globals,eps);
2853 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2855 _globals->loadProfileInFile(fid,id,pflName);
2858 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
2860 _globals->loadProfileInFile(fid,id);
2863 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2865 _globals->loadGlobals(fid,*this);
2868 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2870 _globals->loadAllGlobals(fid);
2873 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2875 _globals->writeGlobals(fid,opt);
2878 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
2880 return _globals->getPfls();
2883 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
2885 return _globals->getLocs();
2888 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
2890 return _globals->existsPfl(pflName);
2893 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
2895 return _globals->existsLoc(locName);
2898 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2900 return _globals->createNewNameOfPfl();
2903 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2905 return _globals->createNewNameOfLoc();
2908 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
2910 _globals->setFileName(fileName);
2913 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
2915 return _globals->whichAreEqualProfiles();
2918 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
2920 return _globals->whichAreEqualLocs(eps);
2923 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2925 _globals->changePflsNamesInStruct(mapOfModif);
2928 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2930 _globals->changeLocsNamesInStruct(mapOfModif);
2934 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2935 * This method contrary to abstract method MEDFileFieldGlobsReal::changePflsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changePflsRefsNamesGen,
2936 * the profiles themselves and not only leaves of field.
2938 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2940 changePflsRefsNamesGen(mapOfModif);
2941 changePflsNamesInStruct(mapOfModif);
2945 * This method is a generalization of MEDFileFieldGlobsReal::changePflName.
2946 * This method contrary to abstract method MEDFileFieldGlobsReal::changeLocsRefsNamesGen updates in addition of MEDFileFieldGlobsReal::changeLocsRefsNamesGen,
2947 * the localizations themselves and not only leaves of field.
2949 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2951 changeLocsRefsNamesGen(mapOfModif);
2952 changeLocsNamesInStruct(mapOfModif);
2956 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changePflsNames.
2958 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2960 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2961 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2963 changePflsNames(mapOfModif);
2967 * This method is a more friendly API but less general method than MEDFileFieldGlobsReal::changeLocsNames.
2969 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
2971 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
2972 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
2974 changeLocsNames(mapOfModif);
2977 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
2979 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
2980 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
2982 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
2984 std::vector< std::string > tmp((*it).size());
2986 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
2987 tmp[j]=std::string(getProfileFromId(*it2)->getName());
2988 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
2990 std::vector<int> tmp2((*it).begin()+1,(*it).end());
2991 killProfileIds(tmp2);
2993 changePflsRefsNamesGen(ret);
2997 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
2999 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3000 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3002 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3004 std::vector< std::string > tmp((*it).size());
3006 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3007 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3008 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3010 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3011 killLocalizationIds(tmp2);
3013 changeLocsRefsNamesGen(ret);
3017 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3019 return _globals->getNbOfGaussPtPerCell(locId);
3022 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3024 return _globals->getLocalizationId(loc);
3027 const char *MEDFileFieldGlobsReal::getFileName() const
3029 return _globals->getFileName();
3032 std::string MEDFileFieldGlobsReal::getFileName2() const
3034 return _globals->getFileName2();
3037 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3039 return _globals->getLocalization(locName);
3042 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3044 return _globals->getLocalizationFromId(locId);
3047 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3049 return _globals->getProfile(pflName);
3052 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3054 return _globals->getProfileFromId(pflId);
3057 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3059 return _globals->getLocalizationFromId(locId);
3062 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3064 return _globals->getLocalization(locName);
3067 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3069 return _globals->getProfile(pflName);
3072 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3074 return _globals->getProfileFromId(pflId);
3077 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3079 _globals->killProfileIds(pflIds);
3082 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3084 _globals->killLocalizationIds(locIds);
3087 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3089 _globals->appendProfile(pfl);
3092 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)
3094 _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
3098 * This method returns the max dimension of 'this'.
3099 * This method returns -2 if 'this' is empty, -1 if only nodes are defined.
3101 int MEDFileField1TSWithoutSDA::getDimension() const
3104 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3105 (*it)->getDimension(ret);
3109 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
3111 if(meshDimRelToMax>0)
3112 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
3115 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3118 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
3119 int nbOfTypes=geoTypes.size();
3120 std::vector<int> code(3*nbOfTypes);
3121 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
3122 arr1->alloc(nbOfTypes,1);
3123 int *arrPtr=arr1->getPointer();
3124 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
3125 for(int i=0;i<nbOfTypes;i++,it++)
3126 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
3127 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
3128 const int *arrPtr2=arr2->getConstPointer();
3130 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
3133 int nbCells=mesh->getNumberOfCellsWithType(*it);
3134 code[3*pos]=(int)(*it);
3135 code[3*pos+1]=nbCells;
3136 code[3*pos+2]=-1;//no profiles
3138 std::vector<const DataArrayInt *> idsPerType;//no profiles
3139 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
3143 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
3148 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
3150 return new MEDFileField1TSWithoutSDA(fieldName,csit,fieldtype,iteration,order,infos);
3154 * This method copyies tiny info but also preallocated the DataArrayDouble instance in this->_arr.
3155 * This not allocated it allocates to the size of 'field' array. If already allocated it grows the array to
3156 * the previous size + the size of the array of the input 'field'.
3157 * This method returns the position (in tuple id) where to start to feed 'this->_arr'
3159 int MEDFileField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
3161 std::string name(field->getName());
3162 getOrCreateAndGetArray()->setName(name.c_str());
3164 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
3165 const DataArrayDouble *arr=field->getArray();
3167 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
3168 _dt=field->getTime(_iteration,_order);
3169 int nbOfComponents=arr->getNumberOfComponents();
3170 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
3171 if(!getOrCreateAndGetArray()->isAllocated())
3173 _arr->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
3178 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
3179 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
3180 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New();
3181 tmp->alloc(newNbOfTuples,nbOfComponents);
3182 tmp->copyStringInfoFrom(*_arr);
3183 std::copy(_arr->begin(),_arr->end(),tmp->getPointer());
3185 return oldNbOfTuples;
3189 std::string MEDFileField1TSWithoutSDA::getName() const
3191 const DataArrayDouble *arr=getOrCreateAndGetArray();
3192 return arr->getName();
3195 void MEDFileField1TSWithoutSDA::setName(const char *name)
3197 DataArrayDouble *arr=getOrCreateAndGetArray();
3201 void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3203 std::string startOfLine(bkOffset,' ');
3204 oss << startOfLine << "Field on One time Step ";
3206 oss << "(" << f1tsId << ") ";
3207 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3208 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3209 const DataArrayDouble *arr=_arr;
3212 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3215 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3216 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3217 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3218 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3220 if(arr->isAllocated())
3222 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3225 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3229 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3231 oss << startOfLine << "----------------------" << std::endl;
3232 if(!_field_per_mesh.empty())
3235 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3237 const MEDFileFieldPerMesh *cur=(*it2);
3239 cur->simpleRepr(bkOffset,oss,i);
3241 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3246 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3248 oss << startOfLine << "----------------------" << std::endl;
3251 std::string MEDFileField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3253 if(_field_per_mesh.empty())
3254 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3255 return _field_per_mesh[0]->getMeshName();
3258 void MEDFileField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3260 std::string oldName(getMeshName());
3261 std::vector< std::pair<std::string,std::string> > v(1);
3262 v[0].first=oldName; v[0].second=newMeshName;
3266 bool MEDFileField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3269 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3271 MEDFileFieldPerMesh *cur(*it);
3273 ret=cur->changeMeshNames(modifTab) || ret;
3278 bool MEDFileField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3279 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3282 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3284 MEDFileFieldPerMesh *fpm(*it);
3286 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3291 int MEDFileField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3293 if(_field_per_mesh.empty())
3294 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3295 return _field_per_mesh[0]->getMeshIteration();
3298 int MEDFileField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3300 if(_field_per_mesh.empty())
3301 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3302 return _field_per_mesh[0]->getMeshOrder();
3305 int MEDFileField1TSWithoutSDA::getNumberOfComponents() const
3307 return getOrCreateAndGetArray()->getNumberOfComponents();
3310 bool MEDFileField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3312 return iteration==_iteration && order==_order;
3315 std::pair<int,int> MEDFileField1TSWithoutSDA::getDtIt() const
3317 std::pair<int,int> p;
3322 void MEDFileField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3328 void MEDFileField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3330 std::set<TypeOfField> types2;
3331 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3333 (*it)->fillTypesOfFieldAvailable(types2);
3335 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3336 std::copy(types2.begin(),types2.end(),bi);
3339 const std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo() const
3341 const DataArrayDouble *arr=getOrCreateAndGetArray();
3342 return arr->getInfoOnComponents();
3345 std::vector<std::string>& MEDFileField1TSWithoutSDA::getInfo()
3347 DataArrayDouble *arr=getOrCreateAndGetArray();
3348 return arr->getInfoOnComponents();
3352 * 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'
3353 * This method returns two things.
3354 * - The absolute dimension of 'this' in first parameter.
3355 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
3356 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
3358 * This method is designed for MEDFileField1TS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
3359 * Only these 3 discretizations will be taken into account here.
3361 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
3362 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
3363 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
3365 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
3366 * 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'.
3368 * Let's consider the typical following case :
3369 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
3370 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
3371 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
3373 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
3375 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
3377 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
3378 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
3379 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
3380 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
3382 int MEDFileField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3385 int meshId=getMeshIdFromMeshName(mname);
3386 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3387 std::vector< std::vector<TypeOfField> > typesF;
3388 std::vector< std::vector<std::string> > pfls, locs;
3389 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3391 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3392 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3393 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3395 st.erase(INTERP_KERNEL::NORM_ERROR);
3397 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3399 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3400 ret1.insert((int)cm.getDimension());
3402 int ret=*std::max_element(ret1.begin(),ret1.end());
3403 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3404 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3408 std::vector<TypeOfField> MEDFileField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3410 std::vector<TypeOfField> ret;
3411 fillTypesOfFieldAvailable(ret);
3416 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
3418 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)
3422 meshId=getMeshIdFromMeshName(mname);
3424 if(_field_per_mesh.empty())
3425 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3426 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3430 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
3431 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
3433 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)
3437 meshId=getMeshIdFromMeshName(mname);
3439 if(_field_per_mesh.empty())
3440 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3441 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3442 int nbOfRet=ret0.size();
3443 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
3444 for(int i=0;i<nbOfRet;i++)
3446 const std::vector< std::pair<int,int> >& p=ret0[i];
3447 int nbOfRet1=p.size();
3448 ret[i].resize(nbOfRet1);
3449 for(int j=0;j<nbOfRet1;j++)
3451 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
3458 void MEDFileField1TSWithoutSDA::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
3460 med_int numdt,numit;
3464 med_int meshnumdt,meshnumit;
3465 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3466 MEDfieldComputingStepInfo(fid,getName().c_str(),_csit,&numdt,&numit,&_dt);
3467 MEDfield23ComputingStepMeshInfo(fid,getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
3468 if(_iteration!=numdt || _order!=numit)
3469 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
3470 _field_per_mesh.resize(nmesh);
3471 for(int i=0;i<nmesh;i++)
3472 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit);
3474 for(int i=0;i<nmesh;i++)
3476 _field_per_mesh[i]->prepareLoading(fid,start);
3478 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
3479 for(int i=0;i<nmesh;i++)
3481 _field_per_mesh[i]->finishLoading(fid,_field_type);
3485 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsed2() const
3487 std::vector<std::string> ret;
3488 std::set<std::string> ret2;
3489 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3491 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3492 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3493 if(ret2.find(*it2)==ret2.end())
3495 ret.push_back(*it2);
3502 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsed2() const
3504 std::vector<std::string> ret;
3505 std::set<std::string> ret2;
3506 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3508 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3509 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3510 if(ret2.find(*it2)==ret2.end())
3512 ret.push_back(*it2);
3519 std::vector<std::string> MEDFileField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3521 std::vector<std::string> ret;
3522 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3524 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3525 ret.insert(ret.end(),tmp.begin(),tmp.end());
3530 std::vector<std::string> MEDFileField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3532 std::vector<std::string> ret;
3533 std::set<std::string> ret2;
3534 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3536 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3537 ret.insert(ret.end(),tmp.begin(),tmp.end());
3542 void MEDFileField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3544 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3545 (*it)->changePflsRefsNamesGen(mapOfModif);
3548 void MEDFileField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3550 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3551 (*it)->changeLocsRefsNamesGen(mapOfModif);
3554 void MEDFileField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
3556 if(_field_per_mesh.empty())
3557 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3558 if(_field_per_mesh.size()>1)
3559 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3560 _field_per_mesh[0]->copyOptionsFrom(opts);
3561 _field_per_mesh[0]->writeLL(fid);
3565 * SBT means Sort By Type.
3566 * 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.
3568 void MEDFileField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3570 const MEDCouplingMesh *mesh=field->getMesh();
3572 TypeOfField type=field->getTypeOfField();
3573 std::vector<DataArrayInt *> dummy;
3574 int start=copyTinyInfoFrom(field);
3575 int pos=addNewEntryIfNecessary(mesh);
3578 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
3579 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,glob);
3582 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,glob);
3586 * Generalization of MEDFileField1TSWithoutSDA::setFieldNoProfileSBT method.
3588 void MEDFileField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3590 TypeOfField type=field->getTypeOfField();
3591 int start=copyTinyInfoFrom(field);
3592 std::vector<DataArrayInt *> idsInPflPerType;
3593 std::vector<DataArrayInt *> idsPerType;
3594 std::vector<int> code,code2;
3595 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3598 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
3599 code2=m->getDistributionOfTypes();
3601 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
3602 for(std::size_t i=0;i<idsInPflPerType.size();i++)
3603 idsInPflPerType2[i]=idsInPflPerType[i];
3604 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
3605 for(std::size_t i=0;i<idsPerType.size();i++)
3606 idsPerType2[i]=idsPerType[i];
3608 int pos=addNewEntryIfNecessary(m);
3609 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,m,glob);
3613 int pos=addNewEntryIfNecessary(m);
3614 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,glob);
3618 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3620 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3622 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3624 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
3625 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3628 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
3630 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
3631 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
3632 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
3633 if(meshDimRelToMax==1)
3634 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
3635 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
3638 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3640 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
3642 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
3644 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
3645 int absDim=getDimension();
3646 int meshDimRelToMax=absDim-mm->getMeshDimension();
3647 return MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
3651 * \param [in] mesh is the whole mesh.
3653 MEDCouplingFieldDouble *MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
3655 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
3656 int meshId=getMeshIdFromMeshName(mesh->getName());
3658 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
3663 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3670 throw INTERP_KERNEL::Exception(msg1);
3671 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3674 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
3676 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3677 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
3678 throw INTERP_KERNEL::Exception(oss.str().c_str());
3680 ret->renumberCells(cellRenum->getConstPointer(),true);
3687 //no need to test _field_per_mesh.empty() because geMeshName has already done it
3689 throw INTERP_KERNEL::Exception(msg1);
3692 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
3694 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
3695 oss << "\"" << getName() << "\" not defined on all nodes !";
3696 throw INTERP_KERNEL::Exception(oss.str().c_str());
3698 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
3699 ret->renumberNodes(nodeRenumSafe->getConstPointer());
3704 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
3708 DataArrayDouble *MEDFileField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
3710 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
3711 int meshId=getMeshIdFromMeshName(mesh->getName());
3712 return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
3716 * This method retrieves direct access to the underground ParaMEDMEM::DataArrayDouble instance. The returned array is not a newly
3717 * created array so it should \b not be dealed by the caller.
3718 * This method allows to the user a direct access to the values.
3719 * This method is quite unusable if there is more than a nodal field or a cell field on single geometric cell type.
3721 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
3723 const DataArrayDouble *ret=_arr;
3725 return const_cast<DataArrayDouble *>(ret);
3731 * This method returns an array that the caller must deal with (contrary to those returned by MEDFileField1TSWithoutSDA::getUndergroundDataArray method).
3732 * 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
3733 * '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
3734 * id attached to it. The second pair of pair precise the range [begin,end) into the returned array.
3735 * This method makes the hypothesis that the field lies only on one mesh. If it is not the case an exception will be thrown.
3737 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
3739 if(_field_per_mesh.size()!=1)
3740 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
3741 if(_field_per_mesh[0]==0)
3742 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
3743 return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
3746 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order,
3747 const std::vector<std::string>& infos):_iteration(iteration),_order(order),_csit(csit),_field_type(fieldtype)
3749 DataArrayDouble *arr=getOrCreateAndGetArray();
3750 arr->setName(fieldName);
3751 arr->setInfoAndChangeNbOfCompo(infos);
3754 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():_csit(-1),_field_type(-1)
3758 int MEDFileField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3760 std::string tmp(mesh->getName());
3762 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3763 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3765 for(;it!=_field_per_mesh.end();it++,i++)
3767 if((*it)->getMeshName()==tmp)
3770 int sz=_field_per_mesh.size();
3771 _field_per_mesh.resize(sz+1);
3772 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3777 * \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.
3779 int MEDFileField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3781 if(_field_per_mesh.empty())
3782 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3785 std::string mName2(mName);
3787 std::vector<std::string> msg;
3788 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3789 if(mName2==(*it)->getMeshName())
3792 msg.push_back((*it)->getMeshName());
3793 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3794 oss << "Possible meshes are : ";
3795 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3796 oss << "\"" << (*it2) << "\" ";
3797 throw INTERP_KERNEL::Exception(oss.str().c_str());
3801 * \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.
3802 * \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.
3803 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3804 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3806 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3808 int mid=getMeshIdFromMeshName(mName);
3809 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3813 * \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.
3814 * \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.
3815 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3816 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3818 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3820 int mid=getMeshIdFromMeshName(mName);
3821 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3824 std::size_t MEDFileField1TSWithoutSDA::getHeapMemorySize() const
3826 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
3827 if((const DataArrayDouble *)_arr)
3828 ret+=_arr->getHeapMemorySize();
3829 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3830 ret+=(*it)->getHeapMemorySize();
3834 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
3836 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=new MEDFileField1TSWithoutSDA(*this);
3837 if((const DataArrayDouble *)_arr)
3838 ret->_arr=_arr->deepCpy();
3840 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,i++)
3842 if((const MEDFileFieldPerMesh *)*it)
3843 ret->_field_per_mesh[i]=(*it)->deepCpy((MEDFileField1TSWithoutSDA *)ret);
3848 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
3850 DataArrayDouble *ret=_arr;
3853 _arr=DataArrayDouble::New();
3857 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
3859 const DataArrayDouble *ret=_arr;
3862 DataArrayDouble *ret2=DataArrayDouble::New();
3863 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
3868 * This methods returns a new instance (to be dealt by the caller).
3869 * This method returns for the first field in the file \a fileName the first time step of this first field, if
3870 * such field exists and time step exists. If not, an INTERP_KERNEL::Exception will be thrown.
3872 MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
3874 return new MEDFileField1TS(fileName);
3878 * This methods returns a new instance (to be dealt by the caller).
3879 * This method returns the first time step of the field \a fieldName in file \a fieldName, if
3880 * such field exists. If not, an INTERP_KERNEL::Exception will be thrown.
3882 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
3884 return new MEDFileField1TS(fileName,fieldName);
3887 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
3889 return new MEDFileField1TS(fileName,fieldName,iteration,order);
3893 * \warning this is a shallow copy constructor
3895 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
3897 return new MEDFileField1TS(other,shallowCopyOfContent);
3900 MEDFileField1TS *MEDFileField1TS::New()
3902 return new MEDFileField1TS;
3905 std::string MEDFileField1TS::simpleRepr() const
3907 std::ostringstream oss;
3908 _content->simpleRepr(0,oss,-1);
3909 MEDFileFieldGlobsReal::simpleRepr(oss);
3913 void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
3915 int nbComp=getNumberOfComponents();
3916 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3917 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
3918 for(int i=0;i<nbComp;i++)
3920 std::string info=getInfo()[i];
3922 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
3923 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
3924 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
3926 if(getName().empty())
3927 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
3928 MEDfieldCr(fid,getName().c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
3929 writeGlobals(fid,*this);
3930 _content->writeLL(fid,*this);
3933 void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
3935 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
3936 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
3940 MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
3941 try:MEDFileFieldGlobsReal(fileName)
3943 MEDFileUtilities::CheckFileForRead(fileName);
3944 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
3945 med_field_type typcha;
3947 int nbFields=MEDnField(fid);
3950 std::ostringstream oss; oss << "MEDFileField1TS(fileName) : no field present in file \'" << fileName << "\' !";
3951 throw INTERP_KERNEL::Exception(oss.str().c_str());
3953 int ncomp=MEDfieldnComponent(fid,1);
3954 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3955 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
3956 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
3957 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3958 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3961 MEDfieldInfo(fid,1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
3962 std::string fieldName(nomcha);
3965 std::ostringstream oss; oss << "MEDFileField1TS(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
3966 throw INTERP_KERNEL::Exception(oss.str().c_str());
3968 std::vector<std::string> infos(ncomp);
3969 for(int j=0;j<ncomp;j++)
3970 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
3971 _content=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
3972 _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
3974 med_int numdt,numit;
3976 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
3977 _content->setTime(numdt,numit,dt);
3979 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
3980 _content->finishLoading(fid);
3984 catch(INTERP_KERNEL::Exception& e)
3989 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
3990 try:MEDFileFieldGlobsReal(fileName),_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>()))
3992 MEDFileUtilities::CheckFileForRead(fileName);
3993 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
3994 med_field_type typcha;
3995 int nbSteps=locateField(fid,fileName,fieldName,typcha);
3998 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
3999 throw INTERP_KERNEL::Exception(oss.str().c_str());
4002 med_int numdt,numit;
4004 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
4005 _content->setTime(numdt,numit,dt);
4007 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
4008 _content->finishLoading(fid);
4012 catch(INTERP_KERNEL::Exception& e)
4017 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
4018 try:MEDFileFieldGlobsReal(fileName),_content(MEDFileField1TSWithoutSDA::New(fieldName,-1,-1,iteration,order,std::vector<std::string>()))
4020 MEDFileUtilities::CheckFileForRead(fileName);
4021 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4022 med_field_type typcha;
4023 int nbOfStep2=locateField(fid,fileName,fieldName,typcha);
4025 std::vector< std::pair<int,int> > dtits(nbOfStep2);
4026 for(int i=0;i<nbOfStep2 && !found;i++)
4028 med_int numdt,numit;
4030 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
4031 if(numdt==iteration && numit==order)
4034 _content->_csit=i+1;
4035 _content->_field_type=MEDFileUtilities::TraduceFieldType(typcha);
4038 dtits[i]=std::pair<int,int>(numdt,numit);
4042 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
4043 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
4044 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
4045 throw INTERP_KERNEL::Exception(oss.str().c_str());
4047 _content->finishLoading(fid);
4051 catch(INTERP_KERNEL::Exception& e)
4057 * \warning this is a shallow copy constructor
4059 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
4061 if(!shallowCopyOfContent)
4063 const MEDFileField1TSWithoutSDA *otherPtr(&other);
4064 otherPtr->incrRef();
4065 _content=const_cast<MEDFileField1TSWithoutSDA *>(otherPtr);
4069 _content=new MEDFileField1TSWithoutSDA(other);
4073 MEDFileField1TS::MEDFileField1TS():_content(new MEDFileField1TSWithoutSDA)
4078 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
4081 * \return in case of success the number of time steps available for the field with name \a fieldName.
4083 int MEDFileField1TS::locateField(med_idt fid, const char *fileName, const char *fieldName, med_field_type& typcha) throw(INTERP_KERNEL::Exception)
4085 int nbFields=MEDnField(fid);
4087 std::vector<std::string> fns(nbFields);
4089 for(int i=0;i<nbFields && !found;i++)
4091 int ncomp=MEDfieldnComponent(fid,i+1);
4092 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4093 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4094 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4095 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4096 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4099 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4100 std::string tmp(nomcha);
4102 found=(tmp==fieldName);
4106 std::string mname=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
4107 std::vector<std::string> infos(ncomp);
4108 for(int j=0;j<ncomp;j++)
4109 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
4110 _content->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4115 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
4116 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
4117 oss << "\"" << *it << "\" ";
4118 throw INTERP_KERNEL::Exception(oss.str().c_str());
4124 * This method returns all profiles whose name is non empty used.
4125 * \b WARNING If profile is used several times it will be reported \b only \b once.
4126 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
4128 std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
4130 return _content->getPflsReallyUsed2();
4134 * This method returns all localizations whose name is non empty used.
4135 * \b WARNING If localization is used several times it will be reported \b only \b once.
4137 std::vector<std::string> MEDFileField1TS::getLocsReallyUsed() const
4139 return _content->getLocsReallyUsed2();
4143 * This method returns all profiles whose name is non empty used.
4144 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
4146 std::vector<std::string> MEDFileField1TS::getPflsReallyUsedMulti() const
4148 return _content->getPflsReallyUsedMulti2();
4152 * This method returns all localizations whose name is non empty used.
4153 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
4155 std::vector<std::string> MEDFileField1TS::getLocsReallyUsedMulti() const
4157 return _content->getLocsReallyUsedMulti2();
4160 void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4162 _content->changePflsRefsNamesGen2(mapOfModif);
4165 void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
4167 _content->changeLocsRefsNamesGen2(mapOfModif);
4171 * 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
4172 * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead.
4173 * \b WARNING ! Parameter 'meshDimRelToMax' is relative from read mesh in file that can be different from the field in MED file !
4174 * It leads that the returned field of this method is always coherent.
4176 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4178 if(getFileName2().empty())
4179 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
4180 return _content->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
4184 * This method is close to MEDFileField1TS::getFieldAtLevel except that here the 'meshDimRelToMax' param is ignored and the maximal dimension is taken
4185 * automatically. If the field lies on different level and that an another level than the maximal is requested MEDFileField1TS::getFieldAtLevel
4186 * should be called instead.
4188 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
4190 if(getFileName2().empty())
4191 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
4192 return _content->getFieldAtTopLevel(type,0,renumPol,this);
4196 * \b WARNING, there is a main difference with the two close methods (MEDFileField1TS::getFieldAtLevel and MEDFileField1TS::getFieldOnMeshAtLevel method) !
4197 * Here the mesh-dimension of 'mesh' is used by this to automatically request the right geoTypes regarding 'type'.
4198 * If no such element fufilled the deduced dimension and 'type' an exception will be thrown.
4199 * It leads that the returned field of this method is always coherent.
4201 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4203 return _content->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
4207 * This method can be called whatever the mode of instance feeding of this (MED file or from scratch).
4208 * 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' !
4209 * It leads that the returned field of this method is always coherent.
4211 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
4213 return _content->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
4217 * This method is identical to MEDFileField1TS::getFieldAtLevel method except that meshName 'mname' should be specified.
4218 * 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.
4219 * See MEDFileField1TS::getFieldAtLevel for more information.
4221 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
4223 if(getFileName2().empty())
4224 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
4225 return _content->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
4228 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
4230 return _content->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
4234 * SBT means Sort By Type.
4235 * 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.
4238 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4241 _content->setFieldNoProfileSBT(field,*this);
4245 * This method is a generalization of MEDFileField1TS::setFieldNoProfileSBT method. Here a profile array is given in input.
4246 * The support of field 'field' is \b not used by this method, so it can be null or incoherent with field.
4247 * 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,
4248 * an exception will be thrown.
4249 * 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'.
4250 * In this case, if this profile name is empty an exception will be thrown.
4252 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
4255 _content->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
4259 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4260 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4261 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4262 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4263 * to keep a valid instance.
4264 * 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.
4265 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
4266 * 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.
4268 * \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.
4269 * \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.
4270 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4271 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4272 * \param [in] newLocName is the new localization name.
4273 * \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.
4274 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
4276 void MEDFileField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4278 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4279 std::string oldPflName=disc->getProfile();
4280 std::vector<std::string> vv=getPflsReallyUsedMulti();
4281 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
4282 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
4284 disc->setProfile(newPflName);
4285 DataArrayInt *pfl=getProfile(oldPflName.c_str());
4286 pfl->setName(newPflName);
4290 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
4291 throw INTERP_KERNEL::Exception(oss.str().c_str());
4296 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
4297 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
4298 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
4299 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
4300 * to keep a valid instance.
4301 * 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.
4302 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
4303 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
4304 * 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.
4306 * \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.
4307 * \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.
4308 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4309 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4310 * \param [in] newLocName is the new localization name.
4311 * \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.
4312 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
4314 void MEDFileField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
4316 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4317 std::string oldLocName=disc->getLocalization();
4318 std::vector<std::string> vv=getLocsReallyUsedMulti();
4319 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
4320 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
4322 disc->setLocalization(newLocName);
4323 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
4324 loc.setName(newLocName);
4328 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
4329 throw INTERP_KERNEL::Exception(oss.str().c_str());
4333 std::size_t MEDFileField1TS::getHeapMemorySize() const
4336 if((const MEDFileField1TSWithoutSDA *)_content)
4337 ret+=_content->getHeapMemorySize();
4338 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
4341 MEDFileField1TS *MEDFileField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
4343 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(*this);
4344 if((const MEDFileField1TSWithoutSDA *)_content)
4345 ret->_content=_content->deepCpy();
4346 ret->deepCpyGlobs(*this);
4350 int MEDFileField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4352 return _content->copyTinyInfoFrom(field);
4355 int MEDFileField1TS::getDimension() const
4357 return _content->getDimension();
4360 int MEDFileField1TS::getIteration() const
4362 return _content->getIteration();
4365 int MEDFileField1TS::getOrder() const
4367 return _content->getOrder();
4370 double MEDFileField1TS::getTime(int& iteration, int& order) const
4372 return _content->getTime(iteration,order);
4375 void MEDFileField1TS::setTime(int iteration, int order, double val)
4377 _content->setTime(iteration,order,val);
4380 std::string MEDFileField1TS::getName() const
4382 return _content->getName();
4385 void MEDFileField1TS::setName(const char *name)
4387 _content->setName(name);
4390 void MEDFileField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4392 _content->simpleRepr(bkOffset,oss,f1tsId);
4395 const std::string& MEDFileField1TS::getDtUnit() const
4397 return _content->getDtUnit();
4400 std::string MEDFileField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
4402 return _content->getMeshName();
4405 void MEDFileField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4407 _content->setMeshName(newMeshName);
4410 bool MEDFileField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4412 return _content->changeMeshNames(modifTab);
4415 int MEDFileField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
4417 return _content->getMeshIteration();
4420 int MEDFileField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
4422 return _content->getMeshOrder();
4425 int MEDFileField1TS::getNumberOfComponents() const
4427 return _content->getNumberOfComponents();
4430 bool MEDFileField1TS::isDealingTS(int iteration, int order) const
4432 return _content->isDealingTS(iteration,order);
4435 std::pair<int,int> MEDFileField1TS::getDtIt() const
4437 return _content->getDtIt();
4440 void MEDFileField1TS::fillIteration(std::pair<int,int>& p) const
4442 _content->fillIteration(p);
4444 void MEDFileField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
4446 _content->fillTypesOfFieldAvailable(types);
4449 const std::vector<std::string>& MEDFileField1TS::getInfo() const
4451 return _content->getInfo();
4453 std::vector<std::string>& MEDFileField1TS::getInfo()
4455 return _content->getInfo();
4458 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4460 return _content->getUndergroundDataArray();
4463 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4465 return _content->getUndergroundDataArrayExt(entries);
4468 MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
4470 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4473 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
4475 return _content->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
4478 int MEDFileField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4480 return _content->getNonEmptyLevels(mname,levs);
4483 std::vector<TypeOfField> MEDFileField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4485 return _content->getTypesOfFieldAvailable();
4488 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,
4489 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4491 return _content->getFieldSplitedByType(mname,types,typesF,pfls,locs);
4493 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
4494 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4496 return _content->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4499 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)
4501 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,id,ft,infos,nbOfStep);
4504 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA():_field_type(-1)
4508 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):_name(fieldName),_field_type(-1)
4513 * \param [in] fieldId field id in C mode
4515 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
4518 med_field_type typcha;
4520 int ncomp=MEDfieldnComponent(fid,fieldId+1);
4521 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4522 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
4523 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
4524 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4525 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4528 MEDfieldInfo(fid,fieldId+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
4529 _name=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
4530 _field_type=MEDFileUtilities::TraduceFieldType(typcha);
4531 _infos.resize(ncomp);
4532 for(int j=0;j<ncomp;j++)
4533 _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
4535 finishLoading(fid,nbOfStep);
4537 catch(INTERP_KERNEL::Exception& e)
4542 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
4543 try:_name(fieldName),_infos(infos),_field_type(ft)
4545 finishLoading(fid,nbOfStep);
4547 catch(INTERP_KERNEL::Exception& e)
4552 std::size_t MEDFileFieldMultiTSWithoutSDA::getHeapMemorySize() const
4554 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
4555 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
4556 ret+=(*it).capacity();
4557 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4558 if((const MEDFileField1TSWithoutSDA *)(*it))
4559 ret+=(*it)->getHeapMemorySize();
4563 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4565 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret=new MEDFileFieldMultiTSWithoutSDA(*this);
4567 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
4569 if((const MEDFileField1TSWithoutSDA *)*it)
4570 ret->_time_steps[i]=(*it)->deepCpy();
4575 const std::vector<std::string>& MEDFileFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
4577 if(_time_steps.empty())
4578 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getInfos : not time steps !");
4579 return _time_steps[0]->getInfo();
4583 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
4585 DataArrayDouble *MEDFileFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4587 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
4591 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
4593 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)
4595 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
4598 std::string MEDFileFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
4600 if(_time_steps.empty())
4601 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4602 return _time_steps[0]->getMeshName();
4605 void MEDFileFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
4607 std::string oldName(getMeshName());
4608 std::vector< std::pair<std::string,std::string> > v(1);
4609 v[0].first=oldName; v[0].second=newMeshName;
4613 bool MEDFileFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
4616 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4618 MEDFileField1TSWithoutSDA *cur(*it);
4620 ret=cur->changeMeshNames(modifTab) || ret;
4625 bool MEDFileFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4626 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4629 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4631 MEDFileField1TSWithoutSDA *f1ts(*it);
4633 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4638 void MEDFileFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4640 if(_time_steps.empty())
4642 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4643 obj->setFieldNoProfileSBT(field,glob);
4644 copyTinyInfoFrom(field);
4645 _time_steps.push_back(obj);
4649 checkCoherencyOfTinyInfo(field);
4650 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4651 obj->setFieldNoProfileSBT(field,glob);
4652 _time_steps.push_back(obj);
4656 void MEDFileFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4658 if(_time_steps.empty())
4660 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4661 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4662 copyTinyInfoFrom(field);
4663 _time_steps.push_back(obj);
4667 checkCoherencyOfTinyInfo(field);
4668 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> obj=new MEDFileField1TSWithoutSDA;
4669 obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,glob);
4670 _time_steps.push_back(obj);
4674 std::string MEDFileFieldMultiTSWithoutSDA::getDtUnit() const throw(INTERP_KERNEL::Exception)
4676 if(_time_steps.empty())
4677 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
4678 return _time_steps[0]->getDtUnit();
4681 std::string MEDFileFieldMultiTSWithoutSDA::getName() const
4686 void MEDFileFieldMultiTSWithoutSDA::setName(const char *name)
4691 void MEDFileFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
4693 std::string startLine(bkOffset,' ');
4694 oss << startLine << "Field multi time steps";
4696 oss << " (" << fmtsId << ")";
4697 oss << " has the following name: \"" << _name << "\"." << std::endl;
4698 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
4699 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
4701 oss << startLine << " - \"" << *it << "\"" << std::endl;
4704 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
4706 std::string chapter(17,'0'+i);
4707 oss << startLine << chapter << std::endl;
4708 const MEDFileField1TSWithoutSDA *cur=(*it);
4710 cur->simpleRepr(bkOffset+2,oss,i);
4712 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
4713 oss << startLine << chapter << std::endl;
4717 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
4719 std::size_t sz=_time_steps.size();
4720 std::vector< std::pair<int,int> > ret(sz);
4722 for(std::size_t i=0;i<sz;i++)
4724 const MEDFileField1TSWithoutSDA *f1ts=_time_steps[i];
4727 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
4731 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
4732 throw INTERP_KERNEL::Exception(oss.str().c_str());
4738 void MEDFileFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
4740 _time_steps.resize(nbPdt);
4741 for(int i=0;i<nbPdt;i++)
4743 std::vector< std::pair<int,int> > ts;
4744 med_int numdt=0,numo=0;
4745 med_int meshIt=0,meshOrder=0;
4747 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
4748 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
4749 _time_steps[i]->finishLoading(fid);
4753 void MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
4755 _name=field->getName();
4757 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4758 const DataArrayDouble *arr=field->getArray();
4760 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
4761 _infos=arr->getInfoOnComponents();
4764 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
4766 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
4767 if(_name!=field->getName())
4769 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
4770 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
4771 throw INTERP_KERNEL::Exception(oss.str().c_str());
4773 const DataArrayDouble *arr=field->getArray();
4775 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
4776 if(_infos!=arr->getInfoOnComponents())
4778 std::ostringstream oss; oss << MSG << "components ! should be \"";
4779 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
4780 oss << " But compo in input fields are : ";
4781 std::vector<std::string> tmp=arr->getInfoOnComponents();
4782 std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
4784 throw INTERP_KERNEL::Exception(oss.str().c_str());
4788 void MEDFileFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
4790 if(_time_steps.empty())
4791 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
4792 std::vector<std::string> infos(getInfo());
4793 int nbComp=infos.size();
4794 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4795 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
4796 for(int i=0;i<nbComp;i++)
4798 std::string info=infos[i];
4800 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
4801 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4802 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
4805 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
4806 MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
4807 int nbOfTS=_time_steps.size();
4808 for(int i=0;i<nbOfTS;i++)
4809 _time_steps[i]->writeLL(fid,opts);
4812 int MEDFileFieldMultiTSWithoutSDA::getNumberOfTS() const
4814 return _time_steps.size();
4817 void MEDFileFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
4819 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4820 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4822 const MEDFileField1TSWithoutSDA *tmp=(*it);
4824 newTS.push_back(*it);
4829 void MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
4831 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > newTS;
4832 int maxId=(int)_time_steps.size();
4834 std::set<int> idsToDel;
4835 for(const int *id=startIds;id!=endIds;id++,ii++)
4837 if(*id>=0 && *id<maxId)
4839 idsToDel.insert(*id);
4843 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
4844 throw INTERP_KERNEL::Exception(oss.str().c_str());
4847 for(int iii=0;iii<maxId;iii++)
4848 if(idsToDel.find(iii)==idsToDel.end())
4849 newTS.push_back(_time_steps[iii]);
4853 int MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4856 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
4857 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4859 const MEDFileField1TSWithoutSDA *tmp(*it);
4863 tmp->getTime(it2,ord);
4864 if(it2==iteration && order==ord)
4867 oss << "(" << it2 << "," << ord << "), ";
4870 throw INTERP_KERNEL::Exception(oss.str().c_str());
4873 int MEDFileFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
4876 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
4878 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
4880 const MEDFileField1TSWithoutSDA *tmp(*it);
4884 double ti=tmp->getTime(it2,ord);
4885 if(fabs(time-ti)<eps)
4891 throw INTERP_KERNEL::Exception(oss.str().c_str());
4894 std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutSDA::getIterations() const
4896 int lgth=_time_steps.size();
4897 std::vector< std::pair<int,int> > ret(lgth);
4898 for(int i=0;i<lgth;i++)
4899 _time_steps[i]->fillIteration(ret[i]);
4904 * 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'
4905 * This method returns two things.
4906 * - The absolute dimension of 'this' in first parameter.
4907 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
4908 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
4910 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
4911 * Only these 3 discretizations will be taken into account here.
4913 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
4914 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
4915 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
4917 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
4918 * 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'.
4920 * Let's consider the typical following case :
4921 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
4922 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
4923 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
4925 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
4927 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
4929 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
4930 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
4931 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
4932 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
4934 int MEDFileFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
4936 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
4939 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
4941 int lgth=_time_steps.size();
4942 std::vector< std::vector<TypeOfField> > ret(lgth);
4943 for(int i=0;i<lgth;i++)
4944 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
4949 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
4951 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)
4953 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
4957 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
4958 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
4960 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)
4962 return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
4965 const MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
4967 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4968 if((*it)->isDealingTS(iteration,order))
4970 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4971 std::vector< std::pair<int,int> > vp=getIterations();
4972 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4973 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4974 throw INTERP_KERNEL::Exception(oss.str().c_str());
4977 MEDFileField1TSWithoutSDA& MEDFileFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
4979 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
4980 if((*it)->isDealingTS(iteration,order))
4982 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepEntry : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
4983 std::vector< std::pair<int,int> > vp=getIterations();
4984 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
4985 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
4986 throw INTERP_KERNEL::Exception(oss.str().c_str());
4989 const MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
4991 if(pos<0 || pos>=(int)_time_steps.size())
4993 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
4994 throw INTERP_KERNEL::Exception(oss.str().c_str());
4996 const MEDFileField1TSWithoutSDA *item=_time_steps[pos];
4999 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
5000 oss << "\nTry to use following method eraseEmptyTS !";
5001 throw INTERP_KERNEL::Exception(oss.str().c_str());
5006 MEDFileField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
5008 if(pos<0 || pos>=(int)_time_steps.size())
5010 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
5011 throw INTERP_KERNEL::Exception(oss.str().c_str());
5013 MEDFileField1TSWithoutSDA *item=_time_steps[pos];
5016 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
5017 oss << "\nTry to use following method eraseEmptyTS !";
5018 throw INTERP_KERNEL::Exception(oss.str().c_str());
5023 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
5025 std::vector<std::string> ret;
5026 std::set<std::string> ret2;
5027 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5029 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
5030 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5031 if(ret2.find(*it2)==ret2.end())
5033 ret.push_back(*it2);
5040 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
5042 std::vector<std::string> ret;
5043 std::set<std::string> ret2;
5044 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5046 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5047 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5048 if(ret2.find(*it2)==ret2.end())
5050 ret.push_back(*it2);
5057 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
5059 std::vector<std::string> ret;
5060 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5062 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
5063 ret.insert(ret.end(),tmp.begin(),tmp.end());
5068 std::vector<std::string> MEDFileFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
5070 std::vector<std::string> ret;
5071 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5073 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
5074 ret.insert(ret.end(),tmp.begin(),tmp.end());
5079 void MEDFileFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5081 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5082 (*it)->changePflsRefsNamesGen2(mapOfModif);
5085 void MEDFileFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5087 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
5088 (*it)->changeLocsRefsNamesGen2(mapOfModif);
5091 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
5093 return new MEDFileFieldMultiTS;
5096 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5098 return new MEDFileFieldMultiTS(fileName);
5101 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5103 return new MEDFileFieldMultiTS(fileName,fieldName);
5106 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
5108 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
5111 std::size_t MEDFileFieldMultiTS::getHeapMemorySize() const
5114 if((const MEDFileFieldMultiTSWithoutSDA*)_content)
5115 ret+=_content->getHeapMemorySize();
5116 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5119 MEDFileFieldMultiTS *MEDFileFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
5121 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(*this);
5122 if((const MEDFileFieldMultiTSWithoutSDA *)_content)
5123 ret->_content=_content->deepCpy();
5124 ret->deepCpyGlobs(*this);
5129 * \return a new allocated object that the caller should deal with.
5131 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
5133 const MEDFileField1TSWithoutSDA *item=_content->getTimeStepAtPos2(pos);
5134 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item,false);
5135 ret->shallowCpyGlobs(*this);
5140 * \return a new allocated object that the caller should deal with.
5142 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5144 int pos=getPosOfTimeStep(iteration,order);
5145 return getTimeStepAtPos(pos);
5149 * \return a new allocated object that the caller should deal with.
5151 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
5153 int pos=getPosGivenTime(time,eps);
5154 return getTimeStepAtPos(pos);
5157 MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
5159 return new MEDFileFieldMultiTSIterator(this);
5162 std::string MEDFileFieldMultiTS::simpleRepr() const
5164 std::ostringstream oss;
5165 _content->simpleRepr(0,oss,-1);
5166 MEDFileFieldGlobsReal::simpleRepr(oss);
5170 void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5172 writeGlobals(fid,*this);
5173 _content->writeLL(fid,*this);
5176 void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5178 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5179 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5184 * Performs the job than MEDFileField1TS::getFieldAtLevel except that (iteration,order) couple should be specified !
5185 * If such couple does not exist an exception is thrown.
5187 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5189 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5190 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
5193 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
5195 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5196 return myF1TS.getFieldAtTopLevel(type,0,renumPol,this);
5200 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
5201 * If such couple does not exist an exception is thrown.
5203 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5205 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5206 return myF1TS.getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh);
5210 * Performs the job than MEDFileField1TS::getFieldOnMeshAtLevel except that (iteration,order) couple should be specified !
5211 * If such couple does not exist an exception is thrown.
5213 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5215 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5216 return myF1TS.getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0);
5220 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
5221 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
5222 * This method is useful for MED2 file format when field on different mesh was autorized.
5224 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5226 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5227 return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
5230 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5232 const MEDFileField1TSWithoutSDA& myF1TS=_content->getTimeStepEntry(iteration,order);
5233 return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
5236 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5238 _content->appendFieldNoProfileSBT(field,*this);
5241 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
5243 _content->appendFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
5246 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> MEDFileFieldMultiTS::getContent()
5251 MEDFileFieldMultiTS::MEDFileFieldMultiTS():_content(new MEDFileFieldMultiTSWithoutSDA)
5257 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
5258 try:MEDFileFieldGlobsReal(fileName)
5260 MEDFileUtilities::CheckFileForRead(fileName);
5261 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5262 int nbFields=MEDnField(fid);
5265 std::ostringstream oss; oss << "MEDFileFieldMultiTS(const char *fileName) constructor : no fields in file \"" << fileName << "\" !";
5266 throw INTERP_KERNEL::Exception(oss.str().c_str());
5268 _content=new MEDFileFieldMultiTSWithoutSDA(fid,0);
5272 catch(INTERP_KERNEL::Exception& e)
5277 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5278 try:MEDFileFieldGlobsReal(fileName)
5280 MEDFileUtilities::CheckFileForRead(fileName);
5281 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5282 int nbFields=MEDnField(fid);
5283 med_field_type typcha;
5285 std::vector<std::string> fns(nbFields);
5286 for(int i=0;i<nbFields && !found;i++)
5288 int ncomp=MEDfieldnComponent(fid,i+1);
5289 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5290 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5291 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5292 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5293 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5296 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5297 std::string tmp(nomcha);
5299 found=(tmp==fieldName);
5301 _content=new MEDFileFieldMultiTSWithoutSDA(fid,i);
5305 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5306 std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
5307 throw INTERP_KERNEL::Exception(oss.str().c_str());
5312 catch(INTERP_KERNEL::Exception& e)
5317 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
5319 if(!shallowCopyOfContent)
5321 const MEDFileFieldMultiTSWithoutSDA *otherPtr(&other);
5322 otherPtr->incrRef();
5323 _content=const_cast<MEDFileFieldMultiTSWithoutSDA *>(otherPtr);
5327 _content=new MEDFileFieldMultiTSWithoutSDA(other);
5331 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
5333 return _content->getPflsReallyUsed2();
5336 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsed() const
5338 return _content->getLocsReallyUsed2();
5341 std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsedMulti() const
5343 return _content->getPflsReallyUsedMulti2();
5346 std::vector<std::string> MEDFileFieldMultiTS::getLocsReallyUsedMulti() const
5348 return _content->getLocsReallyUsedMulti2();
5351 void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5353 _content->changePflsRefsNamesGen2(mapOfModif);
5356 void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5358 _content->changeLocsRefsNamesGen2(mapOfModif);
5361 int MEDFileFieldMultiTS::getNumberOfTS() const
5363 return _content->getNumberOfTS();
5366 void MEDFileFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
5368 _content->eraseEmptyTS();
5371 void MEDFileFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
5373 _content->eraseTimeStepIds(startIds,endIds);
5376 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getIterations() const
5378 return _content->getIterations();
5381 int MEDFileFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5383 return _content->getPosOfTimeStep(iteration,order);
5386 int MEDFileFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
5388 return _content->getPosGivenTime(time,eps);
5391 int MEDFileFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5393 return _content->getNonEmptyLevels(iteration,order,mname,levs);
5396 std::vector< std::vector<TypeOfField> > MEDFileFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5398 return _content->getTypesOfFieldAvailable();
5401 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)
5403 return _content->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
5406 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)
5408 return _content->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
5411 std::string MEDFileFieldMultiTS::getName() const
5413 return _content->getName();
5416 void MEDFileFieldMultiTS::setName(const char *name)
5418 _content->setName(name);
5421 void MEDFileFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
5423 _content->simpleRepr(bkOffset,oss,fmtsId);
5426 std::vector< std::pair<int,int> > MEDFileFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
5428 return _content->getTimeSteps(ret1);
5431 std::string MEDFileFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
5433 return _content->getMeshName();
5436 void MEDFileFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5438 _content->setMeshName(newMeshName);
5441 bool MEDFileFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5443 return _content->changeMeshNames(modifTab);
5446 const std::vector<std::string>& MEDFileFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
5448 return _content->getInfo();
5451 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
5453 return _content->getUndergroundDataArray(iteration,order);
5456 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)
5458 return _content->getUndergroundDataArrayExt(iteration,order,entries);
5461 MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
5466 _nb_iter=fmts->getNumberOfTS();
5470 MEDFileFieldMultiTSIterator::~MEDFileFieldMultiTSIterator()
5474 MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
5476 if(_iter_id<_nb_iter)
5478 MEDFileFieldMultiTS *fmts(_fmts);
5480 return fmts->getTimeStepAtPos(_iter_id++);
5488 MEDFileFields *MEDFileFields::New()
5490 return new MEDFileFields;
5493 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5495 return new MEDFileFields(fileName);
5498 std::size_t MEDFileFields::getHeapMemorySize() const
5500 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA>);
5501 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5502 if((const MEDFileFieldMultiTSWithoutSDA *)*it)
5503 ret+=(*it)->getHeapMemorySize();
5504 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5507 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
5509 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=new MEDFileFields(*this);
5511 for( std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5513 if((const MEDFileFieldMultiTSWithoutSDA*)*it)
5514 ret->_fields[i]=(*it)->deepCpy();
5516 ret->deepCpyGlobs(*this);
5520 int MEDFileFields::getNumberOfFields() const
5522 return _fields.size();
5525 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
5527 std::vector<std::string> ret(_fields.size());
5529 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5531 const MEDFileFieldMultiTSWithoutSDA *f=(*it);
5534 ret[i]=f->getName();
5538 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
5539 throw INTERP_KERNEL::Exception(oss.str().c_str());
5545 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
5547 std::vector<std::string> ret;
5548 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5550 const MEDFileFieldMultiTSWithoutSDA *cur(*it);
5552 ret.push_back(cur->getMeshName());
5557 std::string MEDFileFields::simpleRepr() const
5559 std::ostringstream oss;
5560 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
5565 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
5567 int nbOfFields=getNumberOfFields();
5568 std::string startLine(bkOffset,' ');
5569 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
5571 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5573 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5576 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
5580 oss << startLine << " - not defined !" << std::endl;
5584 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5586 const MEDFileFieldMultiTSWithoutSDA *cur=(*it);
5587 std::string chapter(17,'0'+i);
5588 oss << startLine << chapter << std::endl;
5591 cur->simpleRepr(bkOffset+2,oss,i);
5595 oss << startLine << " - not defined !" << std::endl;
5597 oss << startLine << chapter << std::endl;
5599 MEDFileFieldGlobsReal::simpleRepr(oss);
5602 MEDFileFields::MEDFileFields()
5606 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
5607 try:MEDFileFieldGlobsReal(fileName)
5609 MEDFileUtilities::CheckFileForRead(fileName);
5610 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5611 int nbFields=MEDnField(fid);
5612 _fields.resize(nbFields);
5613 med_field_type typcha;
5614 for(int i=0;i<nbFields;i++)
5616 int ncomp=MEDfieldnComponent(fid,i+1);
5617 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5618 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5619 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5620 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5621 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5624 MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5625 int ft=MEDFileUtilities::TraduceFieldType(typcha);
5626 std::vector<std::string> infos(ncomp);
5627 for(int j=0;j<ncomp;j++)
5628 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5629 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,nomcha,i+1,ft,infos,nbOfStep);
5631 loadAllGlobals(fid);
5633 catch(INTERP_KERNEL::Exception& e)
5638 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5641 writeGlobals(fid,*this);
5642 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
5644 const MEDFileFieldMultiTSWithoutSDA *elt=*it;
5647 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
5648 throw INTERP_KERNEL::Exception(oss.str().c_str());
5650 elt->writeLL(fid,*this);
5654 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5656 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5657 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5661 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
5663 std::vector<std::string> ret;
5664 std::set<std::string> ret2;
5665 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5667 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
5668 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5669 if(ret2.find(*it2)==ret2.end())
5671 ret.push_back(*it2);
5678 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
5680 std::vector<std::string> ret;
5681 std::set<std::string> ret2;
5682 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5684 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5685 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
5686 if(ret2.find(*it2)==ret2.end())
5688 ret.push_back(*it2);
5695 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
5697 std::vector<std::string> ret;
5698 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5700 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
5701 ret.insert(ret.end(),tmp.begin(),tmp.end());
5706 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
5708 std::vector<std::string> ret;
5709 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
5711 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
5712 ret.insert(ret.end(),tmp.begin(),tmp.end());
5717 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5719 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5720 (*it)->changePflsRefsNamesGen2(mapOfModif);
5723 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5725 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
5726 (*it)->changeLocsRefsNamesGen2(mapOfModif);
5729 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
5731 _fields.resize(newSize);
5734 void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5737 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
5738 _fields.push_back(field->getContent());
5739 appendGlobs(*field,1e-12);
5742 void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
5745 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
5746 if(i>=(int)_fields.size())
5747 _fields.resize(i+1);
5748 _fields[i]=field->getContent();
5749 appendGlobs(*field,1e-12);
5752 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
5754 if(i<0 || i>=(int)_fields.size())
5756 std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5757 throw INTERP_KERNEL::Exception(oss.str().c_str());
5759 _fields.erase(_fields.begin()+i);
5762 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5765 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5767 MEDFileFieldMultiTSWithoutSDA *cur(*it);
5769 ret=cur->changeMeshNames(modifTab) || ret;
5775 * \param [in] meshName the name of the mesh that will be renumbered.
5776 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
5777 * This code corresponds to the distribution of types in the corresponding mesh.
5778 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
5779 * \param [in] renumO2N the old to new renumber array.
5780 * \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
5783 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
5786 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
5788 MEDFileFieldMultiTSWithoutSDA *fmts(*it);
5791 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
5797 MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
5799 if(i<0 || i>=(int)_fields.size())
5801 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
5802 throw INTERP_KERNEL::Exception(oss.str().c_str());
5804 const MEDFileFieldMultiTSWithoutSDA *fmts=_fields[i];
5805 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts,false);
5806 ret->shallowCpyGlobs(*this);
5810 MEDFileFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5812 return getFieldAtPos(getPosFromFieldName(fieldName));
5815 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
5817 return new MEDFileFieldsIterator(this);
5820 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
5822 std::string tmp(fieldName);
5823 std::vector<std::string> poss;
5824 for(std::size_t i=0;i<_fields.size();i++)
5826 const MEDFileFieldMultiTSWithoutSDA *f=_fields[i];
5829 std::string fname(f->getName());
5833 poss.push_back(fname);
5836 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
5837 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
5839 throw INTERP_KERNEL::Exception(oss.str().c_str());
5842 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
5847 _nb_iter=fs->getNumberOfFields();
5851 MEDFileFieldsIterator::~MEDFileFieldsIterator()
5855 MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
5857 if(_iter_id<_nb_iter)
5859 MEDFileFields *fs(_fs);
5861 return fs->getFieldAtPos(_iter_id++);