1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
40 using namespace ParaMEDMEM;
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
47 return new MEDFileFieldLoc(fid,locName);
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
52 return new MEDFileFieldLoc(fid,id);
55 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
57 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
62 med_geometry_type geotype;
63 med_geometry_type sectiongeotype;
65 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
68 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70 _nb_node_per_cell=cm.getNumberOfNodes();
71 _ref_coo.resize(_dim*_nb_node_per_cell);
72 _gs_coo.resize(_dim*_nb_gauss_pt);
73 _w.resize(_nb_gauss_pt);
74 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
79 med_geometry_type geotype;
80 med_geometry_type sectiongeotype;
82 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
87 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89 _nb_node_per_cell=cm.getNumberOfNodes();
90 _ref_coo.resize(_dim*_nb_node_per_cell);
91 _gs_coo.resize(_dim*_nb_gauss_pt);
92 _w.resize(_nb_gauss_pt);
93 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101 _dim=cm.getDimension();
102 _nb_node_per_cell=cm.getNumberOfNodes();
103 _nb_gauss_pt=_w.size();
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
108 return new MEDFileFieldLoc(*this);
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
113 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
118 static const char OFF7[]="\n ";
119 oss << "\"" << _name << "\"" << OFF7;
120 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121 oss << "Dimension=" << _dim << OFF7;
122 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
129 void MEDFileFieldLoc::setName(const char *name)
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
136 if(_name!=other._name)
140 if(_nb_gauss_pt!=other._nb_gauss_pt)
142 if(_nb_node_per_cell!=other._nb_node_per_cell)
144 if(_geo_type!=other._geo_type)
146 if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
148 if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
150 if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
158 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
161 std::string MEDFileFieldLoc::repr() const
163 std::ostringstream oss; oss.precision(15);
164 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
166 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
167 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
168 oss << "\n - Ref coords are : ";
169 int sz=_ref_coo.size();
172 int nbOfTuples=sz/_dim;
173 for(int i=0;i<nbOfTuples;i++)
176 for(int j=0;j<_dim;j++)
177 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
182 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183 oss << "\n - Gauss coords in reference element : ";
187 int nbOfTuples=sz/_dim;
188 for(int i=0;i<nbOfTuples;i++)
191 for(int j=0;j<_dim;j++)
192 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
197 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
204 _type=field->getTypeOfField();
210 getArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211 _end=_start+nbOfCells;
217 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218 const int *arrPtr=arr->getConstPointer();
219 getArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
226 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
230 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233 const int *dai2Ptr=dai2->getConstPointer();
234 int nbi=gsLoc.getWeights().size();
235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237 const int *da3Ptr=da3->getConstPointer();
238 if(da3->getNumberOfTuples()!=nbOfCells)
239 {//profile : for gauss even in NoProfile !!!
240 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
242 da3->setName(_profile.c_str());
243 glob.appendProfile(da3);
245 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246 _nval=da3->getNbOfElems();
247 da4->alloc(_nval*nbi,1);
248 int *da4Ptr=da4->getPointer();
249 for(int i=0;i<_nval;i++)
251 int ref=dai2Ptr[offset+da3Ptr[i]];
252 for(int j=0;j<nbi;j++)
255 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256 _localization=oss2.str();
257 getArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258 _end=_start+_nval*nbi;
259 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
263 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
269 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
271 * \param [in] multiTypePfl is the end user profile specified in high level API
272 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
274 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
280 _type=field->getTypeOfField();
281 std::string pflName(multiTypePfl->getName());
282 std::ostringstream oss; oss << pflName;
283 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288 if(_type!=ON_GAUSS_PT)
290 locIds->setName(oss.str().c_str());
291 glob.appendProfile(locIds);
300 _nval=idsInPfl->getNumberOfTuples();
301 getArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
307 _nval=idsInPfl->getNumberOfTuples();
308 getArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
314 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317 arr3->computeOffsets2();
318 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319 int trueNval=tmp->getNumberOfTuples();
320 _nval=idsInPfl->getNumberOfTuples();
321 getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322 _end=_start+trueNval;
327 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
329 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
336 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
339 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
341 for(const int *pt=da4->begin();pt!=da4->end();pt++)
342 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343 tmp->alloc(trueNval,1);
344 int *tmpPtr=tmp->getPointer();
345 for(const int *pt=da4->begin();pt!=da4->end();pt++)
346 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
349 _nval=da4->getNumberOfTuples();
350 getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351 _end=_start+trueNval;
352 oss << "_loc_" << _loc_id;
355 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356 da5->setName(oss.str().c_str());
357 glob.appendProfile(da5);
362 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
364 da3->setName(oss.str().c_str());
365 glob.appendProfile(da3);
369 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370 _localization=oss2.str();
371 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
375 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
383 _nval=arrr->getNumberOfTuples();
384 getArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
391 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
396 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
401 return new MEDFileFieldPerMeshPerTypePerDisc(other);
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
406 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
411 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
420 catch(INTERP_KERNEL::Exception& e)
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
443 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
445 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447 std::string fieldName=nasc.getName();
448 std::string meshName=getMeshName();
449 int iteration=getIteration();
450 int order=getOrder();
451 TypeOfField type=getType();
452 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
454 med_geometry_type mgeoti;
455 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457 pflname,&profilesize,locname,&nbi);
458 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
461 _end=start+_nval*nbi;
463 if(type==ON_CELLS && !_localization.empty())
465 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466 setType(ON_GAUSS_PT);
469 setType(ON_GAUSS_NE);
470 _localization.clear();
475 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
477 std::string fieldName=nasc.getName();
478 std::string meshName=getMeshName();
479 int iteration=getIteration();
480 int order=getOrder();
481 TypeOfField type=getType();
482 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483 med_geometry_type mgeoti;
484 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
485 DataArray *arr=getArray();
486 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
489 double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents();
490 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
491 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
494 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
497 int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents();
498 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
499 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
502 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
506 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
508 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
510 int delta=_end-_start;
511 _start=newValueOfStart;
515 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
517 return _father->getIteration();
520 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
522 return _father->getOrder();
525 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
527 return _father->getTime();
530 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
532 return _father->getMeshName();
535 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
537 const char startLine[]=" ## ";
538 std::string startLine2(bkOffset,' ');
539 startLine2+=startLine;
540 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
541 oss << startLine2 << "Localization #" << id << "." << std::endl;
542 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
544 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
545 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
546 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
549 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
554 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
559 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
564 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
566 return _father->getGeoType();
569 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
571 return _father->getNumberOfComponents();
574 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
579 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray()
581 return _father->getArray();
584 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
586 const MEDFileFieldPerMeshPerType *fath=_father;
587 return fath->getArray();
590 DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble()
592 return _father->getArrayDouble();
595 const DataArrayDouble *MEDFileFieldPerMeshPerTypePerDisc::getArrayDouble() const
597 const MEDFileFieldPerMeshPerType *fath=_father;
598 return fath->getArrayDouble();
601 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
603 return _father->getInfo();
606 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
611 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
616 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
618 return _localization;
621 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
623 _localization=newLocName;
626 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
628 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
630 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
632 _profile=(*it2).second;
638 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
640 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
642 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
644 _localization=(*it2).second;
650 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
654 dads.push_back(std::pair<int,int>(_start,_end));
655 geoTypes.push_back(getGeoType());
660 pfls.push_back(glob->getProfile(_profile.c_str()));
662 if(_localization.empty())
666 locs.push_back(glob->getLocalizationId(_localization.c_str()));
670 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
672 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
676 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
678 TypeOfField type=getType();
679 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
680 med_geometry_type mgeoti;
681 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
682 const DataArray *arr=getArray();
684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
685 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
686 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
687 const unsigned char *locToWrite=0;
689 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
691 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
693 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
694 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
695 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
699 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
704 dad.first=_start; dad.second=_end;
708 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
709 * This code corresponds to the distribution of types in the corresponding mesh.
710 * \param [out] ptToFill memory zone where the output will be stored.
711 * \return the size of data pushed into output param \a ptToFill
713 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
716 std::ostringstream oss;
717 std::size_t nbOfType=codeOfMesh.size()/3;
719 for(std::size_t i=0;i<nbOfType && found==-1;i++)
720 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
724 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
725 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
726 throw INTERP_KERNEL::Exception(oss.str().c_str());
731 if(_nval!=codeOfMesh[3*found+1])
733 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
734 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
735 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
736 throw INTERP_KERNEL::Exception(oss.str().c_str());
738 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
743 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
744 if(pfl->getNumberOfTuples()!=_nval)
746 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
747 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
749 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
750 throw INTERP_KERNEL::Exception(oss.str().c_str());
752 int offset2=codeOfMesh[3*found+2];
753 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
755 if(*pflId<codeOfMesh[3*found+1])
756 *work++=offset2+*pflId;
762 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
764 for(int i=_start;i<_end;i++)
769 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
780 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
784 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
787 std::map<std::pair<std::string,TypeOfField>,int> m;
788 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
789 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
790 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
791 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
793 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
794 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
799 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
801 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
802 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
803 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
804 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
805 * \param [in,out] glob if necessary by the method, new profiles can be added to it
806 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
807 * \param [out] result All new entries will be appended on it.
808 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
810 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
811 const DataArrayInt *explicitIdsInMesh,
812 const std::vector<int>& newCode,
813 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
814 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
816 if(entriesOnSameDisc.empty())
818 TypeOfField type=entriesOnSameDisc[0]->getType();
819 int szEntities=0,szTuples=0;
820 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
821 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
822 int nbi=szTuples/szEntities;
823 if(szTuples%szEntities!=0)
824 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
825 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
826 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
827 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
828 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
829 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
830 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
831 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
833 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
835 int startOfEltIdOfChunk=(*it)->_start;
836 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
840 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
841 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
843 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
844 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
846 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
847 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
851 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
853 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
854 arrPart->renumberInPlace(renumTupleIds->begin());
855 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
857 const int *idIt=diffVals->begin();
858 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
860 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
862 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
864 int nbEntityElts=subIds->getNumberOfTuples();
866 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
867 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
871 result.push_back(eltToAdd);
872 offset2+=nbEntityElts*nbi;
874 ret=ret || li.empty();
879 * \param [in] typeF type of field of new chunk
880 * \param [in] geoType the geometric type of the chunk
881 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
882 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
883 * \param [in] nbi number of integration points
884 * \param [in] offset The offset in the **global array of data**.
885 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
886 * to the new chunk to create.
887 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
888 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
889 * and corresponding entry erased from \a entriesOnSameDisc.
890 * \return a newly allocated chunk
892 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
893 bool isPfl, int nbi, int offset,
894 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
895 MEDFileFieldGlobsReal& glob,
896 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
898 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
899 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
900 for(;it!=entriesOnSameDisc.end();it++)
902 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
906 if((*it)->_profile.empty())
909 if(!(*it)->_profile.empty())
911 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
912 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
918 if(it==entriesOnSameDisc.end())
921 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
923 ret->_loc_id=(int)geoType;
924 ret->_nval=nbMeshEntities;
926 ret->_end=ret->_start+ret->_nval*nbi;
929 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
930 glob.appendProfile(idsOfMeshElt);
931 ret->_profile=idsOfMeshElt->getName();
933 //tony treatment of localization
939 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
940 ret->_loc_id=(int)geoType;
941 ret->setNewStart(offset);
942 entriesOnSameDisc.erase(it);
948 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
950 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
953 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
955 return new MEDFileFieldPerMeshPerType(fath,geoType);
958 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
960 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
961 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
962 ret+=(*it)->getHeapMemorySize();
966 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
968 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
971 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
973 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
974 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
979 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
981 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
982 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
983 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
987 * This method is the most general one. No optimization is done here.
988 * \param [in] multiTypePfl is the end user profile specified in high level API
989 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
990 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
991 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
992 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
993 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
995 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
997 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
998 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
999 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1002 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1004 _field_pm_pt_pd.resize(1);
1005 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1006 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1009 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1011 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1013 _field_pm_pt_pd.resize(1);
1014 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1015 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1018 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1020 TypeOfField type=field->getTypeOfField();
1021 if(type!=ON_GAUSS_PT)
1023 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1024 int sz=_field_pm_pt_pd.size();
1026 for(int j=0;j<sz && !found;j++)
1028 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1030 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1036 _field_pm_pt_pd.resize(sz+1);
1037 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1039 std::vector<int> ret(1,0);
1044 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1045 int sz2=ret2.size();
1046 std::vector<int> ret3(sz2);
1048 for(int i=0;i<sz2;i++)
1050 int sz=_field_pm_pt_pd.size();
1051 int locIdToFind=ret2[i];
1053 for(int j=0;j<sz && !found;j++)
1055 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1057 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1064 _field_pm_pt_pd.resize(sz+1);
1065 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1073 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1075 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1076 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1078 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1079 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1081 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1082 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1083 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1084 if(retTmp->presenceOfValue(-1))
1085 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1086 std::vector<int> ret(retTmp->begin(),retTmp->end());
1090 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1092 TypeOfField type=field->getTypeOfField();
1093 if(type!=ON_GAUSS_PT)
1095 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1096 int sz=_field_pm_pt_pd.size();
1098 for(int j=0;j<sz && !found;j++)
1100 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1102 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1108 _field_pm_pt_pd.resize(sz+1);
1109 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1111 std::vector<int> ret(1,0);
1116 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1117 int sz2=ret2.size();
1118 std::vector<int> ret3(sz2);
1120 for(int i=0;i<sz2;i++)
1122 int sz=_field_pm_pt_pd.size();
1123 int locIdToFind=ret2[i];
1125 for(int j=0;j<sz && !found;j++)
1127 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1129 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136 _field_pm_pt_pd.resize(sz+1);
1137 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1147 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1148 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1150 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1151 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1153 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1154 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1155 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1156 if(retTmp->presenceOfValue(-1))
1157 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1158 std::vector<int> ret(retTmp->begin(),retTmp->end());
1162 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1167 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1169 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1170 int curDim=(int)cm.getDimension();
1171 dim=std::max(dim,curDim);
1174 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1178 (*it)->fillTypesOfFieldAvailable(types);
1182 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
1184 int sz=_field_pm_pt_pd.size();
1185 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1186 for(int i=0;i<sz;i++)
1188 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1192 int MEDFileFieldPerMeshPerType::getIteration() const
1194 return _father->getIteration();
1197 int MEDFileFieldPerMeshPerType::getOrder() const
1199 return _father->getOrder();
1202 double MEDFileFieldPerMeshPerType::getTime() const
1204 return _father->getTime();
1207 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1209 return _father->getMeshName();
1212 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1214 const char startLine[]=" ## ";
1215 std::string startLine2(bkOffset,' ');
1216 std::string startLine3(startLine2);
1217 startLine3+=startLine;
1218 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1220 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1221 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1224 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1225 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1227 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1229 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1231 cur->simpleRepr(bkOffset,oss,i);
1234 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1239 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1241 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1243 globalSz+=(*it)->getNumberOfTuples();
1245 nbOfEntries+=(int)_field_pm_pt_pd.size();
1248 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1254 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1256 return _father->getNumberOfComponents();
1259 DataArray *MEDFileFieldPerMeshPerType::getArray()
1261 return _father->getArray();
1264 const DataArray *MEDFileFieldPerMeshPerType::getArray() const
1266 const MEDFileFieldPerMesh *fath=_father;
1267 return fath->getArray();
1270 DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble()
1272 return _father->getArrayDouble();
1275 const DataArrayDouble *MEDFileFieldPerMeshPerType::getArrayDouble() const
1277 const MEDFileFieldPerMesh *fath=_father;
1278 return fath->getArrayDouble();
1281 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1283 return _father->getInfo();
1286 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1288 std::vector<std::string> ret;
1289 std::set<std::string> ret2;
1290 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1292 std::string tmp=(*it1)->getProfile();
1294 if(ret2.find(tmp)==ret2.end())
1303 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1305 std::vector<std::string> ret;
1306 std::set<std::string> ret2;
1307 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1309 std::string tmp=(*it1)->getLocalization();
1310 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1311 if(ret2.find(tmp)==ret2.end())
1320 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1322 std::vector<std::string> ret;
1323 std::set<std::string> ret2;
1324 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1326 std::string tmp=(*it1)->getProfile();
1333 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1335 std::vector<std::string> ret;
1336 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1338 std::string tmp=(*it1)->getLocalization();
1339 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1345 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1347 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1348 (*it1)->changePflsRefsNamesGen(mapOfModif);
1351 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1353 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1354 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1357 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1359 if(_field_pm_pt_pd.empty())
1361 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1362 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1363 throw INTERP_KERNEL::Exception(oss.str().c_str());
1365 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1366 return _field_pm_pt_pd[locId];
1367 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1368 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1369 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1370 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1371 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1374 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1376 if(_field_pm_pt_pd.empty())
1378 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1379 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1380 throw INTERP_KERNEL::Exception(oss.str().c_str());
1382 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1383 return _field_pm_pt_pd[locId];
1384 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1385 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1386 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1387 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1388 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1391 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1393 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1395 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1396 if(meshDim!=(int)cm.getDimension())
1399 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1400 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1403 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1406 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1408 (*it)->fillValues(i,startEntryId,entries);
1412 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1414 _field_pm_pt_pd=leaves;
1415 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1416 (*it)->setFather(this);
1419 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1423 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1425 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1426 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1427 med_geometry_type mgeoti;
1428 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1429 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1430 _field_pm_pt_pd.resize(nbProfiles);
1431 for(int i=0;i<nbProfiles;i++)
1433 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1437 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1440 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1442 (*it)->prepareLoading(fid,pflId+1,start,nasc);//tony
1446 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1449 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1451 (*it)->finishLoading(fid,pflId+1,nasc);//tony
1455 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1457 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1459 (*it)->copyOptionsFrom(*this);
1460 (*it)->writeLL(fid,nasc);
1464 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1469 medfGeoType=typmai3[(int)ikGeoType];
1472 medfGeoType=MED_NONE;
1475 medfGeoType=typmai3[(int)ikGeoType];
1476 return MED_NODE_ELEMENT;
1478 medfGeoType=typmai3[(int)ikGeoType];
1481 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1483 return MED_UNDEF_ENTITY_TYPE;
1486 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1488 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1491 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1493 return new MEDFileFieldPerMesh(fath,mesh);
1496 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1498 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1499 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1500 if((const MEDFileFieldPerMeshPerType *)*it)
1501 ret+=(*it)->getHeapMemorySize();
1505 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1507 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1508 ret->_father=father;
1510 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1512 if((const MEDFileFieldPerMeshPerType *)*it)
1513 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1518 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1520 std::string startLine(bkOffset,' ');
1521 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1522 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1524 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1526 const MEDFileFieldPerMeshPerType *cur=*it;
1528 cur->simpleRepr(bkOffset,oss,i);
1531 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1536 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1538 _mesh_name=mesh->getName();
1539 mesh->getTime(_mesh_iteration,_mesh_order);
1542 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1544 int nbOfTypes=code.size()/3;
1546 for(int i=0;i<nbOfTypes;i++)
1548 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1549 int nbOfCells=code[3*i+1];
1550 int pos=addNewEntryIfNecessary(type);
1551 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1557 * This method is the most general one. No optimization is done here.
1558 * \param [in] multiTypePfl is the end user profile specified in high level API
1559 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1560 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1561 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1562 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1563 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1565 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1567 int nbOfTypes=code.size()/3;
1568 for(int i=0;i<nbOfTypes;i++)
1570 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1571 int pos=addNewEntryIfNecessary(type);
1572 DataArrayInt *pfl=0;
1574 pfl=idsPerType[code[3*i+2]];
1575 int nbOfTupes2=code2.size()/3;
1577 for(;found<nbOfTupes2;found++)
1578 if(code[3*i]==code2[3*found])
1580 if(found==nbOfTupes2)
1581 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1582 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1586 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1588 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1589 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1592 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1594 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1595 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1598 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1600 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1601 (*it)->prepareLoading(fid,start,nasc);
1604 void MEDFileFieldPerMesh::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1606 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1607 (*it)->finishLoading(fid,nasc);
1610 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1612 int nbOfTypes=_field_pm_pt.size();
1613 for(int i=0;i<nbOfTypes;i++)
1615 _field_pm_pt[i]->copyOptionsFrom(*this);
1616 _field_pm_pt[i]->writeLL(fid,nasc);
1620 void MEDFileFieldPerMesh::getDimension(int& dim) const
1622 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1623 (*it)->getDimension(dim);
1626 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1628 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1629 (*it)->fillTypesOfFieldAvailable(types);
1632 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const throw(INTERP_KERNEL::Exception)
1634 int sz=_field_pm_pt.size();
1635 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1636 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1637 for(int i=0;i<sz;i++)
1639 types[i]=_field_pm_pt[i]->getGeoType();
1640 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1645 double MEDFileFieldPerMesh::getTime() const
1648 return _father->getTime(tmp1,tmp2);
1651 int MEDFileFieldPerMesh::getIteration() const
1653 return _father->getIteration();
1656 int MEDFileFieldPerMesh::getOrder() const
1658 return _father->getOrder();
1661 int MEDFileFieldPerMesh::getNumberOfComponents() const
1663 return _father->getNumberOfComponents();
1666 DataArray *MEDFileFieldPerMesh::getArray()
1669 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1670 return _father->getOrCreateAndGetArray();
1673 const DataArray *MEDFileFieldPerMesh::getArray() const
1676 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1677 return _father->getOrCreateAndGetArray();
1680 DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble()
1682 MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<MEDFileField1TSWithoutSDA *>(_father);
1684 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
1685 return fatherC->getOrCreateAndGetArrayDouble();
1688 const DataArrayDouble *MEDFileFieldPerMesh::getArrayDouble() const
1690 const MEDFileField1TSWithoutSDA *fatherC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(_father);
1692 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArrayDouble : Expected to be called on double array !");
1693 return fatherC->getOrCreateAndGetArrayDouble();
1696 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1698 return _father->getInfo();
1702 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1703 * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1704 * It returns 2 output vectors :
1705 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1706 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1707 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1709 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1711 int notNullPflsSz=0;
1712 int nbOfArrs=geoTypes.size();
1713 for(int i=0;i<nbOfArrs;i++)
1716 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1717 int nbOfDiffGeoTypes=geoTypes3.size();
1718 code.resize(3*nbOfDiffGeoTypes);
1719 notNullPfls.resize(notNullPflsSz);
1722 for(int i=0;i<nbOfDiffGeoTypes;i++)
1725 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1726 std::vector<const DataArrayInt *> notNullTmp;
1728 notNullTmp.push_back(pfls[j]);
1730 for(;j<nbOfArrs;j++)
1731 if(geoTypes[j]==refType)
1734 notNullTmp.push_back(pfls[j]);
1738 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1739 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1740 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1741 code[3*i]=(int)refType;
1742 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1743 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1744 if(notNullTmp.empty())
1748 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1749 code[3*i+2]=notNullPflsSz++;
1755 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1757 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
1761 for(int i=0;i<sz;i++)
1765 if(type!=ON_GAUSS_NE)
1766 ret+=dads[i].second-dads[i].first;
1769 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1770 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1775 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1776 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1782 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1784 std::vector<std::string> ret;
1785 std::set<std::string> ret2;
1786 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1788 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1789 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1790 if(ret2.find(*it2)==ret2.end())
1792 ret.push_back(*it2);
1799 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1801 std::vector<std::string> ret;
1802 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1805 ret.insert(ret.end(),tmp.begin(),tmp.end());
1810 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1812 std::vector<std::string> ret;
1813 std::set<std::string> ret2;
1814 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1816 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1817 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1818 if(ret2.find(*it2)==ret2.end())
1820 ret.push_back(*it2);
1827 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1829 std::vector<std::string> ret;
1830 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1832 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1833 ret.insert(ret.end(),tmp.begin(),tmp.end());
1838 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1840 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1842 if((*it).first==_mesh_name)
1844 _mesh_name=(*it).second;
1851 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1852 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1854 if(_mesh_name!=meshName)
1856 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1857 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1858 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1859 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1860 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1861 getUndergroundDataArrayExt(entries);
1862 DataArrayDouble *arr=getArrayDouble();
1865 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1866 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1868 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1870 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1871 sz+=(*it).second.second-(*it).second.first;
1874 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1876 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1877 ////////////////////
1878 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1879 int *workI2=explicitIdsOldInMesh->getPointer();
1880 int sz1=0,sz2=0,sid=1;
1881 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1882 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1883 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1885 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1886 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1887 int *workI=explicitIdsOldInArr->getPointer();
1888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1890 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1891 (*itL2)->setLocId(sz2);
1892 (*itL2)->_tmp_work1=(*itL2)->getStart();
1893 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1895 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1897 explicitIdsOldInMesh->reAlloc(sz2);
1898 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1899 ////////////////////
1900 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1901 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1902 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1903 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1905 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1906 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1907 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1909 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1910 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1911 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1913 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1914 int newStart=elt->getLocId();
1915 elt->setLocId((*it)->getGeoType());
1916 elt->setNewStart(newStart);
1917 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1918 entriesKeptNew.push_back(elt);
1919 entriesKeptNew2.push_back(elt);
1921 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1922 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1923 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1924 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1926 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1929 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1931 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1932 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1934 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1935 glob,arr2,otherEntriesNew) || ret;
1939 // Assign new dispatching
1940 assignNewLeaves(otherEntriesNew);
1941 arr->cpyFrom(*arr2);
1945 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1947 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1948 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1949 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1951 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1952 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1953 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1954 for(;it1!=types.end();it1++,it2++)
1956 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1957 elt->setLeaves((*it1).second);
1960 _field_pm_pt=fieldPmPt;
1963 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1965 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1966 (*it)->changePflsRefsNamesGen(mapOfModif);
1969 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1971 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1972 (*it)->changeLocsRefsNamesGen(mapOfModif);
1976 * \param [in] mesh is the whole mesh
1978 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1980 if(_field_pm_pt.empty())
1981 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1983 std::vector< std::pair<int,int> > dads;
1984 std::vector<const DataArrayInt *> pfls;
1985 std::vector<DataArrayInt *> notNullPflsPerGeoType;
1986 std::vector<int> locs,code;
1987 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1988 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1989 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1991 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1994 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1995 throw INTERP_KERNEL::Exception(oss.str().c_str());
1998 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1999 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2002 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2004 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2007 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2008 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2014 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2018 if(nb!=mesh->getNumberOfNodes())
2020 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2021 oss << " nodes in mesh !";
2022 throw INTERP_KERNEL::Exception(oss.str().c_str());
2024 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2027 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2031 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2033 if(_field_pm_pt.empty())
2034 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2036 std::vector<std::pair<int,int> > dads;
2037 std::vector<const DataArrayInt *> pfls;
2038 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2039 std::vector<int> locs,code;
2040 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2041 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2042 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2044 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2047 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2048 throw INTERP_KERNEL::Exception(oss.str().c_str());
2050 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2051 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2054 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2055 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2060 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2064 if(nb!=mesh->getNumberOfNodes())
2066 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2067 oss << " nodes in mesh !";
2068 throw INTERP_KERNEL::Exception(oss.str().c_str());
2071 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2077 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2081 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2083 (*it)->getSizes(globalSz,nbOfEntries);
2085 entries.resize(nbOfEntries);
2087 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2089 (*it)->fillValues(nbOfEntries,entries);
2093 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2095 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2097 if((*it)->getGeoType()==typ)
2098 return (*it)->getLeafGivenLocId(locId);
2100 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2101 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2102 oss << "Possiblities are : ";
2103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2106 oss << "\"" << cm2.getRepr() << "\", ";
2108 throw INTERP_KERNEL::Exception(oss.str().c_str());
2111 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2113 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2115 if((*it)->getGeoType()==typ)
2116 return (*it)->getLeafGivenLocId(locId);
2118 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2119 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2120 oss << "Possiblities are : ";
2121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2124 oss << "\"" << cm2.getRepr() << "\", ";
2126 throw INTERP_KERNEL::Exception(oss.str().c_str());
2129 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2132 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2133 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2134 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2136 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2141 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2146 int ret=std::distance(_field_pm_pt.begin(),it2);
2147 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2152 * 'dads' and 'locs' input parameters have the same number of elements
2153 * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2155 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2156 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2157 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2160 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2161 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2162 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2163 const std::vector<std::string>& infos=getInfo();
2164 da->setInfoOnComponents(infos);
2166 if(type==ON_GAUSS_PT)
2169 int nbOfArrs=dads.size();
2170 for(int i=0;i<nbOfArrs;i++)
2172 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2173 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2174 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2175 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2176 di->alloc(nbOfElems,1);
2178 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2179 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2188 * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2189 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2190 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2191 * The order of cells in the returned field is those imposed by the profile.
2192 * \param [in] mesh is the global mesh.
2194 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2195 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2196 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2197 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2199 if(da->isIdentity())
2201 int nbOfTuples=da->getNumberOfTuples();
2202 if(nbOfTuples==mesh->getNumberOfCells())
2203 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2205 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2206 m2->setName(mesh->getName());
2207 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2213 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2215 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2216 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2217 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2219 if(da->isIdentity())
2221 int nbOfTuples=da->getNumberOfTuples();
2222 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2223 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2225 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2226 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2229 if(meshu->getNodalConnectivity()==0)
2231 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2232 int nb=da->getNbOfElems();
2233 const int *ptr=da->getConstPointer();
2234 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2235 meshuc->allocateCells(nb);
2236 for(int i=0;i<nb;i++)
2237 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2238 meshuc->finishInsertingCells();
2239 ret->setMesh(meshuc);
2240 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2241 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2242 disc->checkCoherencyBetween(meshuc,arrOut);
2247 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2249 DataArrayInt *arr2=0;
2250 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2251 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2252 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2253 int nnodes=mesh2->getNumberOfNodes();
2254 if(nnodes==(int)da->getNbOfElems())
2256 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2257 arrOut->renumberInPlace(da3->getConstPointer());
2258 mesh2->setName(mesh->getName());
2259 ret->setMesh(mesh2);
2264 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2265 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2266 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2267 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2268 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2269 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2270 throw INTERP_KERNEL::Exception(oss.str().c_str());
2276 * This method is the most light method of field retrieving.
2278 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2282 pflOut=DataArrayInt::New();
2283 pflOut->alloc(nbOfElems,1);
2288 pflOut=const_cast<DataArrayInt*>(pflIn);
2291 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2292 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2293 const std::vector<std::string>& infos=getInfo();
2294 int nbOfComp=infos.size();
2295 for(int i=0;i<nbOfComp;i++)
2296 da->setInfoOnComponent(i,infos[i].c_str());
2301 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2302 _mesh_csit(meshCsit),_father(fath)
2304 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2305 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2306 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2307 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2309 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2312 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2313 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2315 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2318 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2319 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2322 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2325 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2326 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2330 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2332 copyTinyInfoFrom(mesh);
2335 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2337 if(id>=(int)_pfls.size())
2339 _pfls[id]=DataArrayInt::New();
2340 int lgth=MEDprofileSizeByName(fid,pflName);
2341 _pfls[id]->setName(pflName);
2342 _pfls[id]->alloc(lgth,1);
2343 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2344 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2347 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2349 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2351 MEDprofileInfo(fid,i+1,pflName,&sz);
2352 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2353 if(i>=(int)_pfls.size())
2355 _pfls[i]=DataArrayInt::New();
2356 _pfls[i]->alloc(sz,1);
2357 _pfls[i]->setName(pflCpp.c_str());
2358 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2359 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2362 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2364 int nbOfPfls=_pfls.size();
2365 for(int i=0;i<nbOfPfls;i++)
2367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2368 cpy->applyLin(1,1,0);
2369 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2370 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2371 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2374 int nbOfLocs=_locs.size();
2375 for(int i=0;i<nbOfLocs;i++)
2376 _locs[i]->writeLL(fid);
2379 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2381 std::vector<std::string> pfls=getPfls();
2382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2384 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2387 _pfls.push_back(*it);
2391 int id=std::distance(pfls.begin(),it2);
2392 if(!(*it)->isEqual(*_pfls[id]))
2394 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2395 throw INTERP_KERNEL::Exception(oss.str().c_str());
2399 std::vector<std::string> locs=getLocs();
2400 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2402 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2405 _locs.push_back(*it);
2409 int id=std::distance(locs.begin(),it2);
2410 if(!(*it)->isEqual(*_locs[id],eps))
2412 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2413 throw INTERP_KERNEL::Exception(oss.str().c_str());
2419 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2421 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2422 getProfile((*it).c_str());
2425 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2427 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2428 getLocalization((*it).c_str());
2431 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2433 std::vector<std::string> profiles=real.getPflsReallyUsed();
2434 int sz=profiles.size();
2436 for(int i=0;i<sz;i++)
2437 loadProfileInFile(fid,i,profiles[i].c_str());
2439 std::vector<std::string> locs=real.getLocsReallyUsed();
2442 for(int i=0;i<sz;i++)
2443 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2446 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2448 int nProfil=MEDnProfile(fid);
2449 for(int i=0;i<nProfil;i++)
2450 loadProfileInFile(fid,i);
2451 int sz=MEDnLocalization(fid);
2453 for(int i=0;i<sz;i++)
2455 _locs[i]=MEDFileFieldLoc::New(fid,i);
2459 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2461 return new MEDFileFieldGlobs(fname);
2464 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2466 return new MEDFileFieldGlobs;
2469 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2471 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2472 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2473 ret+=(*it)->getHeapMemorySize();
2474 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2475 ret+=(*it)->getHeapMemorySize();
2479 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2481 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2483 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2485 if((const DataArrayInt *)*it)
2486 ret->_pfls[i]=(*it)->deepCpy();
2489 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2491 if((const MEDFileFieldLoc*)*it)
2492 ret->_locs[i]=(*it)->deepCpy();
2498 * \throw if a profile in \a pfls in not in \a this.
2499 * \throw if a localization in \a locs in not in \a this.
2500 * \sa MEDFileFieldGlobs::deepCpyPart
2502 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2504 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2505 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2507 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2509 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2511 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2512 ret->_pfls.push_back(pfl2);
2514 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2516 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2518 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2520 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2521 ret->_locs.push_back(loc2);
2523 ret->setFileName(getFileName());
2528 * \throw if a profile in \a pfls in not in \a this.
2529 * \throw if a localization in \a locs in not in \a this.
2530 * \sa MEDFileFieldGlobs::shallowCpyPart
2532 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2534 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2535 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2537 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2539 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2540 ret->_pfls.push_back(pfl->deepCpy());
2542 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2544 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2546 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2547 ret->_locs.push_back(loc->deepCpy());
2549 ret->setFileName(getFileName());
2553 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2557 MEDFileFieldGlobs::MEDFileFieldGlobs()
2561 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2565 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2567 oss << "Profiles :\n";
2568 std::size_t n=_pfls.size();
2569 for(std::size_t i=0;i<n;i++)
2571 oss << " - #" << i << " ";
2572 const DataArrayInt *pfl=_pfls[i];
2574 oss << "\"" << pfl->getName() << "\"\n";
2579 oss << "Localizations :\n";
2580 for(std::size_t i=0;i<n;i++)
2582 oss << " - #" << i << " ";
2583 const MEDFileFieldLoc *loc=_locs[i];
2585 loc->simpleRepr(oss);
2591 void MEDFileFieldGlobs::setFileName(const char *fileName)
2593 _file_name=fileName;
2596 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2598 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2600 DataArrayInt *elt(*it);
2603 std::string name(elt->getName());
2604 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2606 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2608 elt->setName((*it2).second.c_str());
2616 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2618 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2620 MEDFileFieldLoc *elt(*it);
2623 std::string name(elt->getName());
2624 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2626 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2628 elt->setName((*it2).second.c_str());
2636 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2638 if(locId<0 || locId>=(int)_locs.size())
2639 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2640 return _locs[locId]->getNbOfGaussPtPerCell();
2643 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2645 return getLocalizationFromId(getLocalizationId(locName));
2648 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2650 if(locId<0 || locId>=(int)_locs.size())
2651 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2652 return *_locs[locId];
2655 namespace ParaMEDMEMImpl
2660 LocFinder(const char *loc):_loc(loc) { }
2661 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2669 PflFinder(const std::string& pfl):_pfl(pfl) { }
2670 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2672 const std::string& _pfl;
2676 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2678 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2681 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2682 for(it=_locs.begin();it!=_locs.end();it++)
2683 oss << "\"" << (*it)->getName() << "\", ";
2684 throw INTERP_KERNEL::Exception(oss.str().c_str());
2686 return std::distance(_locs.begin(),it);
2690 * The returned value is never null.
2692 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2694 std::string pflNameCpp(pflName);
2695 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2698 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2699 for(it=_pfls.begin();it!=_pfls.end();it++)
2700 oss << "\"" << (*it)->getName() << "\", ";
2701 throw INTERP_KERNEL::Exception(oss.str().c_str());
2706 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2708 if(pflId<0 || pflId>=(int)_pfls.size())
2709 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2710 return _pfls[pflId];
2713 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2715 if(locId<0 || locId>=(int)_locs.size())
2716 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2717 return *_locs[locId];
2720 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2722 return getLocalizationFromId(getLocalizationId(locName));
2726 * The returned value is never null.
2728 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2730 std::string pflNameCpp(pflName);
2731 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2734 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2735 for(it=_pfls.begin();it!=_pfls.end();it++)
2736 oss << "\"" << (*it)->getName() << "\", ";
2737 throw INTERP_KERNEL::Exception(oss.str().c_str());
2742 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2744 if(pflId<0 || pflId>=(int)_pfls.size())
2745 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2746 return _pfls[pflId];
2749 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2751 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2753 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2755 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2756 newPfls.push_back(*it);
2761 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2763 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2765 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2767 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2768 newLocs.push_back(*it);
2773 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2775 int sz=_pfls.size();
2776 std::vector<std::string> ret(sz);
2777 for(int i=0;i<sz;i++)
2778 ret[i]=_pfls[i]->getName();
2782 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2784 int sz=_locs.size();
2785 std::vector<std::string> ret(sz);
2786 for(int i=0;i<sz;i++)
2787 ret[i]=_locs[i]->getName();
2791 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2793 std::vector<std::string> v=getPfls();
2794 std::string s(pflName);
2795 return std::find(v.begin(),v.end(),s)!=v.end();
2798 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2800 std::vector<std::string> v=getLocs();
2801 std::string s(locName);
2802 return std::find(v.begin(),v.end(),s)!=v.end();
2805 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2807 std::map<int,std::vector<int> > m;
2809 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2811 const DataArrayInt *tmp=(*it);
2814 m[tmp->getHashCode()].push_back(i);
2817 std::vector< std::vector<int> > ret;
2818 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2820 if((*it2).second.size()>1)
2822 std::vector<int> ret0;
2823 bool equalityOrNot=false;
2824 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2826 std::vector<int>::const_iterator it4=it3; it4++;
2827 for(;it4!=(*it2).second.end();it4++)
2829 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2832 ret0.push_back(*it3);
2833 ret0.push_back(*it4);
2839 ret.push_back(ret0);
2845 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2847 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2850 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2852 std::string name(pfl->getName());
2854 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2855 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2856 if(name==(*it)->getName())
2858 if(!pfl->isEqual(*(*it)))
2860 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2861 throw INTERP_KERNEL::Exception(oss.str().c_str());
2865 _pfls.push_back(pfl);
2868 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
2870 std::string name(locName);
2872 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2873 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2874 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2875 if((*it)->isName(locName))
2877 if(!(*it)->isEqual(*obj,1e-12))
2879 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2880 throw INTERP_KERNEL::Exception(oss.str().c_str());
2883 _locs.push_back(obj);
2886 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2888 std::vector<std::string> names=getPfls();
2889 return CreateNewNameNotIn("NewPfl_",names);
2892 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2894 std::vector<std::string> names=getLocs();
2895 return CreateNewNameNotIn("NewLoc_",names);
2898 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2900 for(std::size_t sz=0;sz<100000;sz++)
2902 std::ostringstream tryName;
2903 tryName << prefix << sz;
2904 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2905 return tryName.str();
2907 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2911 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2912 * \param [in] fname - the file name.
2914 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2919 * Creates an empty MEDFileFieldGlobsReal.
2921 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2925 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2928 if((const MEDFileFieldGlobs *)_globals)
2929 ret+=_globals->getHeapMemorySize();
2934 * Returns a string describing profiles and Gauss points held in \a this.
2935 * \return std::string - the description string.
2937 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2939 const MEDFileFieldGlobs *glob=_globals;
2940 std::ostringstream oss2; oss2 << glob;
2941 std::string stars(oss2.str().length(),'*');
2942 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2944 glob->simpleRepr(oss);
2946 oss << "NO GLOBAL INFORMATION !\n";
2949 void MEDFileFieldGlobsReal::resetContent()
2951 _globals=MEDFileFieldGlobs::New();
2954 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2959 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2960 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2962 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2964 _globals=other._globals;
2968 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2969 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2971 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2973 const MEDFileFieldGlobs *otherg(other._globals);
2976 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2980 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2981 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2983 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2985 const MEDFileFieldGlobs *otherg(other._globals);
2988 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2991 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2993 _globals=other._globals;
2994 if((const MEDFileFieldGlobs *)_globals)
2995 _globals=other._globals->deepCpy();
2999 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3000 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3001 * \param [in] eps - a precision used to compare Gauss points with same name held by
3002 * \a this and \a other MEDFileFieldGlobsReal.
3003 * \throw If \a this and \a other hold profiles with equal names but different ids.
3004 * \throw If \a this and \a other hold different Gauss points with equal names.
3006 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3008 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3009 if(thisGlobals==otherGlobals)
3013 _globals=other._globals;
3016 _globals->appendGlobs(*other._globals,eps);
3019 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3021 checkGlobsPflsPartCoherency();
3022 checkGlobsLocsPartCoherency();
3025 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3027 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3030 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3032 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3035 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3037 contentNotNull()->loadProfileInFile(fid,id,pflName);
3040 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3042 contentNotNull()->loadProfileInFile(fid,id);
3045 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3047 contentNotNull()->loadGlobals(fid,*this);
3050 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3052 contentNotNull()->loadAllGlobals(fid);
3055 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3057 contentNotNull()->writeGlobals(fid,opt);
3061 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3062 * or getPflsReallyUsedMulti().
3063 * \return std::vector<std::string> - a sequence of names of all profiles.
3065 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3067 return contentNotNull()->getPfls();
3071 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3072 * or getLocsReallyUsedMulti().
3073 * \return std::vector<std::string> - a sequence of names of all localizations.
3075 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3077 return contentNotNull()->getLocs();
3081 * Checks if the profile with a given name exists.
3082 * \param [in] pflName - the profile name of interest.
3083 * \return bool - \c true if the profile named \a pflName exists.
3085 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3087 return contentNotNull()->existsPfl(pflName);
3091 * Checks if the localization with a given name exists.
3092 * \param [in] locName - the localization name of interest.
3093 * \return bool - \c true if the localization named \a locName exists.
3095 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3097 return contentNotNull()->existsLoc(locName);
3100 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3102 return contentNotNull()->createNewNameOfPfl();
3105 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3107 return contentNotNull()->createNewNameOfLoc();
3111 * Sets the name of a MED file.
3112 * \param [inout] fileName - the file name.
3114 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3116 contentNotNull()->setFileName(fileName);
3120 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3121 * in the same order.
3122 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3123 * Each item of this sequence is a vector containing ids of equal profiles.
3125 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3127 return contentNotNull()->whichAreEqualProfiles();
3131 * Finds equal localizations.
3132 * \param [in] eps - a precision used to compare real values of the localizations.
3133 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3134 * Each item of this sequence is a vector containing ids of equal localizations.
3136 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3138 return contentNotNull()->whichAreEqualLocs(eps);
3142 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3143 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3144 * this sequence is a pair whose
3145 * - the first item is a vector of profile names to replace by the second item,
3146 * - the second item is a profile name to replace every profile name of the first item.
3148 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3150 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3154 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3155 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3156 * this sequence is a pair whose
3157 * - the first item is a vector of localization names to replace by the second item,
3158 * - the second item is a localization name to replace every localization name of the first item.
3160 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3162 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3166 * Replaces references to some profiles (a reference is a profile name) by references
3167 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3168 * them-selves accordingly. <br>
3169 * This method is a generalization of changePflName().
3170 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3171 * this sequence is a pair whose
3172 * - the first item is a vector of profile names to replace by the second item,
3173 * - the second item is a profile name to replace every profile of the first item.
3174 * \sa changePflsRefsNamesGen()
3175 * \sa changePflName()
3177 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3179 changePflsRefsNamesGen(mapOfModif);
3180 changePflsNamesInStruct(mapOfModif);
3184 * Replaces references to some localizations (a reference is a localization name) by references
3185 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3186 * them-selves accordingly. <br>
3187 * This method is a generalization of changeLocName().
3188 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3189 * this sequence is a pair whose
3190 * - the first item is a vector of localization names to replace by the second item,
3191 * - the second item is a localization name to replace every localization of the first item.
3192 * \sa changeLocsRefsNamesGen()
3193 * \sa changeLocName()
3195 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3197 changeLocsRefsNamesGen(mapOfModif);
3198 changeLocsNamesInStruct(mapOfModif);
3202 * Renames the profile having a given name and updates references to this profile.
3203 * \param [in] oldName - the name of the profile to rename.
3204 * \param [in] newName - a new name of the profile.
3205 * \sa changePflsNames().
3207 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3209 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3210 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3212 changePflsNames(mapOfModif);
3216 * Renames the localization having a given name and updates references to this localization.
3217 * \param [in] oldName - the name of the localization to rename.
3218 * \param [in] newName - a new name of the localization.
3219 * \sa changeLocsNames().
3221 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3223 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3224 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3226 changeLocsNames(mapOfModif);
3230 * Removes duplicated profiles. Returns a map used to update references to removed
3231 * profiles via changePflsRefsNamesGen().
3232 * Equal profiles are found using whichAreEqualProfiles().
3233 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3234 * a sequence describing the performed replacements of profiles. Each element of
3235 * this sequence is a pair whose
3236 * - the first item is a vector of profile names replaced by the second item,
3237 * - the second item is a profile name replacing every profile of the first item.
3239 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3241 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3242 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3244 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3246 std::vector< std::string > tmp((*it).size());
3248 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3249 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3250 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3252 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3253 killProfileIds(tmp2);
3255 changePflsRefsNamesGen(ret);
3260 * Removes duplicated localizations. Returns a map used to update references to removed
3261 * localizations via changeLocsRefsNamesGen().
3262 * Equal localizations are found using whichAreEqualLocs().
3263 * \param [in] eps - a precision used to compare real values of the localizations.
3264 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3265 * a sequence describing the performed replacements of localizations. Each element of
3266 * this sequence is a pair whose
3267 * - the first item is a vector of localization names replaced by the second item,
3268 * - the second item is a localization name replacing every localization of the first item.
3270 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3272 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3273 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3275 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3277 std::vector< std::string > tmp((*it).size());
3279 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3280 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3281 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3283 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3284 killLocalizationIds(tmp2);
3286 changeLocsRefsNamesGen(ret);
3291 * Returns number of Gauss points per cell in a given localization.
3292 * \param [in] locId - an id of the localization of interest.
3293 * \return int - the number of the Gauss points per cell.
3295 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3297 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3301 * Returns an id of a localization by its name.
3302 * \param [in] loc - the localization name of interest.
3303 * \return int - the id of the localization.
3304 * \throw If there is no a localization named \a loc.
3306 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3308 return contentNotNull()->getLocalizationId(loc);
3312 * Returns the name of the MED file.
3313 * \return const char * - the MED file name.
3315 const char *MEDFileFieldGlobsReal::getFileName() const
3317 return contentNotNull()->getFileName();
3320 std::string MEDFileFieldGlobsReal::getFileName2() const
3322 return contentNotNull()->getFileName2();
3326 * Returns a localization object by its name.
3327 * \param [in] locName - the name of the localization of interest.
3328 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3329 * \throw If there is no a localization named \a locName.
3331 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3333 return contentNotNull()->getLocalization(locName);
3337 * Returns a localization object by its id.
3338 * \param [in] locId - the id of the localization of interest.
3339 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3340 * \throw If there is no a localization with id \a locId.
3342 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3344 return contentNotNull()->getLocalizationFromId(locId);
3348 * Returns a profile array by its name.
3349 * \param [in] pflName - the name of the profile of interest.
3350 * \return const DataArrayInt * - the profile array having the name \a pflName.
3351 * \throw If there is no a profile named \a pflName.
3353 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3355 return contentNotNull()->getProfile(pflName);
3359 * Returns a profile array by its id.
3360 * \param [in] pflId - the id of the profile of interest.
3361 * \return const DataArrayInt * - the profile array having the id \a pflId.
3362 * \throw If there is no a profile with id \a pflId.
3364 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3366 return contentNotNull()->getProfileFromId(pflId);
3370 * Returns a localization object, apt for modification, by its id.
3371 * \param [in] locId - the id of the localization of interest.
3372 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3373 * having the id \a locId.
3374 * \throw If there is no a localization with id \a locId.
3376 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3378 return contentNotNull()->getLocalizationFromId(locId);
3382 * Returns a localization object, apt for modification, by its name.
3383 * \param [in] locName - the name of the localization of interest.
3384 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3385 * having the name \a locName.
3386 * \throw If there is no a localization named \a locName.
3388 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3390 return contentNotNull()->getLocalization(locName);
3394 * Returns a profile array, apt for modification, by its name.
3395 * \param [in] pflName - the name of the profile of interest.
3396 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3397 * \throw If there is no a profile named \a pflName.
3399 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3401 return contentNotNull()->getProfile(pflName);
3405 * Returns a profile array, apt for modification, by its id.
3406 * \param [in] pflId - the id of the profile of interest.
3407 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3408 * \throw If there is no a profile with id \a pflId.
3410 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3412 return contentNotNull()->getProfileFromId(pflId);
3416 * Removes profiles given by their ids. No data is updated to track this removal.
3417 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3419 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3421 contentNotNull()->killProfileIds(pflIds);
3425 * Removes localizations given by their ids. No data is updated to track this removal.
3426 * \param [in] locIds - a sequence of ids of the localizations to remove.
3428 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3430 contentNotNull()->killLocalizationIds(locIds);
3434 * Stores a profile array.
3435 * \param [in] pfl - the profile array to store.
3436 * \throw If the name of \a pfl is empty.
3437 * \throw If a profile with the same name as that of \a pfl already exists but contains
3440 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3442 contentNotNull()->appendProfile(pfl);
3446 * Adds a new localization of Gauss points.
3447 * \param [in] locName - the name of the new localization.
3448 * \param [in] geoType - a geometrical type of the reference cell.
3449 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3450 * must be \c nbOfNodesPerCell * \c dimOfType.
3451 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3452 * must be _wg_.size() * \c dimOfType.
3453 * \param [in] w - the weights of Gauss points.
3454 * \throw If \a locName is empty.
3455 * \throw If a localization with the name \a locName already exists but is
3456 * different form the new one.
3458 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
3460 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3463 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3465 MEDFileFieldGlobs *g(_globals);
3467 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3471 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3473 const MEDFileFieldGlobs *g(_globals);
3475 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3479 //= MEDFileFieldNameScope
3481 MEDFileFieldNameScope::MEDFileFieldNameScope()
3485 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3490 * Returns the name of \a this field.
3491 * \return std::string - a string containing the field name.
3493 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3499 * Sets name of \a this field
3500 * \param [in] name - the new field name.
3502 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3507 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3512 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3517 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3520 _dt_unit=other._dt_unit;
3523 //= MEDFileAnyTypeField1TSWithoutSDA
3526 * Prints a string describing \a this field into a stream. This string is outputted
3527 * by \c print Python command.
3528 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3529 * \param [in,out] oss - the out stream.
3530 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3531 * info id printed, else, not.
3533 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3535 std::string startOfLine(bkOffset,' ');
3536 oss << startOfLine << "Field ";
3538 oss << "[Type=" << getTypeStr() << "] ";
3539 oss << "on One time Step ";
3541 oss << "(" << f1tsId << ") ";
3542 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3543 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3544 const DataArray *arr=getUndergroundDataArray();
3547 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3550 oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3551 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3552 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3553 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3555 if(arr->isAllocated())
3557 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3560 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3564 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3566 oss << startOfLine << "----------------------" << std::endl;
3567 if(!_field_per_mesh.empty())
3570 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3572 const MEDFileFieldPerMesh *cur=(*it2);
3574 cur->simpleRepr(bkOffset,oss,i);
3576 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3581 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3583 oss << startOfLine << "----------------------" << std::endl;
3586 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3588 const DataArray *arr(getUndergroundDataArray());
3590 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3591 int nbOfCompo=arr->getNumberOfComponents();
3592 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3593 for(int i=0;i<nbOfCompo;i++)
3596 std::vector<int> v(1,i);
3597 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3598 ret[i]->setArray(arr2);
3603 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit)
3607 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1)
3612 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3613 * empty. Returns -1 if this in on nodes.
3614 * \return int - the dimension of \a this.
3616 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3619 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3620 (*it)->getDimension(ret);
3625 * Returns the mesh name.
3626 * \return std::string - a string holding the mesh name.
3627 * \throw If \c _field_per_mesh.empty()
3629 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3631 if(_field_per_mesh.empty())
3632 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3633 return _field_per_mesh[0]->getMeshName();
3636 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3638 std::string oldName(getMeshName());
3639 std::vector< std::pair<std::string,std::string> > v(1);
3640 v[0].first=oldName; v[0].second=newMeshName;
3644 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3647 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3649 MEDFileFieldPerMesh *cur(*it);
3651 ret=cur->changeMeshNames(modifTab) || ret;
3657 * Returns the number of iteration of the state of underlying mesh.
3658 * \return int - the iteration number.
3659 * \throw If \c _field_per_mesh.empty()
3661 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3663 if(_field_per_mesh.empty())
3664 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3665 return _field_per_mesh[0]->getMeshIteration();
3669 * Returns the order number of iteration of the state of underlying mesh.
3670 * \return int - the order number.
3671 * \throw If \c _field_per_mesh.empty()
3673 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3675 if(_field_per_mesh.empty())
3676 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3677 return _field_per_mesh[0]->getMeshOrder();
3681 * Checks if \a this field is tagged by a given iteration number and a given
3682 * iteration order number.
3683 * \param [in] iteration - the iteration number of interest.
3684 * \param [in] order - the iteration order number of interest.
3685 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3686 * \a this->getOrder() == \a order.
3688 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3690 return iteration==_iteration && order==_order;
3694 * Returns number of iteration and order number of iteration when
3695 * \a this field has been calculated.
3696 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3699 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3701 std::pair<int,int> p;
3707 * Returns number of iteration and order number of iteration when
3708 * \a this field has been calculated.
3709 * \param [in,out] p - a pair returning the iteration number and the iteration
3712 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3719 * Returns all types of spatial discretization of \a this field.
3720 * \param [in,out] types - a sequence of types of \a this field.
3722 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3724 std::set<TypeOfField> types2;
3725 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3727 (*it)->fillTypesOfFieldAvailable(types2);
3729 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3730 std::copy(types2.begin(),types2.end(),bi);
3734 * Returns all types of spatial discretization of \a this field.
3735 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3738 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3740 std::vector<TypeOfField> ret;
3741 fillTypesOfFieldAvailable(ret);
3745 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3747 std::vector<std::string> ret;
3748 std::set<std::string> ret2;
3749 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3751 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3752 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3753 if(ret2.find(*it2)==ret2.end())
3755 ret.push_back(*it2);
3762 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3764 std::vector<std::string> ret;
3765 std::set<std::string> ret2;
3766 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3768 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3769 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3770 if(ret2.find(*it2)==ret2.end())
3772 ret.push_back(*it2);
3779 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3781 std::vector<std::string> ret;
3782 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3784 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3785 ret.insert(ret.end(),tmp.begin(),tmp.end());
3790 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3792 std::vector<std::string> ret;
3793 std::set<std::string> ret2;
3794 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3796 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3797 ret.insert(ret.end(),tmp.begin(),tmp.end());
3802 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3804 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3805 (*it)->changePflsRefsNamesGen(mapOfModif);
3808 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3810 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3811 (*it)->changeLocsRefsNamesGen(mapOfModif);
3815 * Returns all attributes of parts of \a this field lying on a given mesh.
3816 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3817 * item of every of returned sequences refers to the _i_-th part of \a this field.
3818 * Thus all sequences returned by this method are of the same length equal to number
3819 * of different types of supporting entities.<br>
3820 * A field part can include sub-parts with several different spatial discretizations,
3821 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3822 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3823 * of a nested sequence corresponds to a type of spatial discretization.<br>
3824 * This method allows for iteration over MEDFile DataStructure without any overhead.
3825 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3826 * for the case with only one underlying mesh. (Actually, the number of meshes is
3827 * not checked if \a mname == \c NULL).
3828 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3829 * a field part is returned.
3830 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3831 * This sequence is of the same length as \a types.
3832 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3833 * discretization. A profile name can be empty.
3834 * Length of this and of nested sequences is the same as that of \a typesF.
3835 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3836 * discretization. A localization name can be empty.
3837 * Length of this and of nested sequences is the same as that of \a typesF.
3838 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3839 * of ids of tuples within the data array, per each type of spatial
3840 * discretization within one mesh entity type.
3841 * Length of this and of nested sequences is the same as that of \a typesF.
3842 * \throw If no field is lying on \a mname.
3844 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
3848 meshId=getMeshIdFromMeshName(mname);
3850 if(_field_per_mesh.empty())
3851 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3852 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3856 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3857 * maximal absolute dimension and values returned via the out parameter \a levs are
3858 * dimensions relative to the maximal absolute dimension. <br>
3859 * This method is designed for MEDFileField1TS instances that have a discretization
3860 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3861 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3862 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3863 * Only these 3 discretizations will be taken into account here. If \a this is
3864 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3865 * This method is useful to make the link between the dimension of the underlying mesh
3866 * and the levels of \a this, because it is possible that the highest dimension of \a this
3867 * field is not equal to the dimension of the underlying mesh.
3869 * Let's consider the following case:
3870 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3871 * TETRA4, HEXA8, TRI3 and SEG2.
3872 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3873 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3875 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3876 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3877 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3878 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3879 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3880 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3882 * to retrieve the highest level of
3883 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3884 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3885 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3886 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3887 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3888 * for the case with only one underlying mesh. (Actually, the number of meshes is
3889 * not checked if \a mname == \c NULL).
3890 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3891 * absolute one. They are in decreasing order. This sequence is cleared before
3893 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3894 * \throw If no field is lying on \a mname.
3896 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3899 int meshId=getMeshIdFromMeshName(mname);
3900 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3901 std::vector< std::vector<TypeOfField> > typesF;
3902 std::vector< std::vector<std::string> > pfls, locs;
3903 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3905 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3906 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3907 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3909 st.erase(INTERP_KERNEL::NORM_ERROR);
3911 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3913 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3914 ret1.insert((int)cm.getDimension());
3916 int ret=*std::max_element(ret1.begin(),ret1.end());
3917 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3918 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3923 * \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.
3924 * \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.
3925 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3926 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3928 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3930 int mid=getMeshIdFromMeshName(mName);
3931 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3935 * \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.
3936 * \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.
3937 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3938 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3940 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3942 int mid=getMeshIdFromMeshName(mName);
3943 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3947 * \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.
3949 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3951 if(_field_per_mesh.empty())
3952 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3955 std::string mName2(mName);
3957 std::vector<std::string> msg;
3958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3959 if(mName2==(*it)->getMeshName())
3962 msg.push_back((*it)->getMeshName());
3963 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3964 oss << "Possible meshes are : ";
3965 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3966 oss << "\"" << (*it2) << "\" ";
3967 throw INTERP_KERNEL::Exception(oss.str().c_str());
3970 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3973 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3974 std::string tmp(mesh->getName());
3976 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3977 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3979 for(;it!=_field_per_mesh.end();it++,i++)
3981 if((*it)->getMeshName()==tmp)
3984 int sz=_field_per_mesh.size();
3985 _field_per_mesh.resize(sz+1);
3986 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3990 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3991 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3994 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3996 MEDFileFieldPerMesh *fpm(*it);
3998 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4003 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4005 if(_field_per_mesh.empty())
4006 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4007 if(_field_per_mesh.size()>1)
4008 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4009 _field_per_mesh[0]->copyOptionsFrom(opts);
4010 _field_per_mesh[0]->writeLL(fid,nasc);
4013 void MEDFileAnyTypeField1TSWithoutSDA::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4015 med_int numdt,numit;
4019 med_int meshnumdt,meshnumit;
4020 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4021 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4022 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4023 if(_iteration!=numdt || _order!=numit)
4024 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
4025 _field_per_mesh.resize(nmesh);
4026 for(int i=0;i<nmesh;i++)
4027 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4029 for(int i=0;i<nmesh;i++)
4031 _field_per_mesh[i]->prepareLoading(fid,start,nasc);
4033 getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
4034 for(int i=0;i<nmesh;i++)
4036 _field_per_mesh[i]->finishLoading(fid,nasc);
4040 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4042 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4043 if(getUndergroundDataArray())
4044 ret+=getUndergroundDataArray()->getHeapMemorySize();
4045 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4046 ret+=(*it)->getHeapMemorySize();
4051 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4052 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4053 * "Sort By Type"), if not, an exception is thrown.
4054 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4055 * \param [in] arr - the array of values.
4056 * \param [in,out] glob - the global data where profiles and localization present in
4057 * \a field, if any, are added.
4058 * \throw If the name of \a field is empty.
4059 * \throw If the data array of \a field is not set.
4060 * \throw If \a this->_arr is already allocated but has different number of components
4062 * \throw If the underlying mesh of \a field has no name.
4063 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4065 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4067 const MEDCouplingMesh *mesh=field->getMesh();
4069 TypeOfField type=field->getTypeOfField();
4070 std::vector<DataArrayInt *> dummy;
4071 int start=copyTinyInfoFrom(field,arr);
4072 int pos=addNewEntryIfNecessary(mesh);
4075 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4076 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4079 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4083 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4084 * of a given mesh are used as the support of the given field (a real support is not used).
4085 * Elements of the given mesh must be sorted suitable for writing to MED file.
4086 * Order of underlying mesh entities of the given field specified by \a profile parameter
4087 * is not prescribed; this method permutes field values to have them sorted by element
4088 * type as required for writing to MED file. A new profile is added only if no equal
4089 * profile is missing.
4090 * \param [in] field - the field to add to \a this. The field double values are ignored.
4091 * \param [in] arrOfVals - the values of the field \a field used.
4092 * \param [in] mesh - the supporting mesh of \a field.
4093 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4094 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4095 * \param [in,out] glob - the global data where profiles and localization present in
4096 * \a field, if any, are added.
4097 * \throw If either \a field or \a mesh or \a profile has an empty name.
4098 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4099 * \throw If the data array of \a field is not set.
4100 * \throw If \a this->_arr is already allocated but has different number of components
4102 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4103 * \sa setFieldNoProfileSBT()
4105 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4107 TypeOfField type=field->getTypeOfField();
4108 int start=copyTinyInfoFrom(field,arrOfVals);
4109 std::vector<DataArrayInt *> idsInPflPerType;
4110 std::vector<DataArrayInt *> idsPerType;
4111 std::vector<int> code,code2;
4112 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4115 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4116 code2=m->getDistributionOfTypes();
4118 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4119 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4120 idsInPflPerType2[i]=idsInPflPerType[i];
4121 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4122 for(std::size_t i=0;i<idsPerType.size();i++)
4123 idsPerType2[i]=idsPerType[i];
4125 int pos=addNewEntryIfNecessary(m);
4126 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4130 int pos=addNewEntryIfNecessary(m);
4131 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4136 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4137 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4138 * larger by the size of \a field. Returns an id of the first not filled
4139 * tuple of \a this->_arr.
4140 * \param [in] field - the field to copy the info on components and the name from.
4141 * \return int - the id of first not initialized tuple of \a this->_arr.
4142 * \throw If the name of \a field is empty.
4143 * \throw If the data array of \a field is not set.
4144 * \throw If \a this->_arr is already allocated but has different number of components
4147 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4151 std::string name(field->getName());
4152 setName(name.c_str());
4153 setDtUnit(field->getTimeUnit());
4155 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4157 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4158 _dt=field->getTime(_iteration,_order);
4159 int nbOfComponents=arr->getNumberOfComponents();
4160 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4161 if(!getOrCreateAndGetArray()->isAllocated())
4163 getOrCreateAndGetArray()->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
4168 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4169 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4170 MEDCouplingAutoRefCountObjectPtr<DataArray> tmp=createNewEmptyDataArrayInstance();
4171 tmp->alloc(newNbOfTuples,nbOfComponents);
4172 tmp->copyStringInfoFrom(*getOrCreateAndGetArray());
4173 DataArray *arrr=getOrCreateAndGetArray();
4174 tmp->setContigPartOfSelectedValues2(0,arrr,0,oldNbOfTuples,1);
4176 return oldNbOfTuples;
4181 * Returns number of components in \a this field
4182 * \return int - the number of components.
4184 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4186 return getOrCreateAndGetArray()->getNumberOfComponents();
4190 * Change info on components in \a this.
4191 * \throw If size of \a infos is not equal to the number of components already in \a this.
4193 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4195 DataArray *arr=getOrCreateAndGetArray();
4196 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4200 * Returns info on components of \a this field.
4201 * \return const std::vector<std::string>& - a sequence of strings each being an
4202 * information on _i_-th component.
4204 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4206 const DataArray *arr=getOrCreateAndGetArray();
4207 return arr->getInfoOnComponents();
4211 * Returns a mutable info on components of \a this field.
4212 * \return std::vector<std::string>& - a sequence of strings each being an
4213 * information on _i_-th component.
4215 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4217 DataArray *arr=getOrCreateAndGetArray();
4218 return arr->getInfoOnComponents();
4222 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4223 * \param [in] type - a spatial discretization of the new field.
4224 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4225 * \param [in] mName - a name of the supporting mesh.
4226 * \param [in] renumPol - specifies how to permute values of the result field according to
4227 * the optional numbers of cells and nodes, if any. The valid values are
4228 * - 0 - do not permute.
4229 * - 1 - permute cells.
4230 * - 2 - permute nodes.
4231 * - 3 - permute cells and nodes.
4233 * \param [in] glob - the global data storing profiles and localization.
4234 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4235 * caller is to delete this field using decrRef() as it is no more needed.
4236 * \throw If the MED file is not readable.
4237 * \throw If there is no mesh named \a mName in the MED file.
4238 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4239 * \throw If no field of \a this is lying on the mesh \a mName.
4240 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4242 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4244 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4246 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4248 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4249 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4253 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4254 * \param [in] type - a spatial discretization of the new field.
4255 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4256 * \param [in] renumPol - specifies how to permute values of the result field according to
4257 * the optional numbers of cells and nodes, if any. The valid values are
4258 * - 0 - do not permute.
4259 * - 1 - permute cells.
4260 * - 2 - permute nodes.
4261 * - 3 - permute cells and nodes.
4263 * \param [in] glob - the global data storing profiles and localization.
4264 * \param [in] mesh - the supporting mesh.
4265 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4266 * caller is to delete this field using decrRef() as it is no more needed.
4267 * \throw If the MED file is not readable.
4268 * \throw If no field of \a this is lying on \a mesh.
4269 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4270 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4272 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4274 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4275 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4276 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4277 if(meshDimRelToMax==1)
4278 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4279 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4283 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4285 * \param [in] type - a spatial discretization of the new field.
4286 * \param [in] mName - a name of the supporting mesh.
4287 * \param [in] renumPol - specifies how to permute values of the result field according to
4288 * the optional numbers of cells and nodes, if any. The valid values are
4289 * - 0 - do not permute.
4290 * - 1 - permute cells.
4291 * - 2 - permute nodes.
4292 * - 3 - permute cells and nodes.
4294 * \param [in] glob - the global data storing profiles and localization.
4295 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4296 * caller is to delete this field using decrRef() as it is no more needed.
4297 * \throw If the MED file is not readable.
4298 * \throw If there is no mesh named \a mName in the MED file.
4299 * \throw If there are no mesh entities in the mesh.
4300 * \throw If no field values of the given \a type are available.
4302 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4304 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4306 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4308 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4309 int absDim=getDimension();
4310 int meshDimRelToMax=absDim-mm->getMeshDimension();
4311 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4315 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4316 * \param [in] type - a spatial discretization of the new field.
4317 * \param [in] renumPol - specifies how to permute values of the result field according to
4318 * the optional numbers of cells and nodes, if any. The valid values are
4319 * - 0 - do not permute.
4320 * - 1 - permute cells.
4321 * - 2 - permute nodes.
4322 * - 3 - permute cells and nodes.
4324 * \param [in] glob - the global data storing profiles and localization.
4325 * \param [in] mesh - the supporting mesh.
4326 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4327 * field according to \a renumPol.
4328 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4329 * field according to \a renumPol.
4330 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4331 * caller is to delete this field using decrRef() as it is no more needed.
4332 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4333 * \throw If no field of \a this is lying on \a mesh.
4334 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4336 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4338 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4339 int meshId=getMeshIdFromMeshName(mesh->getName());
4341 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4346 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4353 throw INTERP_KERNEL::Exception(msg1);
4354 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4357 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4359 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4360 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4361 throw INTERP_KERNEL::Exception(oss.str().c_str());
4363 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4364 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4365 std::vector<DataArray *> arrOut2(1,arrOut);
4366 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4367 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4368 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4375 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4377 throw INTERP_KERNEL::Exception(msg1);
4380 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4382 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4383 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4384 throw INTERP_KERNEL::Exception(oss.str().c_str());
4386 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4387 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4388 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4389 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4394 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4399 * Returns values and a profile of the field of a given type lying on a given support.
4400 * \param [in] type - a spatial discretization of the field.
4401 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4402 * \param [in] mesh - the supporting mesh.
4403 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4404 * field of interest lies on. If the field lies on all entities of the given
4405 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4406 * using decrRef() as it is no more needed.
4407 * \param [in] glob - the global data storing profiles and localization.
4408 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4409 * field. The caller is to delete this array using decrRef() as it is no more needed.
4410 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4411 * \throw If no field of \a this is lying on \a mesh.
4412 * \throw If no field values of the given \a type are available.
4414 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4416 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4417 int meshId=getMeshIdFromMeshName(mesh->getName());
4418 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4419 ret->setName(nasc.getName().c_str());
4423 //= MEDFileField1TSWithoutSDA
4426 * Throws if a given value is not a valid (non-extended) relative dimension.
4427 * \param [in] meshDimRelToMax - the relative dimension value.
4428 * \throw If \a meshDimRelToMax > 0.
4430 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4432 if(meshDimRelToMax>0)
4433 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4437 * Checks if elements of a given mesh are in the order suitable for writing
4438 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4439 * vector describing types of elements and their number.
4440 * \param [in] mesh - the mesh to check.
4441 * \return std::vector<int> - a vector holding for each element type (1) item of
4442 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4443 * These values are in full-interlace mode.
4444 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4446 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4449 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4450 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4451 int nbOfTypes=geoTypes.size();
4452 std::vector<int> code(3*nbOfTypes);
4453 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4454 arr1->alloc(nbOfTypes,1);
4455 int *arrPtr=arr1->getPointer();
4456 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4457 for(int i=0;i<nbOfTypes;i++,it++)
4458 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4459 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4460 const int *arrPtr2=arr2->getConstPointer();
4462 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4465 int nbCells=mesh->getNumberOfCellsWithType(*it);
4466 code[3*pos]=(int)(*it);
4467 code[3*pos+1]=nbCells;
4468 code[3*pos+2]=-1;//no profiles
4470 std::vector<const DataArrayInt *> idsPerType;//no profiles
4471 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4475 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4480 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4482 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4486 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4487 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4488 * item of every of returned sequences refers to the _i_-th part of \a this field.
4489 * Thus all sequences returned by this method are of the same length equal to number
4490 * of different types of supporting entities.<br>
4491 * A field part can include sub-parts with several different spatial discretizations,
4492 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4493 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4494 * of a nested sequence corresponds to a type of spatial discretization.<br>
4495 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4496 * The overhead is due to selecting values into new instances of DataArrayDouble.
4497 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4498 * for the case with only one underlying mesh. (Actually, the number of meshes is
4499 * not checked if \a mname == \c NULL).
4500 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4501 * a field part is returned.
4502 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4503 * A field part can include sub-parts with several different spatial discretizations,
4504 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4505 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4506 * This sequence is of the same length as \a types.
4507 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4508 * discretization. A profile name can be empty.
4509 * Length of this and of nested sequences is the same as that of \a typesF.
4510 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4511 * discretization. A localization name can be empty.
4512 * Length of this and of nested sequences is the same as that of \a typesF.
4513 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4514 * per each type of spatial discretization within one mesh entity type.
4515 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4516 * Length of this and of nested sequences is the same as that of \a typesF.
4517 * \throw If no field is lying on \a mname.
4519 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)
4523 meshId=getMeshIdFromMeshName(mname);
4525 if(_field_per_mesh.empty())
4526 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4527 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4528 int nbOfRet=ret0.size();
4529 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4530 for(int i=0;i<nbOfRet;i++)
4532 const std::vector< std::pair<int,int> >& p=ret0[i];
4533 int nbOfRet1=p.size();
4534 ret[i].resize(nbOfRet1);
4535 for(int j=0;j<nbOfRet1;j++)
4537 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4545 * Returns a pointer to the underground DataArrayDouble instance. So the
4546 * caller should not decrRef() it. This method allows for a direct access to the field
4547 * values. This method is quite unusable if there is more than a nodal field or a cell
4548 * field on single geometric cell type.
4549 * \return DataArrayDouble * - the pointer to the field values array.
4551 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4553 const DataArrayDouble *ret=_arr;
4555 return const_cast<DataArrayDouble *>(ret);
4560 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4566 * Returns a pointer to the underground DataArrayDouble instance. So the
4567 * caller should not decrRef() it. This method allows for a direct access to the field
4568 * values. This method is quite unusable if there is more than a nodal field or a cell
4569 * field on single geometric cell type.
4570 * \return DataArrayDouble * - the pointer to the field values array.
4572 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4574 return getUndergroundDataArrayDouble();
4578 * Returns a pointer to the underground DataArrayDouble instance and a
4579 * sequence describing parameters of a support of each part of \a this field. The
4580 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4581 * direct access to the field values. This method is intended for the field lying on one
4583 * \param [in,out] entries - the sequence describing parameters of a support of each
4584 * part of \a this field. Each item of this sequence consists of two parts. The
4585 * first part describes a type of mesh entity and an id of discretization of a
4586 * current field part. The second part describes a range of values [begin,end)
4587 * within the returned array relating to the current field part.
4588 * \return DataArrayDouble * - the pointer to the field values array.
4589 * \throw If the number of underlying meshes is not equal to 1.
4590 * \throw If no field values are available.
4591 * \sa getUndergroundDataArray()
4593 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4595 if(_field_per_mesh.size()!=1)
4596 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4597 if(_field_per_mesh[0]==0)
4598 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4599 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4600 return getUndergroundDataArrayDouble();
4604 * Returns a pointer to the underground DataArrayDouble instance and a
4605 * sequence describing parameters of a support of each part of \a this field. The
4606 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4607 * direct access to the field values. This method is intended for the field lying on one
4609 * \param [in,out] entries - the sequence describing parameters of a support of each
4610 * part of \a this field. Each item of this sequence consists of two parts. The
4611 * first part describes a type of mesh entity and an id of discretization of a
4612 * current field part. The second part describes a range of values [begin,end)
4613 * within the returned array relating to the current field part.
4614 * \return DataArrayDouble * - the pointer to the field values array.
4615 * \throw If the number of underlying meshes is not equal to 1.
4616 * \throw If no field values are available.
4617 * \sa getUndergroundDataArray()
4619 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4621 return getUndergroundDataArrayDoubleExt(entries);
4624 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4625 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4627 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4628 arr->setInfoAndChangeNbOfCompo(infos);
4631 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4635 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4637 return new MEDFileField1TSWithoutSDA(*this);
4640 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4642 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4643 if((const DataArrayDouble *)_arr)
4644 ret->_arr=_arr->deepCpy();
4646 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,i++)
4648 if((const MEDFileFieldPerMesh *)*it)
4649 ret->_field_per_mesh[i]=(*it)->deepCpy((MEDFileField1TSWithoutSDA *)ret);
4654 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4658 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4660 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4665 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4667 return DataArrayDouble::New();
4670 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4672 DataArrayDouble *ret=_arr;
4675 _arr=DataArrayDouble::New();
4679 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4681 return getOrCreateAndGetArrayDouble();
4684 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4686 const DataArrayDouble *ret=_arr;
4689 DataArrayDouble *ret2=DataArrayDouble::New();
4690 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4694 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4696 return getOrCreateAndGetArrayDouble();
4699 //= MEDFileIntField1TSWithoutSDA
4701 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4702 const std::vector<std::string>& infos)
4704 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4707 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4711 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4712 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4714 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4715 arr->setInfoAndChangeNbOfCompo(infos);
4718 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4724 * Returns a pointer to the underground DataArrayInt instance. So the
4725 * caller should not decrRef() it. This method allows for a direct access to the field
4726 * values. This method is quite unusable if there is more than a nodal field or a cell
4727 * field on single geometric cell type.
4728 * \return DataArrayInt * - the pointer to the field values array.
4730 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4732 return getUndergroundDataArrayInt();
4736 * Returns a pointer to the underground DataArrayInt instance. So the
4737 * caller should not decrRef() it. This method allows for a direct access to the field
4738 * values. This method is quite unusable if there is more than a nodal field or a cell
4739 * field on single geometric cell type.
4740 * \return DataArrayInt * - the pointer to the field values array.
4742 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4744 const DataArrayInt *ret=_arr;
4746 return const_cast<DataArrayInt *>(ret);
4752 * Returns a pointer to the underground DataArrayInt instance and a
4753 * sequence describing parameters of a support of each part of \a this field. The
4754 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4755 * direct access to the field values. This method is intended for the field lying on one
4757 * \param [in,out] entries - the sequence describing parameters of a support of each
4758 * part of \a this field. Each item of this sequence consists of two parts. The
4759 * first part describes a type of mesh entity and an id of discretization of a
4760 * current field part. The second part describes a range of values [begin,end)
4761 * within the returned array relating to the current field part.
4762 * \return DataArrayInt * - the pointer to the field values array.
4763 * \throw If the number of underlying meshes is not equal to 1.
4764 * \throw If no field values are available.
4765 * \sa getUndergroundDataArray()
4767 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4769 return getUndergroundDataArrayIntExt(entries);
4773 * Returns a pointer to the underground DataArrayInt instance and a
4774 * sequence describing parameters of a support of each part of \a this field. The
4775 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4776 * direct access to the field values. This method is intended for the field lying on one
4778 * \param [in,out] entries - the sequence describing parameters of a support of each
4779 * part of \a this field. Each item of this sequence consists of two parts. The
4780 * first part describes a type of mesh entity and an id of discretization of a
4781 * current field part. The second part describes a range of values [begin,end)
4782 * within the returned array relating to the current field part.
4783 * \return DataArrayInt * - the pointer to the field values array.
4784 * \throw If the number of underlying meshes is not equal to 1.
4785 * \throw If no field values are available.
4786 * \sa getUndergroundDataArray()
4788 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4790 if(_field_per_mesh.size()!=1)
4791 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4792 if(_field_per_mesh[0]==0)
4793 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4794 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4795 return getUndergroundDataArrayInt();
4798 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4800 return new MEDFileIntField1TSWithoutSDA(*this);
4803 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4805 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4806 if((const DataArrayInt *)_arr)
4807 ret->_arr=_arr->deepCpy();
4809 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,i++)
4811 if((const MEDFileFieldPerMesh *)*it)
4812 ret->_field_per_mesh[i]=(*it)->deepCpy((MEDFileIntField1TSWithoutSDA *)ret);
4817 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4821 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4823 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4827 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4829 return DataArrayInt::New();
4832 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4834 DataArrayInt *ret=_arr;
4837 _arr=DataArrayInt::New();
4841 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4843 return getOrCreateAndGetArrayInt();
4846 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4848 const DataArrayInt *ret=_arr;
4851 DataArrayInt *ret2=DataArrayInt::New();
4852 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4856 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4858 return getOrCreateAndGetArrayInt();
4861 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4865 //= MEDFileAnyTypeField1TS
4867 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
4869 med_field_type typcha;
4871 std::vector<std::string> infos;
4872 std::string dtunit,fieldName;
4873 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4874 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4879 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4884 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4889 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
4890 throw INTERP_KERNEL::Exception(oss.str().c_str());
4893 ret->setDtUnit(dtunit.c_str());
4894 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4896 med_int numdt,numit;
4898 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4899 ret->setTime(numdt,numit,dt);
4901 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4905 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
4906 try:MEDFileFieldGlobsReal(fileName)
4908 MEDFileUtilities::CheckFileForRead(fileName);
4909 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4910 _content=BuildContentFrom(fid,fileName);
4913 catch(INTERP_KERNEL::Exception& e)
4918 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4920 med_field_type typcha;
4921 std::vector<std::string> infos;
4924 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
4925 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4930 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4935 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4940 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
4941 throw INTERP_KERNEL::Exception(oss.str().c_str());
4944 ret->setDtUnit(dtunit.c_str());
4945 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4949 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
4950 throw INTERP_KERNEL::Exception(oss.str().c_str());
4953 med_int numdt,numit;
4955 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
4956 ret->setTime(numdt,numit,dt);
4958 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4962 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4963 try:MEDFileFieldGlobsReal(fileName)
4965 MEDFileUtilities::CheckFileForRead(fileName);
4966 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4967 _content=BuildContentFrom(fid,fileName,fieldName);
4970 catch(INTERP_KERNEL::Exception& e)
4975 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
4978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
4979 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
4981 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
4982 ret->setFileName(fileName);
4983 ret->_content=c; c->incrRef();
4986 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
4988 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
4989 ret->setFileName(fileName);
4990 ret->_content=c; c->incrRef();
4993 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
4996 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4998 MEDFileUtilities::CheckFileForRead(fileName);
4999 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5000 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName);
5001 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5002 ret->loadGlobals(fid);
5006 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5008 MEDFileUtilities::CheckFileForRead(fileName);
5009 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5010 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
5011 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5012 ret->loadGlobals(fid);
5016 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5018 MEDFileUtilities::CheckFileForRead(fileName);
5019 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5020 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5021 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5022 ret->loadGlobals(fid);
5026 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5028 med_field_type typcha;
5029 std::vector<std::string> infos;
5032 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5033 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5038 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5043 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5048 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5049 throw INTERP_KERNEL::Exception(oss.str().c_str());
5052 ret->setDtUnit(dtunit.c_str());
5053 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5056 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5057 for(int i=0;i<nbOfStep2 && !found;i++)
5059 med_int numdt,numit;
5061 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5062 if(numdt==iteration && numit==order)
5068 dtits[i]=std::pair<int,int>(numdt,numit);
5072 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5073 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5074 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5075 throw INTERP_KERNEL::Exception(oss.str().c_str());
5077 ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5081 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5082 try:MEDFileFieldGlobsReal(fileName)
5084 MEDFileUtilities::CheckFileForRead(fileName);
5085 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5086 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5089 catch(INTERP_KERNEL::Exception& e)
5095 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5096 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5098 * \warning this is a shallow copy constructor
5100 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5102 if(!shallowCopyOfContent)
5104 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5105 otherPtr->incrRef();
5106 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5110 _content=other.shallowCpy();
5114 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5118 int nbFields=MEDnField(fid);
5119 if(fieldIdCFormat>=nbFields)
5121 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5122 throw INTERP_KERNEL::Exception(oss.str().c_str());
5125 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5126 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5127 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5128 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5129 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5130 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5133 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5134 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5135 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5136 infos.clear(); infos.resize(ncomp);
5137 for(int j=0;j<ncomp;j++)
5138 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5143 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5146 * \return in case of success the number of time steps available for the field with name \a fieldName.
5148 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5150 int nbFields=MEDnField(fid);
5152 std::vector<std::string> fns(nbFields);
5154 for(int i=0;i<nbFields && !found;i++)
5157 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5159 found=(tmp==fieldName);
5165 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5166 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5167 oss << "\"" << *it << "\" ";
5168 throw INTERP_KERNEL::Exception(oss.str().c_str());
5174 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5175 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5176 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5177 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5178 * to keep a valid instance.
5179 * 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.
5180 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5181 * 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.
5183 * \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.
5184 * \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.
5185 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5186 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5187 * \param [in] newLocName is the new localization name.
5188 * \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.
5189 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5191 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5193 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5194 std::string oldPflName=disc->getProfile();
5195 std::vector<std::string> vv=getPflsReallyUsedMulti();
5196 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5197 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5199 disc->setProfile(newPflName);
5200 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5201 pfl->setName(newPflName);
5205 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5206 throw INTERP_KERNEL::Exception(oss.str().c_str());
5211 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5212 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5213 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5214 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5215 * to keep a valid instance.
5216 * 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.
5217 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5218 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5219 * 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.
5221 * \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.
5222 * \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.
5223 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5224 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5225 * \param [in] newLocName is the new localization name.
5226 * \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.
5227 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5229 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5231 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5232 std::string oldLocName=disc->getLocalization();
5233 std::vector<std::string> vv=getLocsReallyUsedMulti();
5234 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5235 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5237 disc->setLocalization(newLocName);
5238 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5239 loc.setName(newLocName);
5243 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5244 throw INTERP_KERNEL::Exception(oss.str().c_str());
5248 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5250 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5252 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5256 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5258 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5260 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5265 * Writes \a this field into a MED file specified by its name.
5266 * \param [in] fileName - the MED file name.
5267 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5268 * - 2 - erase; an existing file is removed.
5269 * - 1 - append; same data should not be present in an existing file.
5270 * - 0 - overwrite; same data present in an existing file is overwritten.
5271 * \throw If the field name is not set.
5272 * \throw If no field data is set.
5273 * \throw If \a mode == 1 and the same data is present in an existing file.
5275 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5277 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5278 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5282 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5284 int nbComp=getNumberOfComponents();
5285 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5286 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5287 for(int i=0;i<nbComp;i++)
5289 std::string info=getInfo()[i];
5291 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5292 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5293 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5295 if(getName().empty())
5296 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5297 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5298 writeGlobals(fid,*this);
5299 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5302 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5305 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5306 ret+=_content->getHeapMemorySize();
5307 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5311 * Returns a string describing \a this field. This string is outputted
5312 * by \c print Python command.
5314 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5316 std::ostringstream oss;
5317 contentNotNullBase()->simpleRepr(0,oss,-1);
5318 simpleReprGlobs(oss);
5323 * This method returns all profiles whose name is non empty used.
5324 * \b WARNING If profile is used several times it will be reported \b only \b once.
5325 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5327 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5329 return contentNotNullBase()->getPflsReallyUsed2();
5333 * This method returns all localizations whose name is non empty used.
5334 * \b WARNING If localization is used several times it will be reported \b only \b once.
5336 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5338 return contentNotNullBase()->getLocsReallyUsed2();
5342 * This method returns all profiles whose name is non empty used.
5343 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5345 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5347 return contentNotNullBase()->getPflsReallyUsedMulti2();
5351 * This method returns all localizations whose name is non empty used.
5352 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5354 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5356 return contentNotNullBase()->getLocsReallyUsedMulti2();
5359 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5361 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5364 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5366 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5369 int MEDFileAnyTypeField1TS::getDimension() const
5371 return contentNotNullBase()->getDimension();
5374 int MEDFileAnyTypeField1TS::getIteration() const
5376 return contentNotNullBase()->getIteration();
5379 int MEDFileAnyTypeField1TS::getOrder() const
5381 return contentNotNullBase()->getOrder();
5384 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5386 return contentNotNullBase()->getTime(iteration,order);
5389 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5391 contentNotNullBase()->setTime(iteration,order,val);
5394 std::string MEDFileAnyTypeField1TS::getName() const
5396 return contentNotNullBase()->getName();
5399 void MEDFileAnyTypeField1TS::setName(const char *name)
5401 contentNotNullBase()->setName(name);
5404 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5406 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5409 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5411 return contentNotNullBase()->getDtUnit();
5414 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5416 contentNotNullBase()->setDtUnit(dtUnit);
5419 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5421 return contentNotNullBase()->getMeshName();
5424 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5426 contentNotNullBase()->setMeshName(newMeshName);
5429 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5431 return contentNotNullBase()->changeMeshNames(modifTab);
5434 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5436 return contentNotNullBase()->getMeshIteration();
5439 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5441 return contentNotNullBase()->getMeshOrder();
5444 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5446 return contentNotNullBase()->getNumberOfComponents();
5449 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5451 return contentNotNullBase()->isDealingTS(iteration,order);
5454 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5456 return contentNotNullBase()->getDtIt();
5459 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5461 contentNotNullBase()->fillIteration(p);
5464 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5466 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5469 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5471 contentNotNullBase()->setInfo(infos);
5474 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5476 return contentNotNullBase()->getInfo();
5478 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5480 return contentNotNullBase()->getInfo();
5483 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5485 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5488 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5490 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5493 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5495 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5498 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5500 return contentNotNullBase()->getTypesOfFieldAvailable();
5503 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5504 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5506 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5510 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5511 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5512 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5514 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5516 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5518 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5519 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5520 std::size_t sz(contentsSplit.size());
5521 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5522 for(std::size_t i=0;i<sz;i++)
5524 ret[i]=shallowCpy();
5525 ret[i]->_content=contentsSplit[i];
5530 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5532 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5533 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5534 ret->_content=_content->deepCpy();
5535 ret->deepCpyGlobs(*this);
5539 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5541 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5547 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5548 * the first field that has been read from a specified MED file.
5549 * \param [in] fileName - the name of the MED file to read.
5550 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5551 * is to delete this field using decrRef() as it is no more needed.
5552 * \throw If reading the file fails.
5554 MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5556 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName);
5557 ret->contentNotNull();
5562 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5563 * a given field that has been read from a specified MED file.
5564 * \param [in] fileName - the name of the MED file to read.
5565 * \param [in] fieldName - the name of the field to read.
5566 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5567 * is to delete this field using decrRef() as it is no more needed.
5568 * \throw If reading the file fails.
5569 * \throw If there is no field named \a fieldName in the file.
5571 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5573 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName);
5574 ret->contentNotNull();
5579 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5580 * a given field that has been read from a specified MED file.
5581 * \param [in] fileName - the name of the MED file to read.
5582 * \param [in] fieldName - the name of the field to read.
5583 * \param [in] iteration - the iteration number of a required time step.
5584 * \param [in] order - the iteration order number of required time step.
5585 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5586 * is to delete this field using decrRef() as it is no more needed.
5587 * \throw If reading the file fails.
5588 * \throw If there is no field named \a fieldName in the file.
5589 * \throw If the required time step is missing from the file.
5591 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5593 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order);
5594 ret->contentNotNull();
5599 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5600 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5602 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5603 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5604 * \warning this is a shallow copy constructor
5605 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5606 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5607 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5608 * is to delete this field using decrRef() as it is no more needed.
5610 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5612 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5613 ret->contentNotNull();
5618 * Returns a new empty instance of MEDFileField1TS.
5619 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5620 * is to delete this field using decrRef() as it is no more needed.
5622 MEDFileField1TS *MEDFileField1TS::New()
5624 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5625 ret->contentNotNull();
5629 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5631 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5633 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5634 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5636 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5640 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5642 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5644 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5645 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5647 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5651 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5654 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5655 if(!((DataArray*)arr))
5656 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5657 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5659 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5660 f->setArray(arrOutC);
5663 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5665 if(!((DataArray*)arr))
5666 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5667 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5669 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5674 MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
5675 try:MEDFileAnyTypeField1TS(fileName)
5678 catch(INTERP_KERNEL::Exception& e)
5681 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5682 try:MEDFileAnyTypeField1TS(fileName,fieldName)
5685 catch(INTERP_KERNEL::Exception& e)
5688 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5689 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
5692 catch(INTERP_KERNEL::Exception& e)
5696 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5697 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5699 * \warning this is a shallow copy constructor
5701 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5702 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5705 catch(INTERP_KERNEL::Exception& e)
5708 MEDFileField1TS::MEDFileField1TS()
5710 _content=new MEDFileField1TSWithoutSDA;
5714 * Returns a new MEDCouplingFieldDouble of a given type lying on
5715 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
5716 * has not been constructed via file reading, an exception is thrown.
5717 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5718 * \param [in] type - a spatial discretization of interest.
5719 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5720 * \param [in] renumPol - specifies how to permute values of the result field according to
5721 * the optional numbers of cells and nodes, if any. The valid values are
5722 * - 0 - do not permute.
5723 * - 1 - permute cells.
5724 * - 2 - permute nodes.
5725 * - 3 - permute cells and nodes.
5727 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5728 * caller is to delete this field using decrRef() as it is no more needed.
5729 * \throw If \a this field has not been constructed via file reading.
5730 * \throw If the MED file is not readable.
5731 * \throw If there is no mesh in the MED file.
5732 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5733 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5734 * \sa getFieldOnMeshAtLevel()
5736 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5738 if(getFileName2().empty())
5739 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5740 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5741 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5742 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5747 * Returns a new MEDCouplingFieldDouble of a given type lying on
5748 * the top level cells of the first mesh in MED file. If \a this field
5749 * has not been constructed via file reading, an exception is thrown.
5750 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5751 * \param [in] type - a spatial discretization of interest.
5752 * \param [in] renumPol - specifies how to permute values of the result field according to
5753 * the optional numbers of cells and nodes, if any. The valid values are
5754 * - 0 - do not permute.
5755 * - 1 - permute cells.
5756 * - 2 - permute nodes.
5757 * - 3 - permute cells and nodes.
5759 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5760 * caller is to delete this field using decrRef() as it is no more needed.
5761 * \throw If \a this field has not been constructed via file reading.
5762 * \throw If the MED file is not readable.
5763 * \throw If there is no mesh in the MED file.
5764 * \throw If no field values of the given \a type.
5765 * \throw If no field values lying on the top level support.
5766 * \sa getFieldAtLevel()
5768 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5770 if(getFileName2().empty())
5771 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5772 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5773 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5774 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5779 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5780 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5781 * \param [in] type - a spatial discretization of the new field.
5782 * \param [in] mesh - the supporting mesh.
5783 * \param [in] renumPol - specifies how to permute values of the result field according to
5784 * the optional numbers of cells and nodes, if any. The valid values are
5785 * - 0 - do not permute.
5786 * - 1 - permute cells.
5787 * - 2 - permute nodes.
5788 * - 3 - permute cells and nodes.
5790 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5791 * caller is to delete this field using decrRef() as it is no more needed.
5792 * \throw If no field of \a this is lying on \a mesh.
5793 * \throw If the mesh is empty.
5794 * \throw If no field values of the given \a type are available.
5795 * \sa getFieldAtLevel()
5796 * \sa getFieldOnMeshAtLevel()
5798 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5800 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5801 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5802 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5807 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5808 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5809 * \param [in] type - a spatial discretization of interest.
5810 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5811 * \param [in] mesh - the supporting mesh.
5812 * \param [in] renumPol - specifies how to permute values of the result field according to
5813 * the optional numbers of cells and nodes, if any. The valid values are
5814 * - 0 - do not permute.
5815 * - 1 - permute cells.
5816 * - 2 - permute nodes.
5817 * - 3 - permute cells and nodes.
5819 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5820 * caller is to delete this field using decrRef() as it is no more needed.
5821 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5822 * \throw If no field of \a this is lying on \a mesh.
5823 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5824 * \sa getFieldAtLevel()
5825 * \sa getFieldOnMeshAtLevel()
5827 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5829 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5830 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5831 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5836 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5837 * This method is called "Old" because in MED3 norm a field has only one meshName
5838 * attached, so this method is for readers of MED2 files. If \a this field
5839 * has not been constructed via file reading, an exception is thrown.
5840 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5841 * \param [in] type - a spatial discretization of interest.
5842 * \param [in] mName - a name of the supporting mesh.
5843 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5844 * \param [in] renumPol - specifies how to permute values of the result field according to
5845 * the optional numbers of cells and nodes, if any. The valid values are
5846 * - 0 - do not permute.
5847 * - 1 - permute cells.
5848 * - 2 - permute nodes.
5849 * - 3 - permute cells and nodes.
5851 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5852 * caller is to delete this field using decrRef() as it is no more needed.
5853 * \throw If the MED file is not readable.
5854 * \throw If there is no mesh named \a mName in the MED file.
5855 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5856 * \throw If \a this field has not been constructed via file reading.
5857 * \throw If no field of \a this is lying on the mesh named \a mName.
5858 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5859 * \sa getFieldAtLevel()
5861 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5863 if(getFileName2().empty())
5864 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5865 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5866 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
5867 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5872 * Returns values and a profile of the field of a given type lying on a given support.
5873 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5874 * \param [in] type - a spatial discretization of the field.
5875 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5876 * \param [in] mesh - the supporting mesh.
5877 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5878 * field of interest lies on. If the field lies on all entities of the given
5879 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5880 * using decrRef() as it is no more needed.
5881 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5882 * field. The caller is to delete this array using decrRef() as it is no more needed.
5883 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5884 * \throw If no field of \a this is lying on \a mesh.
5885 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5887 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5889 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
5890 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
5894 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5895 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5896 * "Sort By Type"), if not, an exception is thrown.
5897 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5898 * \param [in] field - the field to add to \a this.
5899 * \throw If the name of \a field is empty.
5900 * \throw If the data array of \a field is not set.
5901 * \throw If the data array is already allocated but has different number of components
5903 * \throw If the underlying mesh of \a field has no name.
5904 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5906 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5909 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
5913 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5914 * of a given mesh are used as the support of the given field (a real support is not used).
5915 * Elements of the given mesh must be sorted suitable for writing to MED file.
5916 * Order of underlying mesh entities of the given field specified by \a profile parameter
5917 * is not prescribed; this method permutes field values to have them sorted by element
5918 * type as required for writing to MED file. A new profile is added only if no equal
5919 * profile is missing.
5920 * For more info, see \ref AdvMEDLoaderAPIFieldRW
5921 * \param [in] field - the field to add to \a this.
5922 * \param [in] mesh - the supporting mesh of \a field.
5923 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5924 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
5925 * \throw If either \a field or \a mesh or \a profile has an empty name.
5926 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5927 * \throw If the data array of \a field is not set.
5928 * \throw If the data array of \a this is already allocated but has different number of
5929 * components than \a field.
5930 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5931 * \sa setFieldNoProfileSBT()
5933 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
5936 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
5939 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
5941 return new MEDFileField1TS(*this);
5944 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
5946 return contentNotNull()->getUndergroundDataArrayDouble();
5949 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5951 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
5954 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5955 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5957 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
5960 //= MEDFileIntField1TS
5962 MEDFileIntField1TS *MEDFileIntField1TS::New()
5964 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
5965 ret->contentNotNull();
5969 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5971 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName);
5972 ret->contentNotNull();
5976 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5978 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName);
5979 ret->contentNotNull();
5983 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5985 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order);
5986 ret->contentNotNull();
5990 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
5992 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
5993 ret->contentNotNull();
5997 MEDFileIntField1TS::MEDFileIntField1TS()
5999 _content=new MEDFileIntField1TSWithoutSDA;
6002 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
6003 try:MEDFileAnyTypeField1TS(fileName)
6006 catch(INTERP_KERNEL::Exception& e)
6009 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6010 try:MEDFileAnyTypeField1TS(fileName,fieldName)
6013 catch(INTERP_KERNEL::Exception& e)
6016 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6017 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
6020 catch(INTERP_KERNEL::Exception& e)
6024 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6025 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6027 * \warning this is a shallow copy constructor
6029 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6033 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6035 return new MEDFileIntField1TS(*this);
6039 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6040 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6041 * "Sort By Type"), if not, an exception is thrown.
6042 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6043 * \param [in] field - the field to add to \a this. The field double values are ignored.
6044 * \param [in] arrOfVals - the values of the field \a field used.
6045 * \throw If the name of \a field is empty.
6046 * \throw If the data array of \a field is not set.
6047 * \throw If the data array is already allocated but has different number of components
6049 * \throw If the underlying mesh of \a field has no name.
6050 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6052 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6055 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6059 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6060 * of a given mesh are used as the support of the given field (a real support is not used).
6061 * Elements of the given mesh must be sorted suitable for writing to MED file.
6062 * Order of underlying mesh entities of the given field specified by \a profile parameter
6063 * is not prescribed; this method permutes field values to have them sorted by element
6064 * type as required for writing to MED file. A new profile is added only if no equal
6065 * profile is missing.
6066 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6067 * \param [in] field - the field to add to \a this. The field double values are ignored.
6068 * \param [in] arrOfVals - the values of the field \a field used.
6069 * \param [in] mesh - the supporting mesh of \a field.
6070 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6071 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6072 * \throw If either \a field or \a mesh or \a profile has an empty name.
6073 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6074 * \throw If the data array of \a field is not set.
6075 * \throw If the data array of \a this is already allocated but has different number of
6076 * components than \a field.
6077 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6078 * \sa setFieldNoProfileSBT()
6080 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6083 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6086 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6088 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6090 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6091 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6093 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6097 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6099 if(getFileName2().empty())
6100 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6101 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6102 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6103 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6105 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6110 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6112 if(!((DataArray *)arr))
6113 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6114 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6116 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6122 * Returns a new MEDCouplingFieldDouble of a given type lying on
6123 * the top level cells of the first mesh in MED file. If \a this field
6124 * has not been constructed via file reading, an exception is thrown.
6125 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6126 * \param [in] type - a spatial discretization of interest.
6127 * \param [out] arrOut - the DataArrayInt containing values of field.
6128 * \param [in] renumPol - specifies how to permute values of the result field according to
6129 * the optional numbers of cells and nodes, if any. The valid values are
6130 * - 0 - do not permute.
6131 * - 1 - permute cells.
6132 * - 2 - permute nodes.
6133 * - 3 - permute cells and nodes.
6135 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6136 * caller is to delete this field using decrRef() as it is no more needed.
6137 * \throw If \a this field has not been constructed via file reading.
6138 * \throw If the MED file is not readable.
6139 * \throw If there is no mesh in the MED file.
6140 * \throw If no field values of the given \a type.
6141 * \throw If no field values lying on the top level support.
6142 * \sa getFieldAtLevel()
6144 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6146 if(getFileName2().empty())
6147 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6148 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6149 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6150 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6155 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6156 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6157 * \param [in] type - a spatial discretization of the new field.
6158 * \param [in] mesh - the supporting mesh.
6159 * \param [out] arrOut - the DataArrayInt containing values of field.
6160 * \param [in] renumPol - specifies how to permute values of the result field according to
6161 * the optional numbers of cells and nodes, if any. The valid values are
6162 * - 0 - do not permute.
6163 * - 1 - permute cells.
6164 * - 2 - permute nodes.
6165 * - 3 - permute cells and nodes.
6167 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6168 * caller is to delete this field using decrRef() as it is no more needed.
6169 * \throw If no field of \a this is lying on \a mesh.
6170 * \throw If the mesh is empty.
6171 * \throw If no field values of the given \a type are available.
6172 * \sa getFieldAtLevel()
6173 * \sa getFieldOnMeshAtLevel()
6175 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6177 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6178 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6179 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6184 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6185 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6186 * \param [in] type - a spatial discretization of interest.
6187 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6188 * \param [out] arrOut - the DataArrayInt containing values of field.
6189 * \param [in] mesh - the supporting mesh.
6190 * \param [in] renumPol - specifies how to permute values of the result field according to
6191 * the optional numbers of cells and nodes, if any. The valid values are
6192 * - 0 - do not permute.
6193 * - 1 - permute cells.
6194 * - 2 - permute nodes.
6195 * - 3 - permute cells and nodes.
6197 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6198 * caller is to delete this field using decrRef() as it is no more needed.
6199 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6200 * \throw If no field of \a this is lying on \a mesh.
6201 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6202 * \sa getFieldAtLevel()
6203 * \sa getFieldOnMeshAtLevel()
6205 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6207 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6208 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6209 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6214 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6215 * This method is called "Old" because in MED3 norm a field has only one meshName
6216 * attached, so this method is for readers of MED2 files. If \a this field
6217 * has not been constructed via file reading, an exception is thrown.
6218 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6219 * \param [in] type - a spatial discretization of interest.
6220 * \param [in] mName - a name of the supporting mesh.
6221 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6222 * \param [out] arrOut - the DataArrayInt containing values of field.
6223 * \param [in] renumPol - specifies how to permute values of the result field according to
6224 * the optional numbers of cells and nodes, if any. The valid values are
6225 * - 0 - do not permute.
6226 * - 1 - permute cells.
6227 * - 2 - permute nodes.
6228 * - 3 - permute cells and nodes.
6230 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6231 * caller is to delete this field using decrRef() as it is no more needed.
6232 * \throw If the MED file is not readable.
6233 * \throw If there is no mesh named \a mName in the MED file.
6234 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6235 * \throw If \a this field has not been constructed via file reading.
6236 * \throw If no field of \a this is lying on the mesh named \a mName.
6237 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6238 * \sa getFieldAtLevel()
6240 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6242 if(getFileName2().empty())
6243 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6244 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6245 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6246 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6251 * Returns values and a profile of the field of a given type lying on a given support.
6252 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6253 * \param [in] type - a spatial discretization of the field.
6254 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6255 * \param [in] mesh - the supporting mesh.
6256 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6257 * field of interest lies on. If the field lies on all entities of the given
6258 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6259 * using decrRef() as it is no more needed.
6260 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6261 * field. The caller is to delete this array using decrRef() as it is no more needed.
6262 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6263 * \throw If no field of \a this is lying on \a mesh.
6264 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6266 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6268 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6269 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6272 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6274 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6276 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6277 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6279 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6283 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6285 return contentNotNull()->getUndergroundDataArrayInt();
6288 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6290 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6294 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6299 * \param [in] fieldId field id in C mode
6301 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
6303 med_field_type typcha;
6304 std::string dtunitOut;
6305 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6306 setDtUnit(dtunitOut.c_str());
6307 finishLoading(fid,nbOfStep,typcha);
6310 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
6311 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6313 setDtUnit(dtunit.c_str());
6314 finishLoading(fid,nbOfStep,fieldTyp);
6316 catch(INTERP_KERNEL::Exception& e)
6321 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6323 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6324 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6325 ret+=(*it).capacity();
6326 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6327 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6328 ret+=(*it)->getHeapMemorySize();
6333 * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
6336 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6338 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6339 ret->setInfo(_infos);
6340 int sz=(int)_time_steps.size();
6341 for(const int *id=startIds;id!=endIds;id++)
6343 if(*id>=0 && *id<sz)
6345 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6346 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6350 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6352 ret->pushBackTimeStep(tse2);
6356 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6357 oss << " ! Should be in [0," << sz << ") !";
6358 throw INTERP_KERNEL::Exception(oss.str().c_str());
6361 if(ret->getNumberOfTS()>0)
6362 ret->synchronizeNameScope();
6363 ret->copyNameScope(*this);
6368 * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
6371 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6373 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6374 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6375 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6376 ret->setInfo(_infos);
6377 int sz=(int)_time_steps.size();
6379 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6383 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6384 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6388 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6390 ret->pushBackTimeStep(tse2);
6394 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6395 oss << " ! Should be in [0," << sz << ") !";
6396 throw INTERP_KERNEL::Exception(oss.str().c_str());
6399 if(ret->getNumberOfTS()>0)
6400 ret->synchronizeNameScope();
6401 ret->copyNameScope(*this);
6405 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6408 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6409 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6411 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6414 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6415 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6416 ids->pushBackSilent(id);
6418 return buildFromTimeStepIds(ids->begin(),ids->end());
6421 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6424 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6425 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6427 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6430 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6431 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6432 ids->pushBackSilent(id);
6434 return buildFromTimeStepIds(ids->begin(),ids->end());
6437 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6442 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6447 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6450 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6452 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6453 if(pt->isDealingTS(iteration,order))
6456 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6457 std::vector< std::pair<int,int> > vp=getIterations();
6458 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6459 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6460 throw INTERP_KERNEL::Exception(oss.str().c_str());
6463 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6465 return *_time_steps[getTimeStepPos(iteration,order)];
6468 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6470 return *_time_steps[getTimeStepPos(iteration,order)];
6473 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6475 if(_time_steps.empty())
6476 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6477 return _time_steps[0]->getMeshName();
6480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6482 std::string oldName(getMeshName());
6483 std::vector< std::pair<std::string,std::string> > v(1);
6484 v[0].first=oldName; v[0].second=newMeshName;
6488 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6491 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6493 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6495 ret=cur->changeMeshNames(modifTab) || ret;
6501 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6503 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6505 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6509 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6511 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6513 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6516 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6517 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6520 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6522 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6524 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6529 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6531 std::string startLine(bkOffset,' ');
6532 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6534 oss << " (" << fmtsId << ")";
6535 oss << " has the following name: \"" << _name << "\"." << std::endl;
6536 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6537 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6539 oss << startLine << " - \"" << *it << "\"" << std::endl;
6542 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6544 std::string chapter(17,'0'+i);
6545 oss << startLine << chapter << std::endl;
6546 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6548 cur->simpleRepr(bkOffset+2,oss,i);
6550 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6551 oss << startLine << chapter << std::endl;
6555 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6557 std::size_t sz=_time_steps.size();
6558 std::vector< std::pair<int,int> > ret(sz);
6560 for(std::size_t i=0;i<sz;i++)
6562 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6565 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6569 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6570 throw INTERP_KERNEL::Exception(oss.str().c_str());
6576 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6578 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6580 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6581 checkCoherencyOfType(tse2);
6582 if(_time_steps.empty())
6584 setName(tse2->getName().c_str());
6585 setInfo(tse2->getInfo());
6587 checkThatComponentsMatch(tse2->getInfo());
6588 _time_steps.push_back(tse);
6591 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6593 std::size_t nbOfCompo=_infos.size();
6594 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6596 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6599 if((cur->getInfo()).size()!=nbOfCompo)
6601 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6602 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6603 throw INTERP_KERNEL::Exception(oss.str().c_str());
6605 cur->copyNameScope(*this);
6610 void MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception)
6612 _time_steps.resize(nbPdt);
6613 for(int i=0;i<nbPdt;i++)
6615 std::vector< std::pair<int,int> > ts;
6616 med_int numdt=0,numo=0;
6617 med_int meshIt=0,meshOrder=0;
6619 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6624 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6629 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6633 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading : managed field type are : FLOAT64, INT32 !");
6635 _time_steps[i]->finishLoading(fid,*this);
6639 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6641 if(_time_steps.empty())
6642 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6643 checkThatNbOfCompoOfTSMatchThis();
6644 std::vector<std::string> infos(getInfo());
6645 int nbComp=infos.size();
6646 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6647 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6648 for(int i=0;i<nbComp;i++)
6650 std::string info=infos[i];
6652 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6653 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6654 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6657 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6658 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6659 int nbOfTS=_time_steps.size();
6660 for(int i=0;i<nbOfTS;i++)
6661 _time_steps[i]->writeLL(fid,opts,*this);
6664 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6666 return _time_steps.size();
6669 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6671 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6672 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6674 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6676 newTS.push_back(*it);
6681 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6683 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6684 int maxId=(int)_time_steps.size();
6686 std::set<int> idsToDel;
6687 for(const int *id=startIds;id!=endIds;id++,ii++)
6689 if(*id>=0 && *id<maxId)
6691 idsToDel.insert(*id);
6695 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6696 throw INTERP_KERNEL::Exception(oss.str().c_str());
6699 for(int iii=0;iii<maxId;iii++)
6700 if(idsToDel.find(iii)==idsToDel.end())
6701 newTS.push_back(_time_steps[iii]);
6705 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6707 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6708 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6709 if(nbOfEntriesToKill==0)
6711 std::size_t sz=_time_steps.size();
6712 std::vector<bool> b(sz,true);
6714 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6716 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6717 for(std::size_t i=0;i<sz;i++)
6719 newTS.push_back(_time_steps[i]);
6723 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6726 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
6727 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6729 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6733 tmp->getTime(it2,ord);
6734 if(it2==iteration && order==ord)
6737 oss << "(" << it2 << "," << ord << "), ";
6740 throw INTERP_KERNEL::Exception(oss.str().c_str());
6743 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6746 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6748 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6750 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6754 double ti=tmp->getTime(it2,ord);
6755 if(fabs(time-ti)<eps)
6761 throw INTERP_KERNEL::Exception(oss.str().c_str());
6764 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6766 int lgth=_time_steps.size();
6767 std::vector< std::pair<int,int> > ret(lgth);
6768 for(int i=0;i<lgth;i++)
6769 _time_steps[i]->fillIteration(ret[i]);
6774 * 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'
6775 * This method returns two things.
6776 * - The absolute dimension of 'this' in first parameter.
6777 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
6778 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
6780 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
6781 * Only these 3 discretizations will be taken into account here.
6783 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
6784 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
6785 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
6787 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
6788 * 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'.
6790 * Let's consider the typical following case :
6791 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
6792 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
6793 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
6795 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
6797 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
6799 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
6800 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
6801 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
6802 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
6804 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
6806 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
6809 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
6811 if(pos<0 || pos>=(int)_time_steps.size())
6813 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6814 throw INTERP_KERNEL::Exception(oss.str().c_str());
6816 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6819 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6820 oss << "\nTry to use following method eraseEmptyTS !";
6821 throw INTERP_KERNEL::Exception(oss.str().c_str());
6826 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
6828 if(pos<0 || pos>=(int)_time_steps.size())
6830 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6831 throw INTERP_KERNEL::Exception(oss.str().c_str());
6833 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6836 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6837 oss << "\nTry to use following method eraseEmptyTS !";
6838 throw INTERP_KERNEL::Exception(oss.str().c_str());
6843 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
6845 std::vector<std::string> ret;
6846 std::set<std::string> ret2;
6847 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6849 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
6850 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6851 if(ret2.find(*it2)==ret2.end())
6853 ret.push_back(*it2);
6860 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
6862 std::vector<std::string> ret;
6863 std::set<std::string> ret2;
6864 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6866 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
6867 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6868 if(ret2.find(*it2)==ret2.end())
6870 ret.push_back(*it2);
6877 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
6879 std::vector<std::string> ret;
6880 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6882 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
6883 ret.insert(ret.end(),tmp.begin(),tmp.end());
6888 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
6890 std::vector<std::string> ret;
6891 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6893 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
6894 ret.insert(ret.end(),tmp.begin(),tmp.end());
6899 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6901 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6902 (*it)->changePflsRefsNamesGen2(mapOfModif);
6905 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6907 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6908 (*it)->changeLocsRefsNamesGen2(mapOfModif);
6911 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
6913 int lgth=_time_steps.size();
6914 std::vector< std::vector<TypeOfField> > ret(lgth);
6915 for(int i=0;i<lgth;i++)
6916 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
6921 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
6923 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6925 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
6928 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
6930 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
6932 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6934 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
6935 ret->_time_steps[i]=(*it)->deepCpy();
6940 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
6942 std::size_t sz(_infos.size()),sz2(_time_steps.size());
6943 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
6944 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
6945 for(std::size_t i=0;i<sz;i++)
6947 ret[i]=shallowCpy();
6948 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
6950 for(std::size_t i=0;i<sz2;i++)
6952 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
6955 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
6956 throw INTERP_KERNEL::Exception(oss.str().c_str());
6960 for(std::size_t i=0;i<sz;i++)
6961 for(std::size_t j=0;j<sz2;j++)
6962 ret[i]->_time_steps[j]=ts[j][i];
6966 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
6968 _name=field->getName();
6970 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
6972 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
6973 _infos=arr->getInfoOnComponents();
6976 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
6978 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
6979 if(_name!=field->getName())
6981 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
6982 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
6983 throw INTERP_KERNEL::Exception(oss.str().c_str());
6986 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
6987 checkThatComponentsMatch(arr->getInfoOnComponents());
6990 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
6992 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
6993 if(getInfo().size()!=compos.size())
6995 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
6996 oss << " number of components of element to append (" << compos.size() << ") !";
6997 throw INTERP_KERNEL::Exception(oss.str().c_str());
7001 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7002 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7003 oss << " But compo in input fields are : ";
7004 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7006 throw INTERP_KERNEL::Exception(oss.str().c_str());
7010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7012 std::size_t sz=_infos.size();
7014 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7016 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7018 if(elt->getInfo().size()!=sz)
7020 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7021 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7022 throw INTERP_KERNEL::Exception(oss.str().c_str());
7027 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7030 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7031 if(!_time_steps.empty())
7032 checkCoherencyOfTinyInfo(field,arr);
7033 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7034 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7035 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7036 copyTinyInfoFrom(field,arr);
7037 _time_steps.push_back(obj);
7040 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7043 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7044 if(!_time_steps.empty())
7045 checkCoherencyOfTinyInfo(field,arr);
7046 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7047 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7048 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7049 copyTinyInfoFrom(field,arr);
7050 _time_steps.push_back(obj);
7053 //= MEDFileFieldMultiTSWithoutSDA
7055 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7057 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7060 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7064 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7069 * \param [in] fieldId field id in C mode
7071 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7072 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7075 catch(INTERP_KERNEL::Exception& e)
7078 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7079 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7082 catch(INTERP_KERNEL::Exception& e)
7085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7087 return new MEDFileField1TSWithoutSDA;
7090 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7093 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7094 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7096 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7099 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7101 return MEDFileField1TSWithoutSDA::TYPE_STR;
7104 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7106 return new MEDFileFieldMultiTSWithoutSDA(*this);
7109 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7111 return new MEDFileFieldMultiTSWithoutSDA;
7115 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7116 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7118 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)
7120 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7121 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7123 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7124 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7127 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7131 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
7132 try:MEDFileFieldGlobsReal(fileName)
7134 MEDFileUtilities::CheckFileForRead(fileName);
7135 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7136 _content=BuildContentFrom(fid,fileName);
7139 catch(INTERP_KERNEL::Exception& e)
7144 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7146 med_field_type typcha;
7147 std::vector<std::string> infos;
7150 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7151 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7156 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i);
7161 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i);
7166 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
7167 throw INTERP_KERNEL::Exception(oss.str().c_str());
7170 ret->setDtUnit(dtunit.c_str());
7174 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
7176 med_field_type typcha;
7178 std::vector<std::string> infos;
7179 std::string dtunit,fieldName;
7180 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7181 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7186 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0);
7191 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0);
7196 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
7197 throw INTERP_KERNEL::Exception(oss.str().c_str());
7200 ret->setDtUnit(dtunit.c_str());
7204 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7207 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7208 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7210 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7211 ret->setFileName(fileName);
7212 ret->_content=c; c->incrRef();
7215 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7217 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7218 ret->setFileName(fileName);
7219 ret->_content=c; c->incrRef();
7222 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7225 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7226 try:MEDFileFieldGlobsReal(fileName)
7228 MEDFileUtilities::CheckFileForRead(fileName);
7229 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7230 _content=BuildContentFrom(fid,fileName,fieldName);
7233 catch(INTERP_KERNEL::Exception& e)
7238 //= MEDFileIntFieldMultiTSWithoutSDA
7240 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7242 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7245 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7249 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7253 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7254 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7257 catch(INTERP_KERNEL::Exception& e)
7261 * \param [in] fieldId field id in C mode
7263 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7264 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7267 catch(INTERP_KERNEL::Exception& e)
7270 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7272 return new MEDFileIntField1TSWithoutSDA;
7275 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7278 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7279 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7281 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7284 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7286 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7289 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7291 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7294 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7296 return new MEDFileIntFieldMultiTSWithoutSDA;
7299 //= MEDFileAnyTypeFieldMultiTS
7302 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7303 * that has been read from a specified MED file.
7304 * \param [in] fileName - the name of the MED file to read.
7305 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7306 * is to delete this field using decrRef() as it is no more needed.
7307 * \throw If reading the file fails.
7309 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7311 MEDFileUtilities::CheckFileForRead(fileName);
7312 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7313 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName);
7314 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7315 ret->loadGlobals(fid);
7320 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7321 * that has been read from a specified MED file.
7322 * \param [in] fileName - the name of the MED file to read.
7323 * \param [in] fieldName - the name of the field to read.
7324 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7325 * is to delete this field using decrRef() as it is no more needed.
7326 * \throw If reading the file fails.
7327 * \throw If there is no field named \a fieldName in the file.
7329 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7331 MEDFileUtilities::CheckFileForRead(fileName);
7332 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7333 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
7334 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7335 ret->loadGlobals(fid);
7340 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7341 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7343 * \warning this is a shallow copy constructor
7345 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7347 if(!shallowCopyOfContent)
7349 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7350 otherPtr->incrRef();
7351 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7355 _content=other.shallowCpy();
7359 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7361 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7363 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7367 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7369 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7375 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7377 return contentNotNullBase()->getPflsReallyUsed2();
7380 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7382 return contentNotNullBase()->getLocsReallyUsed2();
7385 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7387 return contentNotNullBase()->getPflsReallyUsedMulti2();
7390 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7392 return contentNotNullBase()->getLocsReallyUsedMulti2();
7395 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7397 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7400 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7402 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7405 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7407 return contentNotNullBase()->getNumberOfTS();
7410 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7412 contentNotNullBase()->eraseEmptyTS();
7415 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7417 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7420 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7422 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7425 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7427 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7428 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7433 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7435 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7436 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7441 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7443 return contentNotNullBase()->getIterations();
7446 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7448 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7449 pushBackTimeStep(*it);
7452 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7455 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7456 checkCoherencyOfType(f1ts);
7458 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7459 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7461 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7462 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7464 _content->pushBackTimeStep(cSafe);
7465 appendGlobs(*f1ts,1e-12);
7468 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7470 contentNotNullBase()->synchronizeNameScope();
7473 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7475 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7478 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7480 return contentNotNullBase()->getPosGivenTime(time,eps);
7483 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7485 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7488 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7490 return contentNotNullBase()->getTypesOfFieldAvailable();
7493 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
7495 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7498 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7500 return contentNotNullBase()->getName();
7503 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7505 contentNotNullBase()->setName(name);
7508 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7510 return contentNotNullBase()->getDtUnit();
7513 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7515 contentNotNullBase()->setDtUnit(dtUnit);
7518 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7520 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7523 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7525 return contentNotNullBase()->getTimeSteps(ret1);
7528 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7530 return contentNotNullBase()->getMeshName();
7533 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7535 contentNotNullBase()->setMeshName(newMeshName);
7538 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7540 return contentNotNullBase()->changeMeshNames(modifTab);
7543 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7545 return contentNotNullBase()->getInfo();
7548 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7550 return contentNotNullBase()->setInfo(info);
7553 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7555 const std::vector<std::string> ret=getInfo();
7556 return (int)ret.size();
7559 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7561 writeGlobals(fid,*this);
7562 contentNotNullBase()->writeLL(fid,*this);
7566 * Writes \a this field into a MED file specified by its name.
7567 * \param [in] fileName - the MED file name.
7568 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7569 * - 2 - erase; an existing file is removed.
7570 * - 1 - append; same data should not be present in an existing file.
7571 * - 0 - overwrite; same data present in an existing file is overwritten.
7572 * \throw If the field name is not set.
7573 * \throw If no field data is set.
7574 * \throw If \a mode == 1 and the same data is present in an existing file.
7576 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7578 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7579 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7583 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7585 std::ostringstream oss;
7586 contentNotNullBase()->simpleRepr(0,oss,-1);
7587 simpleReprGlobs(oss);
7591 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7594 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7595 ret+=_content->getHeapMemorySize();
7596 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7600 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
7601 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7602 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7604 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7606 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7608 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7609 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7610 std::size_t sz(contentsSplit.size());
7611 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7612 for(std::size_t i=0;i<sz;i++)
7614 ret[i]=shallowCpy();
7615 ret[i]->_content=contentsSplit[i];
7620 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7622 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7623 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7624 ret->_content=_content->deepCpy();
7625 ret->deepCpyGlobs(*this);
7629 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7635 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7636 * \param [in] iteration - the iteration number of a required time step.
7637 * \param [in] order - the iteration order number of required time step.
7638 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7639 * delete this field using decrRef() as it is no more needed.
7640 * \throw If there is no required time step in \a this field.
7642 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7644 int pos=getPosOfTimeStep(iteration,order);
7645 return getTimeStepAtPos(pos);
7649 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7650 * \param [in] time - the time of the time step of interest.
7651 * \param [in] eps - a precision used to compare time values.
7652 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7653 * delete this field using decrRef() as it is no more needed.
7654 * \throw If there is no required time step in \a this field.
7656 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7658 int pos=getPosGivenTime(time,eps);
7659 return getTimeStepAtPos(pos);
7662 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7664 return new MEDFileAnyTypeFieldMultiTSIterator(this);
7667 //= MEDFileFieldMultiTS
7670 * Returns a new empty instance of MEDFileFieldMultiTS.
7671 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7672 * is to delete this field using decrRef() as it is no more needed.
7674 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
7676 return new MEDFileFieldMultiTS;
7680 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
7681 * that has been read from a specified MED file.
7682 * \param [in] fileName - the name of the MED file to read.
7683 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7684 * is to delete this field using decrRef() as it is no more needed.
7685 * \throw If reading the file fails.
7687 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7689 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName);
7690 ret->contentNotNull();//to check that content type matches with \a this type.
7695 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
7696 * that has been read from a specified MED file.
7697 * \param [in] fileName - the name of the MED file to read.
7698 * \param [in] fieldName - the name of the field to read.
7699 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7700 * is to delete this field using decrRef() as it is no more needed.
7701 * \throw If reading the file fails.
7702 * \throw If there is no field named \a fieldName in the file.
7704 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7706 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName);
7707 ret->contentNotNull();//to check that content type matches with \a this type.
7712 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7713 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7715 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
7716 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
7717 * \warning this is a shallow copy constructor
7718 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
7719 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
7720 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7721 * is to delete this field using decrRef() as it is no more needed.
7723 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7725 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
7728 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
7730 return new MEDFileFieldMultiTS(*this);
7733 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
7736 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7737 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
7739 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7743 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
7744 * \param [in] pos - a time step id.
7745 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7746 * delete this field using decrRef() as it is no more needed.
7747 * \throw If \a pos is not a valid time step id.
7749 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
7751 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
7754 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
7755 throw INTERP_KERNEL::Exception(oss.str().c_str());
7757 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
7760 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
7761 ret->shallowCpyGlobs(*this);
7764 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
7765 throw INTERP_KERNEL::Exception(oss.str().c_str());
7769 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7770 * mesh entities of a given dimension of the first mesh in MED file.
7771 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7772 * \param [in] type - a spatial discretization of interest.
7773 * \param [in] iteration - the iteration number of a required time step.
7774 * \param [in] order - the iteration order number of required time step.
7775 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7776 * \param [in] renumPol - specifies how to permute values of the result field according to
7777 * the optional numbers of cells and nodes, if any. The valid values are
7778 * - 0 - do not permute.
7779 * - 1 - permute cells.
7780 * - 2 - permute nodes.
7781 * - 3 - permute cells and nodes.
7783 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7784 * caller is to delete this field using decrRef() as it is no more needed.
7785 * \throw If the MED file is not readable.
7786 * \throw If there is no mesh in the MED file.
7787 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7788 * \throw If no field values of the required parameters are available.
7790 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7792 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7793 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7795 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
7796 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7797 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
7798 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7803 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7804 * the top level cells of the first mesh in MED file.
7805 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7806 * \param [in] type - a spatial discretization of interest.
7807 * \param [in] iteration - the iteration number of a required time step.
7808 * \param [in] order - the iteration order number of required time step.
7809 * \param [in] renumPol - specifies how to permute values of the result field according to
7810 * the optional numbers of cells and nodes, if any. The valid values are
7811 * - 0 - do not permute.
7812 * - 1 - permute cells.
7813 * - 2 - permute nodes.
7814 * - 3 - permute cells and nodes.
7816 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7817 * caller is to delete this field using decrRef() as it is no more needed.
7818 * \throw If the MED file is not readable.
7819 * \throw If there is no mesh in the MED file.
7820 * \throw If no field values of the required parameters are available.
7822 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
7824 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7825 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7827 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
7828 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7829 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
7830 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7835 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7837 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7838 * \param [in] type - a spatial discretization of interest.
7839 * \param [in] iteration - the iteration number of a required time step.
7840 * \param [in] order - the iteration order number of required time step.
7841 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7842 * \param [in] mesh - the supporting mesh.
7843 * \param [in] renumPol - specifies how to permute values of the result field according to
7844 * the optional numbers of cells and nodes, if any. The valid values are
7845 * - 0 - do not permute.
7846 * - 1 - permute cells.
7847 * - 2 - permute nodes.
7848 * - 3 - permute cells and nodes.
7850 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7851 * caller is to delete this field using decrRef() as it is no more needed.
7852 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7853 * \throw If no field of \a this is lying on \a mesh.
7854 * \throw If no field values of the required parameters are available.
7856 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
7858 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7859 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7861 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
7862 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7863 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
7864 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7869 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
7871 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7872 * \param [in] type - a spatial discretization of the new field.
7873 * \param [in] iteration - the iteration number of a required time step.
7874 * \param [in] order - the iteration order number of required time step.
7875 * \param [in] mesh - the supporting mesh.
7876 * \param [in] renumPol - specifies how to permute values of the result field according to
7877 * the optional numbers of cells and nodes, if any. The valid values are
7878 * - 0 - do not permute.
7879 * - 1 - permute cells.
7880 * - 2 - permute nodes.
7881 * - 3 - permute cells and nodes.
7883 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7884 * caller is to delete this field using decrRef() as it is no more needed.
7885 * \throw If no field of \a this is lying on \a mesh.
7886 * \throw If no field values of the required parameters are available.
7888 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
7890 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7891 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7893 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
7894 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7895 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
7896 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7901 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
7902 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
7903 * This method is useful for MED2 file format when field on different mesh was autorized.
7905 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7907 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7908 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7910 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
7911 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7912 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
7913 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7918 * Returns values and a profile of the field of a given type, of a given time step,
7919 * lying on a given support.
7920 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7921 * \param [in] type - a spatial discretization of the field.
7922 * \param [in] iteration - the iteration number of a required time step.
7923 * \param [in] order - the iteration order number of required time step.
7924 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7925 * \param [in] mesh - the supporting mesh.
7926 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7927 * field of interest lies on. If the field lies on all entities of the given
7928 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7929 * using decrRef() as it is no more needed.
7930 * \param [in] glob - the global data storing profiles and localization.
7931 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7932 * field. The caller is to delete this array using decrRef() as it is no more needed.
7933 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7934 * \throw If no field of \a this is lying on \a mesh.
7935 * \throw If no field values of the required parameters are available.
7937 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
7939 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7940 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7942 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
7943 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
7944 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7947 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
7949 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
7951 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
7952 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
7954 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
7958 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
7960 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
7962 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
7963 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
7965 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
7970 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
7971 * the given field is checked if its elements are sorted suitable for writing to MED file
7972 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
7973 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7974 * \param [in] field - the field to add to \a this.
7975 * \throw If the name of \a field is empty.
7976 * \throw If the data array of \a field is not set.
7977 * \throw If existing time steps have different name or number of components than \a field.
7978 * \throw If the underlying mesh of \a field has no name.
7979 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7981 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
7983 const DataArrayDouble *arr=0;
7985 arr=field->getArray();
7986 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
7990 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
7991 * a given dimension of a given mesh are used as the support of the given field.
7992 * Elements of the given mesh must be sorted suitable for writing to MED file.
7993 * Order of underlying mesh entities of the given field specified by \a profile parameter
7994 * is not prescribed; this method permutes field values to have them sorted by element
7995 * type as required for writing to MED file.
7996 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7997 * \param [in] field - the field to add to \a this.
7998 * \param [in] mesh - the supporting mesh of \a field.
7999 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8000 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8001 * \throw If either \a field or \a mesh or \a profile has an empty name.
8002 * \throw If existing time steps have different name or number of components than \a field.
8003 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8004 * \throw If the data array of \a field is not set.
8005 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8007 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8009 const DataArrayDouble *arr=0;
8011 arr=field->getArray();
8012 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8015 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8017 _content=new MEDFileFieldMultiTSWithoutSDA;
8020 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8021 try:MEDFileAnyTypeFieldMultiTS(fileName)
8024 catch(INTERP_KERNEL::Exception& e)
8027 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8028 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8031 catch(INTERP_KERNEL::Exception& e)
8034 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8038 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)
8040 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8043 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8045 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8048 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)
8050 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8053 //= MEDFileAnyTypeFieldMultiTSIterator
8055 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8060 _nb_iter=fmts->getNumberOfTS();
8064 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8068 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8070 if(_iter_id<_nb_iter)
8072 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8074 return fmts->getTimeStepAtPos(_iter_id++);
8082 //= MEDFileIntFieldMultiTS
8085 * Returns a new empty instance of MEDFileFieldMultiTS.
8086 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8087 * is to delete this field using decrRef() as it is no more needed.
8089 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8091 return new MEDFileIntFieldMultiTS;
8095 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8096 * that has been read from a specified MED file.
8097 * \param [in] fileName - the name of the MED file to read.
8098 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8099 * is to delete this field using decrRef() as it is no more needed.
8100 * \throw If reading the file fails.
8102 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8104 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName);
8105 ret->contentNotNull();//to check that content type matches with \a this type.
8110 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8111 * that has been read from a specified MED file.
8112 * \param [in] fileName - the name of the MED file to read.
8113 * \param [in] fieldName - the name of the field to read.
8114 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8115 * is to delete this field using decrRef() as it is no more needed.
8116 * \throw If reading the file fails.
8117 * \throw If there is no field named \a fieldName in the file.
8119 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8121 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName);
8122 ret->contentNotNull();//to check that content type matches with \a this type.
8127 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8128 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8130 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8131 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8132 * \warning this is a shallow copy constructor
8133 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8134 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8135 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8136 * is to delete this field using decrRef() as it is no more needed.
8138 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8140 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8143 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8145 return new MEDFileIntFieldMultiTS(*this);
8148 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8151 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8152 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8154 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8158 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8159 * mesh entities of a given dimension of the first mesh in MED file.
8160 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8161 * \param [in] type - a spatial discretization of interest.
8162 * \param [in] iteration - the iteration number of a required time step.
8163 * \param [in] order - the iteration order number of required time step.
8164 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8165 * \param [out] arrOut - the DataArrayInt containing values of field.
8166 * \param [in] renumPol - specifies how to permute values of the result field according to
8167 * the optional numbers of cells and nodes, if any. The valid values are
8168 * - 0 - do not permute.
8169 * - 1 - permute cells.
8170 * - 2 - permute nodes.
8171 * - 3 - permute cells and nodes.
8173 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8174 * caller is to delete this field using decrRef() as it is no more needed.
8175 * \throw If the MED file is not readable.
8176 * \throw If there is no mesh in the MED file.
8177 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8178 * \throw If no field values of the required parameters are available.
8180 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8182 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8183 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8185 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8186 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8187 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8188 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8193 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8194 * the top level cells of the first mesh in MED file.
8195 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8196 * \param [in] type - a spatial discretization of interest.
8197 * \param [in] iteration - the iteration number of a required time step.
8198 * \param [in] order - the iteration order number of required time step.
8199 * \param [out] arrOut - the DataArrayInt containing values of field.
8200 * \param [in] renumPol - specifies how to permute values of the result field according to
8201 * the optional numbers of cells and nodes, if any. The valid values are
8202 * - 0 - do not permute.
8203 * - 1 - permute cells.
8204 * - 2 - permute nodes.
8205 * - 3 - permute cells and nodes.
8207 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8208 * caller is to delete this field using decrRef() as it is no more needed.
8209 * \throw If the MED file is not readable.
8210 * \throw If there is no mesh in the MED file.
8211 * \throw If no field values of the required parameters are available.
8213 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8215 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8216 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8218 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8219 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8220 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8221 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8226 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8228 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8229 * \param [in] type - a spatial discretization of interest.
8230 * \param [in] iteration - the iteration number of a required time step.
8231 * \param [in] order - the iteration order number of required time step.
8232 * \param [out] arrOut - the DataArrayInt containing values of field.
8233 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8234 * \param [in] mesh - the supporting mesh.
8235 * \param [in] renumPol - specifies how to permute values of the result field according to
8236 * the optional numbers of cells and nodes, if any. The valid values are
8237 * - 0 - do not permute.
8238 * - 1 - permute cells.
8239 * - 2 - permute nodes.
8240 * - 3 - permute cells and nodes.
8242 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8243 * caller is to delete this field using decrRef() as it is no more needed.
8244 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8245 * \throw If no field of \a this is lying on \a mesh.
8246 * \throw If no field values of the required parameters are available.
8248 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8250 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8251 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8253 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8254 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8255 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8256 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8261 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8263 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8264 * \param [in] type - a spatial discretization of the new field.
8265 * \param [in] iteration - the iteration number of a required time step.
8266 * \param [in] order - the iteration order number of required time step.
8267 * \param [in] mesh - the supporting mesh.
8268 * \param [out] arrOut - the DataArrayInt containing values of field.
8269 * \param [in] renumPol - specifies how to permute values of the result field according to
8270 * the optional numbers of cells and nodes, if any. The valid values are
8271 * - 0 - do not permute.
8272 * - 1 - permute cells.
8273 * - 2 - permute nodes.
8274 * - 3 - permute cells and nodes.
8276 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8277 * caller is to delete this field using decrRef() as it is no more needed.
8278 * \throw If no field of \a this is lying on \a mesh.
8279 * \throw If no field values of the required parameters are available.
8281 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8283 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8284 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8286 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8287 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8288 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8289 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8294 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8295 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8296 * This method is useful for MED2 file format when field on different mesh was autorized.
8298 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8300 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8301 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8303 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8304 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8305 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8306 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8311 * Returns values and a profile of the field of a given type, of a given time step,
8312 * lying on a given support.
8313 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8314 * \param [in] type - a spatial discretization of the field.
8315 * \param [in] iteration - the iteration number of a required time step.
8316 * \param [in] order - the iteration order number of required time step.
8317 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8318 * \param [in] mesh - the supporting mesh.
8319 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8320 * field of interest lies on. If the field lies on all entities of the given
8321 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8322 * using decrRef() as it is no more needed.
8323 * \param [in] glob - the global data storing profiles and localization.
8324 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8325 * field. The caller is to delete this array using decrRef() as it is no more needed.
8326 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8327 * \throw If no field of \a this is lying on \a mesh.
8328 * \throw If no field values of the required parameters are available.
8330 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8332 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8333 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8335 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8336 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8337 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8341 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8342 * \param [in] pos - a time step id.
8343 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8344 * delete this field using decrRef() as it is no more needed.
8345 * \throw If \a pos is not a valid time step id.
8347 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8349 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8352 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8353 throw INTERP_KERNEL::Exception(oss.str().c_str());
8355 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8358 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8359 ret->shallowCpyGlobs(*this);
8362 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8363 throw INTERP_KERNEL::Exception(oss.str().c_str());
8367 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8368 * the given field is checked if its elements are sorted suitable for writing to MED file
8369 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8370 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8371 * \param [in] field - the field to add to \a this.
8372 * \throw If the name of \a field is empty.
8373 * \throw If the data array of \a field is not set.
8374 * \throw If existing time steps have different name or number of components than \a field.
8375 * \throw If the underlying mesh of \a field has no name.
8376 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8378 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8380 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8384 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8385 * a given dimension of a given mesh are used as the support of the given field.
8386 * Elements of the given mesh must be sorted suitable for writing to MED file.
8387 * Order of underlying mesh entities of the given field specified by \a profile parameter
8388 * is not prescribed; this method permutes field values to have them sorted by element
8389 * type as required for writing to MED file.
8390 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8391 * \param [in] field - the field to add to \a this.
8392 * \param [in] mesh - the supporting mesh of \a field.
8393 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8394 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8395 * \throw If either \a field or \a mesh or \a profile has an empty name.
8396 * \throw If existing time steps have different name or number of components than \a field.
8397 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8398 * \throw If the data array of \a field is not set.
8399 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8401 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8403 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8406 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8408 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8410 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8411 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8413 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8417 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8419 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8421 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8422 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8424 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8428 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8430 _content=new MEDFileIntFieldMultiTSWithoutSDA;
8433 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8437 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8438 try:MEDFileAnyTypeFieldMultiTS(fileName)
8441 catch(INTERP_KERNEL::Exception& e)
8444 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8445 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8448 catch(INTERP_KERNEL::Exception& e)
8451 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8453 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8458 MEDFileFields *MEDFileFields::New()
8460 return new MEDFileFields;
8463 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8465 return new MEDFileFields(fileName);
8468 std::size_t MEDFileFields::getHeapMemorySize() const
8470 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8471 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8472 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8473 ret+=(*it)->getHeapMemorySize();
8474 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8477 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8479 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8481 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8483 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8484 ret->_fields[i]=(*it)->deepCpy();
8486 ret->deepCpyGlobs(*this);
8490 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8492 return new MEDFileFields(*this);
8496 * This method scans for all fields in \a this which time steps ids are common. Time step are discriminated by the pair of integer (iteration,order) whatever
8497 * the double time value. If all returned time steps are \b exactly those for all fields in \a this output parameter \a areThereSomeForgottenTS will be set to false.
8498 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8500 * \param [out] areThereSomeForgottenTS - indicates to the caller if there is some time steps in \a this that are not present for all fields in \a this.
8501 * \return the sorted list of time steps (specified with a pair of integer iteration first and order second) present for all fields in \a this.
8503 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8505 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8507 std::set< std::pair<int,int> > s;
8508 bool firstShot=true;
8509 areThereSomeForgottenTS=false;
8510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8512 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8514 std::vector< std::pair<int,int> > v=(*it)->getIterations();
8515 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8517 { s=s1; firstShot=false; }
8520 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8522 areThereSomeForgottenTS=true;
8526 std::vector< std::pair<int,int> > ret;
8527 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8531 int MEDFileFields::getNumberOfFields() const
8533 return _fields.size();
8536 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8538 std::vector<std::string> ret(_fields.size());
8540 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8542 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8545 ret[i]=f->getName();
8549 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8550 throw INTERP_KERNEL::Exception(oss.str().c_str());
8556 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8558 std::vector<std::string> ret;
8559 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8561 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8563 ret.push_back(cur->getMeshName());
8568 std::string MEDFileFields::simpleRepr() const
8570 std::ostringstream oss;
8571 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8576 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8578 int nbOfFields=getNumberOfFields();
8579 std::string startLine(bkOffset,' ');
8580 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8582 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8584 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8587 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8591 oss << startLine << " - not defined !" << std::endl;
8595 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8597 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8598 std::string chapter(17,'0'+i);
8599 oss << startLine << chapter << std::endl;
8602 cur->simpleRepr(bkOffset+2,oss,i);
8606 oss << startLine << " - not defined !" << std::endl;
8608 oss << startLine << chapter << std::endl;
8610 simpleReprGlobs(oss);
8613 MEDFileFields::MEDFileFields()
8617 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
8618 try:MEDFileFieldGlobsReal(fileName)
8620 MEDFileUtilities::CheckFileForRead(fileName);
8621 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
8622 int nbFields=MEDnField(fid);
8623 _fields.resize(nbFields);
8624 med_field_type typcha;
8625 for(int i=0;i<nbFields;i++)
8627 std::vector<std::string> infos;
8628 std::string fieldName,dtunit;
8629 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
8634 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8639 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8644 std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8645 throw INTERP_KERNEL::Exception(oss.str().c_str());
8649 loadAllGlobals(fid);
8651 catch(INTERP_KERNEL::Exception& e)
8656 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8659 writeGlobals(fid,*this);
8660 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8662 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
8665 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
8666 throw INTERP_KERNEL::Exception(oss.str().c_str());
8668 elt->writeLL(fid,*this);
8672 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8674 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8675 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8679 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
8681 std::vector<std::string> ret;
8682 std::set<std::string> ret2;
8683 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8685 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8686 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8687 if(ret2.find(*it2)==ret2.end())
8689 ret.push_back(*it2);
8696 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
8698 std::vector<std::string> ret;
8699 std::set<std::string> ret2;
8700 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8702 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8703 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8704 if(ret2.find(*it2)==ret2.end())
8706 ret.push_back(*it2);
8713 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
8715 std::vector<std::string> ret;
8716 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8718 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8719 ret.insert(ret.end(),tmp.begin(),tmp.end());
8724 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
8726 std::vector<std::string> ret;
8727 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8729 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8730 ret.insert(ret.end(),tmp.begin(),tmp.end());
8735 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8737 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8738 (*it)->changePflsRefsNamesGen2(mapOfModif);
8741 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8743 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8744 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8747 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
8749 _fields.resize(newSize);
8752 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
8754 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
8758 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8761 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
8762 _fields.push_back(field->getContent());
8763 appendGlobs(*field,1e-12);
8766 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8769 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
8770 if(i>=(int)_fields.size())
8771 _fields.resize(i+1);
8772 _fields[i]=field->getContent();
8773 appendGlobs(*field,1e-12);
8776 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
8778 destroyFieldsAtPos(&i,&i+1);
8781 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
8783 std::vector<bool> b(_fields.size(),true);
8784 for(const int *i=startIds;i!=endIds;i++)
8786 if(*i<0 || *i>=(int)_fields.size())
8788 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
8789 throw INTERP_KERNEL::Exception(oss.str().c_str());
8793 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8795 for(std::size_t i=0;i<_fields.size();i++)
8797 fields[j++]=_fields[i];
8801 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
8803 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
8804 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8805 std::vector<bool> b(_fields.size(),true);
8807 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
8809 if(k<0 || k>=(int)_fields.size())
8811 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
8812 throw INTERP_KERNEL::Exception(oss.str().c_str());
8816 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8818 for(std::size_t i=0;i<_fields.size();i++)
8820 fields[j++]=_fields[i];
8824 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8827 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
8829 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8831 ret=cur->changeMeshNames(modifTab) || ret;
8837 * \param [in] meshName the name of the mesh that will be renumbered.
8838 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
8839 * This code corresponds to the distribution of types in the corresponding mesh.
8840 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
8841 * \param [in] renumO2N the old to new renumber array.
8842 * \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
8845 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
8848 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
8850 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
8853 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
8859 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
8861 if(i<0 || i>=(int)_fields.size())
8863 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
8864 throw INTERP_KERNEL::Exception(oss.str().c_str());
8866 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
8869 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
8870 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
8871 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
8873 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
8875 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
8878 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
8879 throw INTERP_KERNEL::Exception(oss.str().c_str());
8881 ret->shallowCpyGlobs(*this);
8886 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
8887 * This method is accessible in python using __getitem__ with a list in input.
8888 * \return a new object that the caller should deal with.
8890 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
8892 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8893 std::size_t sz=std::distance(startIds,endIds);
8894 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
8896 for(const int *i=startIds;i!=endIds;i++,j++)
8898 if(*i<0 || *i>=(int)_fields.size())
8900 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
8901 throw INTERP_KERNEL::Exception(oss.str().c_str());
8903 fields[j]=_fields[*i];
8905 ret->_fields=fields;
8909 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
8911 return getFieldAtPos(getPosFromFieldName(fieldName));
8915 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
8916 * This method can be seen as a filter applied on \a this, that returns an object containing
8917 * reduced the list of fields compared to those in \a this. The returned object is a new object but the object on which it lies are only
8918 * shallow copied from \a this.
8920 * \param [in] meshName - the name of the mesh on w
8921 * \return a new object that the caller should deal with.
8923 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
8925 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
8926 ret->shallowCpyOnlyUsedGlobs(*this);
8927 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8929 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8932 if(cur->getMeshName()==meshName)
8935 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
8936 ret->_fields.push_back(cur2);
8943 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
8944 * Input time steps are specified using a pair of integer (iteration, order).
8945 * This method can be seen as a filter applied on \a this, that returns an object containing the same number of fields than those in \a this,
8946 * but for each multitimestep only the time steps in \a timeSteps are kept.
8947 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
8949 * The returned object points to shallow copy of elements in \a this.
8951 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
8952 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
8953 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8955 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
8957 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
8958 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8960 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8963 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
8964 ret->_fields.push_back(elt);
8966 ret->shallowCpyOnlyUsedGlobs(*this);
8971 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
8973 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
8975 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
8976 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8978 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8981 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
8982 if(elt->getNumberOfTS()!=0)
8983 ret->_fields.push_back(elt);
8985 ret->shallowCpyOnlyUsedGlobs(*this);
8989 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
8991 return new MEDFileFieldsIterator(this);
8994 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
8996 std::string tmp(fieldName);
8997 std::vector<std::string> poss;
8998 for(std::size_t i=0;i<_fields.size();i++)
9000 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9003 std::string fname(f->getName());
9007 poss.push_back(fname);
9010 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9011 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9013 throw INTERP_KERNEL::Exception(oss.str().c_str());
9016 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9021 _nb_iter=fs->getNumberOfFields();
9025 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9029 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9031 if(_iter_id<_nb_iter)
9033 MEDFileFields *fs(_fs);
9035 return fs->getFieldAtPos(_iter_id++);