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 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
307 _nval=idsInPfl->getNumberOfTuples();
308 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->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 getOrCreateAndGetArray()->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::loadOnlyStructureOfDataRecursively(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::loadBigArray(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);
486 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
489 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
490 if(_start<0 || _start>=arr->getNumberOfTuples())
492 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
493 throw INTERP_KERNEL::Exception(oss.str().c_str());
495 if(_end<0 || _end>arr->getNumberOfTuples())
497 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
498 throw INTERP_KERNEL::Exception(oss.str().c_str());
501 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
502 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
503 int nbOfCompo=arr->getNumberOfComponents();
504 if(_end-_start!=nbValsInFile*nbi)
506 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
507 throw INTERP_KERNEL::Exception(oss.str().c_str());
509 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
512 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
513 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
514 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
517 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
520 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
521 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
522 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
525 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
529 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
531 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
533 int delta=_end-_start;
534 _start=newValueOfStart;
538 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
540 return _father->getIteration();
543 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
545 return _father->getOrder();
548 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
550 return _father->getTime();
553 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
555 return _father->getMeshName();
558 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
560 const char startLine[]=" ## ";
561 std::string startLine2(bkOffset,' ');
562 startLine2+=startLine;
563 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
564 oss << startLine2 << "Localization #" << id << "." << std::endl;
565 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
567 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
568 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
569 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
572 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
577 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
582 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
587 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
589 return _father->getGeoType();
592 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
594 return _father->getNumberOfComponents();
597 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
602 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
604 return _father->getOrCreateAndGetArray();
607 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
609 const MEDFileFieldPerMeshPerType *fath=_father;
610 return fath->getOrCreateAndGetArray();
613 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
615 return _father->getInfo();
618 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
623 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
628 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
630 return _localization;
633 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
635 _localization=newLocName;
638 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(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(),_profile)!=(*it2).first.end())
644 _profile=(*it2).second;
650 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
652 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
654 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
656 _localization=(*it2).second;
662 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
666 dads.push_back(std::pair<int,int>(_start,_end));
667 geoTypes.push_back(getGeoType());
672 pfls.push_back(glob->getProfile(_profile.c_str()));
674 if(_localization.empty())
678 locs.push_back(glob->getLocalizationId(_localization.c_str()));
682 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
684 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));
688 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
690 TypeOfField type=getType();
691 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
692 med_geometry_type mgeoti;
693 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
694 const DataArray *arr=getOrCreateAndGetArray();
696 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
697 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
698 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
699 const unsigned char *locToWrite=0;
701 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
703 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
705 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
706 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
707 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
711 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
716 dad.first=_start; dad.second=_end;
720 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
721 * This code corresponds to the distribution of types in the corresponding mesh.
722 * \param [out] ptToFill memory zone where the output will be stored.
723 * \return the size of data pushed into output param \a ptToFill
725 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
728 std::ostringstream oss;
729 std::size_t nbOfType=codeOfMesh.size()/3;
731 for(std::size_t i=0;i<nbOfType && found==-1;i++)
732 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
736 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
737 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
738 throw INTERP_KERNEL::Exception(oss.str().c_str());
743 if(_nval!=codeOfMesh[3*found+1])
745 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
746 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
747 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
748 throw INTERP_KERNEL::Exception(oss.str().c_str());
750 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
755 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
756 if(pfl->getNumberOfTuples()!=_nval)
758 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
759 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
761 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
762 throw INTERP_KERNEL::Exception(oss.str().c_str());
764 int offset2=codeOfMesh[3*found+2];
765 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
767 if(*pflId<codeOfMesh[3*found+1])
768 *work++=offset2+*pflId;
774 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
776 for(int i=_start;i<_end;i++)
781 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
792 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
796 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
799 std::map<std::pair<std::string,TypeOfField>,int> m;
800 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
801 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
802 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
803 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
805 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
806 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
811 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
813 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
814 * \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.
815 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
816 * \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)
817 * \param [in,out] glob if necessary by the method, new profiles can be added to it
818 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
819 * \param [out] result All new entries will be appended on it.
820 * \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 !)
822 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
823 const DataArrayInt *explicitIdsInMesh,
824 const std::vector<int>& newCode,
825 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
826 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
828 if(entriesOnSameDisc.empty())
830 TypeOfField type=entriesOnSameDisc[0]->getType();
831 int szEntities=0,szTuples=0;
832 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
833 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
834 int nbi=szTuples/szEntities;
835 if(szTuples%szEntities!=0)
836 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
838 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
839 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
840 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
841 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
842 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
843 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
845 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
847 int startOfEltIdOfChunk=(*it)->_start;
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
850 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
852 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
853 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
855 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
856 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
858 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
859 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
865 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
866 arrPart->renumberInPlace(renumTupleIds->begin());
867 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
869 const int *idIt=diffVals->begin();
870 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
872 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
874 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
875 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
876 int nbEntityElts=subIds->getNumberOfTuples();
878 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
879 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
883 result.push_back(eltToAdd);
884 offset2+=nbEntityElts*nbi;
886 ret=ret || li.empty();
891 * \param [in] typeF type of field of new chunk
892 * \param [in] geoType the geometric type of the chunk
893 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
894 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
895 * \param [in] nbi number of integration points
896 * \param [in] offset The offset in the **global array of data**.
897 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
898 * to the new chunk to create.
899 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
900 * \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
901 * and corresponding entry erased from \a entriesOnSameDisc.
902 * \return a newly allocated chunk
904 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
905 bool isPfl, int nbi, int offset,
906 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
907 MEDFileFieldGlobsReal& glob,
908 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
910 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
911 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
912 for(;it!=entriesOnSameDisc.end();it++)
914 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
918 if((*it)->_profile.empty())
921 if(!(*it)->_profile.empty())
923 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
924 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
930 if(it==entriesOnSameDisc.end())
933 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
935 ret->_loc_id=(int)geoType;
936 ret->_nval=nbMeshEntities;
938 ret->_end=ret->_start+ret->_nval*nbi;
941 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
942 glob.appendProfile(idsOfMeshElt);
943 ret->_profile=idsOfMeshElt->getName();
945 //tony treatment of localization
951 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
952 ret->_loc_id=(int)geoType;
953 ret->setNewStart(offset);
954 entriesOnSameDisc.erase(it);
960 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
962 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
965 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
967 return new MEDFileFieldPerMeshPerType(fath,geoType);
970 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
972 std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
973 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
974 ret+=(*it)->getHeapMemorySize();
978 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
980 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
983 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
985 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
986 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
991 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
993 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
994 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
995 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
999 * This method is the most general one. No optimization is done here.
1000 * \param [in] multiTypePfl is the end user profile specified in high level API
1001 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1002 * \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.
1003 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1004 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1005 * \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.
1007 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)
1009 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1010 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1011 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1014 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1016 _field_pm_pt_pd.resize(1);
1017 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1018 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1021 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1023 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1025 _field_pm_pt_pd.resize(1);
1026 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1027 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1030 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1032 TypeOfField type=field->getTypeOfField();
1033 if(type!=ON_GAUSS_PT)
1035 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1036 int sz=_field_pm_pt_pd.size();
1038 for(int j=0;j<sz && !found;j++)
1040 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1042 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1048 _field_pm_pt_pd.resize(sz+1);
1049 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1051 std::vector<int> ret(1,(int)sz);
1056 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1057 int sz2=ret2.size();
1058 std::vector<int> ret3(sz2);
1060 for(int i=0;i<sz2;i++)
1062 int sz=_field_pm_pt_pd.size();
1063 int locIdToFind=ret2[i];
1065 for(int j=0;j<sz && !found;j++)
1067 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1069 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1076 _field_pm_pt_pd.resize(sz+1);
1077 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1085 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1087 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1088 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1090 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1091 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1093 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1094 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1095 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1096 if(retTmp->presenceOfValue(-1))
1097 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1098 std::vector<int> ret(retTmp->begin(),retTmp->end());
1102 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1104 TypeOfField type=field->getTypeOfField();
1105 if(type!=ON_GAUSS_PT)
1107 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1108 int sz=_field_pm_pt_pd.size();
1110 for(int j=0;j<sz && !found;j++)
1112 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1114 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1120 _field_pm_pt_pd.resize(sz+1);
1121 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1123 std::vector<int> ret(1,0);
1128 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1129 int sz2=ret2.size();
1130 std::vector<int> ret3(sz2);
1132 for(int i=0;i<sz2;i++)
1134 int sz=_field_pm_pt_pd.size();
1135 int locIdToFind=ret2[i];
1137 for(int j=0;j<sz && !found;j++)
1139 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1141 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1148 _field_pm_pt_pd.resize(sz+1);
1149 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1157 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1159 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1160 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1162 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1163 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1165 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1166 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1167 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1168 if(retTmp->presenceOfValue(-1))
1169 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1170 std::vector<int> ret(retTmp->begin(),retTmp->end());
1174 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1179 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1181 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1182 int curDim=(int)cm.getDimension();
1183 dim=std::max(dim,curDim);
1186 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1188 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1190 (*it)->fillTypesOfFieldAvailable(types);
1194 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)
1196 int sz=_field_pm_pt_pd.size();
1197 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1198 for(int i=0;i<sz;i++)
1200 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1204 int MEDFileFieldPerMeshPerType::getIteration() const
1206 return _father->getIteration();
1209 int MEDFileFieldPerMeshPerType::getOrder() const
1211 return _father->getOrder();
1214 double MEDFileFieldPerMeshPerType::getTime() const
1216 return _father->getTime();
1219 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1221 return _father->getMeshName();
1224 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1226 const char startLine[]=" ## ";
1227 std::string startLine2(bkOffset,' ');
1228 std::string startLine3(startLine2);
1229 startLine3+=startLine;
1230 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1232 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1233 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1236 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1237 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1239 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1241 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1243 cur->simpleRepr(bkOffset,oss,i);
1246 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1251 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1253 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1255 globalSz+=(*it)->getNumberOfTuples();
1257 nbOfEntries+=(int)_field_pm_pt_pd.size();
1260 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1266 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1268 return _father->getNumberOfComponents();
1271 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1273 return _father->getOrCreateAndGetArray();
1276 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1278 const MEDFileFieldPerMesh *fath=_father;
1279 return fath->getOrCreateAndGetArray();
1282 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1284 return _father->getInfo();
1287 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1289 std::vector<std::string> ret;
1290 std::set<std::string> ret2;
1291 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1293 std::string tmp=(*it1)->getProfile();
1295 if(ret2.find(tmp)==ret2.end())
1304 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1306 std::vector<std::string> ret;
1307 std::set<std::string> ret2;
1308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1310 std::string tmp=(*it1)->getLocalization();
1311 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1312 if(ret2.find(tmp)==ret2.end())
1321 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1323 std::vector<std::string> ret;
1324 std::set<std::string> ret2;
1325 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1327 std::string tmp=(*it1)->getProfile();
1334 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1336 std::vector<std::string> ret;
1337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1339 std::string tmp=(*it1)->getLocalization();
1340 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1346 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1349 (*it1)->changePflsRefsNamesGen(mapOfModif);
1352 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1354 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1355 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1358 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1360 if(_field_pm_pt_pd.empty())
1362 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1363 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1364 throw INTERP_KERNEL::Exception(oss.str().c_str());
1366 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1367 return _field_pm_pt_pd[locId];
1368 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1369 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1370 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1371 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1372 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1375 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1377 if(_field_pm_pt_pd.empty())
1379 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1380 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1381 throw INTERP_KERNEL::Exception(oss.str().c_str());
1383 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1384 return _field_pm_pt_pd[locId];
1385 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1386 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1387 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1388 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1389 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1392 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
1394 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1396 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1397 if(meshDim!=(int)cm.getDimension())
1400 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1401 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1404 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1407 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1409 (*it)->fillValues(i,startEntryId,entries);
1413 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1415 _field_pm_pt_pd=leaves;
1416 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1417 (*it)->setFather(this);
1421 * \param [in,out] globalNum a global numbering counter for the renumbering.
1422 * \param [out] its - list of pair (start,stop) kept
1423 * \return bool - false if the type of field \a tof is not contained in \a this.
1425 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1428 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1430 if((*it)->getType()==tof)
1432 newPmPtPd.push_back(*it);
1433 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1434 (*it)->setNewStart(globalNum);
1435 globalNum=(*it)->getEnd();
1436 its.push_back(bgEnd);
1440 _field_pm_pt_pd=newPmPtPd;
1444 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1448 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)
1450 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1451 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1452 med_geometry_type mgeoti;
1453 med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1454 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1455 _field_pm_pt_pd.resize(nbProfiles);
1456 for(int i=0;i<nbProfiles;i++)
1458 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1462 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1465 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1467 (*it)->loadOnlyStructureOfDataRecursively(fid,pflId+1,start,nasc);//tony
1471 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1474 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1476 (*it)->loadBigArray(fid,pflId+1,nasc);//tony
1480 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1482 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1484 (*it)->copyOptionsFrom(*this);
1485 (*it)->writeLL(fid,nasc);
1489 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1494 medfGeoType=typmai3[(int)ikGeoType];
1497 medfGeoType=MED_NONE;
1500 medfGeoType=typmai3[(int)ikGeoType];
1501 return MED_NODE_ELEMENT;
1503 medfGeoType=typmai3[(int)ikGeoType];
1506 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1508 return MED_UNDEF_ENTITY_TYPE;
1511 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1513 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1516 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1518 return new MEDFileFieldPerMesh(fath,mesh);
1521 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1523 std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1524 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1525 if((const MEDFileFieldPerMeshPerType *)*it)
1526 ret+=(*it)->getHeapMemorySize();
1530 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1532 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1533 ret->_father=father;
1535 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1537 if((const MEDFileFieldPerMeshPerType *)*it)
1538 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1543 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1545 std::string startLine(bkOffset,' ');
1546 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1547 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1549 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1551 const MEDFileFieldPerMeshPerType *cur=*it;
1553 cur->simpleRepr(bkOffset,oss,i);
1556 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1561 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1563 _mesh_name=mesh->getName();
1564 mesh->getTime(_mesh_iteration,_mesh_order);
1567 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)
1569 int nbOfTypes=code.size()/3;
1571 for(int i=0;i<nbOfTypes;i++)
1573 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1574 int nbOfCells=code[3*i+1];
1575 int pos=addNewEntryIfNecessary(type);
1576 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1582 * This method is the most general one. No optimization is done here.
1583 * \param [in] multiTypePfl is the end user profile specified in high level API
1584 * \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].
1585 * \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.
1586 * \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.
1587 * \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.
1588 * \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.
1590 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)
1592 int nbOfTypes=code.size()/3;
1593 for(int i=0;i<nbOfTypes;i++)
1595 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1596 int pos=addNewEntryIfNecessary(type);
1597 DataArrayInt *pfl=0;
1599 pfl=idsPerType[code[3*i+2]];
1600 int nbOfTupes2=code2.size()/3;
1602 for(;found<nbOfTupes2;found++)
1603 if(code[3*i]==code2[3*found])
1605 if(found==nbOfTupes2)
1606 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1607 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1611 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1613 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1614 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1617 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1619 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1620 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1623 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1625 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1626 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1629 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1631 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1632 (*it)->loadBigArraysRecursively(fid,nasc);
1635 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1637 int nbOfTypes=_field_pm_pt.size();
1638 for(int i=0;i<nbOfTypes;i++)
1640 _field_pm_pt[i]->copyOptionsFrom(*this);
1641 _field_pm_pt[i]->writeLL(fid,nasc);
1645 void MEDFileFieldPerMesh::getDimension(int& dim) const
1647 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1648 (*it)->getDimension(dim);
1651 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1653 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1654 (*it)->fillTypesOfFieldAvailable(types);
1657 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)
1659 int sz=_field_pm_pt.size();
1660 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1661 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1662 for(int i=0;i<sz;i++)
1664 types[i]=_field_pm_pt[i]->getGeoType();
1665 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1670 double MEDFileFieldPerMesh::getTime() const
1673 return _father->getTime(tmp1,tmp2);
1676 int MEDFileFieldPerMesh::getIteration() const
1678 return _father->getIteration();
1681 int MEDFileFieldPerMesh::getOrder() const
1683 return _father->getOrder();
1686 int MEDFileFieldPerMesh::getNumberOfComponents() const
1688 return _father->getNumberOfComponents();
1691 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1694 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1695 return _father->getOrCreateAndGetArray();
1698 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1701 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1702 return _father->getOrCreateAndGetArray();
1705 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1707 return _father->getInfo();
1711 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1712 * 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.
1713 * It returns 2 output vectors :
1714 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1715 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1716 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1718 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)
1720 int notNullPflsSz=0;
1721 int nbOfArrs=geoTypes.size();
1722 for(int i=0;i<nbOfArrs;i++)
1725 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1726 int nbOfDiffGeoTypes=geoTypes3.size();
1727 code.resize(3*nbOfDiffGeoTypes);
1728 notNullPfls.resize(notNullPflsSz);
1731 for(int i=0;i<nbOfDiffGeoTypes;i++)
1734 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1735 std::vector<const DataArrayInt *> notNullTmp;
1737 notNullTmp.push_back(pfls[j]);
1739 for(;j<nbOfArrs;j++)
1740 if(geoTypes[j]==refType)
1743 notNullTmp.push_back(pfls[j]);
1747 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1748 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1749 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1750 code[3*i]=(int)refType;
1751 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1752 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1753 if(notNullTmp.empty())
1757 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1758 code[3*i+2]=notNullPflsSz++;
1764 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1766 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)
1770 for(int i=0;i<sz;i++)
1774 if(type!=ON_GAUSS_NE)
1775 ret+=dads[i].second-dads[i].first;
1778 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1779 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1784 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1785 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1791 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1793 std::vector<std::string> ret;
1794 std::set<std::string> ret2;
1795 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1797 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1798 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1799 if(ret2.find(*it2)==ret2.end())
1801 ret.push_back(*it2);
1808 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1810 std::vector<std::string> ret;
1811 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1813 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1814 ret.insert(ret.end(),tmp.begin(),tmp.end());
1819 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1821 std::vector<std::string> ret;
1822 std::set<std::string> ret2;
1823 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1825 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1826 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1827 if(ret2.find(*it2)==ret2.end())
1829 ret.push_back(*it2);
1836 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1838 std::vector<std::string> ret;
1839 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1841 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1842 ret.insert(ret.end(),tmp.begin(),tmp.end());
1847 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1849 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1851 if((*it).first==_mesh_name)
1853 _mesh_name=(*it).second;
1860 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1861 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1863 if(_mesh_name!=meshName)
1865 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1866 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1867 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1868 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1869 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1870 getUndergroundDataArrayExt(entries);
1871 DataArray *arr0=getOrCreateAndGetArray();//tony
1873 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1874 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1876 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1879 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1880 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1882 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1884 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1885 sz+=(*it).second.second-(*it).second.first;
1888 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1890 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1891 ////////////////////
1892 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1893 int *workI2=explicitIdsOldInMesh->getPointer();
1894 int sz1=0,sz2=0,sid=1;
1895 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1896 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1897 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1899 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1900 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1901 int *workI=explicitIdsOldInArr->getPointer();
1902 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1904 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1905 (*itL2)->setLocId(sz2);
1906 (*itL2)->_tmp_work1=(*itL2)->getStart();
1907 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1909 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1911 explicitIdsOldInMesh->reAlloc(sz2);
1912 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1913 ////////////////////
1914 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1915 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1916 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1917 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1919 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1920 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1921 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1923 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1924 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1925 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1927 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1928 int newStart=elt->getLocId();
1929 elt->setLocId((*it)->getGeoType());
1930 elt->setNewStart(newStart);
1931 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1932 entriesKeptNew.push_back(elt);
1933 entriesKeptNew2.push_back(elt);
1935 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1936 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1937 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1938 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1940 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1943 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1945 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1946 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1948 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1949 glob,arr2,otherEntriesNew) || ret;
1953 // Assign new dispatching
1954 assignNewLeaves(otherEntriesNew);
1955 arr->cpyFrom(*arr2);
1960 * \param [in,out] globalNum a global numbering counter for the renumbering.
1961 * \param [out] its - list of pair (start,stop) kept
1963 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1965 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1966 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1968 std::vector< std::pair<int,int> > its2;
1969 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1972 its.insert(its.end(),its2.begin(),its2.end());
1978 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1980 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1981 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1982 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1984 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1985 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1986 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1987 for(;it1!=types.end();it1++,it2++)
1989 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1990 elt->setLeaves((*it1).second);
1993 _field_pm_pt=fieldPmPt;
1996 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1998 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999 (*it)->changePflsRefsNamesGen(mapOfModif);
2002 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2004 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2005 (*it)->changeLocsRefsNamesGen(mapOfModif);
2009 * \param [in] mesh is the whole mesh
2011 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2013 if(_field_pm_pt.empty())
2014 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2016 std::vector< std::pair<int,int> > dads;
2017 std::vector<const DataArrayInt *> pfls;
2018 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2019 std::vector<int> locs,code;
2020 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2021 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2022 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2024 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2027 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2028 throw INTERP_KERNEL::Exception(oss.str().c_str());
2031 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2032 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2035 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2037 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2040 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2041 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2047 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2051 if(nb!=mesh->getNumberOfNodes())
2053 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2054 oss << " nodes in mesh !";
2055 throw INTERP_KERNEL::Exception(oss.str().c_str());
2057 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2060 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2064 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2066 if(_field_pm_pt.empty())
2067 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2069 std::vector<std::pair<int,int> > dads;
2070 std::vector<const DataArrayInt *> pfls;
2071 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2072 std::vector<int> locs,code;
2073 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2074 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2075 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2077 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2080 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2081 throw INTERP_KERNEL::Exception(oss.str().c_str());
2083 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2084 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2087 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2088 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2093 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2097 if(nb!=mesh->getNumberOfNodes())
2099 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2100 oss << " nodes in mesh !";
2101 throw INTERP_KERNEL::Exception(oss.str().c_str());
2104 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2110 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2114 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2116 (*it)->getSizes(globalSz,nbOfEntries);
2118 entries.resize(nbOfEntries);
2120 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2122 (*it)->fillValues(nbOfEntries,entries);
2126 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2128 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130 if((*it)->getGeoType()==typ)
2131 return (*it)->getLeafGivenLocId(locId);
2133 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2134 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2135 oss << "Possiblities are : ";
2136 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2138 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2139 oss << "\"" << cm2.getRepr() << "\", ";
2141 throw INTERP_KERNEL::Exception(oss.str().c_str());
2144 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2146 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2148 if((*it)->getGeoType()==typ)
2149 return (*it)->getLeafGivenLocId(locId);
2151 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2152 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2153 oss << "Possiblities are : ";
2154 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2156 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2157 oss << "\"" << cm2.getRepr() << "\", ";
2159 throw INTERP_KERNEL::Exception(oss.str().c_str());
2162 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2165 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2166 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2167 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2169 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2174 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2179 int ret=std::distance(_field_pm_pt.begin(),it2);
2180 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2185 * 'dads' and 'locs' input parameters have the same number of elements
2186 * \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
2188 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2189 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2190 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2193 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2194 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2195 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2196 const std::vector<std::string>& infos=getInfo();
2197 da->setInfoOnComponents(infos);
2199 if(type==ON_GAUSS_PT)
2202 int nbOfArrs=dads.size();
2203 for(int i=0;i<nbOfArrs;i++)
2205 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2206 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2207 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2208 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2209 di->alloc(nbOfElems,1);
2211 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2212 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2221 * 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.
2222 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2223 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2224 * The order of cells in the returned field is those imposed by the profile.
2225 * \param [in] mesh is the global mesh.
2227 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2228 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2229 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2230 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2232 if(da->isIdentity())
2234 int nbOfTuples=da->getNumberOfTuples();
2235 if(nbOfTuples==mesh->getNumberOfCells())
2236 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2238 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2239 m2->setName(mesh->getName());
2240 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2246 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2248 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2249 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2250 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2252 if(da->isIdentity())
2254 int nbOfTuples=da->getNumberOfTuples();
2255 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2256 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2258 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2259 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2262 if(meshu->getNodalConnectivity()==0)
2264 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2265 int nb=da->getNbOfElems();
2266 const int *ptr=da->getConstPointer();
2267 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2268 meshuc->allocateCells(nb);
2269 for(int i=0;i<nb;i++)
2270 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2271 meshuc->finishInsertingCells();
2272 ret->setMesh(meshuc);
2273 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2274 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2275 disc->checkCoherencyBetween(meshuc,arrOut);
2280 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2282 DataArrayInt *arr2=0;
2283 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2284 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2285 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2286 int nnodes=mesh2->getNumberOfNodes();
2287 if(nnodes==(int)da->getNbOfElems())
2289 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2290 arrOut->renumberInPlace(da3->getConstPointer());
2291 mesh2->setName(mesh->getName());
2292 ret->setMesh(mesh2);
2297 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 !!!";
2298 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2299 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2300 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2301 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2302 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2303 throw INTERP_KERNEL::Exception(oss.str().c_str());
2309 * This method is the most light method of field retrieving.
2311 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2315 pflOut=DataArrayInt::New();
2316 pflOut->alloc(nbOfElems,1);
2321 pflOut=const_cast<DataArrayInt*>(pflIn);
2324 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2325 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2326 const std::vector<std::string>& infos=getInfo();
2327 int nbOfComp=infos.size();
2328 for(int i=0;i<nbOfComp;i++)
2329 da->setInfoOnComponent(i,infos[i].c_str());
2334 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),
2335 _mesh_csit(meshCsit),_father(fath)
2337 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2338 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2339 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2340 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2342 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2345 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2346 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2348 nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2351 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2352 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2355 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2358 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2359 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2363 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2365 copyTinyInfoFrom(mesh);
2368 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2370 if(id>=(int)_pfls.size())
2372 _pfls[id]=DataArrayInt::New();
2373 int lgth=MEDprofileSizeByName(fid,pflName);
2374 _pfls[id]->setName(pflName);
2375 _pfls[id]->alloc(lgth,1);
2376 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2377 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2380 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2382 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2384 MEDprofileInfo(fid,i+1,pflName,&sz);
2385 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2386 if(i>=(int)_pfls.size())
2388 _pfls[i]=DataArrayInt::New();
2389 _pfls[i]->alloc(sz,1);
2390 _pfls[i]->setName(pflCpp.c_str());
2391 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2392 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2395 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2397 int nbOfPfls=_pfls.size();
2398 for(int i=0;i<nbOfPfls;i++)
2400 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2401 cpy->applyLin(1,1,0);
2402 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2403 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2404 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2407 int nbOfLocs=_locs.size();
2408 for(int i=0;i<nbOfLocs;i++)
2409 _locs[i]->writeLL(fid);
2412 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2414 std::vector<std::string> pfls=getPfls();
2415 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2417 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2420 _pfls.push_back(*it);
2424 int id=std::distance(pfls.begin(),it2);
2425 if(!(*it)->isEqual(*_pfls[id]))
2427 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2428 throw INTERP_KERNEL::Exception(oss.str().c_str());
2432 std::vector<std::string> locs=getLocs();
2433 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2435 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2438 _locs.push_back(*it);
2442 int id=std::distance(locs.begin(),it2);
2443 if(!(*it)->isEqual(*_locs[id],eps))
2445 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2446 throw INTERP_KERNEL::Exception(oss.str().c_str());
2452 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2454 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2455 getProfile((*it).c_str());
2458 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2460 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2461 getLocalization((*it).c_str());
2464 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2466 std::vector<std::string> profiles=real.getPflsReallyUsed();
2467 int sz=profiles.size();
2469 for(int i=0;i<sz;i++)
2470 loadProfileInFile(fid,i,profiles[i].c_str());
2472 std::vector<std::string> locs=real.getLocsReallyUsed();
2475 for(int i=0;i<sz;i++)
2476 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2479 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2481 int nProfil=MEDnProfile(fid);
2482 for(int i=0;i<nProfil;i++)
2483 loadProfileInFile(fid,i);
2484 int sz=MEDnLocalization(fid);
2486 for(int i=0;i<sz;i++)
2488 _locs[i]=MEDFileFieldLoc::New(fid,i);
2492 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2494 return new MEDFileFieldGlobs(fname);
2497 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2499 return new MEDFileFieldGlobs;
2502 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2504 std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2505 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2506 ret+=(*it)->getHeapMemorySize();
2507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2508 ret+=(*it)->getHeapMemorySize();
2512 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2514 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2516 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2518 if((const DataArrayInt *)*it)
2519 ret->_pfls[i]=(*it)->deepCpy();
2522 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2524 if((const MEDFileFieldLoc*)*it)
2525 ret->_locs[i]=(*it)->deepCpy();
2531 * \throw if a profile in \a pfls in not in \a this.
2532 * \throw if a localization in \a locs in not in \a this.
2533 * \sa MEDFileFieldGlobs::deepCpyPart
2535 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2537 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2538 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2540 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2542 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2544 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2545 ret->_pfls.push_back(pfl2);
2547 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2549 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2551 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2553 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2554 ret->_locs.push_back(loc2);
2556 ret->setFileName(getFileName());
2561 * \throw if a profile in \a pfls in not in \a this.
2562 * \throw if a localization in \a locs in not in \a this.
2563 * \sa MEDFileFieldGlobs::shallowCpyPart
2565 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2567 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2568 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2570 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2572 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2573 ret->_pfls.push_back(pfl->deepCpy());
2575 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2577 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2579 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2580 ret->_locs.push_back(loc->deepCpy());
2582 ret->setFileName(getFileName());
2586 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2590 MEDFileFieldGlobs::MEDFileFieldGlobs()
2594 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2598 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2600 oss << "Profiles :\n";
2601 std::size_t n=_pfls.size();
2602 for(std::size_t i=0;i<n;i++)
2604 oss << " - #" << i << " ";
2605 const DataArrayInt *pfl=_pfls[i];
2607 oss << "\"" << pfl->getName() << "\"\n";
2612 oss << "Localizations :\n";
2613 for(std::size_t i=0;i<n;i++)
2615 oss << " - #" << i << " ";
2616 const MEDFileFieldLoc *loc=_locs[i];
2618 loc->simpleRepr(oss);
2624 void MEDFileFieldGlobs::setFileName(const char *fileName)
2626 _file_name=fileName;
2629 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2631 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2633 DataArrayInt *elt(*it);
2636 std::string name(elt->getName());
2637 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2639 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2641 elt->setName((*it2).second.c_str());
2649 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2651 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2653 MEDFileFieldLoc *elt(*it);
2656 std::string name(elt->getName());
2657 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2659 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2661 elt->setName((*it2).second.c_str());
2669 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2671 if(locId<0 || locId>=(int)_locs.size())
2672 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2673 return _locs[locId]->getNbOfGaussPtPerCell();
2676 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2678 return getLocalizationFromId(getLocalizationId(locName));
2681 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2683 if(locId<0 || locId>=(int)_locs.size())
2684 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2685 return *_locs[locId];
2688 namespace ParaMEDMEMImpl
2693 LocFinder(const char *loc):_loc(loc) { }
2694 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2702 PflFinder(const std::string& pfl):_pfl(pfl) { }
2703 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2705 const std::string& _pfl;
2709 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2711 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2714 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2715 for(it=_locs.begin();it!=_locs.end();it++)
2716 oss << "\"" << (*it)->getName() << "\", ";
2717 throw INTERP_KERNEL::Exception(oss.str().c_str());
2719 return std::distance(_locs.begin(),it);
2723 * The returned value is never null.
2725 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2727 std::string pflNameCpp(pflName);
2728 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2731 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2732 for(it=_pfls.begin();it!=_pfls.end();it++)
2733 oss << "\"" << (*it)->getName() << "\", ";
2734 throw INTERP_KERNEL::Exception(oss.str().c_str());
2739 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2741 if(pflId<0 || pflId>=(int)_pfls.size())
2742 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2743 return _pfls[pflId];
2746 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2748 if(locId<0 || locId>=(int)_locs.size())
2749 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2750 return *_locs[locId];
2753 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2755 return getLocalizationFromId(getLocalizationId(locName));
2759 * The returned value is never null.
2761 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2763 std::string pflNameCpp(pflName);
2764 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2767 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2768 for(it=_pfls.begin();it!=_pfls.end();it++)
2769 oss << "\"" << (*it)->getName() << "\", ";
2770 throw INTERP_KERNEL::Exception(oss.str().c_str());
2775 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2777 if(pflId<0 || pflId>=(int)_pfls.size())
2778 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2779 return _pfls[pflId];
2782 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2784 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2786 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2788 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2789 newPfls.push_back(*it);
2794 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2796 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2798 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2800 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2801 newLocs.push_back(*it);
2806 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2808 int sz=_pfls.size();
2809 std::vector<std::string> ret(sz);
2810 for(int i=0;i<sz;i++)
2811 ret[i]=_pfls[i]->getName();
2815 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2817 int sz=_locs.size();
2818 std::vector<std::string> ret(sz);
2819 for(int i=0;i<sz;i++)
2820 ret[i]=_locs[i]->getName();
2824 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2826 std::vector<std::string> v=getPfls();
2827 std::string s(pflName);
2828 return std::find(v.begin(),v.end(),s)!=v.end();
2831 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2833 std::vector<std::string> v=getLocs();
2834 std::string s(locName);
2835 return std::find(v.begin(),v.end(),s)!=v.end();
2838 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2840 std::map<int,std::vector<int> > m;
2842 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2844 const DataArrayInt *tmp=(*it);
2847 m[tmp->getHashCode()].push_back(i);
2850 std::vector< std::vector<int> > ret;
2851 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2853 if((*it2).second.size()>1)
2855 std::vector<int> ret0;
2856 bool equalityOrNot=false;
2857 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2859 std::vector<int>::const_iterator it4=it3; it4++;
2860 for(;it4!=(*it2).second.end();it4++)
2862 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2865 ret0.push_back(*it3);
2866 ret0.push_back(*it4);
2872 ret.push_back(ret0);
2878 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2880 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2883 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2885 std::string name(pfl->getName());
2887 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2888 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2889 if(name==(*it)->getName())
2891 if(!pfl->isEqual(*(*it)))
2893 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2894 throw INTERP_KERNEL::Exception(oss.str().c_str());
2898 _pfls.push_back(pfl);
2901 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)
2903 std::string name(locName);
2905 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2906 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2907 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2908 if((*it)->isName(locName))
2910 if(!(*it)->isEqual(*obj,1e-12))
2912 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2913 throw INTERP_KERNEL::Exception(oss.str().c_str());
2916 _locs.push_back(obj);
2919 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2921 std::vector<std::string> names=getPfls();
2922 return CreateNewNameNotIn("NewPfl_",names);
2925 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2927 std::vector<std::string> names=getLocs();
2928 return CreateNewNameNotIn("NewLoc_",names);
2931 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2933 for(std::size_t sz=0;sz<100000;sz++)
2935 std::ostringstream tryName;
2936 tryName << prefix << sz;
2937 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2938 return tryName.str();
2940 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2944 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2945 * \param [in] fname - the file name.
2947 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2952 * Creates an empty MEDFileFieldGlobsReal.
2954 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2958 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2961 if((const MEDFileFieldGlobs *)_globals)
2962 ret+=_globals->getHeapMemorySize();
2967 * Returns a string describing profiles and Gauss points held in \a this.
2968 * \return std::string - the description string.
2970 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2972 const MEDFileFieldGlobs *glob=_globals;
2973 std::ostringstream oss2; oss2 << glob;
2974 std::string stars(oss2.str().length(),'*');
2975 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
2977 glob->simpleRepr(oss);
2979 oss << "NO GLOBAL INFORMATION !\n";
2982 void MEDFileFieldGlobsReal::resetContent()
2984 _globals=MEDFileFieldGlobs::New();
2987 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2992 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2993 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2995 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2997 _globals=other._globals;
3001 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3002 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3004 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3006 const MEDFileFieldGlobs *otherg(other._globals);
3009 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3013 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3014 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3016 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3018 const MEDFileFieldGlobs *otherg(other._globals);
3021 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3024 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3026 _globals=other._globals;
3027 if((const MEDFileFieldGlobs *)_globals)
3028 _globals=other._globals->deepCpy();
3032 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3033 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3034 * \param [in] eps - a precision used to compare Gauss points with same name held by
3035 * \a this and \a other MEDFileFieldGlobsReal.
3036 * \throw If \a this and \a other hold profiles with equal names but different ids.
3037 * \throw If \a this and \a other hold different Gauss points with equal names.
3039 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3041 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3042 if(thisGlobals==otherGlobals)
3046 _globals=other._globals;
3049 _globals->appendGlobs(*other._globals,eps);
3052 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3054 checkGlobsPflsPartCoherency();
3055 checkGlobsLocsPartCoherency();
3058 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3060 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3063 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3065 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3068 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3070 contentNotNull()->loadProfileInFile(fid,id,pflName);
3073 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3075 contentNotNull()->loadProfileInFile(fid,id);
3078 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3080 contentNotNull()->loadGlobals(fid,*this);
3083 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3085 contentNotNull()->loadAllGlobals(fid);
3088 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3090 contentNotNull()->writeGlobals(fid,opt);
3094 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3095 * or getPflsReallyUsedMulti().
3096 * \return std::vector<std::string> - a sequence of names of all profiles.
3098 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3100 return contentNotNull()->getPfls();
3104 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3105 * or getLocsReallyUsedMulti().
3106 * \return std::vector<std::string> - a sequence of names of all localizations.
3108 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3110 return contentNotNull()->getLocs();
3114 * Checks if the profile with a given name exists.
3115 * \param [in] pflName - the profile name of interest.
3116 * \return bool - \c true if the profile named \a pflName exists.
3118 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3120 return contentNotNull()->existsPfl(pflName);
3124 * Checks if the localization with a given name exists.
3125 * \param [in] locName - the localization name of interest.
3126 * \return bool - \c true if the localization named \a locName exists.
3128 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3130 return contentNotNull()->existsLoc(locName);
3133 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3135 return contentNotNull()->createNewNameOfPfl();
3138 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3140 return contentNotNull()->createNewNameOfLoc();
3144 * Sets the name of a MED file.
3145 * \param [inout] fileName - the file name.
3147 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3149 contentNotNull()->setFileName(fileName);
3153 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3154 * in the same order.
3155 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3156 * Each item of this sequence is a vector containing ids of equal profiles.
3158 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3160 return contentNotNull()->whichAreEqualProfiles();
3164 * Finds equal localizations.
3165 * \param [in] eps - a precision used to compare real values of the localizations.
3166 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3167 * Each item of this sequence is a vector containing ids of equal localizations.
3169 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3171 return contentNotNull()->whichAreEqualLocs(eps);
3175 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3176 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3177 * this sequence is a pair whose
3178 * - the first item is a vector of profile names to replace by the second item,
3179 * - the second item is a profile name to replace every profile name of the first item.
3181 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3183 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3187 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3188 * \param [in] mapOfModif - a sequence describing required renaming. 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 name of the first item.
3193 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3195 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3199 * Replaces references to some profiles (a reference is a profile name) by references
3200 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3201 * them-selves accordingly. <br>
3202 * This method is a generalization of changePflName().
3203 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3204 * this sequence is a pair whose
3205 * - the first item is a vector of profile names to replace by the second item,
3206 * - the second item is a profile name to replace every profile of the first item.
3207 * \sa changePflsRefsNamesGen()
3208 * \sa changePflName()
3210 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3212 changePflsRefsNamesGen(mapOfModif);
3213 changePflsNamesInStruct(mapOfModif);
3217 * Replaces references to some localizations (a reference is a localization name) by references
3218 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3219 * them-selves accordingly. <br>
3220 * This method is a generalization of changeLocName().
3221 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3222 * this sequence is a pair whose
3223 * - the first item is a vector of localization names to replace by the second item,
3224 * - the second item is a localization name to replace every localization of the first item.
3225 * \sa changeLocsRefsNamesGen()
3226 * \sa changeLocName()
3228 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3230 changeLocsRefsNamesGen(mapOfModif);
3231 changeLocsNamesInStruct(mapOfModif);
3235 * Renames the profile having a given name and updates references to this profile.
3236 * \param [in] oldName - the name of the profile to rename.
3237 * \param [in] newName - a new name of the profile.
3238 * \sa changePflsNames().
3240 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3242 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3243 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3245 changePflsNames(mapOfModif);
3249 * Renames the localization having a given name and updates references to this localization.
3250 * \param [in] oldName - the name of the localization to rename.
3251 * \param [in] newName - a new name of the localization.
3252 * \sa changeLocsNames().
3254 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3256 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3257 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3259 changeLocsNames(mapOfModif);
3263 * Removes duplicated profiles. Returns a map used to update references to removed
3264 * profiles via changePflsRefsNamesGen().
3265 * Equal profiles are found using whichAreEqualProfiles().
3266 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3267 * a sequence describing the performed replacements of profiles. Each element of
3268 * this sequence is a pair whose
3269 * - the first item is a vector of profile names replaced by the second item,
3270 * - the second item is a profile name replacing every profile of the first item.
3272 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3274 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3275 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3277 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3279 std::vector< std::string > tmp((*it).size());
3281 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3282 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3283 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3285 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3286 killProfileIds(tmp2);
3288 changePflsRefsNamesGen(ret);
3293 * Removes duplicated localizations. Returns a map used to update references to removed
3294 * localizations via changeLocsRefsNamesGen().
3295 * Equal localizations are found using whichAreEqualLocs().
3296 * \param [in] eps - a precision used to compare real values of the localizations.
3297 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3298 * a sequence describing the performed replacements of localizations. Each element of
3299 * this sequence is a pair whose
3300 * - the first item is a vector of localization names replaced by the second item,
3301 * - the second item is a localization name replacing every localization of the first item.
3303 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3305 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3306 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3308 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3310 std::vector< std::string > tmp((*it).size());
3312 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3313 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3314 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3316 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3317 killLocalizationIds(tmp2);
3319 changeLocsRefsNamesGen(ret);
3324 * Returns number of Gauss points per cell in a given localization.
3325 * \param [in] locId - an id of the localization of interest.
3326 * \return int - the number of the Gauss points per cell.
3328 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3330 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3334 * Returns an id of a localization by its name.
3335 * \param [in] loc - the localization name of interest.
3336 * \return int - the id of the localization.
3337 * \throw If there is no a localization named \a loc.
3339 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3341 return contentNotNull()->getLocalizationId(loc);
3345 * Returns the name of the MED file.
3346 * \return const char * - the MED file name.
3348 const char *MEDFileFieldGlobsReal::getFileName() const
3350 return contentNotNull()->getFileName();
3353 std::string MEDFileFieldGlobsReal::getFileName2() const
3355 return contentNotNull()->getFileName2();
3359 * Returns a localization object by its name.
3360 * \param [in] locName - the name of the localization of interest.
3361 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3362 * \throw If there is no a localization named \a locName.
3364 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3366 return contentNotNull()->getLocalization(locName);
3370 * Returns a localization object by its id.
3371 * \param [in] locId - the id of the localization of interest.
3372 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3373 * \throw If there is no a localization with id \a locId.
3375 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3377 return contentNotNull()->getLocalizationFromId(locId);
3381 * Returns a profile array by its name.
3382 * \param [in] pflName - the name of the profile of interest.
3383 * \return const DataArrayInt * - the profile array having the name \a pflName.
3384 * \throw If there is no a profile named \a pflName.
3386 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3388 return contentNotNull()->getProfile(pflName);
3392 * Returns a profile array by its id.
3393 * \param [in] pflId - the id of the profile of interest.
3394 * \return const DataArrayInt * - the profile array having the id \a pflId.
3395 * \throw If there is no a profile with id \a pflId.
3397 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3399 return contentNotNull()->getProfileFromId(pflId);
3403 * Returns a localization object, apt for modification, by its id.
3404 * \param [in] locId - the id of the localization of interest.
3405 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3406 * having the id \a locId.
3407 * \throw If there is no a localization with id \a locId.
3409 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3411 return contentNotNull()->getLocalizationFromId(locId);
3415 * Returns a localization object, apt for modification, by its name.
3416 * \param [in] locName - the name of the localization of interest.
3417 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3418 * having the name \a locName.
3419 * \throw If there is no a localization named \a locName.
3421 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3423 return contentNotNull()->getLocalization(locName);
3427 * Returns a profile array, apt for modification, by its name.
3428 * \param [in] pflName - the name of the profile of interest.
3429 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3430 * \throw If there is no a profile named \a pflName.
3432 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3434 return contentNotNull()->getProfile(pflName);
3438 * Returns a profile array, apt for modification, by its id.
3439 * \param [in] pflId - the id of the profile of interest.
3440 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3441 * \throw If there is no a profile with id \a pflId.
3443 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3445 return contentNotNull()->getProfileFromId(pflId);
3449 * Removes profiles given by their ids. No data is updated to track this removal.
3450 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3452 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3454 contentNotNull()->killProfileIds(pflIds);
3458 * Removes localizations given by their ids. No data is updated to track this removal.
3459 * \param [in] locIds - a sequence of ids of the localizations to remove.
3461 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3463 contentNotNull()->killLocalizationIds(locIds);
3467 * Stores a profile array.
3468 * \param [in] pfl - the profile array to store.
3469 * \throw If the name of \a pfl is empty.
3470 * \throw If a profile with the same name as that of \a pfl already exists but contains
3473 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3475 contentNotNull()->appendProfile(pfl);
3479 * Adds a new localization of Gauss points.
3480 * \param [in] locName - the name of the new localization.
3481 * \param [in] geoType - a geometrical type of the reference cell.
3482 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3483 * must be \c nbOfNodesPerCell * \c dimOfType.
3484 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3485 * must be _wg_.size() * \c dimOfType.
3486 * \param [in] w - the weights of Gauss points.
3487 * \throw If \a locName is empty.
3488 * \throw If a localization with the name \a locName already exists but is
3489 * different form the new one.
3491 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)
3493 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3496 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3498 MEDFileFieldGlobs *g(_globals);
3500 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3504 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3506 const MEDFileFieldGlobs *g(_globals);
3508 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3512 //= MEDFileFieldNameScope
3514 MEDFileFieldNameScope::MEDFileFieldNameScope()
3518 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3523 * Returns the name of \a this field.
3524 * \return std::string - a string containing the field name.
3526 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3532 * Sets name of \a this field
3533 * \param [in] name - the new field name.
3535 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3540 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3545 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3550 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3553 _dt_unit=other._dt_unit;
3556 //= MEDFileAnyTypeField1TSWithoutSDA
3558 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3560 _field_per_mesh.resize(other._field_per_mesh.size());
3562 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3564 if((const MEDFileFieldPerMesh *)*it)
3565 _field_per_mesh[i]=(*it)->deepCpy(this);
3570 * Prints a string describing \a this field into a stream. This string is outputted
3571 * by \c print Python command.
3572 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3573 * \param [in,out] oss - the out stream.
3574 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3575 * info id printed, else, not.
3577 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3579 std::string startOfLine(bkOffset,' ');
3580 oss << startOfLine << "Field ";
3582 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3583 oss << "on one time Step ";
3585 oss << "(" << f1tsId << ") ";
3586 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3587 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3588 const DataArray *arr=getUndergroundDataArray();
3591 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3594 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3595 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3596 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3598 if(arr->isAllocated())
3600 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3603 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3607 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3609 oss << startOfLine << "----------------------" << std::endl;
3610 if(!_field_per_mesh.empty())
3613 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3615 const MEDFileFieldPerMesh *cur=(*it2);
3617 cur->simpleRepr(bkOffset,oss,i);
3619 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3624 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3626 oss << startOfLine << "----------------------" << std::endl;
3629 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3631 const DataArray *arr(getUndergroundDataArray());
3633 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3634 int nbOfCompo=arr->getNumberOfComponents();
3635 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3636 for(int i=0;i<nbOfCompo;i++)
3639 std::vector<int> v(1,i);
3640 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3641 ret[i]->setArray(arr2);
3646 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3650 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3655 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3656 * empty. Returns -1 if this in on nodes.
3657 * \return int - the dimension of \a this.
3659 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3662 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3663 (*it)->getDimension(ret);
3668 * Returns the mesh name.
3669 * \return std::string - a string holding the mesh name.
3670 * \throw If \c _field_per_mesh.empty()
3672 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3674 if(_field_per_mesh.empty())
3675 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3676 return _field_per_mesh[0]->getMeshName();
3679 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3681 std::string oldName(getMeshName());
3682 std::vector< std::pair<std::string,std::string> > v(1);
3683 v[0].first=oldName; v[0].second=newMeshName;
3687 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3690 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3692 MEDFileFieldPerMesh *cur(*it);
3694 ret=cur->changeMeshNames(modifTab) || ret;
3700 * Returns the number of iteration of the state of underlying mesh.
3701 * \return int - the iteration number.
3702 * \throw If \c _field_per_mesh.empty()
3704 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3706 if(_field_per_mesh.empty())
3707 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3708 return _field_per_mesh[0]->getMeshIteration();
3712 * Returns the order number of iteration of the state of underlying mesh.
3713 * \return int - the order number.
3714 * \throw If \c _field_per_mesh.empty()
3716 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3718 if(_field_per_mesh.empty())
3719 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3720 return _field_per_mesh[0]->getMeshOrder();
3724 * Checks if \a this field is tagged by a given iteration number and a given
3725 * iteration order number.
3726 * \param [in] iteration - the iteration number of interest.
3727 * \param [in] order - the iteration order number of interest.
3728 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3729 * \a this->getOrder() == \a order.
3731 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3733 return iteration==_iteration && order==_order;
3737 * Returns number of iteration and order number of iteration when
3738 * \a this field has been calculated.
3739 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3742 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3744 std::pair<int,int> p;
3750 * Returns number of iteration and order number of iteration when
3751 * \a this field has been calculated.
3752 * \param [in,out] p - a pair returning the iteration number and the iteration
3755 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3762 * Returns all types of spatial discretization of \a this field.
3763 * \param [in,out] types - a sequence of types of \a this field.
3765 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3767 std::set<TypeOfField> types2;
3768 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3770 (*it)->fillTypesOfFieldAvailable(types2);
3772 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3773 std::copy(types2.begin(),types2.end(),bi);
3777 * Returns all types of spatial discretization of \a this field.
3778 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3781 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3783 std::vector<TypeOfField> ret;
3784 fillTypesOfFieldAvailable(ret);
3788 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3790 std::vector<std::string> ret;
3791 std::set<std::string> ret2;
3792 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3794 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3795 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3796 if(ret2.find(*it2)==ret2.end())
3798 ret.push_back(*it2);
3805 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3807 std::vector<std::string> ret;
3808 std::set<std::string> ret2;
3809 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3811 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3812 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3813 if(ret2.find(*it2)==ret2.end())
3815 ret.push_back(*it2);
3822 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3824 std::vector<std::string> ret;
3825 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3827 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3828 ret.insert(ret.end(),tmp.begin(),tmp.end());
3833 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3835 std::vector<std::string> ret;
3836 std::set<std::string> ret2;
3837 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3839 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3840 ret.insert(ret.end(),tmp.begin(),tmp.end());
3845 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3847 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3848 (*it)->changePflsRefsNamesGen(mapOfModif);
3851 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3853 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3854 (*it)->changeLocsRefsNamesGen(mapOfModif);
3858 * Returns all attributes of parts of \a this field lying on a given mesh.
3859 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3860 * item of every of returned sequences refers to the _i_-th part of \a this field.
3861 * Thus all sequences returned by this method are of the same length equal to number
3862 * of different types of supporting entities.<br>
3863 * A field part can include sub-parts with several different spatial discretizations,
3864 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3865 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3866 * of a nested sequence corresponds to a type of spatial discretization.<br>
3867 * This method allows for iteration over MEDFile DataStructure without any overhead.
3868 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3869 * for the case with only one underlying mesh. (Actually, the number of meshes is
3870 * not checked if \a mname == \c NULL).
3871 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3872 * a field part is returned.
3873 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3874 * This sequence is of the same length as \a types.
3875 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3876 * discretization. A profile name can be empty.
3877 * Length of this and of nested sequences is the same as that of \a typesF.
3878 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3879 * discretization. A localization name can be empty.
3880 * Length of this and of nested sequences is the same as that of \a typesF.
3881 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3882 * of ids of tuples within the data array, per each type of spatial
3883 * discretization within one mesh entity type.
3884 * Length of this and of nested sequences is the same as that of \a typesF.
3885 * \throw If no field is lying on \a mname.
3887 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)
3891 meshId=getMeshIdFromMeshName(mname);
3893 if(_field_per_mesh.empty())
3894 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3895 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3899 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3900 * maximal absolute dimension and values returned via the out parameter \a levs are
3901 * dimensions relative to the maximal absolute dimension. <br>
3902 * This method is designed for MEDFileField1TS instances that have a discretization
3903 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3904 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3905 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3906 * Only these 3 discretizations will be taken into account here. If \a this is
3907 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3908 * This method is useful to make the link between the dimension of the underlying mesh
3909 * and the levels of \a this, because it is possible that the highest dimension of \a this
3910 * field is not equal to the dimension of the underlying mesh.
3912 * Let's consider the following case:
3913 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3914 * TETRA4, HEXA8, TRI3 and SEG2.
3915 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3916 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3918 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3919 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3920 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3921 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3922 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3923 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3925 * to retrieve the highest level of
3926 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3927 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3928 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3929 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3930 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3931 * for the case with only one underlying mesh. (Actually, the number of meshes is
3932 * not checked if \a mname == \c NULL).
3933 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3934 * absolute one. They are in decreasing order. This sequence is cleared before
3936 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3937 * \throw If no field is lying on \a mname.
3939 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3942 int meshId=getMeshIdFromMeshName(mname);
3943 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3944 std::vector< std::vector<TypeOfField> > typesF;
3945 std::vector< std::vector<std::string> > pfls, locs;
3946 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3948 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3949 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3950 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3952 st.erase(INTERP_KERNEL::NORM_ERROR);
3954 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3956 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3957 ret1.insert((int)cm.getDimension());
3959 int ret=*std::max_element(ret1.begin(),ret1.end());
3960 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3961 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3966 * \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.
3967 * \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.
3968 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3969 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3971 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3973 int mid=getMeshIdFromMeshName(mName);
3974 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3978 * \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.
3979 * \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.
3980 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
3981 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3983 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3985 int mid=getMeshIdFromMeshName(mName);
3986 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3990 * \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.
3992 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3994 if(_field_per_mesh.empty())
3995 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3998 std::string mName2(mName);
4000 std::vector<std::string> msg;
4001 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4002 if(mName2==(*it)->getMeshName())
4005 msg.push_back((*it)->getMeshName());
4006 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4007 oss << "Possible meshes are : ";
4008 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4009 oss << "\"" << (*it2) << "\" ";
4010 throw INTERP_KERNEL::Exception(oss.str().c_str());
4013 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4016 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4017 std::string tmp(mesh->getName());
4019 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4020 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4022 for(;it!=_field_per_mesh.end();it++,i++)
4024 if((*it)->getMeshName()==tmp)
4027 int sz=_field_per_mesh.size();
4028 _field_per_mesh.resize(sz+1);
4029 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4033 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4034 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4037 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4039 MEDFileFieldPerMesh *fpm(*it);
4041 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4046 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4048 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4049 std::vector< std::vector<TypeOfField> > typesF;
4050 std::vector< std::vector<std::string> > pfls,locs;
4051 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4052 std::set<TypeOfField> allEnt;
4053 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4054 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4055 allEnt.insert(*it2);
4056 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4057 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4058 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4060 std::vector< std::pair<int,int> > its;
4061 ret[i]=shallowCpy();
4062 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4063 ret[i]->updateData(newLgth,its);
4068 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4070 int globalCounter=0;
4071 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4072 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4073 return globalCounter;
4076 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4078 if(_nb_of_tuples_to_be_allocated>=0)
4080 _nb_of_tuples_to_be_allocated=newLgth;
4083 if(_nb_of_tuples_to_be_allocated==-1)
4085 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4087 const DataArray *oldArr=getUndergroundDataArray();
4088 if(!oldArr || !oldArr->isAllocated())
4089 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4090 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4091 newArr->alloc(newLgth,getNumberOfComponents());
4093 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4095 if((*it).second<(*it).first)
4096 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4097 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4098 pos+=(*it).second-(*it).first;
4103 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4106 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4108 if(_field_per_mesh.empty())
4109 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4110 if(_field_per_mesh.size()>1)
4111 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4112 _field_per_mesh[0]->copyOptionsFrom(opts);
4113 _field_per_mesh[0]->writeLL(fid,nasc);
4117 * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated.
4118 * If false is returned the memory allocation is not required.
4120 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4122 if(_nb_of_tuples_to_be_allocated>=0)
4124 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4125 _nb_of_tuples_to_be_allocated=-2;
4128 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4130 if(_nb_of_tuples_to_be_allocated==-1)
4131 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4132 if(_nb_of_tuples_to_be_allocated<-3)
4133 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4137 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4139 med_int numdt,numit;
4143 med_int meshnumdt,meshnumit;
4144 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4145 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4146 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4147 if(_iteration!=numdt || _order!=numit)
4148 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4149 _field_per_mesh.resize(nmesh);
4150 for(int i=0;i<nmesh;i++)
4151 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4152 _nb_of_tuples_to_be_allocated=0;
4153 for(int i=0;i<nmesh;i++)
4154 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4157 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4159 allocIfNecessaryTheArrayToReceiveDataFromFile();
4160 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4161 (*it)->loadBigArraysRecursively(fid,nasc);
4164 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4166 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4167 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4168 (*it)->loadBigArraysRecursively(fid,nasc);
4171 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4173 loadOnlyStructureOfDataRecursively(fid,nasc);
4174 loadBigArraysRecursively(fid,nasc);
4177 void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
4179 DataArray *thisArr(getUndergroundDataArray());
4180 if(thisArr && thisArr->isAllocated())
4182 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4183 thisArr->desallocate();
4187 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4189 std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4190 if(getUndergroundDataArray())
4191 ret+=getUndergroundDataArray()->getHeapMemorySize();
4192 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4193 ret+=(*it)->getHeapMemorySize();
4198 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4199 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4200 * "Sort By Type"), if not, an exception is thrown.
4201 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4202 * \param [in] arr - the array of values.
4203 * \param [in,out] glob - the global data where profiles and localization present in
4204 * \a field, if any, are added.
4205 * \throw If the name of \a field is empty.
4206 * \throw If the data array of \a field is not set.
4207 * \throw If \a this->_arr is already allocated but has different number of components
4209 * \throw If the underlying mesh of \a field has no name.
4210 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4212 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4214 const MEDCouplingMesh *mesh=field->getMesh();
4216 TypeOfField type=field->getTypeOfField();
4217 std::vector<DataArrayInt *> dummy;
4218 int start=copyTinyInfoFrom(field,arr);
4219 int pos=addNewEntryIfNecessary(mesh);
4222 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4223 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4226 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4230 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4231 * of a given mesh are used as the support of the given field (a real support is not used).
4232 * Elements of the given mesh must be sorted suitable for writing to MED file.
4233 * Order of underlying mesh entities of the given field specified by \a profile parameter
4234 * is not prescribed; this method permutes field values to have them sorted by element
4235 * type as required for writing to MED file. A new profile is added only if no equal
4236 * profile is missing.
4237 * \param [in] field - the field to add to \a this. The field double values are ignored.
4238 * \param [in] arrOfVals - the values of the field \a field used.
4239 * \param [in] mesh - the supporting mesh of \a field.
4240 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4241 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4242 * \param [in,out] glob - the global data where profiles and localization present in
4243 * \a field, if any, are added.
4244 * \throw If either \a field or \a mesh or \a profile has an empty name.
4245 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4246 * \throw If the data array of \a field is not set.
4247 * \throw If \a this->_arr is already allocated but has different number of components
4249 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4250 * \sa setFieldNoProfileSBT()
4252 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)
4254 TypeOfField type=field->getTypeOfField();
4255 int start=copyTinyInfoFrom(field,arrOfVals);
4256 std::vector<DataArrayInt *> idsInPflPerType;
4257 std::vector<DataArrayInt *> idsPerType;
4258 std::vector<int> code,code2;
4259 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4262 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4263 code2=m->getDistributionOfTypes();
4265 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4266 for(std::size_t i=0;i<idsInPflPerType.size();i++)
4267 idsInPflPerType2[i]=idsInPflPerType[i];
4268 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4269 for(std::size_t i=0;i<idsPerType.size();i++)
4270 idsPerType2[i]=idsPerType[i];
4272 int pos=addNewEntryIfNecessary(m);
4273 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4277 int pos=addNewEntryIfNecessary(m);
4278 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4283 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4285 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4287 if(_nb_of_tuples_to_be_allocated>=0)
4288 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile : the object is expected to be appended to a data coming from a file but not loaded ! Load before appending data !");
4289 DataArray *arr(getOrCreateAndGetArray());
4290 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4291 _nb_of_tuples_to_be_allocated=-3;
4295 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4296 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4297 * larger by the size of \a field. Returns an id of the first not filled
4298 * tuple of \a this->_arr.
4299 * \param [in] field - the field to copy the info on components and the name from.
4300 * \return int - the id of first not initialized tuple of \a this->_arr.
4301 * \throw If the name of \a field is empty.
4302 * \throw If the data array of \a field is not set.
4303 * \throw If \a this->_arr is already allocated but has different number of components
4306 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4309 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4310 std::string name(field->getName());
4311 setName(name.c_str());
4312 setDtUnit(field->getTimeUnit());
4314 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4316 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4317 if(!arr->isAllocated())
4318 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4319 _dt=field->getTime(_iteration,_order);
4320 int nbOfComponents=arr->getNumberOfComponents();
4321 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4322 if(!getOrCreateAndGetArray()->isAllocated())
4324 allocNotFromFile(arr->getNumberOfTuples());
4329 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4330 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4331 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4332 _nb_of_tuples_to_be_allocated=-3;
4333 return oldNbOfTuples;
4338 * Returns number of components in \a this field
4339 * \return int - the number of components.
4341 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4343 return getOrCreateAndGetArray()->getNumberOfComponents();
4347 * Change info on components in \a this.
4348 * \throw If size of \a infos is not equal to the number of components already in \a this.
4350 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4352 DataArray *arr=getOrCreateAndGetArray();
4353 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4357 * Returns info on components of \a this field.
4358 * \return const std::vector<std::string>& - a sequence of strings each being an
4359 * information on _i_-th component.
4361 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4363 const DataArray *arr=getOrCreateAndGetArray();
4364 return arr->getInfoOnComponents();
4368 * Returns a mutable info on components of \a this field.
4369 * \return std::vector<std::string>& - a sequence of strings each being an
4370 * information on _i_-th component.
4372 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4374 DataArray *arr=getOrCreateAndGetArray();
4375 return arr->getInfoOnComponents();
4379 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4380 * \param [in] type - a spatial discretization of the new field.
4381 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4382 * \param [in] mName - a name of the supporting mesh.
4383 * \param [in] renumPol - specifies how to permute values of the result field according to
4384 * the optional numbers of cells and nodes, if any. The valid values are
4385 * - 0 - do not permute.
4386 * - 1 - permute cells.
4387 * - 2 - permute nodes.
4388 * - 3 - permute cells and nodes.
4390 * \param [in] glob - the global data storing profiles and localization.
4391 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4392 * caller is to delete this field using decrRef() as it is no more needed.
4393 * \throw If the MED file is not readable.
4394 * \throw If there is no mesh named \a mName in the MED file.
4395 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4396 * \throw If no field of \a this is lying on the mesh \a mName.
4397 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4399 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)
4401 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4403 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4405 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4406 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4410 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4411 * \param [in] type - a spatial discretization of the new field.
4412 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4413 * \param [in] renumPol - specifies how to permute values of the result field according to
4414 * the optional numbers of cells and nodes, if any. The valid values are
4415 * - 0 - do not permute.
4416 * - 1 - permute cells.
4417 * - 2 - permute nodes.
4418 * - 3 - permute cells and nodes.
4420 * \param [in] glob - the global data storing profiles and localization.
4421 * \param [in] mesh - the supporting mesh.
4422 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4423 * caller is to delete this field using decrRef() as it is no more needed.
4424 * \throw If the MED file is not readable.
4425 * \throw If no field of \a this is lying on \a mesh.
4426 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4427 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4429 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)
4431 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4432 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4433 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4434 if(meshDimRelToMax==1)
4435 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4436 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4440 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4442 * \param [in] type - a spatial discretization of the new field.
4443 * \param [in] mName - a name of the supporting mesh.
4444 * \param [in] renumPol - specifies how to permute values of the result field according to
4445 * the optional numbers of cells and nodes, if any. The valid values are
4446 * - 0 - do not permute.
4447 * - 1 - permute cells.
4448 * - 2 - permute nodes.
4449 * - 3 - permute cells and nodes.
4451 * \param [in] glob - the global data storing profiles and localization.
4452 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4453 * caller is to delete this field using decrRef() as it is no more needed.
4454 * \throw If the MED file is not readable.
4455 * \throw If there is no mesh named \a mName in the MED file.
4456 * \throw If there are no mesh entities in the mesh.
4457 * \throw If no field values of the given \a type are available.
4459 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4461 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4463 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4465 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4466 int absDim=getDimension();
4467 int meshDimRelToMax=absDim-mm->getMeshDimension();
4468 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4472 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4473 * \param [in] type - a spatial discretization of the new field.
4474 * \param [in] renumPol - specifies how to permute values of the result field according to
4475 * the optional numbers of cells and nodes, if any. The valid values are
4476 * - 0 - do not permute.
4477 * - 1 - permute cells.
4478 * - 2 - permute nodes.
4479 * - 3 - permute cells and nodes.
4481 * \param [in] glob - the global data storing profiles and localization.
4482 * \param [in] mesh - the supporting mesh.
4483 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4484 * field according to \a renumPol.
4485 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4486 * field according to \a renumPol.
4487 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4488 * caller is to delete this field using decrRef() as it is no more needed.
4489 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4490 * \throw If no field of \a this is lying on \a mesh.
4491 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4493 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)
4495 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4496 int meshId=getMeshIdFromMeshName(mesh->getName());
4498 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4503 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4510 throw INTERP_KERNEL::Exception(msg1);
4511 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4514 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4516 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4517 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4518 throw INTERP_KERNEL::Exception(oss.str().c_str());
4520 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4521 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4522 std::vector<DataArray *> arrOut2(1,arrOut);
4523 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4524 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4525 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4532 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4534 throw INTERP_KERNEL::Exception(msg1);
4537 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4539 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4540 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4541 throw INTERP_KERNEL::Exception(oss.str().c_str());
4543 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4544 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4545 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4546 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4551 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4556 * Returns values and a profile of the field of a given type lying on a given support.
4557 * \param [in] type - a spatial discretization of the field.
4558 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4559 * \param [in] mesh - the supporting mesh.
4560 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4561 * field of interest lies on. If the field lies on all entities of the given
4562 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4563 * using decrRef() as it is no more needed.
4564 * \param [in] glob - the global data storing profiles and localization.
4565 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4566 * field. The caller is to delete this array using decrRef() as it is no more needed.
4567 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4568 * \throw If no field of \a this is lying on \a mesh.
4569 * \throw If no field values of the given \a type are available.
4571 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4573 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4574 int meshId=getMeshIdFromMeshName(mesh->getName());
4575 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4576 ret->setName(nasc.getName().c_str());
4580 //= MEDFileField1TSWithoutSDA
4583 * Throws if a given value is not a valid (non-extended) relative dimension.
4584 * \param [in] meshDimRelToMax - the relative dimension value.
4585 * \throw If \a meshDimRelToMax > 0.
4587 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4589 if(meshDimRelToMax>0)
4590 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4594 * Checks if elements of a given mesh are in the order suitable for writing
4595 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4596 * vector describing types of elements and their number.
4597 * \param [in] mesh - the mesh to check.
4598 * \return std::vector<int> - a vector holding for each element type (1) item of
4599 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4600 * These values are in full-interlace mode.
4601 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4603 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4606 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4607 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4608 int nbOfTypes=geoTypes.size();
4609 std::vector<int> code(3*nbOfTypes);
4610 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4611 arr1->alloc(nbOfTypes,1);
4612 int *arrPtr=arr1->getPointer();
4613 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4614 for(int i=0;i<nbOfTypes;i++,it++)
4615 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4616 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4617 const int *arrPtr2=arr2->getConstPointer();
4619 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4622 int nbCells=mesh->getNumberOfCellsWithType(*it);
4623 code[3*pos]=(int)(*it);
4624 code[3*pos+1]=nbCells;
4625 code[3*pos+2]=-1;//no profiles
4627 std::vector<const DataArrayInt *> idsPerType;//no profiles
4628 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4632 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4637 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4639 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4643 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4644 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4645 * item of every of returned sequences refers to the _i_-th part of \a this field.
4646 * Thus all sequences returned by this method are of the same length equal to number
4647 * of different types of supporting entities.<br>
4648 * A field part can include sub-parts with several different spatial discretizations,
4649 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4650 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4651 * of a nested sequence corresponds to a type of spatial discretization.<br>
4652 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4653 * The overhead is due to selecting values into new instances of DataArrayDouble.
4654 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4655 * for the case with only one underlying mesh. (Actually, the number of meshes is
4656 * not checked if \a mname == \c NULL).
4657 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4658 * a field part is returned.
4659 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4660 * A field part can include sub-parts with several different spatial discretizations,
4661 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4662 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4663 * This sequence is of the same length as \a types.
4664 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4665 * discretization. A profile name can be empty.
4666 * Length of this and of nested sequences is the same as that of \a typesF.
4667 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4668 * discretization. A localization name can be empty.
4669 * Length of this and of nested sequences is the same as that of \a typesF.
4670 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4671 * per each type of spatial discretization within one mesh entity type.
4672 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4673 * Length of this and of nested sequences is the same as that of \a typesF.
4674 * \throw If no field is lying on \a mname.
4676 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)
4680 meshId=getMeshIdFromMeshName(mname);
4682 if(_field_per_mesh.empty())
4683 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4684 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4685 int nbOfRet=ret0.size();
4686 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4687 for(int i=0;i<nbOfRet;i++)
4689 const std::vector< std::pair<int,int> >& p=ret0[i];
4690 int nbOfRet1=p.size();
4691 ret[i].resize(nbOfRet1);
4692 for(int j=0;j<nbOfRet1;j++)
4694 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4702 * Returns a pointer to the underground DataArrayDouble instance. So the
4703 * caller should not decrRef() it. This method allows for a direct access to the field
4704 * values. This method is quite unusable if there is more than a nodal field or a cell
4705 * field on single geometric cell type.
4706 * \return DataArrayDouble * - the pointer to the field values array.
4708 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4710 const DataArrayDouble *ret=_arr;
4712 return const_cast<DataArrayDouble *>(ret);
4717 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4722 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4724 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4725 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4726 ret->deepCpyLeavesFrom(*this);
4727 const DataArrayDouble *arr(_arr);
4730 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4731 ret->setArray(arr2);
4737 * Returns a pointer to the underground DataArrayDouble instance. So the
4738 * caller should not decrRef() it. This method allows for a direct access to the field
4739 * values. This method is quite unusable if there is more than a nodal field or a cell
4740 * field on single geometric cell type.
4741 * \return DataArrayDouble * - the pointer to the field values array.
4743 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4745 return getUndergroundDataArrayDouble();
4749 * Returns a pointer to the underground DataArrayDouble instance and a
4750 * sequence describing parameters of a support of each part of \a this field. The
4751 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4752 * direct access to the field values. This method is intended for the field lying on one
4754 * \param [in,out] entries - the sequence describing parameters of a support of each
4755 * part of \a this field. Each item of this sequence consists of two parts. The
4756 * first part describes a type of mesh entity and an id of discretization of a
4757 * current field part. The second part describes a range of values [begin,end)
4758 * within the returned array relating to the current field part.
4759 * \return DataArrayDouble * - the pointer to the field values array.
4760 * \throw If the number of underlying meshes is not equal to 1.
4761 * \throw If no field values are available.
4762 * \sa getUndergroundDataArray()
4764 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4766 if(_field_per_mesh.size()!=1)
4767 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4768 if(_field_per_mesh[0]==0)
4769 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4770 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4771 return getUndergroundDataArrayDouble();
4775 * Returns a pointer to the underground DataArrayDouble instance and a
4776 * sequence describing parameters of a support of each part of \a this field. The
4777 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4778 * direct access to the field values. This method is intended for the field lying on one
4780 * \param [in,out] entries - the sequence describing parameters of a support of each
4781 * part of \a this field. Each item of this sequence consists of two parts. The
4782 * first part describes a type of mesh entity and an id of discretization of a
4783 * current field part. The second part describes a range of values [begin,end)
4784 * within the returned array relating to the current field part.
4785 * \return DataArrayDouble * - the pointer to the field values array.
4786 * \throw If the number of underlying meshes is not equal to 1.
4787 * \throw If no field values are available.
4788 * \sa getUndergroundDataArray()
4790 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4792 return getUndergroundDataArrayDoubleExt(entries);
4795 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4796 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4798 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4799 arr->setInfoAndChangeNbOfCompo(infos);
4802 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4806 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4808 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4809 ret->deepCpyLeavesFrom(*this);
4813 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4815 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4816 if((const DataArrayDouble *)_arr)
4817 ret->_arr=_arr->deepCpy();
4821 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4825 _nb_of_tuples_to_be_allocated=-1;
4829 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4831 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4833 _nb_of_tuples_to_be_allocated=-3;
4838 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4840 return DataArrayDouble::New();
4843 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4845 DataArrayDouble *ret=_arr;
4848 _arr=DataArrayDouble::New();
4852 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4854 return getOrCreateAndGetArrayDouble();
4857 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4859 const DataArrayDouble *ret=_arr;
4862 DataArrayDouble *ret2=DataArrayDouble::New();
4863 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4867 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4869 return getOrCreateAndGetArrayDouble();
4872 //= MEDFileIntField1TSWithoutSDA
4874 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4875 const std::vector<std::string>& infos)
4877 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4880 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4884 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4885 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4887 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4888 arr->setInfoAndChangeNbOfCompo(infos);
4891 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4896 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4898 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4899 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4900 ret->deepCpyLeavesFrom(*this);
4901 const DataArrayInt *arr(_arr);
4904 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4905 ret->setArray(arr2);
4911 * Returns a pointer to the underground DataArrayInt instance. So the
4912 * caller should not decrRef() it. This method allows for a direct access to the field
4913 * values. This method is quite unusable if there is more than a nodal field or a cell
4914 * field on single geometric cell type.
4915 * \return DataArrayInt * - the pointer to the field values array.
4917 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4919 return getUndergroundDataArrayInt();
4923 * Returns a pointer to the underground DataArrayInt instance. So the
4924 * caller should not decrRef() it. This method allows for a direct access to the field
4925 * values. This method is quite unusable if there is more than a nodal field or a cell
4926 * field on single geometric cell type.
4927 * \return DataArrayInt * - the pointer to the field values array.
4929 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4931 const DataArrayInt *ret=_arr;
4933 return const_cast<DataArrayInt *>(ret);
4939 * Returns a pointer to the underground DataArrayInt instance and a
4940 * sequence describing parameters of a support of each part of \a this field. The
4941 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4942 * direct access to the field values. This method is intended for the field lying on one
4944 * \param [in,out] entries - the sequence describing parameters of a support of each
4945 * part of \a this field. Each item of this sequence consists of two parts. The
4946 * first part describes a type of mesh entity and an id of discretization of a
4947 * current field part. The second part describes a range of values [begin,end)
4948 * within the returned array relating to the current field part.
4949 * \return DataArrayInt * - the pointer to the field values array.
4950 * \throw If the number of underlying meshes is not equal to 1.
4951 * \throw If no field values are available.
4952 * \sa getUndergroundDataArray()
4954 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4956 return getUndergroundDataArrayIntExt(entries);
4960 * Returns a pointer to the underground DataArrayInt instance and a
4961 * sequence describing parameters of a support of each part of \a this field. The
4962 * caller should not decrRef() the returned DataArrayInt. This method allows for a
4963 * direct access to the field values. This method is intended for the field lying on one
4965 * \param [in,out] entries - the sequence describing parameters of a support of each
4966 * part of \a this field. Each item of this sequence consists of two parts. The
4967 * first part describes a type of mesh entity and an id of discretization of a
4968 * current field part. The second part describes a range of values [begin,end)
4969 * within the returned array relating to the current field part.
4970 * \return DataArrayInt * - the pointer to the field values array.
4971 * \throw If the number of underlying meshes is not equal to 1.
4972 * \throw If no field values are available.
4973 * \sa getUndergroundDataArray()
4975 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4977 if(_field_per_mesh.size()!=1)
4978 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4979 if(_field_per_mesh[0]==0)
4980 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4981 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4982 return getUndergroundDataArrayInt();
4985 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4987 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4988 ret->deepCpyLeavesFrom(*this);
4992 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4994 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4995 if((const DataArrayInt *)_arr)
4996 ret->_arr=_arr->deepCpy();
5000 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5004 _nb_of_tuples_to_be_allocated=-1;
5008 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5010 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5012 _nb_of_tuples_to_be_allocated=-3;
5017 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5019 return DataArrayInt::New();
5022 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5024 DataArrayInt *ret=_arr;
5027 _arr=DataArrayInt::New();
5031 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5033 return getOrCreateAndGetArrayInt();
5036 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5038 const DataArrayInt *ret=_arr;
5041 DataArrayInt *ret2=DataArrayInt::New();
5042 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5046 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5048 return getOrCreateAndGetArrayInt();
5051 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5055 //= MEDFileAnyTypeField1TS
5057 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5059 med_field_type typcha;
5061 std::vector<std::string> infos;
5062 std::string dtunit,fieldName;
5063 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5064 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5069 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5074 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5079 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] !";
5080 throw INTERP_KERNEL::Exception(oss.str().c_str());
5083 ret->setDtUnit(dtunit.c_str());
5084 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5086 med_int numdt,numit;
5088 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5089 ret->setTime(numdt,numit,dt);
5092 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5094 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5098 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5099 try:MEDFileFieldGlobsReal(fileName)
5101 MEDFileUtilities::CheckFileForRead(fileName);
5102 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5103 _content=BuildContentFrom(fid,fileName,loadAll);
5106 catch(INTERP_KERNEL::Exception& e)
5111 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5113 med_field_type typcha;
5114 std::vector<std::string> infos;
5117 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5118 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5123 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5128 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5133 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] !";
5134 throw INTERP_KERNEL::Exception(oss.str().c_str());
5137 ret->setDtUnit(dtunit.c_str());
5138 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5142 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5143 throw INTERP_KERNEL::Exception(oss.str().c_str());
5146 med_int numdt,numit;
5148 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5149 ret->setTime(numdt,numit,dt);
5152 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5154 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5158 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5159 try:MEDFileFieldGlobsReal(fileName)
5161 MEDFileUtilities::CheckFileForRead(fileName);
5162 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5163 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5166 catch(INTERP_KERNEL::Exception& e)
5171 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5174 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5175 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5177 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5178 ret->setFileName(fileName);
5179 ret->_content=c; c->incrRef();
5182 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5184 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5185 ret->setFileName(fileName);
5186 ret->_content=c; c->incrRef();
5189 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5192 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5194 MEDFileUtilities::CheckFileForRead(fileName);
5195 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5196 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5197 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5198 ret->loadGlobals(fid);
5202 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5204 MEDFileUtilities::CheckFileForRead(fileName);
5205 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5206 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5207 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5208 ret->loadGlobals(fid);
5212 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5214 MEDFileUtilities::CheckFileForRead(fileName);
5215 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5216 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5217 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5218 ret->loadGlobals(fid);
5222 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5224 med_field_type typcha;
5225 std::vector<std::string> infos;
5228 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5229 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5234 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5239 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5244 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] !";
5245 throw INTERP_KERNEL::Exception(oss.str().c_str());
5248 ret->setDtUnit(dtunit.c_str());
5249 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5252 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5253 for(int i=0;i<nbOfStep2 && !found;i++)
5255 med_int numdt,numit;
5257 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5258 if(numdt==iteration && numit==order)
5264 dtits[i]=std::pair<int,int>(numdt,numit);
5268 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5269 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5270 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5271 throw INTERP_KERNEL::Exception(oss.str().c_str());
5274 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5276 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5280 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5281 try:MEDFileFieldGlobsReal(fileName)
5283 MEDFileUtilities::CheckFileForRead(fileName);
5284 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5285 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5288 catch(INTERP_KERNEL::Exception& e)
5294 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5295 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5297 * \warning this is a shallow copy constructor
5299 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5301 if(!shallowCopyOfContent)
5303 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5304 otherPtr->incrRef();
5305 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5309 _content=other.shallowCpy();
5313 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)
5317 int nbFields=MEDnField(fid);
5318 if(fieldIdCFormat>=nbFields)
5320 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5321 throw INTERP_KERNEL::Exception(oss.str().c_str());
5324 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5325 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5326 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5327 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5328 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5329 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5332 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5333 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5334 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5335 infos.clear(); infos.resize(ncomp);
5336 for(int j=0;j<ncomp;j++)
5337 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5342 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5345 * \return in case of success the number of time steps available for the field with name \a fieldName.
5347 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)
5349 int nbFields=MEDnField(fid);
5351 std::vector<std::string> fns(nbFields);
5353 for(int i=0;i<nbFields && !found;i++)
5356 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5358 found=(tmp==fieldName);
5364 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5365 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5366 oss << "\"" << *it << "\" ";
5367 throw INTERP_KERNEL::Exception(oss.str().c_str());
5373 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5374 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5375 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5376 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5377 * to keep a valid instance.
5378 * 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.
5379 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5380 * 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.
5382 * \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.
5383 * \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.
5384 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5385 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5386 * \param [in] newLocName is the new localization name.
5387 * \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.
5388 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5390 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5392 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5393 std::string oldPflName=disc->getProfile();
5394 std::vector<std::string> vv=getPflsReallyUsedMulti();
5395 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5396 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5398 disc->setProfile(newPflName);
5399 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5400 pfl->setName(newPflName);
5404 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5405 throw INTERP_KERNEL::Exception(oss.str().c_str());
5410 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5411 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5412 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5413 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5414 * to keep a valid instance.
5415 * 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.
5416 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5417 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5418 * 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.
5420 * \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.
5421 * \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.
5422 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5423 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5424 * \param [in] newLocName is the new localization name.
5425 * \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.
5426 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5428 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5430 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5431 std::string oldLocName=disc->getLocalization();
5432 std::vector<std::string> vv=getLocsReallyUsedMulti();
5433 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5434 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5436 disc->setLocalization(newLocName);
5437 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5438 loc.setName(newLocName);
5442 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5443 throw INTERP_KERNEL::Exception(oss.str().c_str());
5447 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5449 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5455 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5457 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5459 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5464 * Writes \a this field into a MED file specified by its name.
5465 * \param [in] fileName - the MED file name.
5466 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5467 * - 2 - erase; an existing file is removed.
5468 * - 1 - append; same data should not be present in an existing file.
5469 * - 0 - overwrite; same data present in an existing file is overwritten.
5470 * \throw If the field name is not set.
5471 * \throw If no field data is set.
5472 * \throw If \a mode == 1 and the same data is present in an existing file.
5474 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5476 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5477 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5482 * This method alloc the arrays and load potentially huge arrays contained in this field.
5483 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5484 * This method can be also called to refresh or reinit values from a file.
5486 * \throw If the fileName is not set or points to a non readable MED file.
5487 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5489 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5491 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5492 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5496 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5497 * But once data loaded once, this method does nothing.
5499 * \throw If the fileName is not set or points to a non readable MED file.
5500 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays
5502 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5504 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5505 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5509 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5510 * This method does not release arrays set outside the context of a MED file.
5512 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5514 void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception)
5516 contentNotNullBase()->releaseArrays();
5519 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5521 int nbComp=getNumberOfComponents();
5522 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5523 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5524 for(int i=0;i<nbComp;i++)
5526 std::string info=getInfo()[i];
5528 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5529 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5530 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5532 if(getName().empty())
5533 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5534 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5535 writeGlobals(fid,*this);
5536 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5539 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5542 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5543 ret+=_content->getHeapMemorySize();
5544 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5548 * Returns a string describing \a this field. This string is outputted
5549 * by \c print Python command.
5551 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5553 std::ostringstream oss;
5554 contentNotNullBase()->simpleRepr(0,oss,-1);
5555 simpleReprGlobs(oss);
5560 * This method returns all profiles whose name is non empty used.
5561 * \b WARNING If profile is used several times it will be reported \b only \b once.
5562 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5564 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5566 return contentNotNullBase()->getPflsReallyUsed2();
5570 * This method returns all localizations whose name is non empty used.
5571 * \b WARNING If localization is used several times it will be reported \b only \b once.
5573 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5575 return contentNotNullBase()->getLocsReallyUsed2();
5579 * This method returns all profiles whose name is non empty used.
5580 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5582 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5584 return contentNotNullBase()->getPflsReallyUsedMulti2();
5588 * This method returns all localizations whose name is non empty used.
5589 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5591 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5593 return contentNotNullBase()->getLocsReallyUsedMulti2();
5596 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5598 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5601 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5603 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5606 int MEDFileAnyTypeField1TS::getDimension() const
5608 return contentNotNullBase()->getDimension();
5611 int MEDFileAnyTypeField1TS::getIteration() const
5613 return contentNotNullBase()->getIteration();
5616 int MEDFileAnyTypeField1TS::getOrder() const
5618 return contentNotNullBase()->getOrder();
5621 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5623 return contentNotNullBase()->getTime(iteration,order);
5626 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5628 contentNotNullBase()->setTime(iteration,order,val);
5631 std::string MEDFileAnyTypeField1TS::getName() const
5633 return contentNotNullBase()->getName();
5636 void MEDFileAnyTypeField1TS::setName(const char *name)
5638 contentNotNullBase()->setName(name);
5641 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5643 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5646 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5648 return contentNotNullBase()->getDtUnit();
5651 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5653 contentNotNullBase()->setDtUnit(dtUnit);
5656 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5658 return contentNotNullBase()->getMeshName();
5661 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5663 contentNotNullBase()->setMeshName(newMeshName);
5666 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5668 return contentNotNullBase()->changeMeshNames(modifTab);
5671 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5673 return contentNotNullBase()->getMeshIteration();
5676 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5678 return contentNotNullBase()->getMeshOrder();
5681 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5683 return contentNotNullBase()->getNumberOfComponents();
5686 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5688 return contentNotNullBase()->isDealingTS(iteration,order);
5691 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5693 return contentNotNullBase()->getDtIt();
5696 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5698 contentNotNullBase()->fillIteration(p);
5701 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5703 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5706 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5708 contentNotNullBase()->setInfo(infos);
5711 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5713 return contentNotNullBase()->getInfo();
5715 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5717 return contentNotNullBase()->getInfo();
5720 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5722 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5725 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5727 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5730 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5732 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5735 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5737 return contentNotNullBase()->getTypesOfFieldAvailable();
5740 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,
5741 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5743 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5747 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5748 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5749 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5751 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5753 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5755 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5756 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5757 std::size_t sz(contentsSplit.size());
5758 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5759 for(std::size_t i=0;i<sz;i++)
5761 ret[i]=shallowCpy();
5762 ret[i]->_content=contentsSplit[i];
5768 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5769 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5771 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5773 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5775 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5776 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5777 std::size_t sz(contentsSplit.size());
5778 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5779 for(std::size_t i=0;i<sz;i++)
5781 ret[i]=shallowCpy();
5782 ret[i]->_content=contentsSplit[i];
5787 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5789 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5790 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5791 ret->_content=_content->deepCpy();
5792 ret->deepCpyGlobs(*this);
5796 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5798 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5804 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5805 * the first field that has been read from a specified MED file.
5806 * \param [in] fileName - the name of the MED file to read.
5807 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5808 * is to delete this field using decrRef() as it is no more needed.
5809 * \throw If reading the file fails.
5811 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5813 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5814 ret->contentNotNull();
5819 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5820 * a given field that has been read from a specified MED file.
5821 * \param [in] fileName - the name of the MED file to read.
5822 * \param [in] fieldName - the name of the field to read.
5823 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5824 * is to delete this field using decrRef() as it is no more needed.
5825 * \throw If reading the file fails.
5826 * \throw If there is no field named \a fieldName in the file.
5828 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5830 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5831 ret->contentNotNull();
5836 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5837 * a given field that has been read from a specified MED file.
5838 * \param [in] fileName - the name of the MED file to read.
5839 * \param [in] fieldName - the name of the field to read.
5840 * \param [in] iteration - the iteration number of a required time step.
5841 * \param [in] order - the iteration order number of required time step.
5842 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5843 * is to delete this field using decrRef() as it is no more needed.
5844 * \throw If reading the file fails.
5845 * \throw If there is no field named \a fieldName in the file.
5846 * \throw If the required time step is missing from the file.
5848 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5850 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5851 ret->contentNotNull();
5856 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5857 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5859 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5860 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5861 * \warning this is a shallow copy constructor
5862 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5863 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5864 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5865 * is to delete this field using decrRef() as it is no more needed.
5867 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5869 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5870 ret->contentNotNull();
5875 * Returns a new empty instance of MEDFileField1TS.
5876 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5877 * is to delete this field using decrRef() as it is no more needed.
5879 MEDFileField1TS *MEDFileField1TS::New()
5881 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5882 ret->contentNotNull();
5887 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5888 * following the given input policy.
5890 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5891 * By default (true) the globals are deeply copied.
5892 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5894 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5896 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5897 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5900 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5902 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5903 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5904 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5907 ret=MEDFileIntField1TS::New();
5909 ret->deepCpyGlobs(*this);
5911 ret->shallowCpyGlobs(*this);
5915 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5917 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5919 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5920 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5922 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 !");
5926 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5928 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5930 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5931 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5933 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 !");
5937 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5940 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5941 if(!((DataArray*)arr))
5942 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5943 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5945 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5946 f->setArray(arrOutC);
5949 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5951 if(!((DataArray*)arr))
5952 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5953 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5955 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5960 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5961 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5964 catch(INTERP_KERNEL::Exception& e)
5967 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5968 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5971 catch(INTERP_KERNEL::Exception& e)
5974 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5975 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
5978 catch(INTERP_KERNEL::Exception& e)
5982 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5983 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5985 * \warning this is a shallow copy constructor
5987 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5988 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5991 catch(INTERP_KERNEL::Exception& e)
5994 MEDFileField1TS::MEDFileField1TS()
5996 _content=new MEDFileField1TSWithoutSDA;
6000 * Returns a new MEDCouplingFieldDouble of a given type lying on
6001 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6002 * has not been constructed via file reading, an exception is thrown.
6003 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6004 * \param [in] type - a spatial discretization of interest.
6005 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6006 * \param [in] renumPol - specifies how to permute values of the result field according to
6007 * the optional numbers of cells and nodes, if any. The valid values are
6008 * - 0 - do not permute.
6009 * - 1 - permute cells.
6010 * - 2 - permute nodes.
6011 * - 3 - permute cells and nodes.
6013 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6014 * caller is to delete this field using decrRef() as it is no more needed.
6015 * \throw If \a this field has not been constructed via file reading.
6016 * \throw If the MED file is not readable.
6017 * \throw If there is no mesh in the MED file.
6018 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6019 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6020 * \sa getFieldOnMeshAtLevel()
6022 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6024 if(getFileName2().empty())
6025 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6026 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6027 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6028 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6033 * Returns a new MEDCouplingFieldDouble of a given type lying on
6034 * the top level cells of the first mesh in MED file. If \a this field
6035 * has not been constructed via file reading, an exception is thrown.
6036 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6037 * \param [in] type - a spatial discretization of interest.
6038 * \param [in] renumPol - specifies how to permute values of the result field according to
6039 * the optional numbers of cells and nodes, if any. The valid values are
6040 * - 0 - do not permute.
6041 * - 1 - permute cells.
6042 * - 2 - permute nodes.
6043 * - 3 - permute cells and nodes.
6045 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6046 * caller is to delete this field using decrRef() as it is no more needed.
6047 * \throw If \a this field has not been constructed via file reading.
6048 * \throw If the MED file is not readable.
6049 * \throw If there is no mesh in the MED file.
6050 * \throw If no field values of the given \a type.
6051 * \throw If no field values lying on the top level support.
6052 * \sa getFieldAtLevel()
6054 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6056 if(getFileName2().empty())
6057 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6058 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6059 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6060 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6065 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6066 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6067 * \param [in] type - a spatial discretization of the new field.
6068 * \param [in] mesh - the supporting mesh.
6069 * \param [in] renumPol - specifies how to permute values of the result field according to
6070 * the optional numbers of cells and nodes, if any. The valid values are
6071 * - 0 - do not permute.
6072 * - 1 - permute cells.
6073 * - 2 - permute nodes.
6074 * - 3 - permute cells and nodes.
6076 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6077 * caller is to delete this field using decrRef() as it is no more needed.
6078 * \throw If no field of \a this is lying on \a mesh.
6079 * \throw If the mesh is empty.
6080 * \throw If no field values of the given \a type are available.
6081 * \sa getFieldAtLevel()
6082 * \sa getFieldOnMeshAtLevel()
6084 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6086 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6087 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6088 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6093 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6094 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6095 * \param [in] type - a spatial discretization of interest.
6096 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6097 * \param [in] mesh - the supporting mesh.
6098 * \param [in] renumPol - specifies how to permute values of the result field according to
6099 * the optional numbers of cells and nodes, if any. The valid values are
6100 * - 0 - do not permute.
6101 * - 1 - permute cells.
6102 * - 2 - permute nodes.
6103 * - 3 - permute cells and nodes.
6105 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6106 * caller is to delete this field using decrRef() as it is no more needed.
6107 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6108 * \throw If no field of \a this is lying on \a mesh.
6109 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6110 * \sa getFieldAtLevel()
6111 * \sa getFieldOnMeshAtLevel()
6113 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6115 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6116 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6117 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6122 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6123 * This method is called "Old" because in MED3 norm a field has only one meshName
6124 * attached, so this method is for readers of MED2 files. If \a this field
6125 * has not been constructed via file reading, an exception is thrown.
6126 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6127 * \param [in] type - a spatial discretization of interest.
6128 * \param [in] mName - a name of the supporting mesh.
6129 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6130 * \param [in] renumPol - specifies how to permute values of the result field according to
6131 * the optional numbers of cells and nodes, if any. The valid values are
6132 * - 0 - do not permute.
6133 * - 1 - permute cells.
6134 * - 2 - permute nodes.
6135 * - 3 - permute cells and nodes.
6137 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6138 * caller is to delete this field using decrRef() as it is no more needed.
6139 * \throw If the MED file is not readable.
6140 * \throw If there is no mesh named \a mName in the MED file.
6141 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6142 * \throw If \a this field has not been constructed via file reading.
6143 * \throw If no field of \a this is lying on the mesh named \a mName.
6144 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6145 * \sa getFieldAtLevel()
6147 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6149 if(getFileName2().empty())
6150 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6151 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6152 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6153 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6158 * Returns values and a profile of the field of a given type lying on a given support.
6159 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6160 * \param [in] type - a spatial discretization of the field.
6161 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6162 * \param [in] mesh - the supporting mesh.
6163 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6164 * field of interest lies on. If the field lies on all entities of the given
6165 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6166 * using decrRef() as it is no more needed.
6167 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6168 * field. The caller is to delete this array using decrRef() as it is no more needed.
6169 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6170 * \throw If no field of \a this is lying on \a mesh.
6171 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6173 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6175 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6176 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6180 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6181 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6182 * "Sort By Type"), if not, an exception is thrown.
6183 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6184 * \param [in] field - the field to add to \a this.
6185 * \throw If the name of \a field is empty.
6186 * \throw If the data array of \a field is not set.
6187 * \throw If the data array is already allocated but has different number of components
6189 * \throw If the underlying mesh of \a field has no name.
6190 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6192 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6195 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6199 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6200 * of a given mesh are used as the support of the given field (a real support is not used).
6201 * Elements of the given mesh must be sorted suitable for writing to MED file.
6202 * Order of underlying mesh entities of the given field specified by \a profile parameter
6203 * is not prescribed; this method permutes field values to have them sorted by element
6204 * type as required for writing to MED file. A new profile is added only if no equal
6205 * profile is missing.
6206 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6207 * \param [in] field - the field to add to \a this.
6208 * \param [in] mesh - the supporting mesh of \a field.
6209 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6210 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6211 * \throw If either \a field or \a mesh or \a profile has an empty name.
6212 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6213 * \throw If the data array of \a field is not set.
6214 * \throw If the data array of \a this is already allocated but has different number of
6215 * components than \a field.
6216 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6217 * \sa setFieldNoProfileSBT()
6219 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6222 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6225 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6227 return new MEDFileField1TS(*this);
6230 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6232 return contentNotNull()->getUndergroundDataArrayDouble();
6235 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6237 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6240 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6241 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6243 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6246 //= MEDFileIntField1TS
6248 MEDFileIntField1TS *MEDFileIntField1TS::New()
6250 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6251 ret->contentNotNull();
6255 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6257 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6258 ret->contentNotNull();
6262 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6264 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6265 ret->contentNotNull();
6269 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6271 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6272 ret->contentNotNull();
6276 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6278 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6279 ret->contentNotNull();
6283 MEDFileIntField1TS::MEDFileIntField1TS()
6285 _content=new MEDFileIntField1TSWithoutSDA;
6288 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6289 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6292 catch(INTERP_KERNEL::Exception& e)
6295 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6296 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6299 catch(INTERP_KERNEL::Exception& e)
6302 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6303 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6306 catch(INTERP_KERNEL::Exception& e)
6310 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6311 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6313 * \warning this is a shallow copy constructor
6315 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6319 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6321 return new MEDFileIntField1TS(*this);
6325 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6326 * following the given input policy.
6328 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6329 * By default (true) the globals are deeply copied.
6330 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6332 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6334 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6335 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6338 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6340 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6341 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6342 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6345 ret=MEDFileField1TS::New();
6347 ret->deepCpyGlobs(*this);
6349 ret->shallowCpyGlobs(*this);
6354 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6355 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6356 * "Sort By Type"), if not, an exception is thrown.
6357 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6358 * \param [in] field - the field to add to \a this. The field double values are ignored.
6359 * \param [in] arrOfVals - the values of the field \a field used.
6360 * \throw If the name of \a field is empty.
6361 * \throw If the data array of \a field is not set.
6362 * \throw If the data array is already allocated but has different number of components
6364 * \throw If the underlying mesh of \a field has no name.
6365 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6367 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6370 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6374 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6375 * of a given mesh are used as the support of the given field (a real support is not used).
6376 * Elements of the given mesh must be sorted suitable for writing to MED file.
6377 * Order of underlying mesh entities of the given field specified by \a profile parameter
6378 * is not prescribed; this method permutes field values to have them sorted by element
6379 * type as required for writing to MED file. A new profile is added only if no equal
6380 * profile is missing.
6381 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6382 * \param [in] field - the field to add to \a this. The field double values are ignored.
6383 * \param [in] arrOfVals - the values of the field \a field used.
6384 * \param [in] mesh - the supporting mesh of \a field.
6385 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6386 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6387 * \throw If either \a field or \a mesh or \a profile has an empty name.
6388 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6389 * \throw If the data array of \a field is not set.
6390 * \throw If the data array of \a this is already allocated but has different number of
6391 * components than \a field.
6392 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6393 * \sa setFieldNoProfileSBT()
6395 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6398 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6401 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6403 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6405 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6406 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6408 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 !");
6412 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6414 if(getFileName2().empty())
6415 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6416 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6417 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6418 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6420 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6425 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6427 if(!((DataArray *)arr))
6428 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6429 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6431 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6437 * Returns a new MEDCouplingFieldDouble of a given type lying on
6438 * the top level cells of the first mesh in MED file. If \a this field
6439 * has not been constructed via file reading, an exception is thrown.
6440 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6441 * \param [in] type - a spatial discretization of interest.
6442 * \param [out] arrOut - the DataArrayInt containing values of field.
6443 * \param [in] renumPol - specifies how to permute values of the result field according to
6444 * the optional numbers of cells and nodes, if any. The valid values are
6445 * - 0 - do not permute.
6446 * - 1 - permute cells.
6447 * - 2 - permute nodes.
6448 * - 3 - permute cells and nodes.
6450 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6451 * caller is to delete this field using decrRef() as it is no more needed.
6452 * \throw If \a this field has not been constructed via file reading.
6453 * \throw If the MED file is not readable.
6454 * \throw If there is no mesh in the MED file.
6455 * \throw If no field values of the given \a type.
6456 * \throw If no field values lying on the top level support.
6457 * \sa getFieldAtLevel()
6459 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6461 if(getFileName2().empty())
6462 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6463 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6464 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6465 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6470 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6471 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6472 * \param [in] type - a spatial discretization of the new field.
6473 * \param [in] mesh - the supporting mesh.
6474 * \param [out] arrOut - the DataArrayInt containing values of field.
6475 * \param [in] renumPol - specifies how to permute values of the result field according to
6476 * the optional numbers of cells and nodes, if any. The valid values are
6477 * - 0 - do not permute.
6478 * - 1 - permute cells.
6479 * - 2 - permute nodes.
6480 * - 3 - permute cells and nodes.
6482 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6483 * caller is to delete this field using decrRef() as it is no more needed.
6484 * \throw If no field of \a this is lying on \a mesh.
6485 * \throw If the mesh is empty.
6486 * \throw If no field values of the given \a type are available.
6487 * \sa getFieldAtLevel()
6488 * \sa getFieldOnMeshAtLevel()
6490 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6492 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6493 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6494 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6499 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6500 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6501 * \param [in] type - a spatial discretization of interest.
6502 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6503 * \param [out] arrOut - the DataArrayInt containing values of field.
6504 * \param [in] mesh - the supporting mesh.
6505 * \param [in] renumPol - specifies how to permute values of the result field according to
6506 * the optional numbers of cells and nodes, if any. The valid values are
6507 * - 0 - do not permute.
6508 * - 1 - permute cells.
6509 * - 2 - permute nodes.
6510 * - 3 - permute cells and nodes.
6512 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6513 * caller is to delete this field using decrRef() as it is no more needed.
6514 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6515 * \throw If no field of \a this is lying on \a mesh.
6516 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6517 * \sa getFieldAtLevel()
6518 * \sa getFieldOnMeshAtLevel()
6520 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6522 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6523 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6524 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6529 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6530 * This method is called "Old" because in MED3 norm a field has only one meshName
6531 * attached, so this method is for readers of MED2 files. If \a this field
6532 * has not been constructed via file reading, an exception is thrown.
6533 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6534 * \param [in] type - a spatial discretization of interest.
6535 * \param [in] mName - a name of the supporting mesh.
6536 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6537 * \param [out] arrOut - the DataArrayInt containing values of field.
6538 * \param [in] renumPol - specifies how to permute values of the result field according to
6539 * the optional numbers of cells and nodes, if any. The valid values are
6540 * - 0 - do not permute.
6541 * - 1 - permute cells.
6542 * - 2 - permute nodes.
6543 * - 3 - permute cells and nodes.
6545 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6546 * caller is to delete this field using decrRef() as it is no more needed.
6547 * \throw If the MED file is not readable.
6548 * \throw If there is no mesh named \a mName in the MED file.
6549 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6550 * \throw If \a this field has not been constructed via file reading.
6551 * \throw If no field of \a this is lying on the mesh named \a mName.
6552 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6553 * \sa getFieldAtLevel()
6555 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6557 if(getFileName2().empty())
6558 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6559 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6560 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6561 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6566 * Returns values and a profile of the field of a given type lying on a given support.
6567 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6568 * \param [in] type - a spatial discretization of the field.
6569 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6570 * \param [in] mesh - the supporting mesh.
6571 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6572 * field of interest lies on. If the field lies on all entities of the given
6573 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6574 * using decrRef() as it is no more needed.
6575 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6576 * field. The caller is to delete this array using decrRef() as it is no more needed.
6577 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6578 * \throw If no field of \a this is lying on \a mesh.
6579 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6581 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6583 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6584 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6587 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6589 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6591 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6592 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6594 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 !");
6598 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6600 return contentNotNull()->getUndergroundDataArrayInt();
6603 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6605 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6609 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6614 * \param [in] fieldId field id in C mode
6616 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6618 med_field_type typcha;
6619 std::string dtunitOut;
6620 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6621 setDtUnit(dtunitOut.c_str());
6622 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6625 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
6626 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6628 setDtUnit(dtunit.c_str());
6629 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6631 catch(INTERP_KERNEL::Exception& e)
6636 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6638 std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6639 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6640 ret+=(*it).capacity();
6641 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6642 if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6643 ret+=(*it)->getHeapMemorySize();
6648 * 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
6651 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6653 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6654 ret->setInfo(_infos);
6655 int sz=(int)_time_steps.size();
6656 for(const int *id=startIds;id!=endIds;id++)
6658 if(*id>=0 && *id<sz)
6660 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6661 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6665 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6667 ret->pushBackTimeStep(tse2);
6671 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6672 oss << " ! Should be in [0," << sz << ") !";
6673 throw INTERP_KERNEL::Exception(oss.str().c_str());
6676 if(ret->getNumberOfTS()>0)
6677 ret->synchronizeNameScope();
6678 ret->copyNameScope(*this);
6683 * 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
6686 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6688 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6689 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6690 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6691 ret->setInfo(_infos);
6692 int sz=(int)_time_steps.size();
6694 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6698 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6699 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6703 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6705 ret->pushBackTimeStep(tse2);
6709 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6710 oss << " ! Should be in [0," << sz << ") !";
6711 throw INTERP_KERNEL::Exception(oss.str().c_str());
6714 if(ret->getNumberOfTS()>0)
6715 ret->synchronizeNameScope();
6716 ret->copyNameScope(*this);
6720 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6723 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6724 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6726 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6729 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6730 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6731 ids->pushBackSilent(id);
6733 return buildFromTimeStepIds(ids->begin(),ids->end());
6736 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6739 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6740 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6742 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6745 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6746 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6747 ids->pushBackSilent(id);
6749 return buildFromTimeStepIds(ids->begin(),ids->end());
6752 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6757 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6762 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6765 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6767 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6768 if(pt->isDealingTS(iteration,order))
6771 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6772 std::vector< std::pair<int,int> > vp=getIterations();
6773 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6774 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6775 throw INTERP_KERNEL::Exception(oss.str().c_str());
6778 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6780 return *_time_steps[getTimeStepPos(iteration,order)];
6783 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6785 return *_time_steps[getTimeStepPos(iteration,order)];
6788 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6790 if(_time_steps.empty())
6791 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6792 return _time_steps[0]->getMeshName();
6795 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6797 std::string oldName(getMeshName());
6798 std::vector< std::pair<std::string,std::string> > v(1);
6799 v[0].first=oldName; v[0].second=newMeshName;
6803 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6806 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6808 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6810 ret=cur->changeMeshNames(modifTab) || ret;
6816 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6818 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6820 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6824 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6826 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)
6828 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6831 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6832 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6835 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6837 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6839 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6844 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6846 std::string startLine(bkOffset,' ');
6847 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6849 oss << " (" << fmtsId << ")";
6850 oss << " has the following name: \"" << _name << "\"." << std::endl;
6851 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6852 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6854 oss << startLine << " - \"" << *it << "\"" << std::endl;
6857 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6859 std::string chapter(17,'0'+i);
6860 oss << startLine << chapter << std::endl;
6861 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6863 cur->simpleRepr(bkOffset+2,oss,i);
6865 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6866 oss << startLine << chapter << std::endl;
6870 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6872 std::size_t sz=_time_steps.size();
6873 std::vector< std::pair<int,int> > ret(sz);
6875 for(std::size_t i=0;i<sz;i++)
6877 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6880 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6884 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6885 throw INTERP_KERNEL::Exception(oss.str().c_str());
6891 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6893 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6895 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6896 checkCoherencyOfType(tse2);
6897 if(_time_steps.empty())
6899 setName(tse2->getName().c_str());
6900 setInfo(tse2->getInfo());
6902 checkThatComponentsMatch(tse2->getInfo());
6903 _time_steps.push_back(tse);
6906 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6908 std::size_t nbOfCompo=_infos.size();
6909 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6911 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6914 if((cur->getInfo()).size()!=nbOfCompo)
6916 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6917 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6918 throw INTERP_KERNEL::Exception(oss.str().c_str());
6920 cur->copyNameScope(*this);
6925 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6927 _time_steps.resize(nbPdt);
6928 for(int i=0;i<nbPdt;i++)
6930 std::vector< std::pair<int,int> > ts;
6931 med_int numdt=0,numo=0;
6932 med_int meshIt=0,meshOrder=0;
6934 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6939 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6944 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6948 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6951 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6953 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6957 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6959 if(_time_steps.empty())
6960 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6961 checkThatNbOfCompoOfTSMatchThis();
6962 std::vector<std::string> infos(getInfo());
6963 int nbComp=infos.size();
6964 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6965 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6966 for(int i=0;i<nbComp;i++)
6968 std::string info=infos[i];
6970 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6971 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6972 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6975 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6976 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6977 int nbOfTS=_time_steps.size();
6978 for(int i=0;i<nbOfTS;i++)
6979 _time_steps[i]->writeLL(fid,opts,*this);
6982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6984 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6986 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6988 elt->loadBigArraysRecursively(fid,nasc);
6992 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
6994 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6996 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
6998 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7002 void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception)
7004 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7006 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7008 elt->releaseArrays();
7012 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7014 return _time_steps.size();
7017 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7019 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7020 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7022 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7024 newTS.push_back(*it);
7029 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7031 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7032 int maxId=(int)_time_steps.size();
7034 std::set<int> idsToDel;
7035 for(const int *id=startIds;id!=endIds;id++,ii++)
7037 if(*id>=0 && *id<maxId)
7039 idsToDel.insert(*id);
7043 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7044 throw INTERP_KERNEL::Exception(oss.str().c_str());
7047 for(int iii=0;iii<maxId;iii++)
7048 if(idsToDel.find(iii)==idsToDel.end())
7049 newTS.push_back(_time_steps[iii]);
7053 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7055 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7056 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7057 if(nbOfEntriesToKill==0)
7059 std::size_t sz=_time_steps.size();
7060 std::vector<bool> b(sz,true);
7062 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7064 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7065 for(std::size_t i=0;i<sz;i++)
7067 newTS.push_back(_time_steps[i]);
7071 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7074 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7075 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7077 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7081 tmp->getTime(it2,ord);
7082 if(it2==iteration && order==ord)
7085 oss << "(" << it2 << "," << ord << "), ";
7088 throw INTERP_KERNEL::Exception(oss.str().c_str());
7091 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7094 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7096 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7098 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7102 double ti=tmp->getTime(it2,ord);
7103 if(fabs(time-ti)<eps)
7109 throw INTERP_KERNEL::Exception(oss.str().c_str());
7112 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7114 int lgth=_time_steps.size();
7115 std::vector< std::pair<int,int> > ret(lgth);
7116 for(int i=0;i<lgth;i++)
7117 _time_steps[i]->fillIteration(ret[i]);
7122 * 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'
7123 * This method returns two things.
7124 * - The absolute dimension of 'this' in first parameter.
7125 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7126 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7128 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7129 * Only these 3 discretizations will be taken into account here.
7131 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7132 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7133 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7135 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7136 * 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'.
7138 * Let's consider the typical following case :
7139 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7140 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7141 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7143 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7145 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7147 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7148 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7149 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7150 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7152 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7154 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7157 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7159 if(pos<0 || pos>=(int)_time_steps.size())
7161 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7162 throw INTERP_KERNEL::Exception(oss.str().c_str());
7164 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7167 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7168 oss << "\nTry to use following method eraseEmptyTS !";
7169 throw INTERP_KERNEL::Exception(oss.str().c_str());
7174 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7176 if(pos<0 || pos>=(int)_time_steps.size())
7178 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7179 throw INTERP_KERNEL::Exception(oss.str().c_str());
7181 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7184 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7185 oss << "\nTry to use following method eraseEmptyTS !";
7186 throw INTERP_KERNEL::Exception(oss.str().c_str());
7191 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7193 std::vector<std::string> ret;
7194 std::set<std::string> ret2;
7195 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7197 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7198 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7199 if(ret2.find(*it2)==ret2.end())
7201 ret.push_back(*it2);
7208 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7210 std::vector<std::string> ret;
7211 std::set<std::string> ret2;
7212 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7214 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7215 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7216 if(ret2.find(*it2)==ret2.end())
7218 ret.push_back(*it2);
7225 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7227 std::vector<std::string> ret;
7228 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7230 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7231 ret.insert(ret.end(),tmp.begin(),tmp.end());
7236 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7238 std::vector<std::string> ret;
7239 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7241 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7242 ret.insert(ret.end(),tmp.begin(),tmp.end());
7247 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7249 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7250 (*it)->changePflsRefsNamesGen2(mapOfModif);
7253 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7255 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7256 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7259 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7261 int lgth=_time_steps.size();
7262 std::vector< std::vector<TypeOfField> > ret(lgth);
7263 for(int i=0;i<lgth;i++)
7264 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7269 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7271 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)
7273 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7276 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7278 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7280 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7282 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7283 ret->_time_steps[i]=(*it)->deepCpy();
7288 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7290 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7291 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7292 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7293 for(std::size_t i=0;i<sz;i++)
7295 ret[i]=shallowCpy();
7296 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7298 for(std::size_t i=0;i<sz2;i++)
7300 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7303 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7304 throw INTERP_KERNEL::Exception(oss.str().c_str());
7308 for(std::size_t i=0;i<sz;i++)
7309 for(std::size_t j=0;j<sz2;j++)
7310 ret[i]->_time_steps[j]=ts[j][i];
7315 * This method splits into discretization each time steps in \a this.
7316 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7320 std::size_t sz(_time_steps.size());
7321 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7322 for(std::size_t i=0;i<sz;i++)
7324 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7327 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7328 throw INTERP_KERNEL::Exception(oss.str().c_str());
7330 items[i]=timeStep->splitDiscretizations();
7333 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7334 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7335 std::vector< TypeOfField > types;
7336 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7339 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7341 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7342 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7343 if(it2==types.end())
7344 types.push_back(ts[0]);
7346 ret.resize(types.size()); ret2.resize(types.size());
7347 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7350 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7351 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7352 ret2[pos].push_back(*it1);
7354 for(std::size_t i=0;i<types.size();i++)
7356 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7357 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7358 elt->pushBackTimeStep(*it1);//also updates infos in elt
7360 elt->MEDFileFieldNameScope::operator=(*this);
7365 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7367 _name=field->getName();
7369 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7371 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7372 _infos=arr->getInfoOnComponents();
7375 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7377 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7378 if(_name!=field->getName())
7380 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7381 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7382 throw INTERP_KERNEL::Exception(oss.str().c_str());
7385 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7386 checkThatComponentsMatch(arr->getInfoOnComponents());
7389 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7391 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7392 if(getInfo().size()!=compos.size())
7394 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7395 oss << " number of components of element to append (" << compos.size() << ") !";
7396 throw INTERP_KERNEL::Exception(oss.str().c_str());
7400 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7401 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7402 oss << " But compo in input fields are : ";
7403 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7405 throw INTERP_KERNEL::Exception(oss.str().c_str());
7409 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7411 std::size_t sz=_infos.size();
7413 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7415 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7417 if(elt->getInfo().size()!=sz)
7419 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7420 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7421 throw INTERP_KERNEL::Exception(oss.str().c_str());
7426 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7429 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7430 if(!_time_steps.empty())
7431 checkCoherencyOfTinyInfo(field,arr);
7432 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7433 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7434 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7435 copyTinyInfoFrom(field,arr);
7436 _time_steps.push_back(obj);
7439 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7442 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7443 if(!_time_steps.empty())
7444 checkCoherencyOfTinyInfo(field,arr);
7445 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7446 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7447 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7448 copyTinyInfoFrom(field,arr);
7449 _time_steps.push_back(obj);
7452 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7454 int sz=(int)_time_steps.size();
7457 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7458 throw INTERP_KERNEL::Exception(oss.str().c_str());
7460 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7463 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7465 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7466 throw INTERP_KERNEL::Exception(oss.str().c_str());
7472 //= MEDFileFieldMultiTSWithoutSDA
7474 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, bool loadAll) throw(INTERP_KERNEL::Exception)
7476 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7479 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7483 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7488 * \param [in] fieldId field id in C mode
7490 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7491 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7494 catch(INTERP_KERNEL::Exception& e)
7497 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7498 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7501 catch(INTERP_KERNEL::Exception& e)
7504 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7506 return new MEDFileField1TSWithoutSDA;
7509 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7512 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7513 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7515 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7518 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7520 return MEDFileField1TSWithoutSDA::TYPE_STR;
7523 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7525 return new MEDFileFieldMultiTSWithoutSDA(*this);
7528 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7530 return new MEDFileFieldMultiTSWithoutSDA;
7534 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7535 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7537 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)
7539 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7540 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7542 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7543 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7546 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7548 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7549 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7551 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7553 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7556 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7558 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7559 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7560 ret->setIteration(i,elt);
7566 //= MEDFileAnyTypeFieldMultiTS
7568 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7572 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7573 try:MEDFileFieldGlobsReal(fileName)
7575 MEDFileUtilities::CheckFileForRead(fileName);
7576 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7577 _content=BuildContentFrom(fid,fileName,loadAll);
7580 catch(INTERP_KERNEL::Exception& e)
7585 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7587 med_field_type typcha;
7588 std::vector<std::string> infos;
7591 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7592 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7597 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7602 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7607 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] !";
7608 throw INTERP_KERNEL::Exception(oss.str().c_str());
7611 ret->setDtUnit(dtunit.c_str());
7615 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7617 med_field_type typcha;
7619 std::vector<std::string> infos;
7620 std::string dtunit,fieldName;
7621 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7622 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7627 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7632 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7637 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] !";
7638 throw INTERP_KERNEL::Exception(oss.str().c_str());
7641 ret->setDtUnit(dtunit.c_str());
7645 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7648 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7649 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7651 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7652 ret->setFileName(fileName);
7653 ret->_content=c; c->incrRef();
7656 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7658 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7659 ret->setFileName(fileName);
7660 ret->_content=c; c->incrRef();
7663 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7666 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7667 try:MEDFileFieldGlobsReal(fileName)
7669 MEDFileUtilities::CheckFileForRead(fileName);
7670 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7671 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7674 catch(INTERP_KERNEL::Exception& e)
7679 //= MEDFileIntFieldMultiTSWithoutSDA
7681 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, bool loadAll) throw(INTERP_KERNEL::Exception)
7683 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7686 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7690 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7694 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7695 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7698 catch(INTERP_KERNEL::Exception& e)
7702 * \param [in] fieldId field id in C mode
7704 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7705 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7708 catch(INTERP_KERNEL::Exception& e)
7711 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7713 return new MEDFileIntField1TSWithoutSDA;
7716 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7719 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7720 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7722 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7725 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7727 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7730 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7732 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7735 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7737 return new MEDFileIntFieldMultiTSWithoutSDA;
7740 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7742 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7743 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7745 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7747 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7750 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7752 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7753 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7754 ret->setIteration(i,elt);
7760 //= MEDFileAnyTypeFieldMultiTS
7763 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7764 * that has been read from a specified MED file.
7765 * \param [in] fileName - the name of the MED file to read.
7766 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7767 * is to delete this field using decrRef() as it is no more needed.
7768 * \throw If reading the file fails.
7770 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7772 MEDFileUtilities::CheckFileForRead(fileName);
7773 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7774 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7775 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7776 ret->loadGlobals(fid);
7781 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7782 * that has been read from a specified MED file.
7783 * \param [in] fileName - the name of the MED file to read.
7784 * \param [in] fieldName - the name of the field to read.
7785 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7786 * is to delete this field using decrRef() as it is no more needed.
7787 * \throw If reading the file fails.
7788 * \throw If there is no field named \a fieldName in the file.
7790 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7792 MEDFileUtilities::CheckFileForRead(fileName);
7793 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7794 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7795 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7796 ret->loadGlobals(fid);
7801 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7802 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7804 * \warning this is a shallow copy constructor
7806 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7808 if(!shallowCopyOfContent)
7810 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7811 otherPtr->incrRef();
7812 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7816 _content=other.shallowCpy();
7820 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7822 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7824 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7828 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7830 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7832 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7836 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7838 return contentNotNullBase()->getPflsReallyUsed2();
7841 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7843 return contentNotNullBase()->getLocsReallyUsed2();
7846 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7848 return contentNotNullBase()->getPflsReallyUsedMulti2();
7851 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7853 return contentNotNullBase()->getLocsReallyUsedMulti2();
7856 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7858 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7861 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7863 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7866 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7868 return contentNotNullBase()->getNumberOfTS();
7871 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7873 contentNotNullBase()->eraseEmptyTS();
7876 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7878 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7881 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7883 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7886 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7888 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7889 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7894 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7896 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7897 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7902 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7904 return contentNotNullBase()->getIterations();
7907 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7909 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7910 pushBackTimeStep(*it);
7913 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7916 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7917 checkCoherencyOfType(f1ts);
7919 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7920 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7922 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7923 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7924 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7925 _content->pushBackTimeStep(cSafe);
7926 appendGlobs(*f1ts,1e-12);
7929 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7931 contentNotNullBase()->synchronizeNameScope();
7934 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7936 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7939 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7941 return contentNotNullBase()->getPosGivenTime(time,eps);
7944 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7946 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7949 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7951 return contentNotNullBase()->getTypesOfFieldAvailable();
7954 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)
7956 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7959 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7961 return contentNotNullBase()->getName();
7964 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7966 contentNotNullBase()->setName(name);
7969 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7971 return contentNotNullBase()->getDtUnit();
7974 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7976 contentNotNullBase()->setDtUnit(dtUnit);
7979 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7981 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7984 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7986 return contentNotNullBase()->getTimeSteps(ret1);
7989 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7991 return contentNotNullBase()->getMeshName();
7994 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7996 contentNotNullBase()->setMeshName(newMeshName);
7999 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8001 return contentNotNullBase()->changeMeshNames(modifTab);
8004 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8006 return contentNotNullBase()->getInfo();
8009 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8011 return contentNotNullBase()->setInfo(info);
8014 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8016 const std::vector<std::string> ret=getInfo();
8017 return (int)ret.size();
8020 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8022 writeGlobals(fid,*this);
8023 contentNotNullBase()->writeLL(fid,*this);
8027 * Writes \a this field into a MED file specified by its name.
8028 * \param [in] fileName - the MED file name.
8029 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8030 * - 2 - erase; an existing file is removed.
8031 * - 1 - append; same data should not be present in an existing file.
8032 * - 0 - overwrite; same data present in an existing file is overwritten.
8033 * \throw If the field name is not set.
8034 * \throw If no field data is set.
8035 * \throw If \a mode == 1 and the same data is present in an existing file.
8037 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8039 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8040 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8045 * This method alloc the arrays and load potentially huge arrays contained in this field.
8046 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8047 * This method can be also called to refresh or reinit values from a file.
8049 * \throw If the fileName is not set or points to a non readable MED file.
8051 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8053 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8054 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8058 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8059 * But once data loaded once, this method does nothing.
8061 * \throw If the fileName is not set or points to a non readable MED file.
8062 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays
8064 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8066 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8067 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8071 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8072 * This method does not release arrays set outside the context of a MED file.
8074 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8076 void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception)
8078 contentNotNullBase()->releaseArrays();
8081 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8083 std::ostringstream oss;
8084 contentNotNullBase()->simpleRepr(0,oss,-1);
8085 simpleReprGlobs(oss);
8089 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8092 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8093 ret+=_content->getHeapMemorySize();
8094 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8098 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8099 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8100 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8102 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8104 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8106 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8107 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8108 std::size_t sz(contentsSplit.size());
8109 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8110 for(std::size_t i=0;i<sz;i++)
8112 ret[i]=shallowCpy();
8113 ret[i]->_content=contentsSplit[i];
8119 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8120 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8122 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8124 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8126 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8127 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8128 std::size_t sz(contentsSplit.size());
8129 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8130 for(std::size_t i=0;i<sz;i++)
8132 ret[i]=shallowCpy();
8133 ret[i]->_content=contentsSplit[i];
8138 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8140 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8141 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8142 ret->_content=_content->deepCpy();
8143 ret->deepCpyGlobs(*this);
8147 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8153 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8154 * \param [in] iteration - the iteration number of a required time step.
8155 * \param [in] order - the iteration order number of required time step.
8156 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8157 * delete this field using decrRef() as it is no more needed.
8158 * \throw If there is no required time step in \a this field.
8160 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8162 int pos=getPosOfTimeStep(iteration,order);
8163 return getTimeStepAtPos(pos);
8167 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8168 * \param [in] time - the time of the time step of interest.
8169 * \param [in] eps - a precision used to compare time values.
8170 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8171 * delete this field using decrRef() as it is no more needed.
8172 * \throw If there is no required time step in \a this field.
8174 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8176 int pos=getPosGivenTime(time,eps);
8177 return getTimeStepAtPos(pos);
8181 * This method groups not null items in \a vectFMTS per time step series. Two time series are considered equal if the list of their pair of integers iteration,order are equal.
8182 * The float64 value of time attached to the pair of integers are not considered here.
8184 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8185 * \throw If there is a null pointer in \a vectFMTS.
8187 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8189 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8190 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8191 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8192 while(!lstFMTS.empty())
8194 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8195 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8197 throw INTERP_KERNEL::Exception(msg);
8198 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8199 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8200 elt.push_back(curIt); it=lstFMTS.erase(it);
8201 while(it!=lstFMTS.end())
8205 throw INTERP_KERNEL::Exception(msg);
8206 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8208 { elt.push_back(curIt); it=lstFMTS.erase(it);}
8217 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8219 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8222 //= MEDFileFieldMultiTS
8225 * Returns a new empty instance of MEDFileFieldMultiTS.
8226 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8227 * is to delete this field using decrRef() as it is no more needed.
8229 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8231 return new MEDFileFieldMultiTS;
8235 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8236 * that has been read from a specified MED file.
8237 * \param [in] fileName - the name of the MED file to read.
8238 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8239 * is to delete this field using decrRef() as it is no more needed.
8240 * \throw If reading the file fails.
8242 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8244 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8245 ret->contentNotNull();//to check that content type matches with \a this type.
8250 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8251 * that has been read from a specified MED file.
8252 * \param [in] fileName - the name of the MED file to read.
8253 * \param [in] fieldName - the name of the field to read.
8254 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8255 * is to delete this field using decrRef() as it is no more needed.
8256 * \throw If reading the file fails.
8257 * \throw If there is no field named \a fieldName in the file.
8259 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8261 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8262 ret->contentNotNull();//to check that content type matches with \a this type.
8267 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8268 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8270 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8271 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8272 * \warning this is a shallow copy constructor
8273 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8274 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8275 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8276 * is to delete this field using decrRef() as it is no more needed.
8278 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8280 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8283 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8285 return new MEDFileFieldMultiTS(*this);
8288 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8291 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8292 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8294 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8298 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8299 * following the given input policy.
8301 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8302 * By default (true) the globals are deeply copied.
8303 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8305 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8307 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8308 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8311 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8313 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8314 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8315 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8318 ret=MEDFileIntFieldMultiTS::New();
8320 ret->deepCpyGlobs(*this);
8322 ret->shallowCpyGlobs(*this);
8327 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8328 * \param [in] pos - a time step id.
8329 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8330 * delete this field using decrRef() as it is no more needed.
8331 * \throw If \a pos is not a valid time step id.
8333 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8335 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8338 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8339 throw INTERP_KERNEL::Exception(oss.str().c_str());
8341 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8344 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8345 ret->shallowCpyGlobs(*this);
8348 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8349 throw INTERP_KERNEL::Exception(oss.str().c_str());
8353 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8354 * mesh entities of a given dimension of the first mesh in MED file.
8355 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8356 * \param [in] type - a spatial discretization of interest.
8357 * \param [in] iteration - the iteration number of a required time step.
8358 * \param [in] order - the iteration order number of required time step.
8359 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8360 * \param [in] renumPol - specifies how to permute values of the result field according to
8361 * the optional numbers of cells and nodes, if any. The valid values are
8362 * - 0 - do not permute.
8363 * - 1 - permute cells.
8364 * - 2 - permute nodes.
8365 * - 3 - permute cells and nodes.
8367 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8368 * caller is to delete this field using decrRef() as it is no more needed.
8369 * \throw If the MED file is not readable.
8370 * \throw If there is no mesh in the MED file.
8371 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8372 * \throw If no field values of the required parameters are available.
8374 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8376 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8377 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8379 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8380 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8381 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8382 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8387 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8388 * the top level cells of the first mesh in MED file.
8389 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8390 * \param [in] type - a spatial discretization of interest.
8391 * \param [in] iteration - the iteration number of a required time step.
8392 * \param [in] order - the iteration order number of required time step.
8393 * \param [in] renumPol - specifies how to permute values of the result field according to
8394 * the optional numbers of cells and nodes, if any. The valid values are
8395 * - 0 - do not permute.
8396 * - 1 - permute cells.
8397 * - 2 - permute nodes.
8398 * - 3 - permute cells and nodes.
8400 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8401 * caller is to delete this field using decrRef() as it is no more needed.
8402 * \throw If the MED file is not readable.
8403 * \throw If there is no mesh in the MED file.
8404 * \throw If no field values of the required parameters are available.
8406 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8408 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8409 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8411 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8412 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8413 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8414 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8419 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8421 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8422 * \param [in] type - a spatial discretization of interest.
8423 * \param [in] iteration - the iteration number of a required time step.
8424 * \param [in] order - the iteration order number of required time step.
8425 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8426 * \param [in] mesh - the supporting mesh.
8427 * \param [in] renumPol - specifies how to permute values of the result field according to
8428 * the optional numbers of cells and nodes, if any. The valid values are
8429 * - 0 - do not permute.
8430 * - 1 - permute cells.
8431 * - 2 - permute nodes.
8432 * - 3 - permute cells and nodes.
8434 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8435 * caller is to delete this field using decrRef() as it is no more needed.
8436 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8437 * \throw If no field of \a this is lying on \a mesh.
8438 * \throw If no field values of the required parameters are available.
8440 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8442 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8443 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8445 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8446 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8447 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8448 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8453 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8455 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8456 * \param [in] type - a spatial discretization of the new field.
8457 * \param [in] iteration - the iteration number of a required time step.
8458 * \param [in] order - the iteration order number of required time step.
8459 * \param [in] mesh - the supporting mesh.
8460 * \param [in] renumPol - specifies how to permute values of the result field according to
8461 * the optional numbers of cells and nodes, if any. The valid values are
8462 * - 0 - do not permute.
8463 * - 1 - permute cells.
8464 * - 2 - permute nodes.
8465 * - 3 - permute cells and nodes.
8467 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8468 * caller is to delete this field using decrRef() as it is no more needed.
8469 * \throw If no field of \a this is lying on \a mesh.
8470 * \throw If no field values of the required parameters are available.
8472 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8474 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8475 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8477 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8478 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8479 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8480 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8485 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8486 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8487 * This method is useful for MED2 file format when field on different mesh was autorized.
8489 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8491 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8492 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8494 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8495 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8496 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8497 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8502 * Returns values and a profile of the field of a given type, of a given time step,
8503 * lying on a given support.
8504 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8505 * \param [in] type - a spatial discretization of the field.
8506 * \param [in] iteration - the iteration number of a required time step.
8507 * \param [in] order - the iteration order number of required time step.
8508 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8509 * \param [in] mesh - the supporting mesh.
8510 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8511 * field of interest lies on. If the field lies on all entities of the given
8512 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8513 * using decrRef() as it is no more needed.
8514 * \param [in] glob - the global data storing profiles and localization.
8515 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8516 * field. The caller is to delete this array using decrRef() as it is no more needed.
8517 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8518 * \throw If no field of \a this is lying on \a mesh.
8519 * \throw If no field values of the required parameters are available.
8521 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8523 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8524 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8526 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8527 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8528 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8531 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8533 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8535 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8536 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8538 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 !");
8542 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8544 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8546 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8547 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8549 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 !");
8554 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8555 * the given field is checked if its elements are sorted suitable for writing to MED file
8556 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8557 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8558 * \param [in] field - the field to add to \a this.
8559 * \throw If the name of \a field is empty.
8560 * \throw If the data array of \a field is not set.
8561 * \throw If existing time steps have different name or number of components than \a field.
8562 * \throw If the underlying mesh of \a field has no name.
8563 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8565 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8567 const DataArrayDouble *arr=0;
8569 arr=field->getArray();
8570 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8574 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8575 * a given dimension of a given mesh are used as the support of the given field.
8576 * Elements of the given mesh must be sorted suitable for writing to MED file.
8577 * Order of underlying mesh entities of the given field specified by \a profile parameter
8578 * is not prescribed; this method permutes field values to have them sorted by element
8579 * type as required for writing to MED file.
8580 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8581 * \param [in] field - the field to add to \a this.
8582 * \param [in] mesh - the supporting mesh of \a field.
8583 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8584 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8585 * \throw If either \a field or \a mesh or \a profile has an empty name.
8586 * \throw If existing time steps have different name or number of components than \a field.
8587 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8588 * \throw If the data array of \a field is not set.
8589 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8591 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8593 const DataArrayDouble *arr=0;
8595 arr=field->getArray();
8596 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8599 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8601 _content=new MEDFileFieldMultiTSWithoutSDA;
8604 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8605 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8608 catch(INTERP_KERNEL::Exception& e)
8611 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8612 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8615 catch(INTERP_KERNEL::Exception& e)
8618 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8622 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)
8624 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8627 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8629 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8632 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)
8634 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8637 //= MEDFileAnyTypeFieldMultiTSIterator
8639 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8644 _nb_iter=fmts->getNumberOfTS();
8648 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8652 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8654 if(_iter_id<_nb_iter)
8656 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8658 return fmts->getTimeStepAtPos(_iter_id++);
8666 //= MEDFileIntFieldMultiTS
8669 * Returns a new empty instance of MEDFileFieldMultiTS.
8670 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8671 * is to delete this field using decrRef() as it is no more needed.
8673 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8675 return new MEDFileIntFieldMultiTS;
8679 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8680 * that has been read from a specified MED file.
8681 * \param [in] fileName - the name of the MED file to read.
8682 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8683 * is to delete this field using decrRef() as it is no more needed.
8684 * \throw If reading the file fails.
8686 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8688 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8689 ret->contentNotNull();//to check that content type matches with \a this type.
8694 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8695 * that has been read from a specified MED file.
8696 * \param [in] fileName - the name of the MED file to read.
8697 * \param [in] fieldName - the name of the field to read.
8698 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8699 * is to delete this field using decrRef() as it is no more needed.
8700 * \throw If reading the file fails.
8701 * \throw If there is no field named \a fieldName in the file.
8703 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8705 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8706 ret->contentNotNull();//to check that content type matches with \a this type.
8711 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8712 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8714 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8715 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8716 * \warning this is a shallow copy constructor
8717 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8718 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8719 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8720 * is to delete this field using decrRef() as it is no more needed.
8722 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8724 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8728 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8729 * following the given input policy.
8731 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8732 * By default (true) the globals are deeply copied.
8733 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8735 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8737 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8738 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8741 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8743 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8744 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8745 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8748 ret=MEDFileFieldMultiTS::New();
8750 ret->deepCpyGlobs(*this);
8752 ret->shallowCpyGlobs(*this);
8756 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8758 return new MEDFileIntFieldMultiTS(*this);
8761 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8764 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8765 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8767 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8771 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8772 * mesh entities of a given dimension of the first mesh in MED file.
8773 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8774 * \param [in] type - a spatial discretization of interest.
8775 * \param [in] iteration - the iteration number of a required time step.
8776 * \param [in] order - the iteration order number of required time step.
8777 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8778 * \param [out] arrOut - the DataArrayInt containing values of field.
8779 * \param [in] renumPol - specifies how to permute values of the result field according to
8780 * the optional numbers of cells and nodes, if any. The valid values are
8781 * - 0 - do not permute.
8782 * - 1 - permute cells.
8783 * - 2 - permute nodes.
8784 * - 3 - permute cells and nodes.
8786 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8787 * caller is to delete this field using decrRef() as it is no more needed.
8788 * \throw If the MED file is not readable.
8789 * \throw If there is no mesh in the MED file.
8790 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8791 * \throw If no field values of the required parameters are available.
8793 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8795 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8796 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8798 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8799 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8800 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8801 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8806 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8807 * the top level cells of the first mesh in MED file.
8808 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8809 * \param [in] type - a spatial discretization of interest.
8810 * \param [in] iteration - the iteration number of a required time step.
8811 * \param [in] order - the iteration order number of required time step.
8812 * \param [out] arrOut - the DataArrayInt containing values of field.
8813 * \param [in] renumPol - specifies how to permute values of the result field according to
8814 * the optional numbers of cells and nodes, if any. The valid values are
8815 * - 0 - do not permute.
8816 * - 1 - permute cells.
8817 * - 2 - permute nodes.
8818 * - 3 - permute cells and nodes.
8820 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8821 * caller is to delete this field using decrRef() as it is no more needed.
8822 * \throw If the MED file is not readable.
8823 * \throw If there is no mesh in the MED file.
8824 * \throw If no field values of the required parameters are available.
8826 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8828 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8829 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8831 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8832 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8833 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8834 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8839 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8841 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8842 * \param [in] type - a spatial discretization of interest.
8843 * \param [in] iteration - the iteration number of a required time step.
8844 * \param [in] order - the iteration order number of required time step.
8845 * \param [out] arrOut - the DataArrayInt containing values of field.
8846 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8847 * \param [in] mesh - the supporting mesh.
8848 * \param [in] renumPol - specifies how to permute values of the result field according to
8849 * the optional numbers of cells and nodes, if any. The valid values are
8850 * - 0 - do not permute.
8851 * - 1 - permute cells.
8852 * - 2 - permute nodes.
8853 * - 3 - permute cells and nodes.
8855 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8856 * caller is to delete this field using decrRef() as it is no more needed.
8857 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8858 * \throw If no field of \a this is lying on \a mesh.
8859 * \throw If no field values of the required parameters are available.
8861 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8863 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8864 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8866 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8867 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8868 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8869 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8874 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8876 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8877 * \param [in] type - a spatial discretization of the new field.
8878 * \param [in] iteration - the iteration number of a required time step.
8879 * \param [in] order - the iteration order number of required time step.
8880 * \param [in] mesh - the supporting mesh.
8881 * \param [out] arrOut - the DataArrayInt containing values of field.
8882 * \param [in] renumPol - specifies how to permute values of the result field according to
8883 * the optional numbers of cells and nodes, if any. The valid values are
8884 * - 0 - do not permute.
8885 * - 1 - permute cells.
8886 * - 2 - permute nodes.
8887 * - 3 - permute cells and nodes.
8889 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8890 * caller is to delete this field using decrRef() as it is no more needed.
8891 * \throw If no field of \a this is lying on \a mesh.
8892 * \throw If no field values of the required parameters are available.
8894 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8896 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8897 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8899 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8900 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8901 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8902 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8907 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8908 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8909 * This method is useful for MED2 file format when field on different mesh was autorized.
8911 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8913 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8914 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8916 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8917 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8918 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8919 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8924 * Returns values and a profile of the field of a given type, of a given time step,
8925 * lying on a given support.
8926 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8927 * \param [in] type - a spatial discretization of the field.
8928 * \param [in] iteration - the iteration number of a required time step.
8929 * \param [in] order - the iteration order number of required time step.
8930 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8931 * \param [in] mesh - the supporting mesh.
8932 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8933 * field of interest lies on. If the field lies on all entities of the given
8934 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8935 * using decrRef() as it is no more needed.
8936 * \param [in] glob - the global data storing profiles and localization.
8937 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8938 * field. The caller is to delete this array using decrRef() as it is no more needed.
8939 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8940 * \throw If no field of \a this is lying on \a mesh.
8941 * \throw If no field values of the required parameters are available.
8943 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8945 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8946 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8948 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8949 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8950 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8954 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8955 * \param [in] pos - a time step id.
8956 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8957 * delete this field using decrRef() as it is no more needed.
8958 * \throw If \a pos is not a valid time step id.
8960 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8962 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8965 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8966 throw INTERP_KERNEL::Exception(oss.str().c_str());
8968 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8971 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8972 ret->shallowCpyGlobs(*this);
8975 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8976 throw INTERP_KERNEL::Exception(oss.str().c_str());
8980 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8981 * the given field is checked if its elements are sorted suitable for writing to MED file
8982 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8983 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8984 * \param [in] field - the field to add to \a this.
8985 * \throw If the name of \a field is empty.
8986 * \throw If the data array of \a field is not set.
8987 * \throw If existing time steps have different name or number of components than \a field.
8988 * \throw If the underlying mesh of \a field has no name.
8989 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8991 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8993 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8997 * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8998 * a given dimension of a given mesh are used as the support of the given field.
8999 * Elements of the given mesh must be sorted suitable for writing to MED file.
9000 * Order of underlying mesh entities of the given field specified by \a profile parameter
9001 * is not prescribed; this method permutes field values to have them sorted by element
9002 * type as required for writing to MED file.
9003 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9004 * \param [in] field - the field to add to \a this.
9005 * \param [in] mesh - the supporting mesh of \a field.
9006 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
9007 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9008 * \throw If either \a field or \a mesh or \a profile has an empty name.
9009 * \throw If existing time steps have different name or number of components than \a field.
9010 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9011 * \throw If the data array of \a field is not set.
9012 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9014 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9016 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9019 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9021 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9023 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9024 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9026 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 !");
9030 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9032 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9034 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9035 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9037 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 !");
9041 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9043 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9046 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9050 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9051 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9054 catch(INTERP_KERNEL::Exception& e)
9057 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9058 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9061 catch(INTERP_KERNEL::Exception& e)
9064 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9066 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9071 MEDFileFields *MEDFileFields::New()
9073 return new MEDFileFields;
9076 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9078 return new MEDFileFields(fileName,loadAll);
9081 std::size_t MEDFileFields::getHeapMemorySize() const
9083 std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9084 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9085 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9086 ret+=(*it)->getHeapMemorySize();
9087 return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9090 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9092 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9094 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9096 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9097 ret->_fields[i]=(*it)->deepCpy();
9099 ret->deepCpyGlobs(*this);
9103 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9105 return new MEDFileFields(*this);
9109 * 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
9110 * 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.
9111 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9113 * \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.
9114 * \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.
9116 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9118 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9120 std::set< std::pair<int,int> > s;
9121 bool firstShot=true;
9122 areThereSomeForgottenTS=false;
9123 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9125 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9127 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9128 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9130 { s=s1; firstShot=false; }
9133 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9135 areThereSomeForgottenTS=true;
9139 std::vector< std::pair<int,int> > ret;
9140 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9144 int MEDFileFields::getNumberOfFields() const
9146 return _fields.size();
9149 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9151 std::vector<std::string> ret(_fields.size());
9153 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9155 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9158 ret[i]=f->getName();
9162 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9163 throw INTERP_KERNEL::Exception(oss.str().c_str());
9169 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9171 std::vector<std::string> ret;
9172 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9174 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9176 ret.push_back(cur->getMeshName());
9181 std::string MEDFileFields::simpleRepr() const
9183 std::ostringstream oss;
9184 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9189 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9191 int nbOfFields=getNumberOfFields();
9192 std::string startLine(bkOffset,' ');
9193 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9195 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9197 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9200 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9204 oss << startLine << " - not defined !" << std::endl;
9208 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9210 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9211 std::string chapter(17,'0'+i);
9212 oss << startLine << chapter << std::endl;
9215 cur->simpleRepr(bkOffset+2,oss,i);
9219 oss << startLine << " - not defined !" << std::endl;
9221 oss << startLine << chapter << std::endl;
9223 simpleReprGlobs(oss);
9226 MEDFileFields::MEDFileFields()
9230 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9231 try:MEDFileFieldGlobsReal(fileName)
9233 MEDFileUtilities::CheckFileForRead(fileName);
9234 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9235 int nbFields=MEDnField(fid);
9236 _fields.resize(nbFields);
9237 med_field_type typcha;
9238 for(int i=0;i<nbFields;i++)
9240 std::vector<std::string> infos;
9241 std::string fieldName,dtunit;
9242 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9247 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9252 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9257 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] !";
9258 throw INTERP_KERNEL::Exception(oss.str().c_str());
9262 loadAllGlobals(fid);
9264 catch(INTERP_KERNEL::Exception& e)
9269 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9272 writeGlobals(fid,*this);
9273 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9275 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9278 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9279 throw INTERP_KERNEL::Exception(oss.str().c_str());
9281 elt->writeLL(fid,*this);
9285 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9287 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9288 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9293 * This method alloc the arrays and load potentially huge arrays contained in this field.
9294 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9295 * This method can be also called to refresh or reinit values from a file.
9297 * \throw If the fileName is not set or points to a non readable MED file.
9299 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9301 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9302 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9304 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9306 elt->loadBigArraysRecursively(fid,*elt);
9311 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9312 * But once data loaded once, this method does nothing.
9314 * \throw If the fileName is not set or points to a non readable MED file.
9315 * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays
9317 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9319 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9320 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9322 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9324 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9329 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9330 * This method does not release arrays set outside the context of a MED file.
9332 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9334 void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception)
9336 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9339 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9341 elt->releaseArrays();
9345 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9347 std::vector<std::string> ret;
9348 std::set<std::string> ret2;
9349 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9351 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9352 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9353 if(ret2.find(*it2)==ret2.end())
9355 ret.push_back(*it2);
9362 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9364 std::vector<std::string> ret;
9365 std::set<std::string> ret2;
9366 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9368 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9369 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9370 if(ret2.find(*it2)==ret2.end())
9372 ret.push_back(*it2);
9379 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9381 std::vector<std::string> ret;
9382 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9384 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9385 ret.insert(ret.end(),tmp.begin(),tmp.end());
9390 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9392 std::vector<std::string> ret;
9393 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9395 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9396 ret.insert(ret.end(),tmp.begin(),tmp.end());
9401 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9403 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9404 (*it)->changePflsRefsNamesGen2(mapOfModif);
9407 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9409 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9410 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9413 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9415 _fields.resize(newSize);
9418 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9420 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9424 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9427 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9428 _fields.push_back(field->getContent());
9429 appendGlobs(*field,1e-12);
9432 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9435 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9436 if(i>=(int)_fields.size())
9437 _fields.resize(i+1);
9438 _fields[i]=field->getContent();
9439 appendGlobs(*field,1e-12);
9442 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9444 destroyFieldsAtPos(&i,&i+1);
9447 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9449 std::vector<bool> b(_fields.size(),true);
9450 for(const int *i=startIds;i!=endIds;i++)
9452 if(*i<0 || *i>=(int)_fields.size())
9454 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9455 throw INTERP_KERNEL::Exception(oss.str().c_str());
9459 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9461 for(std::size_t i=0;i<_fields.size();i++)
9463 fields[j++]=_fields[i];
9467 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9469 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9470 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9471 std::vector<bool> b(_fields.size(),true);
9473 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9475 if(k<0 || k>=(int)_fields.size())
9477 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9478 throw INTERP_KERNEL::Exception(oss.str().c_str());
9482 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9484 for(std::size_t i=0;i<_fields.size();i++)
9486 fields[j++]=_fields[i];
9490 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9493 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9495 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9497 ret=cur->changeMeshNames(modifTab) || ret;
9503 * \param [in] meshName the name of the mesh that will be renumbered.
9504 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9505 * This code corresponds to the distribution of types in the corresponding mesh.
9506 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9507 * \param [in] renumO2N the old to new renumber array.
9508 * \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
9511 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9514 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9516 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9519 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9525 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9527 if(i<0 || i>=(int)_fields.size())
9529 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9530 throw INTERP_KERNEL::Exception(oss.str().c_str());
9532 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9535 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9536 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9537 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9539 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9541 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9544 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9545 throw INTERP_KERNEL::Exception(oss.str().c_str());
9547 ret->shallowCpyGlobs(*this);
9552 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9553 * This method is accessible in python using __getitem__ with a list in input.
9554 * \return a new object that the caller should deal with.
9556 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9558 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9559 std::size_t sz=std::distance(startIds,endIds);
9560 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9562 for(const int *i=startIds;i!=endIds;i++,j++)
9564 if(*i<0 || *i>=(int)_fields.size())
9566 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9567 throw INTERP_KERNEL::Exception(oss.str().c_str());
9569 fields[j]=_fields[*i];
9571 ret->_fields=fields;
9575 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9577 return getFieldAtPos(getPosFromFieldName(fieldName));
9581 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9582 * This method can be seen as a filter applied on \a this, that returns an object containing
9583 * 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
9584 * shallow copied from \a this.
9586 * \param [in] meshName - the name of the mesh on w
9587 * \return a new object that the caller should deal with.
9589 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9591 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9592 ret->shallowCpyOnlyUsedGlobs(*this);
9593 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9595 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9598 if(cur->getMeshName()==meshName)
9601 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9602 ret->_fields.push_back(cur2);
9609 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9610 * Input time steps are specified using a pair of integer (iteration, order).
9611 * 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,
9612 * but for each multitimestep only the time steps in \a timeSteps are kept.
9613 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9615 * The returned object points to shallow copy of elements in \a this.
9617 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9618 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9619 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9621 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9623 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9624 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9626 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9629 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9630 ret->_fields.push_back(elt);
9632 ret->shallowCpyOnlyUsedGlobs(*this);
9637 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9639 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9641 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9642 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9644 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9647 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9648 if(elt->getNumberOfTS()!=0)
9649 ret->_fields.push_back(elt);
9651 ret->shallowCpyOnlyUsedGlobs(*this);
9655 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9657 return new MEDFileFieldsIterator(this);
9660 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9662 std::string tmp(fieldName);
9663 std::vector<std::string> poss;
9664 for(std::size_t i=0;i<_fields.size();i++)
9666 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9669 std::string fname(f->getName());
9673 poss.push_back(fname);
9676 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9677 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9679 throw INTERP_KERNEL::Exception(oss.str().c_str());
9682 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9687 _nb_iter=fs->getNumberOfFields();
9691 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9695 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9697 if(_iter_id<_nb_iter)
9699 MEDFileFields *fs(_fs);
9701 return fs->getFieldAtPos(_iter_id++);