1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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"
25 #include "MEDFileFieldOverView.hxx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[34];
41 using namespace ParaMEDMEM;
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
48 return new MEDFileFieldLoc(fid,locName);
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 return new MEDFileFieldLoc(fid,id);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
58 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
63 med_geometry_type geotype;
64 med_geometry_type sectiongeotype;
66 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
70 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71 _nb_node_per_cell=cm.getNumberOfNodes();
72 _ref_coo.resize(_dim*_nb_node_per_cell);
73 _gs_coo.resize(_dim*_nb_gauss_pt);
74 _w.resize(_nb_gauss_pt);
75 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 med_geometry_type geotype;
81 med_geometry_type sectiongeotype;
83 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
88 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
89 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90 _nb_node_per_cell=cm.getNumberOfNodes();
91 _ref_coo.resize(_dim*_nb_node_per_cell);
92 _gs_coo.resize(_dim*_nb_gauss_pt);
93 _w.resize(_nb_gauss_pt);
94 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
98 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),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
119 return std::vector<const BigMemoryObject *>();
122 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 static const char OFF7[]="\n ";
125 oss << "\"" << _name << "\"" << OFF7;
126 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
127 oss << "Dimension=" << _dim << OFF7;
128 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
129 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
130 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
131 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 void MEDFileFieldLoc::setName(const std::string& name)
140 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
142 if(_name!=other._name)
146 if(_nb_gauss_pt!=other._nb_gauss_pt)
148 if(_nb_node_per_cell!=other._nb_node_per_cell)
150 if(_geo_type!=other._geo_type)
152 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
154 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
156 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162 void MEDFileFieldLoc::writeLL(med_idt fid) const
164 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);
167 std::string MEDFileFieldLoc::repr() const
169 std::ostringstream oss; oss.precision(15);
170 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
171 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
172 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
173 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
174 oss << "\n - Ref coords are : ";
175 int sz=_ref_coo.size();
178 int nbOfTuples=sz/_dim;
179 for(int i=0;i<nbOfTuples;i++)
182 for(int j=0;j<_dim;j++)
183 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
188 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
189 oss << "\n - Gauss coords in reference element : ";
193 int nbOfTuples=sz/_dim;
194 for(int i=0;i<nbOfTuples;i++)
197 for(int j=0;j<_dim;j++)
198 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
203 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
204 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
208 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
210 _type=field->getTypeOfField();
216 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
217 _end=_start+nbOfCells;
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
224 const int *arrPtr=arr->getConstPointer();
225 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
226 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
233 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
234 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
236 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
237 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
238 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
239 const int *dai2Ptr=dai2->getConstPointer();
240 int nbi=gsLoc.getWeights().size();
241 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
243 const int *da3Ptr=da3->getConstPointer();
244 if(da3->getNumberOfTuples()!=nbOfCells)
245 {//profile : for gauss even in NoProfile !!!
246 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
248 da3->setName(_profile.c_str());
249 glob.appendProfile(da3);
251 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
252 _nval=da3->getNbOfElems();
253 da4->alloc(_nval*nbi,1);
254 int *da4Ptr=da4->getPointer();
255 for(int i=0;i<_nval;i++)
257 int ref=dai2Ptr[offset+da3Ptr[i]];
258 for(int j=0;j<nbi;j++)
261 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
262 _localization=oss2.str();
263 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
264 _end=_start+_nval*nbi;
265 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
269 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
276 * \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).
277 * \param [in] multiTypePfl is the end user profile specified in high level API
278 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
279 * \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.
280 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
281 * \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.
283 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, 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)
286 _type=field->getTypeOfField();
287 std::string pflName(multiTypePfl->getName());
288 std::ostringstream oss; oss << pflName;
292 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
299 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
300 if(_type!=ON_GAUSS_PT)
302 locIds->setName(oss.str().c_str());
303 glob.appendProfile(locIds);
312 _nval=idsInPfl->getNumberOfTuples();
313 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
319 _nval=idsInPfl->getNumberOfTuples();
320 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
329 arr3->computeOffsets2();
330 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
331 int trueNval=tmp->getNumberOfTuples();
332 _nval=idsInPfl->getNumberOfTuples();
333 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
334 _end=_start+trueNval;
339 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
341 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
342 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
343 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
349 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
351 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
353 for(const int *pt=da4->begin();pt!=da4->end();pt++)
354 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
355 tmp->alloc(trueNval,1);
356 int *tmpPtr=tmp->getPointer();
357 for(const int *pt=da4->begin();pt!=da4->end();pt++)
358 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361 _nval=da4->getNumberOfTuples();
362 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
363 _end=_start+trueNval;
364 oss << "_loc_" << _loc_id;
367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
368 da5->setName(oss.str().c_str());
369 glob.appendProfile(da5);
374 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
376 da3->setName(oss.str().c_str());
377 glob.appendProfile(da3);
381 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
382 _localization=oss2.str();
383 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
387 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
392 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 _nval=arrr->getNumberOfTuples();
396 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
401 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
403 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
413 return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
418 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
421 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
423 std::vector<const BigMemoryObject *> ret(1);
424 ret[0]=(const PartDefinition*)_pd;
428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
430 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
435 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
436 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
441 catch(INTERP_KERNEL::Exception& e)
446 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
450 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(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),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
454 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
455 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
459 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
461 const PartDefinition *pd(_pd);
464 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
466 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
467 if(_end-_start!=nbValsInFile*nbi)
469 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
470 throw INTERP_KERNEL::Exception(oss.str().c_str());
472 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr);
476 if(!_profile.empty())
477 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
478 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
481 int profilesize,nbi,start,stop,step;
482 spd->getSlice(start,stop,step);
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
484 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
485 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
486 med_filter filter=MED_FILTER_INIT;
487 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
488 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
489 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
490 /*lastblocksize=useless because count=1*/0,&filter);
491 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr);
492 MEDfilterClose(&filter);
496 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
500 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
505 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
507 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
508 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
509 std::string fieldName(nasc.getName()),meshName(getMeshName());
510 int iteration(getIteration()),order(getOrder());
511 TypeOfField type(getType());
512 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
514 med_geometry_type mgeoti;
515 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
516 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
517 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
518 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
519 const PartDefinition *pd(_pd);
526 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
528 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : Part def only implemented for split one !");
529 if(!_profile.empty())
530 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
531 int start1,stop1,step1;
532 spd->getSlice(start1,stop1,step1);
533 _nval=DataArray::GetNumberOfItemGivenBES(start1,stop1,step1,"MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively");
536 _end=start+_nval*nbi;
538 if(type==ON_CELLS && !_localization.empty())
540 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
541 setType(ON_GAUSS_PT);
544 setType(ON_GAUSS_NE);
545 _localization.clear();
550 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
552 std::string fieldName(nasc.getName()),meshName(getMeshName());
553 int iteration(getIteration()),order(getOrder());
554 TypeOfField type(getType());
555 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
556 med_geometry_type mgeoti;
557 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
559 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
562 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
563 if(_start<0 || _start>=arr->getNumberOfTuples())
565 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
566 throw INTERP_KERNEL::Exception(oss.str().c_str());
568 if(_end<0 || _end>arr->getNumberOfTuples())
570 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
571 throw INTERP_KERNEL::Exception(oss.str().c_str());
573 int nbOfCompo(arr->getNumberOfComponents());
574 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
577 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
578 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
581 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
584 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
585 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
588 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
592 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
594 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
596 int delta=_end-_start;
597 _start=newValueOfStart;
601 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
603 return _father->getIteration();
606 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
608 return _father->getOrder();
611 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
613 return _father->getTime();
616 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
618 return _father->getMeshName();
621 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
623 const char startLine[]=" ## ";
624 std::string startLine2(bkOffset,' ');
625 startLine2+=startLine;
626 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
627 oss << startLine2 << "Localization #" << id << "." << std::endl;
628 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
630 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
631 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
632 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
635 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
640 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
645 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
650 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
652 return _father->getGeoType();
655 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
657 return _father->getNumberOfComponents();
660 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
665 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
667 return _father->getOrCreateAndGetArray();
670 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
672 const MEDFileFieldPerMeshPerType *fath=_father;
673 return fath->getOrCreateAndGetArray();
676 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
678 return _father->getInfo();
681 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
686 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
691 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
693 return _localization;
696 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
698 _localization=newLocName;
701 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
703 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
705 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
707 _profile=(*it2).second;
713 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
715 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
717 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
719 _localization=(*it2).second;
725 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
729 dads.push_back(std::pair<int,int>(_start,_end));
730 geoTypes.push_back(getGeoType());
735 pfls.push_back(glob->getProfile(_profile.c_str()));
737 if(_localization.empty())
741 locs.push_back(glob->getLocalizationId(_localization.c_str()));
745 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
747 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));
751 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
753 TypeOfField type=getType();
754 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
755 med_geometry_type mgeoti;
756 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
757 const DataArray *arr=getOrCreateAndGetArray();
759 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
760 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
761 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
762 const unsigned char *locToWrite=0;
764 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
766 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
768 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
769 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
770 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
774 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
779 dad.first=_start; dad.second=_end;
783 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
784 * This code corresponds to the distribution of types in the corresponding mesh.
785 * \param [out] ptToFill memory zone where the output will be stored.
786 * \return the size of data pushed into output param \a ptToFill
788 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
791 std::ostringstream oss;
792 std::size_t nbOfType=codeOfMesh.size()/3;
794 for(std::size_t i=0;i<nbOfType && found==-1;i++)
795 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
799 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
800 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
801 throw INTERP_KERNEL::Exception(oss.str().c_str());
806 if(_nval!=codeOfMesh[3*found+1])
808 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
809 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
810 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
811 throw INTERP_KERNEL::Exception(oss.str().c_str());
813 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
818 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
819 if(pfl->getNumberOfTuples()!=_nval)
821 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
822 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
824 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
825 throw INTERP_KERNEL::Exception(oss.str().c_str());
827 int offset2=codeOfMesh[3*found+2];
828 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
830 if(*pflId<codeOfMesh[3*found+1])
831 *work++=offset2+*pflId;
837 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
839 for(int i=_start;i<_end;i++)
844 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
855 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
859 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
862 std::map<std::pair<std::string,TypeOfField>,int> m;
863 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
864 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
865 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
866 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
868 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
869 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
874 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
876 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
877 * \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.
878 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
879 * \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)
880 * \param [in,out] glob if necessary by the method, new profiles can be added to it
881 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
882 * \param [out] result All new entries will be appended on it.
883 * \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 !)
885 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
886 const DataArrayInt *explicitIdsInMesh,
887 const std::vector<int>& newCode,
888 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
889 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
891 if(entriesOnSameDisc.empty())
893 TypeOfField type=entriesOnSameDisc[0]->getType();
894 int szEntities=0,szTuples=0;
895 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
896 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
897 int nbi=szTuples/szEntities;
898 if(szTuples%szEntities!=0)
899 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
900 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
901 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
902 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
903 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
904 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
905 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
906 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
908 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
910 int startOfEltIdOfChunk=(*it)->_start;
911 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
912 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
913 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
915 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
916 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
918 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
919 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
921 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
922 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
923 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
924 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
926 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
928 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
929 arrPart->renumberInPlace(renumTupleIds->begin());
930 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
932 const int *idIt=diffVals->begin();
933 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
935 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
937 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
938 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
939 int nbEntityElts=subIds->getNumberOfTuples();
941 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
942 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
946 result.push_back(eltToAdd);
947 offset2+=nbEntityElts*nbi;
949 ret=ret || li.empty();
954 * \param [in] typeF type of field of new chunk
955 * \param [in] geoType the geometric type of the chunk
956 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
957 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
958 * \param [in] nbi number of integration points
959 * \param [in] offset The offset in the **global array of data**.
960 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
961 * to the new chunk to create.
962 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
963 * \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
964 * and corresponding entry erased from \a entriesOnSameDisc.
965 * \return a newly allocated chunk
967 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
968 bool isPfl, int nbi, int offset,
969 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
970 MEDFileFieldGlobsReal& glob,
973 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
974 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
975 for(;it!=entriesOnSameDisc.end();it++)
977 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
981 if((*it)->_profile.empty())
984 if(!(*it)->_profile.empty())
986 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
987 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
993 if(it==entriesOnSameDisc.end())
996 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
998 ret->_loc_id=(int)geoType;
999 ret->_nval=nbMeshEntities;
1001 ret->_end=ret->_start+ret->_nval*nbi;
1004 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1005 glob.appendProfile(idsOfMeshElt);
1006 ret->_profile=idsOfMeshElt->getName();
1008 //tony treatment of localization
1013 notInExisting=false;
1014 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1015 ret->_loc_id=(int)geoType;
1016 ret->setNewStart(offset);
1017 entriesOnSameDisc.erase(it);
1023 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1025 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1028 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1030 return new MEDFileFieldPerMeshPerType(fath,geoType);
1033 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1035 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1038 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1040 std::vector<const BigMemoryObject *> ret;
1041 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1042 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1046 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1048 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1049 ret->_father=father;
1051 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1053 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1054 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1059 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1061 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1062 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1063 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1067 * This method is the most general one. No optimization is done here.
1068 * \param [in] multiTypePfl is the end user profile specified in high level API
1069 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1070 * \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.
1071 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1072 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1073 * \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.
1075 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, 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)
1077 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1078 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1079 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1082 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1084 _field_pm_pt_pd.resize(1);
1085 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1086 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1089 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1091 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1092 if(!arr || !arr->isAllocated())
1093 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1094 _field_pm_pt_pd.resize(1);
1095 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1096 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1099 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1101 TypeOfField type=field->getTypeOfField();
1102 if(type!=ON_GAUSS_PT)
1104 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1105 int sz=_field_pm_pt_pd.size();
1107 for(int j=0;j<sz && !found;j++)
1109 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1111 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1117 _field_pm_pt_pd.resize(sz+1);
1118 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1120 std::vector<int> ret(1,(int)sz);
1125 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1126 int sz2=ret2.size();
1127 std::vector<int> ret3(sz2);
1129 for(int i=0;i<sz2;i++)
1131 int sz=_field_pm_pt_pd.size();
1132 int locIdToFind=ret2[i];
1134 for(int j=0;j<sz && !found;j++)
1136 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1138 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 _field_pm_pt_pd.resize(sz+1);
1146 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1154 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1156 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1157 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1159 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1160 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1162 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1163 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1164 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1165 if(retTmp->presenceOfValue(-1))
1166 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1167 std::vector<int> ret(retTmp->begin(),retTmp->end());
1171 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1173 TypeOfField type=field->getTypeOfField();
1174 if(type!=ON_GAUSS_PT)
1176 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1177 int sz=_field_pm_pt_pd.size();
1179 for(int j=0;j<sz && !found;j++)
1181 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1183 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1189 _field_pm_pt_pd.resize(sz+1);
1190 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1192 std::vector<int> ret(1,0);
1197 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1198 int sz2=ret2.size();
1199 std::vector<int> ret3(sz2);
1201 for(int i=0;i<sz2;i++)
1203 int sz=_field_pm_pt_pd.size();
1204 int locIdToFind=ret2[i];
1206 for(int j=0;j<sz && !found;j++)
1208 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1210 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1217 _field_pm_pt_pd.resize(sz+1);
1218 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1226 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1228 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1229 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1231 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1232 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1234 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1237 if(retTmp->presenceOfValue(-1))
1238 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1239 std::vector<int> ret(retTmp->begin(),retTmp->end());
1243 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1248 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1250 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1251 int curDim=(int)cm.getDimension();
1252 dim=std::max(dim,curDim);
1255 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1257 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1259 (*it)->fillTypesOfFieldAvailable(types);
1263 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
1265 int sz=_field_pm_pt_pd.size();
1266 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1267 for(int i=0;i<sz;i++)
1269 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1273 int MEDFileFieldPerMeshPerType::getIteration() const
1275 return _father->getIteration();
1278 int MEDFileFieldPerMeshPerType::getOrder() const
1280 return _father->getOrder();
1283 double MEDFileFieldPerMeshPerType::getTime() const
1285 return _father->getTime();
1288 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1290 return _father->getMeshName();
1293 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1295 const char startLine[]=" ## ";
1296 std::string startLine2(bkOffset,' ');
1297 std::string startLine3(startLine2);
1298 startLine3+=startLine;
1299 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1301 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1302 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1305 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1306 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1310 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1312 cur->simpleRepr(bkOffset,oss,i);
1315 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1320 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1322 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1324 globalSz+=(*it)->getNumberOfTuples();
1326 nbOfEntries+=(int)_field_pm_pt_pd.size();
1329 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1335 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1337 return _father->getNumberOfComponents();
1340 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1343 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1345 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1352 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1354 return _father->getOrCreateAndGetArray();
1357 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1359 const MEDFileFieldPerMesh *fath=_father;
1360 return fath->getOrCreateAndGetArray();
1363 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1365 return _father->getInfo();
1368 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1370 std::vector<std::string> ret;
1371 std::set<std::string> ret2;
1372 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1374 std::string tmp=(*it1)->getProfile();
1376 if(ret2.find(tmp)==ret2.end())
1385 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1387 std::vector<std::string> ret;
1388 std::set<std::string> ret2;
1389 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1391 std::string tmp=(*it1)->getLocalization();
1392 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1393 if(ret2.find(tmp)==ret2.end())
1402 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1404 std::vector<std::string> ret;
1405 std::set<std::string> ret2;
1406 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1408 std::string tmp=(*it1)->getProfile();
1415 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1417 std::vector<std::string> ret;
1418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1420 std::string tmp=(*it1)->getLocalization();
1421 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1427 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1430 (*it1)->changePflsRefsNamesGen(mapOfModif);
1433 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1435 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1436 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1439 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1441 if(_field_pm_pt_pd.empty())
1443 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1444 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1445 throw INTERP_KERNEL::Exception(oss.str().c_str());
1447 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1448 return _field_pm_pt_pd[locId];
1449 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1450 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1451 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1452 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1453 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1456 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1458 if(_field_pm_pt_pd.empty())
1460 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1461 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1462 throw INTERP_KERNEL::Exception(oss.str().c_str());
1464 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1465 return _field_pm_pt_pd[locId];
1466 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1467 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1468 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1469 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1470 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1473 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
1475 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1477 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1478 if(meshDim!=(int)cm.getDimension())
1481 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1482 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1485 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1488 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1490 (*it)->fillValues(i,startEntryId,entries);
1494 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1496 _field_pm_pt_pd=leaves;
1497 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1498 (*it)->setFather(this);
1502 * \param [in,out] globalNum a global numbering counter for the renumbering.
1503 * \param [out] its - list of pair (start,stop) kept
1504 * \return bool - false if the type of field \a tof is not contained in \a this.
1506 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1509 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1511 if((*it)->getType()==tof)
1513 newPmPtPd.push_back(*it);
1514 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1515 (*it)->setNewStart(globalNum);
1516 globalNum=(*it)->getEnd();
1517 its.push_back(bgEnd);
1521 _field_pm_pt_pd=newPmPtPd;
1525 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1529 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1531 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1532 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1533 med_geometry_type mgeoti;
1534 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1535 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1536 _field_pm_pt_pd.resize(nbProfiles);
1537 for(int i=0;i<nbProfiles;i++)
1539 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1543 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1544 for(int i=0;i<nbProfiles2;i++)
1545 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1549 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1551 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1552 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1555 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1557 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1558 (*it)->loadBigArray(fid,nasc);
1561 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1563 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1565 (*it)->copyOptionsFrom(*this);
1566 (*it)->writeLL(fid,nasc);
1570 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1575 medfGeoType=typmai3[(int)ikGeoType];
1578 medfGeoType=MED_NONE;
1581 medfGeoType=typmai3[(int)ikGeoType];
1582 return MED_NODE_ELEMENT;
1584 medfGeoType=typmai3[(int)ikGeoType];
1587 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1589 return MED_UNDEF_ENTITY_TYPE;
1592 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1594 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1597 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1599 return new MEDFileFieldPerMesh(fath,mesh);
1602 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1604 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1607 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1609 std::vector<const BigMemoryObject *> ret;
1610 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1611 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1615 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1617 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1618 ret->_father=father;
1620 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1622 if((const MEDFileFieldPerMeshPerType *)*it)
1623 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1628 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1630 std::string startLine(bkOffset,' ');
1631 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1632 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1634 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1636 const MEDFileFieldPerMeshPerType *cur=*it;
1638 cur->simpleRepr(bkOffset,oss,i);
1641 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1646 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1648 _mesh_name=mesh->getName();
1649 mesh->getTime(_mesh_iteration,_mesh_order);
1652 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1654 int nbOfTypes=code.size()/3;
1656 for(int i=0;i<nbOfTypes;i++)
1658 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1659 int nbOfCells=code[3*i+1];
1660 int pos=addNewEntryIfNecessary(type);
1661 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1667 * This method is the most general one. No optimization is done here.
1668 * \param [in] multiTypePfl is the end user profile specified in high level API
1669 * \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].
1670 * \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.
1671 * \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.
1672 * \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.
1673 * \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.
1675 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)
1677 int nbOfTypes(code.size()/3);
1678 for(int i=0;i<nbOfTypes;i++)
1680 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1681 int pos=addNewEntryIfNecessary(type);
1682 DataArrayInt *pfl=0;
1684 pfl=idsPerType[code[3*i+2]];
1685 int nbOfTupes2=code2.size()/3;
1687 for(;found<nbOfTupes2;found++)
1688 if(code[3*i]==code2[3*found])
1690 if(found==nbOfTupes2)
1691 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1692 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1696 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1698 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1699 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1702 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1704 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1705 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1708 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1710 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1711 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1714 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1716 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1717 (*it)->loadBigArraysRecursively(fid,nasc);
1720 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1722 int nbOfTypes=_field_pm_pt.size();
1723 for(int i=0;i<nbOfTypes;i++)
1725 _field_pm_pt[i]->copyOptionsFrom(*this);
1726 _field_pm_pt[i]->writeLL(fid,nasc);
1730 void MEDFileFieldPerMesh::getDimension(int& dim) const
1732 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1733 (*it)->getDimension(dim);
1736 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1738 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1739 (*it)->fillTypesOfFieldAvailable(types);
1742 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
1744 int sz=_field_pm_pt.size();
1745 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1746 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1747 for(int i=0;i<sz;i++)
1749 types[i]=_field_pm_pt[i]->getGeoType();
1750 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1755 double MEDFileFieldPerMesh::getTime() const
1758 return _father->getTime(tmp1,tmp2);
1761 int MEDFileFieldPerMesh::getIteration() const
1763 return _father->getIteration();
1766 int MEDFileFieldPerMesh::getOrder() const
1768 return _father->getOrder();
1771 int MEDFileFieldPerMesh::getNumberOfComponents() const
1773 return _father->getNumberOfComponents();
1776 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1778 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1780 const MEDFileFieldPerMeshPerType *fpmt(*it);
1783 if(fpmt->presenceOfMultiDiscPerGeoType())
1789 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1792 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1793 return _father->getOrCreateAndGetArray();
1796 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1799 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1800 return _father->getOrCreateAndGetArray();
1803 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1805 return _father->getInfo();
1809 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1810 * 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.
1811 * It returns 2 output vectors :
1812 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1813 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1814 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1816 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)
1818 int notNullPflsSz=0;
1819 int nbOfArrs=geoTypes.size();
1820 for(int i=0;i<nbOfArrs;i++)
1823 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1824 int nbOfDiffGeoTypes=geoTypes3.size();
1825 code.resize(3*nbOfDiffGeoTypes);
1826 notNullPfls.resize(notNullPflsSz);
1829 for(int i=0;i<nbOfDiffGeoTypes;i++)
1832 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1833 std::vector<const DataArrayInt *> notNullTmp;
1835 notNullTmp.push_back(pfls[j]);
1837 for(;j<nbOfArrs;j++)
1838 if(geoTypes[j]==refType)
1841 notNullTmp.push_back(pfls[j]);
1845 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1846 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1847 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1848 code[3*i]=(int)refType;
1849 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1850 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1851 if(notNullTmp.empty())
1855 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1856 code[3*i+2]=notNullPflsSz++;
1862 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1864 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)
1868 for(int i=0;i<sz;i++)
1872 if(type!=ON_GAUSS_NE)
1873 ret+=dads[i].second-dads[i].first;
1876 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1877 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1882 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1883 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1889 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1891 std::vector<std::string> ret;
1892 std::set<std::string> ret2;
1893 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1895 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1896 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1897 if(ret2.find(*it2)==ret2.end())
1899 ret.push_back(*it2);
1906 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1908 std::vector<std::string> ret;
1909 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1911 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1912 ret.insert(ret.end(),tmp.begin(),tmp.end());
1917 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1919 std::vector<std::string> ret;
1920 std::set<std::string> ret2;
1921 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1923 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1924 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1925 if(ret2.find(*it2)==ret2.end())
1927 ret.push_back(*it2);
1934 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1936 std::vector<std::string> ret;
1937 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1939 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1940 ret.insert(ret.end(),tmp.begin(),tmp.end());
1945 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1947 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1949 if((*it).first==_mesh_name)
1951 _mesh_name=(*it).second;
1958 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1959 MEDFileFieldGlobsReal& glob)
1961 if(_mesh_name!=meshName)
1963 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1964 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1965 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1966 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1967 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1968 getUndergroundDataArrayExt(entries);
1969 DataArray *arr0=getOrCreateAndGetArray();//tony
1971 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1972 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1974 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1977 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1978 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1980 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1982 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1983 sz+=(*it).second.second-(*it).second.first;
1986 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1988 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1989 ////////////////////
1990 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1991 int *workI2=explicitIdsOldInMesh->getPointer();
1992 int sz1=0,sz2=0,sid=1;
1993 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1994 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1995 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1997 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1998 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1999 int *workI=explicitIdsOldInArr->getPointer();
2000 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2002 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2003 (*itL2)->setLocId(sz2);
2004 (*itL2)->_tmp_work1=(*itL2)->getStart();
2005 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2007 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2009 explicitIdsOldInMesh->reAlloc(sz2);
2010 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2011 ////////////////////
2012 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2013 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2014 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2015 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2017 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2018 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2019 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2021 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2022 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2023 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2025 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2026 int newStart=elt->getLocId();
2027 elt->setLocId((*it)->getGeoType());
2028 elt->setNewStart(newStart);
2029 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2030 entriesKeptNew.push_back(elt);
2031 entriesKeptNew2.push_back(elt);
2033 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2034 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2035 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2036 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2038 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2041 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2043 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2044 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2046 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2047 glob,arr2,otherEntriesNew) || ret;
2051 // Assign new dispatching
2052 assignNewLeaves(otherEntriesNew);
2053 arr->cpyFrom(*arr2);
2058 * \param [in,out] globalNum a global numbering counter for the renumbering.
2059 * \param [out] its - list of pair (start,stop) kept
2061 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2063 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2064 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2066 std::vector< std::pair<int,int> > its2;
2067 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2070 its.insert(its.end(),its2.begin(),its2.end());
2076 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2078 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2079 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2080 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2082 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2083 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2084 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2085 for(;it1!=types.end();it1++,it2++)
2087 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2088 elt->setLeaves((*it1).second);
2091 _field_pm_pt=fieldPmPt;
2094 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2096 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2097 (*it)->changePflsRefsNamesGen(mapOfModif);
2100 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2102 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2103 (*it)->changeLocsRefsNamesGen(mapOfModif);
2107 * \param [in] mesh is the whole mesh
2109 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2111 if(_field_pm_pt.empty())
2112 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2114 std::vector< std::pair<int,int> > dads;
2115 std::vector<const DataArrayInt *> pfls;
2116 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2117 std::vector<int> locs,code;
2118 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2119 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2120 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2122 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2125 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2126 throw INTERP_KERNEL::Exception(oss.str().c_str());
2129 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2130 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2133 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2135 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2138 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2139 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2145 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2149 if(nb!=mesh->getNumberOfNodes())
2151 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2152 oss << " nodes in mesh !";
2153 throw INTERP_KERNEL::Exception(oss.str().c_str());
2155 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2158 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2162 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2164 if(_field_pm_pt.empty())
2165 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2167 std::vector<std::pair<int,int> > dads;
2168 std::vector<const DataArrayInt *> pfls;
2169 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2170 std::vector<int> locs,code;
2171 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2172 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2173 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2175 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2178 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2179 throw INTERP_KERNEL::Exception(oss.str().c_str());
2181 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2182 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2185 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2186 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2191 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2195 if(nb!=mesh->getNumberOfNodes())
2197 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2198 oss << " nodes in mesh !";
2199 throw INTERP_KERNEL::Exception(oss.str().c_str());
2202 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2208 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2212 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2214 (*it)->getSizes(globalSz,nbOfEntries);
2216 entries.resize(nbOfEntries);
2218 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2220 (*it)->fillValues(nbOfEntries,entries);
2224 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2226 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2228 if((*it)->getGeoType()==typ)
2229 return (*it)->getLeafGivenLocId(locId);
2231 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2232 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2233 oss << "Possiblities are : ";
2234 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2236 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2237 oss << "\"" << cm2.getRepr() << "\", ";
2239 throw INTERP_KERNEL::Exception(oss.str().c_str());
2242 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2244 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2246 if((*it)->getGeoType()==typ)
2247 return (*it)->getLeafGivenLocId(locId);
2249 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2250 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2251 oss << "Possiblities are : ";
2252 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2254 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2255 oss << "\"" << cm2.getRepr() << "\", ";
2257 throw INTERP_KERNEL::Exception(oss.str().c_str());
2260 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2263 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2264 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2265 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2267 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2272 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2277 int ret=std::distance(_field_pm_pt.begin(),it2);
2278 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2283 * 'dads' and 'locs' input parameters have the same number of elements
2284 * \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
2286 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2287 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2288 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2291 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2292 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2293 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2294 const std::vector<std::string>& infos=getInfo();
2295 da->setInfoOnComponents(infos);
2297 if(type==ON_GAUSS_PT)
2300 int nbOfArrs=dads.size();
2301 for(int i=0;i<nbOfArrs;i++)
2303 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2304 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2305 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2306 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2307 di->alloc(nbOfElems,1);
2309 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2310 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2319 * 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.
2320 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2321 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2322 * The order of cells in the returned field is those imposed by the profile.
2323 * \param [in] mesh is the global mesh.
2325 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2326 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2327 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2328 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2330 if(da->isIdentity())
2332 int nbOfTuples=da->getNumberOfTuples();
2333 if(nbOfTuples==mesh->getNumberOfCells())
2334 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2336 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2337 m2->setName(mesh->getName().c_str());
2338 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2344 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2346 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2347 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2348 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2350 if(da->isIdentity())
2352 int nbOfTuples=da->getNumberOfTuples();
2353 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2354 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2356 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2357 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2360 if(meshu->getNodalConnectivity()==0)
2362 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2363 int nb=da->getNbOfElems();
2364 const int *ptr=da->getConstPointer();
2365 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2366 meshuc->allocateCells(nb);
2367 for(int i=0;i<nb;i++)
2368 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2369 meshuc->finishInsertingCells();
2370 ret->setMesh(meshuc);
2371 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2372 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2373 disc->checkCoherencyBetween(meshuc,arrOut);
2378 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2380 DataArrayInt *arr2=0;
2381 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2382 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2383 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2384 int nnodes=mesh2->getNumberOfNodes();
2385 if(nnodes==(int)da->getNbOfElems())
2387 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2388 arrOut->renumberInPlace(da3->getConstPointer());
2389 mesh2->setName(mesh->getName().c_str());
2390 ret->setMesh(mesh2);
2395 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 !!!";
2396 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2397 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2398 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2399 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2400 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2401 throw INTERP_KERNEL::Exception(oss.str().c_str());
2407 * This method is the most light method of field retrieving.
2409 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2413 pflOut=DataArrayInt::New();
2414 pflOut->alloc(nbOfElems,1);
2419 pflOut=const_cast<DataArrayInt*>(pflIn);
2422 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2423 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2424 const std::vector<std::string>& infos=getInfo();
2425 int nbOfComp=infos.size();
2426 for(int i=0;i<nbOfComp;i++)
2427 da->setInfoOnComponent(i,infos[i].c_str());
2432 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2435 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2436 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2437 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2438 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2439 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2441 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2442 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2443 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2444 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2445 if(nbProfile>0 || nbProfile2>0)
2447 const PartDefinition *pd(0);
2449 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2450 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2457 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2460 const PartDefinition *pd(0);
2462 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2463 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2464 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2468 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2470 copyTinyInfoFrom(mesh);
2473 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2475 if(id>=(int)_pfls.size())
2477 _pfls[id]=DataArrayInt::New();
2478 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2479 _pfls[id]->setName(pflName);
2480 _pfls[id]->alloc(lgth,1);
2481 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2482 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2485 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2487 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2489 MEDprofileInfo(fid,i+1,pflName,&sz);
2490 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2491 if(i>=(int)_pfls.size())
2493 _pfls[i]=DataArrayInt::New();
2494 _pfls[i]->alloc(sz,1);
2495 _pfls[i]->setName(pflCpp.c_str());
2496 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2497 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2500 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2502 int nbOfPfls=_pfls.size();
2503 for(int i=0;i<nbOfPfls;i++)
2505 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2506 cpy->applyLin(1,1,0);
2507 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2508 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2509 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2512 int nbOfLocs=_locs.size();
2513 for(int i=0;i<nbOfLocs;i++)
2514 _locs[i]->writeLL(fid);
2517 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2519 std::vector<std::string> pfls=getPfls();
2520 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2522 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2525 _pfls.push_back(*it);
2529 int id=std::distance(pfls.begin(),it2);
2530 if(!(*it)->isEqual(*_pfls[id]))
2532 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2533 throw INTERP_KERNEL::Exception(oss.str().c_str());
2537 std::vector<std::string> locs=getLocs();
2538 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2540 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2543 _locs.push_back(*it);
2547 int id=std::distance(locs.begin(),it2);
2548 if(!(*it)->isEqual(*_locs[id],eps))
2550 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2551 throw INTERP_KERNEL::Exception(oss.str().c_str());
2557 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2559 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2560 getProfile((*it).c_str());
2563 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2565 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2566 getLocalization((*it).c_str());
2569 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2571 std::vector<std::string> profiles=real.getPflsReallyUsed();
2572 int sz=profiles.size();
2574 for(int i=0;i<sz;i++)
2575 loadProfileInFile(fid,i,profiles[i].c_str());
2577 std::vector<std::string> locs=real.getLocsReallyUsed();
2580 for(int i=0;i<sz;i++)
2581 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2584 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2586 int nProfil=MEDnProfile(fid);
2587 for(int i=0;i<nProfil;i++)
2588 loadProfileInFile(fid,i);
2589 int sz=MEDnLocalization(fid);
2591 for(int i=0;i<sz;i++)
2593 _locs[i]=MEDFileFieldLoc::New(fid,i);
2597 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2599 return new MEDFileFieldGlobs(fname);
2602 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2604 return new MEDFileFieldGlobs;
2607 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2609 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2612 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2614 std::vector<const BigMemoryObject *> ret;
2615 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2616 ret.push_back((const DataArrayInt *)*it);
2617 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2618 ret.push_back((const MEDFileFieldLoc *)*it);
2622 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2624 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2626 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2628 if((const DataArrayInt *)*it)
2629 ret->_pfls[i]=(*it)->deepCpy();
2632 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2634 if((const MEDFileFieldLoc*)*it)
2635 ret->_locs[i]=(*it)->deepCpy();
2641 * \throw if a profile in \a pfls in not in \a this.
2642 * \throw if a localization in \a locs in not in \a this.
2643 * \sa MEDFileFieldGlobs::deepCpyPart
2645 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2647 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2648 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2650 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2652 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2654 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2655 ret->_pfls.push_back(pfl2);
2657 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2659 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2661 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2663 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2664 ret->_locs.push_back(loc2);
2666 ret->setFileName(getFileName());
2671 * \throw if a profile in \a pfls in not in \a this.
2672 * \throw if a localization in \a locs in not in \a this.
2673 * \sa MEDFileFieldGlobs::shallowCpyPart
2675 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2677 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2678 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2680 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2682 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2683 ret->_pfls.push_back(pfl->deepCpy());
2685 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2687 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2689 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2690 ret->_locs.push_back(loc->deepCpy());
2692 ret->setFileName(getFileName());
2696 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2700 MEDFileFieldGlobs::MEDFileFieldGlobs()
2704 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2708 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2710 oss << "Profiles :\n";
2711 std::size_t n=_pfls.size();
2712 for(std::size_t i=0;i<n;i++)
2714 oss << " - #" << i << " ";
2715 const DataArrayInt *pfl=_pfls[i];
2717 oss << "\"" << pfl->getName() << "\"\n";
2722 oss << "Localizations :\n";
2723 for(std::size_t i=0;i<n;i++)
2725 oss << " - #" << i << " ";
2726 const MEDFileFieldLoc *loc=_locs[i];
2728 loc->simpleRepr(oss);
2734 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2736 _file_name=fileName;
2739 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2741 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2743 DataArrayInt *elt(*it);
2746 std::string name(elt->getName());
2747 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2749 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2751 elt->setName((*it2).second.c_str());
2759 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2761 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2763 MEDFileFieldLoc *elt(*it);
2766 std::string name(elt->getName());
2767 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2769 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2771 elt->setName((*it2).second.c_str());
2779 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2781 if(locId<0 || locId>=(int)_locs.size())
2782 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2783 return _locs[locId]->getNbOfGaussPtPerCell();
2786 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2788 return getLocalizationFromId(getLocalizationId(locName));
2791 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2793 if(locId<0 || locId>=(int)_locs.size())
2794 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2795 return *_locs[locId];
2798 namespace ParaMEDMEMImpl
2803 LocFinder(const std::string& loc):_loc(loc) { }
2804 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2806 const std::string &_loc;
2812 PflFinder(const std::string& pfl):_pfl(pfl) { }
2813 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2815 const std::string& _pfl;
2819 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2821 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2824 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2825 for(it=_locs.begin();it!=_locs.end();it++)
2826 oss << "\"" << (*it)->getName() << "\", ";
2827 throw INTERP_KERNEL::Exception(oss.str().c_str());
2829 return std::distance(_locs.begin(),it);
2833 * The returned value is never null.
2835 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2837 std::string pflNameCpp(pflName);
2838 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2841 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2842 for(it=_pfls.begin();it!=_pfls.end();it++)
2843 oss << "\"" << (*it)->getName() << "\", ";
2844 throw INTERP_KERNEL::Exception(oss.str().c_str());
2849 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2851 if(pflId<0 || pflId>=(int)_pfls.size())
2852 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2853 return _pfls[pflId];
2856 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2858 if(locId<0 || locId>=(int)_locs.size())
2859 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2860 return *_locs[locId];
2863 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2865 return getLocalizationFromId(getLocalizationId(locName));
2869 * The returned value is never null.
2871 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2873 std::string pflNameCpp(pflName);
2874 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2877 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2878 for(it=_pfls.begin();it!=_pfls.end();it++)
2879 oss << "\"" << (*it)->getName() << "\", ";
2880 throw INTERP_KERNEL::Exception(oss.str().c_str());
2885 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2887 if(pflId<0 || pflId>=(int)_pfls.size())
2888 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2889 return _pfls[pflId];
2892 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2894 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2896 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2898 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2899 newPfls.push_back(*it);
2904 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2906 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2908 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2910 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2911 newLocs.push_back(*it);
2916 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2918 int sz=_pfls.size();
2919 std::vector<std::string> ret(sz);
2920 for(int i=0;i<sz;i++)
2921 ret[i]=_pfls[i]->getName();
2925 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2927 int sz=_locs.size();
2928 std::vector<std::string> ret(sz);
2929 for(int i=0;i<sz;i++)
2930 ret[i]=_locs[i]->getName();
2934 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2936 std::vector<std::string> v=getPfls();
2937 std::string s(pflName);
2938 return std::find(v.begin(),v.end(),s)!=v.end();
2941 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2943 std::vector<std::string> v=getLocs();
2944 std::string s(locName);
2945 return std::find(v.begin(),v.end(),s)!=v.end();
2948 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2950 std::map<int,std::vector<int> > m;
2952 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2954 const DataArrayInt *tmp=(*it);
2957 m[tmp->getHashCode()].push_back(i);
2960 std::vector< std::vector<int> > ret;
2961 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2963 if((*it2).second.size()>1)
2965 std::vector<int> ret0;
2966 bool equalityOrNot=false;
2967 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2969 std::vector<int>::const_iterator it4=it3; it4++;
2970 for(;it4!=(*it2).second.end();it4++)
2972 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2975 ret0.push_back(*it3);
2976 ret0.push_back(*it4);
2982 ret.push_back(ret0);
2988 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2990 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2993 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2995 std::string name(pfl->getName());
2997 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2998 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2999 if(name==(*it)->getName())
3001 if(!pfl->isEqual(*(*it)))
3003 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3004 throw INTERP_KERNEL::Exception(oss.str().c_str());
3008 _pfls.push_back(pfl);
3011 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3013 std::string name(locName);
3015 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3016 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3017 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3018 if((*it)->isName(locName))
3020 if(!(*it)->isEqual(*obj,1e-12))
3022 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3023 throw INTERP_KERNEL::Exception(oss.str().c_str());
3026 _locs.push_back(obj);
3029 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3031 std::vector<std::string> names=getPfls();
3032 return CreateNewNameNotIn("NewPfl_",names);
3035 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3037 std::vector<std::string> names=getLocs();
3038 return CreateNewNameNotIn("NewLoc_",names);
3041 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3043 for(std::size_t sz=0;sz<100000;sz++)
3045 std::ostringstream tryName;
3046 tryName << prefix << sz;
3047 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3048 return tryName.str();
3050 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3054 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3055 * \param [in] fname - the file name.
3057 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3062 * Creates an empty MEDFileFieldGlobsReal.
3064 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3068 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3073 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3075 std::vector<const BigMemoryObject *> ret;
3076 ret.push_back((const MEDFileFieldGlobs *)_globals);
3081 * Returns a string describing profiles and Gauss points held in \a this.
3082 * \return std::string - the description string.
3084 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3086 const MEDFileFieldGlobs *glob=_globals;
3087 std::ostringstream oss2; oss2 << glob;
3088 std::string stars(oss2.str().length(),'*');
3089 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3091 glob->simpleRepr(oss);
3093 oss << "NO GLOBAL INFORMATION !\n";
3096 void MEDFileFieldGlobsReal::resetContent()
3098 _globals=MEDFileFieldGlobs::New();
3101 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3106 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3107 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3109 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3111 _globals=other._globals;
3115 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3116 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3118 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3120 const MEDFileFieldGlobs *otherg(other._globals);
3123 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3127 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3128 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3130 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3132 const MEDFileFieldGlobs *otherg(other._globals);
3135 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3138 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3140 _globals=other._globals;
3141 if((const MEDFileFieldGlobs *)_globals)
3142 _globals=other._globals->deepCpy();
3146 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3147 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3148 * \param [in] eps - a precision used to compare Gauss points with same name held by
3149 * \a this and \a other MEDFileFieldGlobsReal.
3150 * \throw If \a this and \a other hold profiles with equal names but different ids.
3151 * \throw If \a this and \a other hold different Gauss points with equal names.
3153 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3155 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3156 if(thisGlobals==otherGlobals)
3160 _globals=other._globals;
3163 _globals->appendGlobs(*other._globals,eps);
3166 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3168 checkGlobsPflsPartCoherency();
3169 checkGlobsLocsPartCoherency();
3172 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3174 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3177 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3179 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3182 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3184 contentNotNull()->loadProfileInFile(fid,id,pflName);
3187 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3189 contentNotNull()->loadProfileInFile(fid,id);
3192 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3194 contentNotNull()->loadGlobals(fid,*this);
3197 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3199 contentNotNull()->loadAllGlobals(fid);
3202 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3204 contentNotNull()->writeGlobals(fid,opt);
3208 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3209 * or getPflsReallyUsedMulti().
3210 * \return std::vector<std::string> - a sequence of names of all profiles.
3212 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3214 return contentNotNull()->getPfls();
3218 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3219 * or getLocsReallyUsedMulti().
3220 * \return std::vector<std::string> - a sequence of names of all localizations.
3222 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3224 return contentNotNull()->getLocs();
3228 * Checks if the profile with a given name exists.
3229 * \param [in] pflName - the profile name of interest.
3230 * \return bool - \c true if the profile named \a pflName exists.
3232 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3234 return contentNotNull()->existsPfl(pflName);
3238 * Checks if the localization with a given name exists.
3239 * \param [in] locName - the localization name of interest.
3240 * \return bool - \c true if the localization named \a locName exists.
3242 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3244 return contentNotNull()->existsLoc(locName);
3247 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3249 return contentNotNull()->createNewNameOfPfl();
3252 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3254 return contentNotNull()->createNewNameOfLoc();
3258 * Sets the name of a MED file.
3259 * \param [inout] fileName - the file name.
3261 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3263 contentNotNull()->setFileName(fileName);
3267 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3268 * in the same order.
3269 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3270 * Each item of this sequence is a vector containing ids of equal profiles.
3272 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3274 return contentNotNull()->whichAreEqualProfiles();
3278 * Finds equal localizations.
3279 * \param [in] eps - a precision used to compare real values of the localizations.
3280 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3281 * Each item of this sequence is a vector containing ids of equal localizations.
3283 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3285 return contentNotNull()->whichAreEqualLocs(eps);
3289 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3290 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3291 * this sequence is a pair whose
3292 * - the first item is a vector of profile names to replace by the second item,
3293 * - the second item is a profile name to replace every profile name of the first item.
3295 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3297 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3301 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3302 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3303 * this sequence is a pair whose
3304 * - the first item is a vector of localization names to replace by the second item,
3305 * - the second item is a localization name to replace every localization name of the first item.
3307 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3309 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3313 * Replaces references to some profiles (a reference is a profile name) by references
3314 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3315 * them-selves accordingly. <br>
3316 * This method is a generalization of changePflName().
3317 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3318 * this sequence is a pair whose
3319 * - the first item is a vector of profile names to replace by the second item,
3320 * - the second item is a profile name to replace every profile of the first item.
3321 * \sa changePflsRefsNamesGen()
3322 * \sa changePflName()
3324 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3326 changePflsRefsNamesGen(mapOfModif);
3327 changePflsNamesInStruct(mapOfModif);
3331 * Replaces references to some localizations (a reference is a localization name) by references
3332 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3333 * them-selves accordingly. <br>
3334 * This method is a generalization of changeLocName().
3335 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3336 * this sequence is a pair whose
3337 * - the first item is a vector of localization names to replace by the second item,
3338 * - the second item is a localization name to replace every localization of the first item.
3339 * \sa changeLocsRefsNamesGen()
3340 * \sa changeLocName()
3342 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3344 changeLocsRefsNamesGen(mapOfModif);
3345 changeLocsNamesInStruct(mapOfModif);
3349 * Renames the profile having a given name and updates references to this profile.
3350 * \param [in] oldName - the name of the profile to rename.
3351 * \param [in] newName - a new name of the profile.
3352 * \sa changePflsNames().
3354 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3356 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3357 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3359 changePflsNames(mapOfModif);
3363 * Renames the localization having a given name and updates references to this localization.
3364 * \param [in] oldName - the name of the localization to rename.
3365 * \param [in] newName - a new name of the localization.
3366 * \sa changeLocsNames().
3368 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3370 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3371 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3373 changeLocsNames(mapOfModif);
3377 * Removes duplicated profiles. Returns a map used to update references to removed
3378 * profiles via changePflsRefsNamesGen().
3379 * Equal profiles are found using whichAreEqualProfiles().
3380 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3381 * a sequence describing the performed replacements of profiles. Each element of
3382 * this sequence is a pair whose
3383 * - the first item is a vector of profile names replaced by the second item,
3384 * - the second item is a profile name replacing every profile of the first item.
3386 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3388 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3389 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3391 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3393 std::vector< std::string > tmp((*it).size());
3395 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3396 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3397 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3399 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3400 killProfileIds(tmp2);
3402 changePflsRefsNamesGen(ret);
3407 * Removes duplicated localizations. Returns a map used to update references to removed
3408 * localizations via changeLocsRefsNamesGen().
3409 * Equal localizations are found using whichAreEqualLocs().
3410 * \param [in] eps - a precision used to compare real values of the localizations.
3411 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3412 * a sequence describing the performed replacements of localizations. Each element of
3413 * this sequence is a pair whose
3414 * - the first item is a vector of localization names replaced by the second item,
3415 * - the second item is a localization name replacing every localization of the first item.
3417 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3419 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3420 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3422 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3424 std::vector< std::string > tmp((*it).size());
3426 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3427 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3428 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3430 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3431 killLocalizationIds(tmp2);
3433 changeLocsRefsNamesGen(ret);
3438 * Returns number of Gauss points per cell in a given localization.
3439 * \param [in] locId - an id of the localization of interest.
3440 * \return int - the number of the Gauss points per cell.
3442 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3444 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3448 * Returns an id of a localization by its name.
3449 * \param [in] loc - the localization name of interest.
3450 * \return int - the id of the localization.
3451 * \throw If there is no a localization named \a loc.
3453 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3455 return contentNotNull()->getLocalizationId(loc);
3459 * Returns the name of the MED file.
3460 * \return const std::string& - the MED file name.
3462 std::string MEDFileFieldGlobsReal::getFileName() const
3464 return contentNotNull()->getFileName();
3468 * Returns a localization object by its name.
3469 * \param [in] locName - the name of the localization of interest.
3470 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3471 * \throw If there is no a localization named \a locName.
3473 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3475 return contentNotNull()->getLocalization(locName);
3479 * Returns a localization object by its id.
3480 * \param [in] locId - the id of the localization of interest.
3481 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3482 * \throw If there is no a localization with id \a locId.
3484 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3486 return contentNotNull()->getLocalizationFromId(locId);
3490 * Returns a profile array by its name.
3491 * \param [in] pflName - the name of the profile of interest.
3492 * \return const DataArrayInt * - the profile array having the name \a pflName.
3493 * \throw If there is no a profile named \a pflName.
3495 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3497 return contentNotNull()->getProfile(pflName);
3501 * Returns a profile array by its id.
3502 * \param [in] pflId - the id of the profile of interest.
3503 * \return const DataArrayInt * - the profile array having the id \a pflId.
3504 * \throw If there is no a profile with id \a pflId.
3506 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3508 return contentNotNull()->getProfileFromId(pflId);
3512 * Returns a localization object, apt for modification, by its id.
3513 * \param [in] locId - the id of the localization of interest.
3514 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3515 * having the id \a locId.
3516 * \throw If there is no a localization with id \a locId.
3518 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3520 return contentNotNull()->getLocalizationFromId(locId);
3524 * Returns a localization object, apt for modification, by its name.
3525 * \param [in] locName - the name of the localization of interest.
3526 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3527 * having the name \a locName.
3528 * \throw If there is no a localization named \a locName.
3530 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3532 return contentNotNull()->getLocalization(locName);
3536 * Returns a profile array, apt for modification, by its name.
3537 * \param [in] pflName - the name of the profile of interest.
3538 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3539 * \throw If there is no a profile named \a pflName.
3541 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3543 return contentNotNull()->getProfile(pflName);
3547 * Returns a profile array, apt for modification, by its id.
3548 * \param [in] pflId - the id of the profile of interest.
3549 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3550 * \throw If there is no a profile with id \a pflId.
3552 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3554 return contentNotNull()->getProfileFromId(pflId);
3558 * Removes profiles given by their ids. No data is updated to track this removal.
3559 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3561 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3563 contentNotNull()->killProfileIds(pflIds);
3567 * Removes localizations given by their ids. No data is updated to track this removal.
3568 * \param [in] locIds - a sequence of ids of the localizations to remove.
3570 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3572 contentNotNull()->killLocalizationIds(locIds);
3576 * Stores a profile array.
3577 * \param [in] pfl - the profile array to store.
3578 * \throw If the name of \a pfl is empty.
3579 * \throw If a profile with the same name as that of \a pfl already exists but contains
3582 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3584 contentNotNull()->appendProfile(pfl);
3588 * Adds a new localization of Gauss points.
3589 * \param [in] locName - the name of the new localization.
3590 * \param [in] geoType - a geometrical type of the reference cell.
3591 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3592 * must be \c nbOfNodesPerCell * \c dimOfType.
3593 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3594 * must be _wg_.size() * \c dimOfType.
3595 * \param [in] w - the weights of Gauss points.
3596 * \throw If \a locName is empty.
3597 * \throw If a localization with the name \a locName already exists but is
3598 * different form the new one.
3600 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3602 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3605 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3607 MEDFileFieldGlobs *g(_globals);
3609 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3613 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3615 const MEDFileFieldGlobs *g(_globals);
3617 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3621 //= MEDFileFieldNameScope
3623 MEDFileFieldNameScope::MEDFileFieldNameScope()
3627 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3632 * Returns the name of \a this field.
3633 * \return std::string - a string containing the field name.
3635 std::string MEDFileFieldNameScope::getName() const
3641 * Sets name of \a this field
3642 * \param [in] name - the new field name.
3644 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3649 std::string MEDFileFieldNameScope::getDtUnit() const
3654 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3659 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3662 _dt_unit=other._dt_unit;
3665 //= MEDFileAnyTypeField1TSWithoutSDA
3667 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3669 _field_per_mesh.resize(other._field_per_mesh.size());
3671 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3673 if((const MEDFileFieldPerMesh *)*it)
3674 _field_per_mesh[i]=(*it)->deepCpy(this);
3679 * Prints a string describing \a this field into a stream. This string is outputted
3680 * by \c print Python command.
3681 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3682 * \param [in,out] oss - the out stream.
3683 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3684 * info id printed, else, not.
3686 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3688 std::string startOfLine(bkOffset,' ');
3689 oss << startOfLine << "Field ";
3691 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3692 oss << "on one time Step ";
3694 oss << "(" << f1tsId << ") ";
3695 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3696 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3697 const DataArray *arr=getUndergroundDataArray();
3700 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3703 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3704 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3705 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3707 if(arr->isAllocated())
3709 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3712 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3716 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3718 oss << startOfLine << "----------------------" << std::endl;
3719 if(!_field_per_mesh.empty())
3722 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3724 const MEDFileFieldPerMesh *cur=(*it2);
3726 cur->simpleRepr(bkOffset,oss,i);
3728 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3733 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3735 oss << startOfLine << "----------------------" << std::endl;
3738 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3740 const DataArray *arr(getUndergroundDataArray());
3742 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3743 int nbOfCompo=arr->getNumberOfComponents();
3744 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3745 for(int i=0;i<nbOfCompo;i++)
3748 std::vector<int> v(1,i);
3749 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3750 ret[i]->setArray(arr2);
3755 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3759 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3764 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3765 * empty. Returns -1 if this in on nodes.
3766 * \return int - the dimension of \a this.
3768 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3771 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3772 (*it)->getDimension(ret);
3777 * Returns the mesh name.
3778 * \return std::string - a string holding the mesh name.
3779 * \throw If \c _field_per_mesh.empty()
3781 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3783 if(_field_per_mesh.empty())
3784 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3785 return _field_per_mesh[0]->getMeshName();
3788 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3790 std::string oldName(getMeshName());
3791 std::vector< std::pair<std::string,std::string> > v(1);
3792 v[0].first=oldName; v[0].second=newMeshName;
3796 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3799 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3801 MEDFileFieldPerMesh *cur(*it);
3803 ret=cur->changeMeshNames(modifTab) || ret;
3809 * Returns the number of iteration of the state of underlying mesh.
3810 * \return int - the iteration number.
3811 * \throw If \c _field_per_mesh.empty()
3813 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3815 if(_field_per_mesh.empty())
3816 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3817 return _field_per_mesh[0]->getMeshIteration();
3821 * Returns the order number of iteration of the state of underlying mesh.
3822 * \return int - the order number.
3823 * \throw If \c _field_per_mesh.empty()
3825 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3827 if(_field_per_mesh.empty())
3828 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3829 return _field_per_mesh[0]->getMeshOrder();
3833 * Checks if \a this field is tagged by a given iteration number and a given
3834 * iteration order number.
3835 * \param [in] iteration - the iteration number of interest.
3836 * \param [in] order - the iteration order number of interest.
3837 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3838 * \a this->getOrder() == \a order.
3840 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3842 return iteration==_iteration && order==_order;
3846 * Returns number of iteration and order number of iteration when
3847 * \a this field has been calculated.
3848 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3851 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3853 std::pair<int,int> p;
3859 * Returns number of iteration and order number of iteration when
3860 * \a this field has been calculated.
3861 * \param [in,out] p - a pair returning the iteration number and the iteration
3864 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3871 * Returns all types of spatial discretization of \a this field.
3872 * \param [in,out] types - a sequence of types of \a this field.
3874 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3876 std::set<TypeOfField> types2;
3877 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3879 (*it)->fillTypesOfFieldAvailable(types2);
3881 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3882 std::copy(types2.begin(),types2.end(),bi);
3886 * Returns all types of spatial discretization of \a this field.
3887 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3890 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3892 std::vector<TypeOfField> ret;
3893 fillTypesOfFieldAvailable(ret);
3897 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3899 std::vector<std::string> ret;
3900 std::set<std::string> ret2;
3901 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3903 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3904 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3905 if(ret2.find(*it2)==ret2.end())
3907 ret.push_back(*it2);
3914 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3916 std::vector<std::string> ret;
3917 std::set<std::string> ret2;
3918 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3920 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3921 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3922 if(ret2.find(*it2)==ret2.end())
3924 ret.push_back(*it2);
3931 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3933 std::vector<std::string> ret;
3934 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3936 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3937 ret.insert(ret.end(),tmp.begin(),tmp.end());
3942 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3944 std::vector<std::string> ret;
3945 std::set<std::string> ret2;
3946 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3948 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3949 ret.insert(ret.end(),tmp.begin(),tmp.end());
3954 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3956 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3957 (*it)->changePflsRefsNamesGen(mapOfModif);
3960 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3962 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3963 (*it)->changeLocsRefsNamesGen(mapOfModif);
3967 * Returns all attributes of parts of \a this field lying on a given mesh.
3968 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3969 * item of every of returned sequences refers to the _i_-th part of \a this field.
3970 * Thus all sequences returned by this method are of the same length equal to number
3971 * of different types of supporting entities.<br>
3972 * A field part can include sub-parts with several different spatial discretizations,
3973 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3974 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3975 * of a nested sequence corresponds to a type of spatial discretization.<br>
3976 * This method allows for iteration over MEDFile DataStructure without any overhead.
3977 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3978 * for the case with only one underlying mesh. (Actually, the number of meshes is
3979 * not checked if \a mname == \c NULL).
3980 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3981 * a field part is returned.
3982 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3983 * This sequence is of the same length as \a types.
3984 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3985 * discretization. A profile name can be empty.
3986 * Length of this and of nested sequences is the same as that of \a typesF.
3987 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3988 * discretization. A localization name can be empty.
3989 * Length of this and of nested sequences is the same as that of \a typesF.
3990 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3991 * of ids of tuples within the data array, per each type of spatial
3992 * discretization within one mesh entity type.
3993 * Length of this and of nested sequences is the same as that of \a typesF.
3994 * \throw If no field is lying on \a mname.
3996 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& 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
4000 meshId=getMeshIdFromMeshName(mname);
4002 if(_field_per_mesh.empty())
4003 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4004 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4008 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4009 * maximal absolute dimension and values returned via the out parameter \a levs are
4010 * dimensions relative to the maximal absolute dimension. <br>
4011 * This method is designed for MEDFileField1TS instances that have a discretization
4012 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4013 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4014 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4015 * Only these 3 discretizations will be taken into account here. If \a this is
4016 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4017 * This method is useful to make the link between the dimension of the underlying mesh
4018 * and the levels of \a this, because it is possible that the highest dimension of \a this
4019 * field is not equal to the dimension of the underlying mesh.
4021 * Let's consider the following case:
4022 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4023 * TETRA4, HEXA8, TRI3 and SEG2.
4024 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4025 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4027 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4028 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4029 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4030 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4031 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4032 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4034 * to retrieve the highest level of
4035 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4036 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4037 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4038 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4039 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4040 * for the case with only one underlying mesh. (Actually, the number of meshes is
4041 * not checked if \a mname == \c NULL).
4042 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4043 * absolute one. They are in decreasing order. This sequence is cleared before
4045 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4046 * \throw If no field is lying on \a mname.
4048 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4051 int meshId=getMeshIdFromMeshName(mname);
4052 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4053 std::vector< std::vector<TypeOfField> > typesF;
4054 std::vector< std::vector<std::string> > pfls, locs;
4055 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4057 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4058 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4059 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4061 st.erase(INTERP_KERNEL::NORM_ERROR);
4063 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4065 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4066 ret1.insert((int)cm.getDimension());
4068 int ret=*std::max_element(ret1.begin(),ret1.end());
4069 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4070 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4075 * \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.
4076 * \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.
4077 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4078 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4080 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4082 int mid=getMeshIdFromMeshName(mName);
4083 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4087 * \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.
4088 * \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.
4089 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4090 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4092 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4094 int mid=getMeshIdFromMeshName(mName);
4095 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4099 * \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.
4101 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4103 if(_field_per_mesh.empty())
4104 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4107 std::string mName2(mName);
4109 std::vector<std::string> msg;
4110 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4111 if(mName2==(*it)->getMeshName())
4114 msg.push_back((*it)->getMeshName());
4115 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4116 oss << "Possible meshes are : ";
4117 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4118 oss << "\"" << (*it2) << "\" ";
4119 throw INTERP_KERNEL::Exception(oss.str().c_str());
4122 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4125 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4126 std::string tmp(mesh->getName());
4128 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4129 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4131 for(;it!=_field_per_mesh.end();it++,i++)
4133 if((*it)->getMeshName()==tmp)
4136 int sz=_field_per_mesh.size();
4137 _field_per_mesh.resize(sz+1);
4138 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4142 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4143 MEDFileFieldGlobsReal& glob)
4146 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4148 MEDFileFieldPerMesh *fpm(*it);
4150 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4155 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4157 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4158 std::vector< std::vector<TypeOfField> > typesF;
4159 std::vector< std::vector<std::string> > pfls,locs;
4160 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4161 std::set<TypeOfField> allEnt;
4162 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4163 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4164 allEnt.insert(*it2);
4165 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4166 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4167 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4169 std::vector< std::pair<int,int> > its;
4170 ret[i]=shallowCpy();
4171 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4172 ret[i]->updateData(newLgth,its);
4177 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4179 int globalCounter=0;
4180 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4181 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4182 return globalCounter;
4185 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4187 if(_nb_of_tuples_to_be_allocated>=0)
4189 _nb_of_tuples_to_be_allocated=newLgth;
4190 const DataArray *oldArr(getUndergroundDataArray());
4193 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4194 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4196 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4200 if(_nb_of_tuples_to_be_allocated==-1)
4202 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4204 const DataArray *oldArr(getUndergroundDataArray());
4205 if(!oldArr || !oldArr->isAllocated())
4206 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4207 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4208 newArr->alloc(newLgth,getNumberOfComponents());
4210 newArr->copyStringInfoFrom(*oldArr);
4212 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4214 if((*it).second<(*it).first)
4215 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4216 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4217 pos+=(*it).second-(*it).first;
4222 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4225 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4227 if(_field_per_mesh.empty())
4228 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4229 if(_field_per_mesh.size()>1)
4230 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4231 _field_per_mesh[0]->copyOptionsFrom(opts);
4232 _field_per_mesh[0]->writeLL(fid,nasc);
4236 * 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.
4237 * If false is returned the memory allocation is not required.
4239 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4241 if(_nb_of_tuples_to_be_allocated>=0)
4243 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4244 _nb_of_tuples_to_be_allocated=-2;
4247 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4249 if(_nb_of_tuples_to_be_allocated==-1)
4250 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4251 if(_nb_of_tuples_to_be_allocated<-3)
4252 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4253 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4256 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4258 med_int numdt,numit;
4262 med_int meshnumdt,meshnumit;
4263 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4264 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4265 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4266 if(_iteration!=numdt || _order!=numit)
4267 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4268 _field_per_mesh.resize(nmesh);
4273 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4274 mm=ms->getMeshWithName(meshNameCpp);
4277 for(int i=0;i<nmesh;i++)
4278 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4279 _nb_of_tuples_to_be_allocated=0;
4280 for(int i=0;i<nmesh;i++)
4281 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4284 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4286 allocIfNecessaryTheArrayToReceiveDataFromFile();
4287 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4288 (*it)->loadBigArraysRecursively(fid,nasc);
4291 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4293 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4294 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4295 (*it)->loadBigArraysRecursively(fid,nasc);
4298 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4300 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4301 loadBigArraysRecursively(fid,nasc);
4304 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4306 DataArray *thisArr(getUndergroundDataArray());
4307 if(thisArr && thisArr->isAllocated())
4309 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4310 thisArr->desallocate();
4314 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4316 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4319 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4321 std::vector<const BigMemoryObject *> ret;
4322 if(getUndergroundDataArray())
4323 ret.push_back(getUndergroundDataArray());
4324 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4325 ret.push_back((const MEDFileFieldPerMesh *)*it);
4330 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4331 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4332 * "Sort By Type"), if not, an exception is thrown.
4333 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4334 * \param [in] arr - the array of values.
4335 * \param [in,out] glob - the global data where profiles and localization present in
4336 * \a field, if any, are added.
4337 * \throw If the name of \a field is empty.
4338 * \throw If the data array of \a field is not set.
4339 * \throw If \a this->_arr is already allocated but has different number of components
4341 * \throw If the underlying mesh of \a field has no name.
4342 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4344 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4346 const MEDCouplingMesh *mesh=field->getMesh();
4348 TypeOfField type=field->getTypeOfField();
4349 std::vector<DataArrayInt *> dummy;
4350 int start=copyTinyInfoFrom(field,arr);
4351 int pos=addNewEntryIfNecessary(mesh);
4354 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4355 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4358 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4362 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4363 * of a given mesh are used as the support of the given field (a real support is not used).
4364 * Elements of the given mesh must be sorted suitable for writing to MED file.
4365 * Order of underlying mesh entities of the given field specified by \a profile parameter
4366 * is not prescribed; this method permutes field values to have them sorted by element
4367 * type as required for writing to MED file. A new profile is added only if no equal
4368 * profile is missing.
4369 * \param [in] field - the field to add to \a this. The field double values are ignored.
4370 * \param [in] arrOfVals - the values of the field \a field used.
4371 * \param [in] mesh - the supporting mesh of \a field.
4372 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4373 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4374 * \param [in,out] glob - the global data where profiles and localization present in
4375 * \a field, if any, are added.
4376 * \throw If either \a field or \a mesh or \a profile has an empty name.
4377 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4378 * \throw If the data array of \a field is not set.
4379 * \throw If \a this->_arr is already allocated but has different number of components
4381 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4382 * \sa setFieldNoProfileSBT()
4384 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4387 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4388 if(!arrOfVals || !arrOfVals->isAllocated())
4389 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4390 TypeOfField type=field->getTypeOfField();
4391 std::vector<DataArrayInt *> idsInPflPerType;
4392 std::vector<DataArrayInt *> idsPerType;
4393 std::vector<int> code,code2;
4394 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4397 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4398 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4399 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4400 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4402 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4403 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4404 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4406 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4407 throw INTERP_KERNEL::Exception(oss.str().c_str());
4410 int start=copyTinyInfoFrom(field,arrOfVals);
4411 code2=m->getDistributionOfTypes();
4413 int pos=addNewEntryIfNecessary(m);
4414 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4418 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4419 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4420 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4421 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4422 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4423 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4425 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4426 throw INTERP_KERNEL::Exception(oss.str().c_str());
4428 int start=copyTinyInfoFrom(field,arrOfVals);
4429 int pos=addNewEntryIfNecessary(m);
4430 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4435 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4437 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4439 if(_nb_of_tuples_to_be_allocated>=0)
4440 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 !");
4441 DataArray *arr(getOrCreateAndGetArray());
4442 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4443 _nb_of_tuples_to_be_allocated=-3;
4447 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4448 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4449 * larger by the size of \a field. Returns an id of the first not filled
4450 * tuple of \a this->_arr.
4451 * \param [in] field - the field to copy the info on components and the name from.
4452 * \return int - the id of first not initialized tuple of \a this->_arr.
4453 * \throw If the name of \a field is empty.
4454 * \throw If the data array of \a field is not set.
4455 * \throw If \a this->_arr is already allocated but has different number of components
4458 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4461 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4462 std::string name(field->getName());
4463 setName(name.c_str());
4464 setDtUnit(field->getTimeUnit());
4466 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4468 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4469 if(!arr->isAllocated())
4470 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4471 _dt=field->getTime(_iteration,_order);
4472 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4473 if(!getOrCreateAndGetArray()->isAllocated())
4475 allocNotFromFile(arr->getNumberOfTuples());
4480 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4481 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4482 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4483 _nb_of_tuples_to_be_allocated=-3;
4484 return oldNbOfTuples;
4489 * Returns number of components in \a this field
4490 * \return int - the number of components.
4492 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4494 return getOrCreateAndGetArray()->getNumberOfComponents();
4498 * Change info on components in \a this.
4499 * \throw If size of \a infos is not equal to the number of components already in \a this.
4501 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4503 DataArray *arr=getOrCreateAndGetArray();
4504 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4508 * Returns info on components of \a this field.
4509 * \return const std::vector<std::string>& - a sequence of strings each being an
4510 * information on _i_-th component.
4512 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4514 const DataArray *arr=getOrCreateAndGetArray();
4515 return arr->getInfoOnComponents();
4519 * Returns a mutable info on components of \a this field.
4520 * \return std::vector<std::string>& - a sequence of strings each being an
4521 * information on _i_-th component.
4523 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4525 DataArray *arr=getOrCreateAndGetArray();
4526 return arr->getInfoOnComponents();
4529 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4531 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4533 const MEDFileFieldPerMesh *fpm(*it);
4536 if(fpm->presenceOfMultiDiscPerGeoType())
4543 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4544 * \param [in] type - a spatial discretization of the new field.
4545 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4546 * \param [in] mName - a name of the supporting mesh.
4547 * \param [in] renumPol - specifies how to permute values of the result field according to
4548 * the optional numbers of cells and nodes, if any. The valid values are
4549 * - 0 - do not permute.
4550 * - 1 - permute cells.
4551 * - 2 - permute nodes.
4552 * - 3 - permute cells and nodes.
4554 * \param [in] glob - the global data storing profiles and localization.
4555 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4556 * caller is to delete this field using decrRef() as it is no more needed.
4557 * \throw If the MED file is not readable.
4558 * \throw If there is no mesh named \a mName in the MED file.
4559 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4560 * \throw If no field of \a this is lying on the mesh \a mName.
4561 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4563 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4565 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4567 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4569 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4570 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4574 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4575 * \param [in] type - a spatial discretization of the new field.
4576 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4577 * \param [in] renumPol - specifies how to permute values of the result field according to
4578 * the optional numbers of cells and nodes, if any. The valid values are
4579 * - 0 - do not permute.
4580 * - 1 - permute cells.
4581 * - 2 - permute nodes.
4582 * - 3 - permute cells and nodes.
4584 * \param [in] glob - the global data storing profiles and localization.
4585 * \param [in] mesh - the supporting mesh.
4586 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4587 * caller is to delete this field using decrRef() as it is no more needed.
4588 * \throw If the MED file is not readable.
4589 * \throw If no field of \a this is lying on \a mesh.
4590 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4591 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4593 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4595 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4596 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4597 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4598 if(meshDimRelToMax==1)
4599 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4600 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4604 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4606 * \param [in] type - a spatial discretization of the new field.
4607 * \param [in] mName - a name of the supporting mesh.
4608 * \param [in] renumPol - specifies how to permute values of the result field according to
4609 * the optional numbers of cells and nodes, if any. The valid values are
4610 * - 0 - do not permute.
4611 * - 1 - permute cells.
4612 * - 2 - permute nodes.
4613 * - 3 - permute cells and nodes.
4615 * \param [in] glob - the global data storing profiles and localization.
4616 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4617 * caller is to delete this field using decrRef() as it is no more needed.
4618 * \throw If the MED file is not readable.
4619 * \throw If there is no mesh named \a mName in the MED file.
4620 * \throw If there are no mesh entities in the mesh.
4621 * \throw If no field values of the given \a type are available.
4623 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4625 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4627 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4629 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4630 int absDim=getDimension();
4631 int meshDimRelToMax=absDim-mm->getMeshDimension();
4632 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4636 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4637 * \param [in] type - a spatial discretization of the new field.
4638 * \param [in] renumPol - specifies how to permute values of the result field according to
4639 * the optional numbers of cells and nodes, if any. The valid values are
4640 * - 0 - do not permute.
4641 * - 1 - permute cells.
4642 * - 2 - permute nodes.
4643 * - 3 - permute cells and nodes.
4645 * \param [in] glob - the global data storing profiles and localization.
4646 * \param [in] mesh - the supporting mesh.
4647 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4648 * field according to \a renumPol.
4649 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4650 * field according to \a renumPol.
4651 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4652 * caller is to delete this field using decrRef() as it is no more needed.
4653 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4654 * \throw If no field of \a this is lying on \a mesh.
4655 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4657 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
4659 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4660 int meshId=getMeshIdFromMeshName(mesh->getName());
4662 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4667 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4674 throw INTERP_KERNEL::Exception(msg1);
4675 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4678 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4680 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4681 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4682 throw INTERP_KERNEL::Exception(oss.str().c_str());
4684 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4685 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4686 std::vector<DataArray *> arrOut2(1,arrOut);
4687 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4688 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4689 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4696 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4698 throw INTERP_KERNEL::Exception(msg1);
4701 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4703 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4704 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4705 throw INTERP_KERNEL::Exception(oss.str().c_str());
4707 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4708 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4709 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4710 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4715 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4720 * Returns values and a profile of the field of a given type lying on a given support.
4721 * \param [in] type - a spatial discretization of the field.
4722 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4723 * \param [in] mesh - the supporting mesh.
4724 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4725 * field of interest lies on. If the field lies on all entities of the given
4726 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4727 * using decrRef() as it is no more needed.
4728 * \param [in] glob - the global data storing profiles and localization.
4729 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4730 * field. The caller is to delete this array using decrRef() as it is no more needed.
4731 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4732 * \throw If no field of \a this is lying on \a mesh.
4733 * \throw If no field values of the given \a type are available.
4735 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4737 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4738 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4739 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4740 ret->setName(nasc.getName().c_str());
4744 //= MEDFileField1TSWithoutSDA
4747 * Throws if a given value is not a valid (non-extended) relative dimension.
4748 * \param [in] meshDimRelToMax - the relative dimension value.
4749 * \throw If \a meshDimRelToMax > 0.
4751 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4753 if(meshDimRelToMax>0)
4754 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4758 * Checks if elements of a given mesh are in the order suitable for writing
4759 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4760 * vector describing types of elements and their number.
4761 * \param [in] mesh - the mesh to check.
4762 * \return std::vector<int> - a vector holding for each element type (1) item of
4763 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4764 * These values are in full-interlace mode.
4765 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4767 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4770 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4771 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4772 int nbOfTypes=geoTypes.size();
4773 std::vector<int> code(3*nbOfTypes);
4774 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4775 arr1->alloc(nbOfTypes,1);
4776 int *arrPtr=arr1->getPointer();
4777 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4778 for(int i=0;i<nbOfTypes;i++,it++)
4779 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4780 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4781 const int *arrPtr2=arr2->getConstPointer();
4783 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4786 int nbCells=mesh->getNumberOfCellsWithType(*it);
4787 code[3*pos]=(int)(*it);
4788 code[3*pos+1]=nbCells;
4789 code[3*pos+2]=-1;//no profiles
4791 std::vector<const DataArrayInt *> idsPerType;//no profiles
4792 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4796 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4801 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4803 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4807 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4808 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4809 * item of every of returned sequences refers to the _i_-th part of \a this field.
4810 * Thus all sequences returned by this method are of the same length equal to number
4811 * of different types of supporting entities.<br>
4812 * A field part can include sub-parts with several different spatial discretizations,
4813 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4814 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4815 * of a nested sequence corresponds to a type of spatial discretization.<br>
4816 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4817 * The overhead is due to selecting values into new instances of DataArrayDouble.
4818 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4819 * for the case with only one underlying mesh. (Actually, the number of meshes is
4820 * not checked if \a mname == \c NULL).
4821 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4822 * a field part is returned.
4823 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4824 * A field part can include sub-parts with several different spatial discretizations,
4825 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4826 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4827 * This sequence is of the same length as \a types.
4828 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4829 * discretization. A profile name can be empty.
4830 * Length of this and of nested sequences is the same as that of \a typesF.
4831 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4832 * discretization. A localization name can be empty.
4833 * Length of this and of nested sequences is the same as that of \a typesF.
4834 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4835 * per each type of spatial discretization within one mesh entity type.
4836 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4837 * Length of this and of nested sequences is the same as that of \a typesF.
4838 * \throw If no field is lying on \a mname.
4840 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& 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
4844 meshId=getMeshIdFromMeshName(mname);
4846 if(_field_per_mesh.empty())
4847 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4848 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4849 int nbOfRet=ret0.size();
4850 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4851 for(int i=0;i<nbOfRet;i++)
4853 const std::vector< std::pair<int,int> >& p=ret0[i];
4854 int nbOfRet1=p.size();
4855 ret[i].resize(nbOfRet1);
4856 for(int j=0;j<nbOfRet1;j++)
4858 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4866 * Returns a pointer to the underground DataArrayDouble instance. So the
4867 * caller should not decrRef() it. This method allows for a direct access to the field
4868 * values. This method is quite unusable if there is more than a nodal field or a cell
4869 * field on single geometric cell type.
4870 * \return DataArrayDouble * - the pointer to the field values array.
4872 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4874 const DataArrayDouble *ret=_arr;
4876 return const_cast<DataArrayDouble *>(ret);
4881 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4886 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4888 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4889 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4890 ret->deepCpyLeavesFrom(*this);
4891 const DataArrayDouble *arr(_arr);
4894 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4895 ret->setArray(arr2);
4901 * Returns a pointer to the underground DataArrayDouble instance. So the
4902 * caller should not decrRef() it. This method allows for a direct access to the field
4903 * values. This method is quite unusable if there is more than a nodal field or a cell
4904 * field on single geometric cell type.
4905 * \return DataArrayDouble * - the pointer to the field values array.
4907 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4909 return getUndergroundDataArrayDouble();
4913 * Returns a pointer to the underground DataArrayDouble instance and a
4914 * sequence describing parameters of a support of each part of \a this field. The
4915 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4916 * direct access to the field values. This method is intended for the field lying on one
4918 * \param [in,out] entries - the sequence describing parameters of a support of each
4919 * part of \a this field. Each item of this sequence consists of two parts. The
4920 * first part describes a type of mesh entity and an id of discretization of a
4921 * current field part. The second part describes a range of values [begin,end)
4922 * within the returned array relating to the current field part.
4923 * \return DataArrayDouble * - the pointer to the field values array.
4924 * \throw If the number of underlying meshes is not equal to 1.
4925 * \throw If no field values are available.
4926 * \sa getUndergroundDataArray()
4928 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4930 if(_field_per_mesh.size()!=1)
4931 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4932 if(_field_per_mesh[0]==0)
4933 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4934 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4935 return getUndergroundDataArrayDouble();
4939 * Returns a pointer to the underground DataArrayDouble 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 DataArrayDouble. 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 DataArrayDouble * - 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 *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4956 return getUndergroundDataArrayDoubleExt(entries);
4959 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4961 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
4962 arr->setInfoAndChangeNbOfCompo(infos);
4965 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4969 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4971 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4972 ret->deepCpyLeavesFrom(*this);
4976 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4978 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4979 if((const DataArrayDouble *)_arr)
4980 ret->_arr=_arr->deepCpy();
4984 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4988 _nb_of_tuples_to_be_allocated=-1;
4992 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4994 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4996 _nb_of_tuples_to_be_allocated=-3;
5001 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5003 return DataArrayDouble::New();
5006 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5008 DataArrayDouble *ret=_arr;
5011 _arr=DataArrayDouble::New();
5015 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5017 return getOrCreateAndGetArrayDouble();
5020 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5022 const DataArrayDouble *ret=_arr;
5025 DataArrayDouble *ret2=DataArrayDouble::New();
5026 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5030 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5032 return getOrCreateAndGetArrayDouble();
5035 //= MEDFileIntField1TSWithoutSDA
5037 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5039 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5042 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5046 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5047 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5049 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5050 arr->setInfoAndChangeNbOfCompo(infos);
5053 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5058 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5060 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5061 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5062 ret->deepCpyLeavesFrom(*this);
5063 const DataArrayInt *arr(_arr);
5066 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5067 ret->setArray(arr2);
5073 * Returns a pointer to the underground DataArrayInt instance. So the
5074 * caller should not decrRef() it. This method allows for a direct access to the field
5075 * values. This method is quite unusable if there is more than a nodal field or a cell
5076 * field on single geometric cell type.
5077 * \return DataArrayInt * - the pointer to the field values array.
5079 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5081 return getUndergroundDataArrayInt();
5085 * Returns a pointer to the underground DataArrayInt instance. So the
5086 * caller should not decrRef() it. This method allows for a direct access to the field
5087 * values. This method is quite unusable if there is more than a nodal field or a cell
5088 * field on single geometric cell type.
5089 * \return DataArrayInt * - the pointer to the field values array.
5091 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5093 const DataArrayInt *ret=_arr;
5095 return const_cast<DataArrayInt *>(ret);
5101 * Returns a pointer to the underground DataArrayInt instance and a
5102 * sequence describing parameters of a support of each part of \a this field. The
5103 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5104 * direct access to the field values. This method is intended for the field lying on one
5106 * \param [in,out] entries - the sequence describing parameters of a support of each
5107 * part of \a this field. Each item of this sequence consists of two parts. The
5108 * first part describes a type of mesh entity and an id of discretization of a
5109 * current field part. The second part describes a range of values [begin,end)
5110 * within the returned array relating to the current field part.
5111 * \return DataArrayInt * - the pointer to the field values array.
5112 * \throw If the number of underlying meshes is not equal to 1.
5113 * \throw If no field values are available.
5114 * \sa getUndergroundDataArray()
5116 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5118 return getUndergroundDataArrayIntExt(entries);
5122 * Returns a pointer to the underground DataArrayInt instance and a
5123 * sequence describing parameters of a support of each part of \a this field. The
5124 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5125 * direct access to the field values. This method is intended for the field lying on one
5127 * \param [in,out] entries - the sequence describing parameters of a support of each
5128 * part of \a this field. Each item of this sequence consists of two parts. The
5129 * first part describes a type of mesh entity and an id of discretization of a
5130 * current field part. The second part describes a range of values [begin,end)
5131 * within the returned array relating to the current field part.
5132 * \return DataArrayInt * - the pointer to the field values array.
5133 * \throw If the number of underlying meshes is not equal to 1.
5134 * \throw If no field values are available.
5135 * \sa getUndergroundDataArray()
5137 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5139 if(_field_per_mesh.size()!=1)
5140 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5141 if(_field_per_mesh[0]==0)
5142 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5143 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5144 return getUndergroundDataArrayInt();
5147 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5149 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5150 ret->deepCpyLeavesFrom(*this);
5154 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5156 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5157 if((const DataArrayInt *)_arr)
5158 ret->_arr=_arr->deepCpy();
5162 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5166 _nb_of_tuples_to_be_allocated=-1;
5170 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5172 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5174 _nb_of_tuples_to_be_allocated=-3;
5179 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5181 return DataArrayInt::New();
5184 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5186 DataArrayInt *ret=_arr;
5189 _arr=DataArrayInt::New();
5193 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5195 return getOrCreateAndGetArrayInt();
5198 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5200 const DataArrayInt *ret=_arr;
5203 DataArrayInt *ret2=DataArrayInt::New();
5204 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5208 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5210 return getOrCreateAndGetArrayInt();
5213 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5217 //= MEDFileAnyTypeField1TS
5219 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5221 med_field_type typcha;
5223 std::vector<std::string> infos;
5224 std::string dtunit,fieldName;
5225 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5226 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5231 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5236 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5241 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] !";
5242 throw INTERP_KERNEL::Exception(oss.str().c_str());
5245 ret->setDtUnit(dtunit.c_str());
5246 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5248 med_int numdt,numit;
5250 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5251 ret->setTime(numdt,numit,dt);
5254 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5256 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5260 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5261 try:MEDFileFieldGlobsReal(fileName)
5263 MEDFileUtilities::CheckFileForRead(fileName);
5264 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5265 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5268 catch(INTERP_KERNEL::Exception& e)
5273 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5275 med_field_type typcha;
5276 std::vector<std::string> infos;
5279 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5280 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5285 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5290 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5295 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] !";
5296 throw INTERP_KERNEL::Exception(oss.str().c_str());
5299 ret->setDtUnit(dtunit.c_str());
5300 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5304 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5305 throw INTERP_KERNEL::Exception(oss.str().c_str());
5308 med_int numdt,numit;
5310 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5311 ret->setTime(numdt,numit,dt);
5314 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5316 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5320 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5321 try:MEDFileFieldGlobsReal(fileName)
5323 MEDFileUtilities::CheckFileForRead(fileName);
5324 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5325 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5328 catch(INTERP_KERNEL::Exception& e)
5333 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5336 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5337 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5339 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5340 ret->setFileName(fileName);
5341 ret->_content=c; c->incrRef();
5344 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5346 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5347 ret->setFileName(fileName);
5348 ret->_content=c; c->incrRef();
5351 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5354 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5356 MEDFileUtilities::CheckFileForRead(fileName);
5357 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5358 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5359 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5360 ret->loadGlobals(fid);
5364 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5366 MEDFileUtilities::CheckFileForRead(fileName);
5367 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5368 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5369 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5370 ret->loadGlobals(fid);
5374 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5376 MEDFileUtilities::CheckFileForRead(fileName);
5377 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5378 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5379 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5380 ret->loadGlobals(fid);
5384 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5386 med_field_type typcha;
5387 std::vector<std::string> infos;
5390 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5391 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5396 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5401 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5406 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] !";
5407 throw INTERP_KERNEL::Exception(oss.str().c_str());
5410 ret->setDtUnit(dtunit.c_str());
5411 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5414 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5415 for(int i=0;i<nbOfStep2 && !found;i++)
5417 med_int numdt,numit;
5419 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5420 if(numdt==iteration && numit==order)
5426 dtits[i]=std::pair<int,int>(numdt,numit);
5430 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5431 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5432 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5433 throw INTERP_KERNEL::Exception(oss.str().c_str());
5436 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5438 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5442 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5443 try:MEDFileFieldGlobsReal(fileName)
5445 MEDFileUtilities::CheckFileForRead(fileName);
5446 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5447 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5450 catch(INTERP_KERNEL::Exception& e)
5456 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5457 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5459 * \warning this is a shallow copy constructor
5461 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5463 if(!shallowCopyOfContent)
5465 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5466 otherPtr->incrRef();
5467 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5471 _content=other.shallowCpy();
5475 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5479 int nbFields=MEDnField(fid);
5480 if(fieldIdCFormat>=nbFields)
5482 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5483 throw INTERP_KERNEL::Exception(oss.str().c_str());
5486 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5487 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5488 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5489 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5490 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5491 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5494 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5495 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5496 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5497 infos.clear(); infos.resize(ncomp);
5498 for(int j=0;j<ncomp;j++)
5499 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5504 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5507 * \return in case of success the number of time steps available for the field with name \a fieldName.
5509 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5511 int nbFields=MEDnField(fid);
5513 std::vector<std::string> fns(nbFields);
5515 for(int i=0;i<nbFields && !found;i++)
5518 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5520 found=(tmp==fieldName);
5526 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5527 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5528 oss << "\"" << *it << "\" ";
5529 throw INTERP_KERNEL::Exception(oss.str().c_str());
5535 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5536 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5537 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5538 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5539 * to keep a valid instance.
5540 * 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.
5541 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5542 * 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.
5544 * \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.
5545 * \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.
5546 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5547 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5548 * \param [in] newLocName is the new localization name.
5549 * \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.
5550 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5552 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5554 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5555 std::string oldPflName=disc->getProfile();
5556 std::vector<std::string> vv=getPflsReallyUsedMulti();
5557 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5558 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5560 disc->setProfile(newPflName);
5561 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5562 pfl->setName(newPflName);
5566 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5567 throw INTERP_KERNEL::Exception(oss.str().c_str());
5572 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5573 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5574 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5575 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5576 * to keep a valid instance.
5577 * 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.
5578 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5579 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5580 * 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.
5582 * \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.
5583 * \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.
5584 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5585 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5586 * \param [in] newLocName is the new localization name.
5587 * \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.
5588 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5590 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5592 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5593 std::string oldLocName=disc->getLocalization();
5594 std::vector<std::string> vv=getLocsReallyUsedMulti();
5595 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5596 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5598 disc->setLocalization(newLocName);
5599 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5600 loc.setName(newLocName);
5604 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5605 throw INTERP_KERNEL::Exception(oss.str().c_str());
5609 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5611 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5613 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5617 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5619 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5621 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5626 * Writes \a this field into a MED file specified by its name.
5627 * \param [in] fileName - the MED file name.
5628 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5629 * - 2 - erase; an existing file is removed.
5630 * - 1 - append; same data should not be present in an existing file.
5631 * - 0 - overwrite; same data present in an existing file is overwritten.
5632 * \throw If the field name is not set.
5633 * \throw If no field data is set.
5634 * \throw If \a mode == 1 and the same data is present in an existing file.
5636 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5638 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5639 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5644 * This method alloc the arrays and load potentially huge arrays contained in this field.
5645 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5646 * This method can be also called to refresh or reinit values from a file.
5648 * \throw If the fileName is not set or points to a non readable MED file.
5649 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5651 void MEDFileAnyTypeField1TS::loadArrays()
5653 if(getFileName().empty())
5654 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5655 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5656 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5660 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5661 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5662 * this method does not throw if \a this does not come from file read.
5664 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5666 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5668 if(!getFileName().empty())
5670 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5671 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5676 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5677 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5678 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5680 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5682 void MEDFileAnyTypeField1TS::unloadArrays()
5684 contentNotNullBase()->unloadArrays();
5688 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
5689 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5690 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5692 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5694 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5696 if(!getFileName().empty())
5697 contentNotNullBase()->unloadArrays();
5700 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5702 int nbComp=getNumberOfComponents();
5703 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5704 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5705 for(int i=0;i<nbComp;i++)
5707 std::string info=getInfo()[i];
5709 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5710 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5711 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5713 if(getName().empty())
5714 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5715 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5716 writeGlobals(fid,*this);
5717 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5720 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5722 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5725 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5727 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5728 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5733 * Returns a string describing \a this field. This string is outputted
5734 * by \c print Python command.
5736 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5738 std::ostringstream oss;
5739 contentNotNullBase()->simpleRepr(0,oss,-1);
5740 simpleReprGlobs(oss);
5745 * This method returns all profiles whose name is non empty used.
5746 * \b WARNING If profile is used several times it will be reported \b only \b once.
5747 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5749 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5751 return contentNotNullBase()->getPflsReallyUsed2();
5755 * This method returns all localizations whose name is non empty used.
5756 * \b WARNING If localization is used several times it will be reported \b only \b once.
5758 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5760 return contentNotNullBase()->getLocsReallyUsed2();
5764 * This method returns all profiles whose name is non empty used.
5765 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5767 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5769 return contentNotNullBase()->getPflsReallyUsedMulti2();
5773 * This method returns all localizations whose name is non empty used.
5774 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5776 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5778 return contentNotNullBase()->getLocsReallyUsedMulti2();
5781 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5783 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5786 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5788 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5791 int MEDFileAnyTypeField1TS::getDimension() const
5793 return contentNotNullBase()->getDimension();
5796 int MEDFileAnyTypeField1TS::getIteration() const
5798 return contentNotNullBase()->getIteration();
5801 int MEDFileAnyTypeField1TS::getOrder() const
5803 return contentNotNullBase()->getOrder();
5806 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5808 return contentNotNullBase()->getTime(iteration,order);
5811 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5813 contentNotNullBase()->setTime(iteration,order,val);
5816 std::string MEDFileAnyTypeField1TS::getName() const
5818 return contentNotNullBase()->getName();
5821 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5823 contentNotNullBase()->setName(name);
5826 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5828 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5831 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5833 return contentNotNullBase()->getDtUnit();
5836 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5838 contentNotNullBase()->setDtUnit(dtUnit);
5841 std::string MEDFileAnyTypeField1TS::getMeshName() const
5843 return contentNotNullBase()->getMeshName();
5846 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5848 contentNotNullBase()->setMeshName(newMeshName);
5851 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5853 return contentNotNullBase()->changeMeshNames(modifTab);
5856 int MEDFileAnyTypeField1TS::getMeshIteration() const
5858 return contentNotNullBase()->getMeshIteration();
5861 int MEDFileAnyTypeField1TS::getMeshOrder() const
5863 return contentNotNullBase()->getMeshOrder();
5866 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5868 return contentNotNullBase()->getNumberOfComponents();
5871 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5873 return contentNotNullBase()->isDealingTS(iteration,order);
5876 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5878 return contentNotNullBase()->getDtIt();
5881 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5883 contentNotNullBase()->fillIteration(p);
5886 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5888 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5891 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5893 contentNotNullBase()->setInfo(infos);
5896 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5898 return contentNotNullBase()->getInfo();
5900 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5902 return contentNotNullBase()->getInfo();
5905 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
5907 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
5910 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5912 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5915 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5917 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5920 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
5922 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5925 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5927 return contentNotNullBase()->getTypesOfFieldAvailable();
5930 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5931 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5933 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5937 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5938 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5939 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5941 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5943 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5945 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5946 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5947 std::size_t sz(contentsSplit.size());
5948 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5949 for(std::size_t i=0;i<sz;i++)
5951 ret[i]=shallowCpy();
5952 ret[i]->_content=contentsSplit[i];
5958 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5959 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5961 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5963 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5965 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5966 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5967 std::size_t sz(contentsSplit.size());
5968 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5969 for(std::size_t i=0;i<sz;i++)
5971 ret[i]=shallowCpy();
5972 ret[i]->_content=contentsSplit[i];
5977 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5979 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5980 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5981 ret->_content=_content->deepCpy();
5982 ret->deepCpyGlobs(*this);
5986 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5988 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5994 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5995 * the first field that has been read from a specified MED file.
5996 * \param [in] fileName - the name of the MED file to read.
5997 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5998 * is to delete this field using decrRef() as it is no more needed.
5999 * \throw If reading the file fails.
6001 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6003 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6004 ret->contentNotNull();
6009 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6010 * a given field that has been read from a specified MED file.
6011 * \param [in] fileName - the name of the MED file to read.
6012 * \param [in] fieldName - the name of the field to read.
6013 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6014 * is to delete this field using decrRef() as it is no more needed.
6015 * \throw If reading the file fails.
6016 * \throw If there is no field named \a fieldName in the file.
6018 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6020 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6021 ret->contentNotNull();
6026 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6027 * a given field that has been read from a specified MED file.
6028 * \param [in] fileName - the name of the MED file to read.
6029 * \param [in] fieldName - the name of the field to read.
6030 * \param [in] iteration - the iteration number of a required time step.
6031 * \param [in] order - the iteration order number of required time step.
6032 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6033 * is to delete this field using decrRef() as it is no more needed.
6034 * \throw If reading the file fails.
6035 * \throw If there is no field named \a fieldName in the file.
6036 * \throw If the required time step is missing from the file.
6038 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6040 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6041 ret->contentNotNull();
6046 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6047 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6049 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6050 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6051 * \warning this is a shallow copy constructor
6052 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6053 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6054 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6055 * is to delete this field using decrRef() as it is no more needed.
6057 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6059 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6060 ret->contentNotNull();
6065 * Returns a new empty instance of MEDFileField1TS.
6066 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6067 * is to delete this field using decrRef() as it is no more needed.
6069 MEDFileField1TS *MEDFileField1TS::New()
6071 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6072 ret->contentNotNull();
6077 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6078 * following the given input policy.
6080 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6081 * By default (true) the globals are deeply copied.
6082 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6084 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6086 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6087 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6090 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6092 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6093 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6094 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6097 ret=MEDFileIntField1TS::New();
6099 ret->deepCpyGlobs(*this);
6101 ret->shallowCpyGlobs(*this);
6105 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6107 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6109 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6110 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6112 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 !");
6116 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6118 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6120 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6121 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6123 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 !");
6127 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6130 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6131 if(!((DataArray*)arr))
6132 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6133 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6135 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6136 f->setArray(arrOutC);
6139 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6141 if(!((DataArray*)arr))
6142 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6143 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6145 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6150 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6151 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6154 catch(INTERP_KERNEL::Exception& e)
6157 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6158 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6161 catch(INTERP_KERNEL::Exception& e)
6164 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6165 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6168 catch(INTERP_KERNEL::Exception& e)
6172 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6173 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6175 * \warning this is a shallow copy constructor
6177 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6178 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6181 catch(INTERP_KERNEL::Exception& e)
6184 MEDFileField1TS::MEDFileField1TS()
6186 _content=new MEDFileField1TSWithoutSDA;
6190 * Returns a new MEDCouplingFieldDouble of a given type lying on
6191 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6192 * has not been constructed via file reading, an exception is thrown.
6193 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6194 * \param [in] type - a spatial discretization of interest.
6195 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6196 * \param [in] renumPol - specifies how to permute values of the result field according to
6197 * the optional numbers of cells and nodes, if any. The valid values are
6198 * - 0 - do not permute.
6199 * - 1 - permute cells.
6200 * - 2 - permute nodes.
6201 * - 3 - permute cells and nodes.
6203 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6204 * caller is to delete this field using decrRef() as it is no more needed.
6205 * \throw If \a this field has not been constructed via file reading.
6206 * \throw If the MED file is not readable.
6207 * \throw If there is no mesh in the MED file.
6208 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6209 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6210 * \sa getFieldOnMeshAtLevel()
6212 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6214 if(getFileName().empty())
6215 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6216 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6217 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6218 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6223 * Returns a new MEDCouplingFieldDouble of a given type lying on
6224 * the top level cells of the first mesh in MED file. If \a this field
6225 * has not been constructed via file reading, an exception is thrown.
6226 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6227 * \param [in] type - a spatial discretization of interest.
6228 * \param [in] renumPol - specifies how to permute values of the result field according to
6229 * the optional numbers of cells and nodes, if any. The valid values are
6230 * - 0 - do not permute.
6231 * - 1 - permute cells.
6232 * - 2 - permute nodes.
6233 * - 3 - permute cells and nodes.
6235 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6236 * caller is to delete this field using decrRef() as it is no more needed.
6237 * \throw If \a this field has not been constructed via file reading.
6238 * \throw If the MED file is not readable.
6239 * \throw If there is no mesh in the MED file.
6240 * \throw If no field values of the given \a type.
6241 * \throw If no field values lying on the top level support.
6242 * \sa getFieldAtLevel()
6244 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6246 if(getFileName().empty())
6247 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6248 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6249 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6250 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6255 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6256 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6257 * \param [in] type - a spatial discretization of the new field.
6258 * \param [in] mesh - the supporting mesh.
6259 * \param [in] renumPol - specifies how to permute values of the result field according to
6260 * the optional numbers of cells and nodes, if any. The valid values are
6261 * - 0 - do not permute.
6262 * - 1 - permute cells.
6263 * - 2 - permute nodes.
6264 * - 3 - permute cells and nodes.
6266 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6267 * caller is to delete this field using decrRef() as it is no more needed.
6268 * \throw If no field of \a this is lying on \a mesh.
6269 * \throw If the mesh is empty.
6270 * \throw If no field values of the given \a type are available.
6271 * \sa getFieldAtLevel()
6272 * \sa getFieldOnMeshAtLevel()
6274 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6276 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6277 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6278 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6283 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6284 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6285 * \param [in] type - a spatial discretization of interest.
6286 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6287 * \param [in] mesh - the supporting mesh.
6288 * \param [in] renumPol - specifies how to permute values of the result field according to
6289 * the optional numbers of cells and nodes, if any. The valid values are
6290 * - 0 - do not permute.
6291 * - 1 - permute cells.
6292 * - 2 - permute nodes.
6293 * - 3 - permute cells and nodes.
6295 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6296 * caller is to delete this field using decrRef() as it is no more needed.
6297 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6298 * \throw If no field of \a this is lying on \a mesh.
6299 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6300 * \sa getFieldAtLevel()
6301 * \sa getFieldOnMeshAtLevel()
6303 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6305 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6306 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6307 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6312 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6313 * This method is called "Old" because in MED3 norm a field has only one meshName
6314 * attached, so this method is for readers of MED2 files. If \a this field
6315 * has not been constructed via file reading, an exception is thrown.
6316 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6317 * \param [in] type - a spatial discretization of interest.
6318 * \param [in] mName - a name of the supporting mesh.
6319 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6320 * \param [in] renumPol - specifies how to permute values of the result field according to
6321 * the optional numbers of cells and nodes, if any. The valid values are
6322 * - 0 - do not permute.
6323 * - 1 - permute cells.
6324 * - 2 - permute nodes.
6325 * - 3 - permute cells and nodes.
6327 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6328 * caller is to delete this field using decrRef() as it is no more needed.
6329 * \throw If the MED file is not readable.
6330 * \throw If there is no mesh named \a mName in the MED file.
6331 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6332 * \throw If \a this field has not been constructed via file reading.
6333 * \throw If no field of \a this is lying on the mesh named \a mName.
6334 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6335 * \sa getFieldAtLevel()
6337 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6339 if(getFileName().empty())
6340 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6341 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6342 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6343 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6348 * Returns values and a profile of the field of a given type lying on a given support.
6349 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6350 * \param [in] type - a spatial discretization of the field.
6351 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6352 * \param [in] mesh - the supporting mesh.
6353 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6354 * field of interest lies on. If the field lies on all entities of the given
6355 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6356 * using decrRef() as it is no more needed.
6357 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6358 * field. The caller is to delete this array using decrRef() as it is no more needed.
6359 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6360 * \throw If no field of \a this is lying on \a mesh.
6361 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6363 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6365 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6366 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6370 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6371 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6372 * "Sort By Type"), if not, an exception is thrown.
6373 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6374 * \param [in] field - the field to add to \a this.
6375 * \throw If the name of \a field is empty.
6376 * \throw If the data array of \a field is not set.
6377 * \throw If the data array is already allocated but has different number of components
6379 * \throw If the underlying mesh of \a field has no name.
6380 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6382 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6385 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6389 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6390 * can be an aggregation of several MEDCouplingFieldDouble instances.
6391 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6392 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6395 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6396 * A new profile is added only if no equal profile is missing.
6397 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6398 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6399 * \param [in] mesh - the supporting mesh of \a field.
6400 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6401 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6402 * \throw If either \a field or \a mesh or \a profile has an empty name.
6403 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6404 * \throw If the data array of \a field is not set.
6405 * \throw If the data array of \a this is already allocated but has different number of
6406 * components than \a field.
6407 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6408 * \sa setFieldNoProfileSBT()
6410 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6413 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6416 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6418 return new MEDFileField1TS(*this);
6421 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6423 return contentNotNull()->getUndergroundDataArrayDouble();
6426 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6428 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6431 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6432 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6434 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6437 //= MEDFileIntField1TS
6439 MEDFileIntField1TS *MEDFileIntField1TS::New()
6441 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6442 ret->contentNotNull();
6446 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6448 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6449 ret->contentNotNull();
6453 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6455 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6456 ret->contentNotNull();
6460 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6462 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6463 ret->contentNotNull();
6467 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6469 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6470 ret->contentNotNull();
6474 MEDFileIntField1TS::MEDFileIntField1TS()
6476 _content=new MEDFileIntField1TSWithoutSDA;
6479 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6480 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6483 catch(INTERP_KERNEL::Exception& e)
6486 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6487 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6490 catch(INTERP_KERNEL::Exception& e)
6493 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6494 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6497 catch(INTERP_KERNEL::Exception& e)
6501 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6502 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6504 * \warning this is a shallow copy constructor
6506 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6510 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6512 return new MEDFileIntField1TS(*this);
6516 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6517 * following the given input policy.
6519 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6520 * By default (true) the globals are deeply copied.
6521 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6523 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6525 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6526 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6529 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6531 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6532 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6533 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6536 ret=MEDFileField1TS::New();
6538 ret->deepCpyGlobs(*this);
6540 ret->shallowCpyGlobs(*this);
6545 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6546 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6547 * "Sort By Type"), if not, an exception is thrown.
6548 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6549 * \param [in] field - the field to add to \a this. The field double values are ignored.
6550 * \param [in] arrOfVals - the values of the field \a field used.
6551 * \throw If the name of \a field is empty.
6552 * \throw If the data array of \a field is not set.
6553 * \throw If the data array is already allocated but has different number of components
6555 * \throw If the underlying mesh of \a field has no name.
6556 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6558 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6561 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6565 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6566 * can be an aggregation of several MEDCouplingFieldDouble instances.
6567 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6568 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6571 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6572 * A new profile is added only if no equal profile is missing.
6573 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6574 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6575 * \param [in] arrOfVals - the values of the field \a field used.
6576 * \param [in] mesh - the supporting mesh of \a field.
6577 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6578 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6579 * \throw If either \a field or \a mesh or \a profile has an empty name.
6580 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6581 * \throw If the data array of \a field is not set.
6582 * \throw If the data array of \a this is already allocated but has different number of
6583 * components than \a field.
6584 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6585 * \sa setFieldNoProfileSBT()
6587 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6590 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6593 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6595 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6597 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6598 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6600 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 !");
6604 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6606 if(getFileName().empty())
6607 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6608 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6609 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6610 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6612 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6617 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6619 if(!((DataArray *)arr))
6620 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6621 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6623 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6629 * Returns a new MEDCouplingFieldDouble of a given type lying on
6630 * the top level cells of the first mesh in MED file. If \a this field
6631 * has not been constructed via file reading, an exception is thrown.
6632 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6633 * \param [in] type - a spatial discretization of interest.
6634 * \param [out] arrOut - the DataArrayInt containing values of field.
6635 * \param [in] renumPol - specifies how to permute values of the result field according to
6636 * the optional numbers of cells and nodes, if any. The valid values are
6637 * - 0 - do not permute.
6638 * - 1 - permute cells.
6639 * - 2 - permute nodes.
6640 * - 3 - permute cells and nodes.
6642 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6643 * caller is to delete this field using decrRef() as it is no more needed.
6644 * \throw If \a this field has not been constructed via file reading.
6645 * \throw If the MED file is not readable.
6646 * \throw If there is no mesh in the MED file.
6647 * \throw If no field values of the given \a type.
6648 * \throw If no field values lying on the top level support.
6649 * \sa getFieldAtLevel()
6651 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6653 if(getFileName().empty())
6654 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6655 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6656 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6657 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6662 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6663 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6664 * \param [in] type - a spatial discretization of the new field.
6665 * \param [in] mesh - the supporting mesh.
6666 * \param [out] arrOut - the DataArrayInt containing values of field.
6667 * \param [in] renumPol - specifies how to permute values of the result field according to
6668 * the optional numbers of cells and nodes, if any. The valid values are
6669 * - 0 - do not permute.
6670 * - 1 - permute cells.
6671 * - 2 - permute nodes.
6672 * - 3 - permute cells and nodes.
6674 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6675 * caller is to delete this field using decrRef() as it is no more needed.
6676 * \throw If no field of \a this is lying on \a mesh.
6677 * \throw If the mesh is empty.
6678 * \throw If no field values of the given \a type are available.
6679 * \sa getFieldAtLevel()
6680 * \sa getFieldOnMeshAtLevel()
6682 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6684 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6685 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6686 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6691 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6692 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6693 * \param [in] type - a spatial discretization of interest.
6694 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6695 * \param [out] arrOut - the DataArrayInt containing values of field.
6696 * \param [in] mesh - the supporting mesh.
6697 * \param [in] renumPol - specifies how to permute values of the result field according to
6698 * the optional numbers of cells and nodes, if any. The valid values are
6699 * - 0 - do not permute.
6700 * - 1 - permute cells.
6701 * - 2 - permute nodes.
6702 * - 3 - permute cells and nodes.
6704 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6705 * caller is to delete this field using decrRef() as it is no more needed.
6706 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6707 * \throw If no field of \a this is lying on \a mesh.
6708 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6709 * \sa getFieldAtLevel()
6710 * \sa getFieldOnMeshAtLevel()
6712 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6714 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6715 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6716 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6721 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6722 * This method is called "Old" because in MED3 norm a field has only one meshName
6723 * attached, so this method is for readers of MED2 files. If \a this field
6724 * has not been constructed via file reading, an exception is thrown.
6725 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6726 * \param [in] type - a spatial discretization of interest.
6727 * \param [in] mName - a name of the supporting mesh.
6728 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6729 * \param [out] arrOut - the DataArrayInt containing values of field.
6730 * \param [in] renumPol - specifies how to permute values of the result field according to
6731 * the optional numbers of cells and nodes, if any. The valid values are
6732 * - 0 - do not permute.
6733 * - 1 - permute cells.
6734 * - 2 - permute nodes.
6735 * - 3 - permute cells and nodes.
6737 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6738 * caller is to delete this field using decrRef() as it is no more needed.
6739 * \throw If the MED file is not readable.
6740 * \throw If there is no mesh named \a mName in the MED file.
6741 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6742 * \throw If \a this field has not been constructed via file reading.
6743 * \throw If no field of \a this is lying on the mesh named \a mName.
6744 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6745 * \sa getFieldAtLevel()
6747 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6749 if(getFileName().empty())
6750 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6751 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6752 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6753 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6758 * Returns values and a profile of the field of a given type lying on a given support.
6759 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6760 * \param [in] type - a spatial discretization of the field.
6761 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6762 * \param [in] mesh - the supporting mesh.
6763 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6764 * field of interest lies on. If the field lies on all entities of the given
6765 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6766 * using decrRef() as it is no more needed.
6767 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6768 * field. The caller is to delete this array using decrRef() as it is no more needed.
6769 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6770 * \throw If no field of \a this is lying on \a mesh.
6771 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6773 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6775 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6776 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6779 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6781 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6783 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6784 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6786 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 !");
6790 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6792 return contentNotNull()->getUndergroundDataArrayInt();
6795 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6797 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6801 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6806 * \param [in] fieldId field id in C mode
6808 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6810 med_field_type typcha;
6811 std::string dtunitOut;
6812 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6813 setDtUnit(dtunitOut.c_str());
6814 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6817 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
6818 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6820 setDtUnit(dtunit.c_str());
6821 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6823 catch(INTERP_KERNEL::Exception& e)
6828 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6830 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6831 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6832 ret+=(*it).capacity();
6836 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6838 std::vector<const BigMemoryObject *> ret;
6839 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6840 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6845 * 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
6848 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6850 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6851 ret->setInfo(_infos);
6852 int sz=(int)_time_steps.size();
6853 for(const int *id=startIds;id!=endIds;id++)
6855 if(*id>=0 && *id<sz)
6857 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6858 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6862 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6864 ret->pushBackTimeStep(tse2);
6868 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6869 oss << " ! Should be in [0," << sz << ") !";
6870 throw INTERP_KERNEL::Exception(oss.str().c_str());
6873 if(ret->getNumberOfTS()>0)
6874 ret->synchronizeNameScope();
6875 ret->copyNameScope(*this);
6880 * 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
6883 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6885 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6886 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6887 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6888 ret->setInfo(_infos);
6889 int sz=(int)_time_steps.size();
6891 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6895 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6896 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6900 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6902 ret->pushBackTimeStep(tse2);
6906 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6907 oss << " ! Should be in [0," << sz << ") !";
6908 throw INTERP_KERNEL::Exception(oss.str().c_str());
6911 if(ret->getNumberOfTS()>0)
6912 ret->synchronizeNameScope();
6913 ret->copyNameScope(*this);
6917 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6921 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6923 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6926 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6927 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6928 ids->pushBackSilent(id);
6930 return buildFromTimeStepIds(ids->begin(),ids->end());
6933 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6936 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6937 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6939 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6942 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6943 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6944 ids->pushBackSilent(id);
6946 return buildFromTimeStepIds(ids->begin(),ids->end());
6949 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
6951 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6953 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6956 if(cur->presenceOfMultiDiscPerGeoType())
6962 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6967 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6972 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6975 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6977 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6978 if(pt->isDealingTS(iteration,order))
6981 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6982 std::vector< std::pair<int,int> > vp=getIterations();
6983 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6984 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6985 throw INTERP_KERNEL::Exception(oss.str().c_str());
6988 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6990 return *_time_steps[getTimeStepPos(iteration,order)];
6993 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6995 return *_time_steps[getTimeStepPos(iteration,order)];
6998 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7000 if(_time_steps.empty())
7001 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7002 return _time_steps[0]->getMeshName();
7005 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7007 std::string oldName(getMeshName());
7008 std::vector< std::pair<std::string,std::string> > v(1);
7009 v[0].first=oldName; v[0].second=newMeshName;
7013 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7016 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7018 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7020 ret=cur->changeMeshNames(modifTab) || ret;
7026 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7028 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7030 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7034 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7036 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7038 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7041 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7042 MEDFileFieldGlobsReal& glob)
7045 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7047 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7049 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7054 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7056 std::string startLine(bkOffset,' ');
7057 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7059 oss << " (" << fmtsId << ")";
7060 oss << " has the following name: \"" << _name << "\"." << std::endl;
7061 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7062 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7064 oss << startLine << " - \"" << *it << "\"" << std::endl;
7067 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7069 std::string chapter(17,'0'+i);
7070 oss << startLine << chapter << std::endl;
7071 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7073 cur->simpleRepr(bkOffset+2,oss,i);
7075 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7076 oss << startLine << chapter << std::endl;
7080 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7082 std::size_t sz=_time_steps.size();
7083 std::vector< std::pair<int,int> > ret(sz);
7085 for(std::size_t i=0;i<sz;i++)
7087 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7090 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7094 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7095 throw INTERP_KERNEL::Exception(oss.str().c_str());
7101 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7103 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7105 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7106 checkCoherencyOfType(tse2);
7107 if(_time_steps.empty())
7109 setName(tse2->getName().c_str());
7110 setInfo(tse2->getInfo());
7112 checkThatComponentsMatch(tse2->getInfo());
7113 _time_steps.push_back(tse);
7116 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7118 std::size_t nbOfCompo=_infos.size();
7119 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7121 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7124 if((cur->getInfo()).size()!=nbOfCompo)
7126 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7127 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7128 throw INTERP_KERNEL::Exception(oss.str().c_str());
7130 cur->copyNameScope(*this);
7135 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7137 _time_steps.resize(nbPdt);
7138 for(int i=0;i<nbPdt;i++)
7140 std::vector< std::pair<int,int> > ts;
7141 med_int numdt=0,numo=0;
7142 med_int meshIt=0,meshOrder=0;
7144 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7149 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7154 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7158 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7161 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7163 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7167 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7169 if(_time_steps.empty())
7170 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7171 checkThatNbOfCompoOfTSMatchThis();
7172 std::vector<std::string> infos(getInfo());
7173 int nbComp=infos.size();
7174 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7175 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7176 for(int i=0;i<nbComp;i++)
7178 std::string info=infos[i];
7180 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7181 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7182 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7185 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7186 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7187 int nbOfTS=_time_steps.size();
7188 for(int i=0;i<nbOfTS;i++)
7189 _time_steps[i]->writeLL(fid,opts,*this);
7192 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7194 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7196 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7198 elt->loadBigArraysRecursively(fid,nasc);
7202 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7204 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7206 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7208 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7212 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7214 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7216 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7218 elt->unloadArrays();
7222 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7224 return _time_steps.size();
7227 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7229 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7230 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7232 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7234 newTS.push_back(*it);
7239 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7241 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7242 int maxId=(int)_time_steps.size();
7244 std::set<int> idsToDel;
7245 for(const int *id=startIds;id!=endIds;id++,ii++)
7247 if(*id>=0 && *id<maxId)
7249 idsToDel.insert(*id);
7253 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7254 throw INTERP_KERNEL::Exception(oss.str().c_str());
7257 for(int iii=0;iii<maxId;iii++)
7258 if(idsToDel.find(iii)==idsToDel.end())
7259 newTS.push_back(_time_steps[iii]);
7263 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7265 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7266 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7267 if(nbOfEntriesToKill==0)
7269 std::size_t sz=_time_steps.size();
7270 std::vector<bool> b(sz,true);
7272 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7274 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7275 for(std::size_t i=0;i<sz;i++)
7277 newTS.push_back(_time_steps[i]);
7281 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7284 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7285 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7287 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7291 tmp->getTime(it2,ord);
7292 if(it2==iteration && order==ord)
7295 oss << "(" << it2 << "," << ord << "), ";
7298 throw INTERP_KERNEL::Exception(oss.str().c_str());
7301 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7304 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7306 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7308 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7312 double ti=tmp->getTime(it2,ord);
7313 if(fabs(time-ti)<eps)
7319 throw INTERP_KERNEL::Exception(oss.str().c_str());
7322 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7324 int lgth=_time_steps.size();
7325 std::vector< std::pair<int,int> > ret(lgth);
7326 for(int i=0;i<lgth;i++)
7327 _time_steps[i]->fillIteration(ret[i]);
7332 * 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'
7333 * This method returns two things.
7334 * - The absolute dimension of 'this' in first parameter.
7335 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7336 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7338 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7339 * Only these 3 discretizations will be taken into account here.
7341 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7342 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7343 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7345 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7346 * 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'.
7348 * Let's consider the typical following case :
7349 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7350 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7351 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7353 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7355 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7357 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7358 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7359 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7360 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7362 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7364 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7367 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7369 if(pos<0 || pos>=(int)_time_steps.size())
7371 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7372 throw INTERP_KERNEL::Exception(oss.str().c_str());
7374 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7377 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7378 oss << "\nTry to use following method eraseEmptyTS !";
7379 throw INTERP_KERNEL::Exception(oss.str().c_str());
7384 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7386 if(pos<0 || pos>=(int)_time_steps.size())
7388 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7389 throw INTERP_KERNEL::Exception(oss.str().c_str());
7391 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7394 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7395 oss << "\nTry to use following method eraseEmptyTS !";
7396 throw INTERP_KERNEL::Exception(oss.str().c_str());
7401 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7403 std::vector<std::string> ret;
7404 std::set<std::string> ret2;
7405 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7407 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7408 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7409 if(ret2.find(*it2)==ret2.end())
7411 ret.push_back(*it2);
7418 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7420 std::vector<std::string> ret;
7421 std::set<std::string> ret2;
7422 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7424 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7425 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7426 if(ret2.find(*it2)==ret2.end())
7428 ret.push_back(*it2);
7435 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7437 std::vector<std::string> ret;
7438 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7440 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7441 ret.insert(ret.end(),tmp.begin(),tmp.end());
7446 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7448 std::vector<std::string> ret;
7449 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7451 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7452 ret.insert(ret.end(),tmp.begin(),tmp.end());
7457 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7459 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7460 (*it)->changePflsRefsNamesGen2(mapOfModif);
7463 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7465 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7466 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7469 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7471 int lgth=_time_steps.size();
7472 std::vector< std::vector<TypeOfField> > ret(lgth);
7473 for(int i=0;i<lgth;i++)
7474 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7479 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7481 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& 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
7483 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7486 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7488 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7490 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7492 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7493 ret->_time_steps[i]=(*it)->deepCpy();
7498 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7500 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7501 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7502 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7503 for(std::size_t i=0;i<sz;i++)
7505 ret[i]=shallowCpy();
7506 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7508 for(std::size_t i=0;i<sz2;i++)
7510 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7513 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7514 throw INTERP_KERNEL::Exception(oss.str().c_str());
7518 for(std::size_t i=0;i<sz;i++)
7519 for(std::size_t j=0;j<sz2;j++)
7520 ret[i]->_time_steps[j]=ts[j][i];
7525 * This method splits into discretization each time steps in \a this.
7526 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7528 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7530 std::size_t sz(_time_steps.size());
7531 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7532 for(std::size_t i=0;i<sz;i++)
7534 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7537 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7538 throw INTERP_KERNEL::Exception(oss.str().c_str());
7540 items[i]=timeStep->splitDiscretizations();
7543 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7544 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7545 std::vector< TypeOfField > types;
7546 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7547 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7549 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7551 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7552 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7553 if(it2==types.end())
7554 types.push_back(ts[0]);
7556 ret.resize(types.size()); ret2.resize(types.size());
7557 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7558 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7560 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7561 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7562 ret2[pos].push_back(*it1);
7564 for(std::size_t i=0;i<types.size();i++)
7566 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7567 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7568 elt->pushBackTimeStep(*it1);//also updates infos in elt
7570 elt->MEDFileFieldNameScope::operator=(*this);
7575 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7577 _name=field->getName();
7579 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7581 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7582 _infos=arr->getInfoOnComponents();
7585 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7587 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7588 if(_name!=field->getName())
7590 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7591 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7592 throw INTERP_KERNEL::Exception(oss.str().c_str());
7595 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7596 checkThatComponentsMatch(arr->getInfoOnComponents());
7599 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7601 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7602 if(getInfo().size()!=compos.size())
7604 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7605 oss << " number of components of element to append (" << compos.size() << ") !";
7606 throw INTERP_KERNEL::Exception(oss.str().c_str());
7610 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7611 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7612 oss << " But compo in input fields are : ";
7613 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7615 throw INTERP_KERNEL::Exception(oss.str().c_str());
7619 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7621 std::size_t sz=_infos.size();
7623 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7625 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7627 if(elt->getInfo().size()!=sz)
7629 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7630 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7631 throw INTERP_KERNEL::Exception(oss.str().c_str());
7636 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7639 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7640 if(!_time_steps.empty())
7641 checkCoherencyOfTinyInfo(field,arr);
7642 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7643 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7644 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7645 copyTinyInfoFrom(field,arr);
7646 _time_steps.push_back(obj);
7649 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7652 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7653 if(!_time_steps.empty())
7654 checkCoherencyOfTinyInfo(field,arr);
7655 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7656 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7657 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7658 copyTinyInfoFrom(field,arr);
7659 _time_steps.push_back(obj);
7662 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7664 int sz=(int)_time_steps.size();
7667 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7668 throw INTERP_KERNEL::Exception(oss.str().c_str());
7670 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7673 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7675 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7676 throw INTERP_KERNEL::Exception(oss.str().c_str());
7682 //= MEDFileFieldMultiTSWithoutSDA
7684 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
7686 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7689 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7693 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7698 * \param [in] fieldId field id in C mode
7700 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7701 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7704 catch(INTERP_KERNEL::Exception& e)
7707 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
7708 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7711 catch(INTERP_KERNEL::Exception& e)
7714 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7716 return new MEDFileField1TSWithoutSDA;
7719 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7722 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7723 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7725 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7728 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7730 return MEDFileField1TSWithoutSDA::TYPE_STR;
7733 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7735 return new MEDFileFieldMultiTSWithoutSDA(*this);
7738 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7740 return new MEDFileFieldMultiTSWithoutSDA;
7744 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7745 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7747 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& 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
7749 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7750 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7752 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7753 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7756 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7758 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7759 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7761 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7763 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7766 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7768 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7769 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7770 ret->setIteration(i,elt);
7776 //= MEDFileAnyTypeFieldMultiTS
7778 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7782 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7783 try:MEDFileFieldGlobsReal(fileName)
7785 MEDFileUtilities::CheckFileForRead(fileName);
7786 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7787 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7790 catch(INTERP_KERNEL::Exception& e)
7795 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7797 med_field_type typcha;
7798 std::vector<std::string> infos;
7801 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7802 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7807 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7812 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7817 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] !";
7818 throw INTERP_KERNEL::Exception(oss.str().c_str());
7821 ret->setDtUnit(dtunit.c_str());
7825 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7827 med_field_type typcha;
7829 std::vector<std::string> infos;
7830 std::string dtunit,fieldName;
7831 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7832 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7837 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7842 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7847 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] !";
7848 throw INTERP_KERNEL::Exception(oss.str().c_str());
7851 ret->setDtUnit(dtunit.c_str());
7855 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
7858 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7859 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7861 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7862 ret->setFileName(fileName);
7863 ret->_content=c; c->incrRef();
7866 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7868 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7869 ret->setFileName(fileName);
7870 ret->_content=c; c->incrRef();
7873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7876 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7877 try:MEDFileFieldGlobsReal(fileName)
7879 MEDFileUtilities::CheckFileForRead(fileName);
7880 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7881 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
7884 catch(INTERP_KERNEL::Exception& e)
7889 //= MEDFileIntFieldMultiTSWithoutSDA
7891 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
7893 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7896 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7900 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7904 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms)
7905 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7908 catch(INTERP_KERNEL::Exception& e)
7912 * \param [in] fieldId field id in C mode
7914 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7915 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7918 catch(INTERP_KERNEL::Exception& e)
7921 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7923 return new MEDFileIntField1TSWithoutSDA;
7926 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7929 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7930 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7932 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7935 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7937 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7940 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7942 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7945 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7947 return new MEDFileIntFieldMultiTSWithoutSDA;
7950 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7952 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7953 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7955 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7957 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7960 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7962 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7963 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7964 ret->setIteration(i,elt);
7970 //= MEDFileAnyTypeFieldMultiTS
7973 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7974 * that has been read from a specified MED file.
7975 * \param [in] fileName - the name of the MED file to read.
7976 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7977 * is to delete this field using decrRef() as it is no more needed.
7978 * \throw If reading the file fails.
7980 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
7982 MEDFileUtilities::CheckFileForRead(fileName);
7983 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7984 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
7985 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7986 ret->loadGlobals(fid);
7991 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7992 * that has been read from a specified MED file.
7993 * \param [in] fileName - the name of the MED file to read.
7994 * \param [in] fieldName - the name of the field to read.
7995 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7996 * is to delete this field using decrRef() as it is no more needed.
7997 * \throw If reading the file fails.
7998 * \throw If there is no field named \a fieldName in the file.
8000 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8002 MEDFileUtilities::CheckFileForRead(fileName);
8003 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8004 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
8005 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8006 ret->loadGlobals(fid);
8011 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8012 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8014 * \warning this is a shallow copy constructor
8016 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8018 if(!shallowCopyOfContent)
8020 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8021 otherPtr->incrRef();
8022 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8026 _content=other.shallowCpy();
8030 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8032 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8034 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8038 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8040 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8042 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8046 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8048 return contentNotNullBase()->getPflsReallyUsed2();
8051 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8053 return contentNotNullBase()->getLocsReallyUsed2();
8056 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8058 return contentNotNullBase()->getPflsReallyUsedMulti2();
8061 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8063 return contentNotNullBase()->getLocsReallyUsedMulti2();
8066 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8068 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8071 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8073 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8076 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8078 return contentNotNullBase()->getNumberOfTS();
8081 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8083 contentNotNullBase()->eraseEmptyTS();
8086 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8088 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8091 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8093 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8096 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8098 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8099 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8104 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8106 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8107 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8112 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8114 return contentNotNullBase()->getIterations();
8117 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8119 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8120 pushBackTimeStep(*it);
8123 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8126 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8127 checkCoherencyOfType(f1ts);
8129 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8130 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8132 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8133 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8134 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8135 _content->pushBackTimeStep(cSafe);
8136 appendGlobs(*f1ts,1e-12);
8139 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8141 contentNotNullBase()->synchronizeNameScope();
8144 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8146 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8149 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8151 return contentNotNullBase()->getPosGivenTime(time,eps);
8154 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8156 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8159 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8161 return contentNotNullBase()->getTypesOfFieldAvailable();
8164 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& 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
8166 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8169 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8171 return contentNotNullBase()->getName();
8174 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8176 contentNotNullBase()->setName(name);
8179 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8181 return contentNotNullBase()->getDtUnit();
8184 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8186 contentNotNullBase()->setDtUnit(dtUnit);
8189 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8191 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8194 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8196 return contentNotNullBase()->getTimeSteps(ret1);
8199 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8201 return contentNotNullBase()->getMeshName();
8204 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8206 contentNotNullBase()->setMeshName(newMeshName);
8209 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8211 return contentNotNullBase()->changeMeshNames(modifTab);
8214 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8216 return contentNotNullBase()->getInfo();
8219 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8221 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8224 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8226 return contentNotNullBase()->setInfo(info);
8229 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8231 const std::vector<std::string> ret=getInfo();
8232 return (int)ret.size();
8235 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8237 writeGlobals(fid,*this);
8238 contentNotNullBase()->writeLL(fid,*this);
8242 * Writes \a this field into a MED file specified by its name.
8243 * \param [in] fileName - the MED file name.
8244 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8245 * - 2 - erase; an existing file is removed.
8246 * - 1 - append; same data should not be present in an existing file.
8247 * - 0 - overwrite; same data present in an existing file is overwritten.
8248 * \throw If the field name is not set.
8249 * \throw If no field data is set.
8250 * \throw If \a mode == 1 and the same data is present in an existing file.
8252 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8254 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8255 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8260 * This method alloc the arrays and load potentially huge arrays contained in this field.
8261 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8262 * This method can be also called to refresh or reinit values from a file.
8264 * \throw If the fileName is not set or points to a non readable MED file.
8266 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8268 if(getFileName().empty())
8269 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8270 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8271 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8275 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8276 * But once data loaded once, this method does nothing.
8278 * \throw If the fileName is not set or points to a non readable MED file.
8279 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8281 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8283 if(!getFileName().empty())
8285 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8286 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8291 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8292 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8293 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8295 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8297 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8299 contentNotNullBase()->unloadArrays();
8303 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
8304 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8305 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8307 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8309 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8311 if(!getFileName().empty())
8312 contentNotNullBase()->unloadArrays();
8315 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8317 std::ostringstream oss;
8318 contentNotNullBase()->simpleRepr(0,oss,-1);
8319 simpleReprGlobs(oss);
8323 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8325 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8328 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8330 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8331 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8336 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8337 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8338 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8340 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8342 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8344 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8345 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8346 std::size_t sz(contentsSplit.size());
8347 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8348 for(std::size_t i=0;i<sz;i++)
8350 ret[i]=shallowCpy();
8351 ret[i]->_content=contentsSplit[i];
8357 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8358 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8360 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8362 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8365 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8366 std::size_t sz(contentsSplit.size());
8367 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8368 for(std::size_t i=0;i<sz;i++)
8370 ret[i]=shallowCpy();
8371 ret[i]->_content=contentsSplit[i];
8376 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8378 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8379 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8380 ret->_content=_content->deepCpy();
8381 ret->deepCpyGlobs(*this);
8385 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8391 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8392 * \param [in] iteration - the iteration number of a required time step.
8393 * \param [in] order - the iteration order number of required time step.
8394 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8395 * delete this field using decrRef() as it is no more needed.
8396 * \throw If there is no required time step in \a this field.
8398 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8400 int pos=getPosOfTimeStep(iteration,order);
8401 return getTimeStepAtPos(pos);
8405 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8406 * \param [in] time - the time of the time step of interest.
8407 * \param [in] eps - a precision used to compare time values.
8408 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8409 * delete this field using decrRef() as it is no more needed.
8410 * \throw If there is no required time step in \a this field.
8412 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8414 int pos=getPosGivenTime(time,eps);
8415 return getTimeStepAtPos(pos);
8419 * 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.
8420 * The float64 value of time attached to the pair of integers are not considered here.
8421 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8423 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8424 * \throw If there is a null pointer in \a vectFMTS.
8426 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8428 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8429 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8430 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8431 while(!lstFMTS.empty())
8433 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8434 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8436 throw INTERP_KERNEL::Exception(msg);
8437 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8438 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8439 elt.push_back(curIt); it=lstFMTS.erase(it);
8440 while(it!=lstFMTS.end())
8444 throw INTERP_KERNEL::Exception(msg);
8445 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8447 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8457 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8458 * All returned instances in a subvector can be safely loaded, rendered along time
8459 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8460 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8461 * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
8462 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8463 * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
8465 * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
8466 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8467 * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
8468 * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
8470 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8471 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8472 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8473 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8474 * \throw If mesh is null.
8475 * \throw If an element in \a vectFMTS is null.
8476 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8478 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8480 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8483 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8484 if(vectFMTS.empty())
8486 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8487 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8489 throw INTERP_KERNEL::Exception(msg);
8491 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8492 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8493 for(;it!=vectFMTS.end();it++,i++)
8496 throw INTERP_KERNEL::Exception(msg);
8497 TypeOfField tof0,tof1;
8498 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8501 vectFMTSNotNodes.push_back(*it);
8503 vectFMTSNodes.push_back(*it);
8506 vectFMTSNotNodes.push_back(*it);
8508 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8509 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8511 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8514 bool isFetched(false);
8515 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8518 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8519 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8520 { ret[i].push_back(*it2); isFetched=true; }
8524 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8525 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8526 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8534 * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
8535 * \param [out] cmps - same size than the returned vector.
8537 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8539 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8540 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8541 while(!lstFMTS.empty())
8543 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8544 MEDFileAnyTypeFieldMultiTS *ref(*it);
8545 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8546 elt.push_back(ref); it=lstFMTS.erase(it);
8547 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8548 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8549 while(it!=lstFMTS.end())
8551 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8552 if(cmp->isEqual(curIt))
8553 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8557 ret.push_back(elt); cmps.push_back(cmp);
8563 * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
8564 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8566 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8567 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8568 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8569 * \thorw If \a f0 and \a f1 do not have the same times steps.
8570 * \throw If mesh is null.
8571 * \throw If \a f0 or \a f1 is null.
8572 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8574 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8577 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8579 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8580 if(f0->getMeshName()!=mesh->getName())
8582 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8583 throw INTERP_KERNEL::Exception(oss.str().c_str());
8585 if(f1->getMeshName()!=mesh->getName())
8587 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8588 throw INTERP_KERNEL::Exception(oss.str().c_str());
8590 int nts=f0->getNumberOfTS();
8591 if(nts!=f1->getNumberOfTS())
8592 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8595 for(int i=0;i<nts;i++)
8597 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8598 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8599 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8600 if(tofs0.size()!=1 || tofs1.size()!=1)
8601 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8604 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8605 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8608 { tof0=tofs0[0]; tof1=tofs1[0]; }
8609 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8611 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8612 throw INTERP_KERNEL::Exception(oss.str().c_str());
8614 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8616 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8617 throw INTERP_KERNEL::Exception(oss.str().c_str());
8619 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8621 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
8622 throw INTERP_KERNEL::Exception(oss.str().c_str());
8628 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8630 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8633 //= MEDFileFieldMultiTS
8636 * Returns a new empty instance of MEDFileFieldMultiTS.
8637 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8638 * is to delete this field using decrRef() as it is no more needed.
8640 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8642 return new MEDFileFieldMultiTS;
8646 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8647 * that has been read from a specified MED file.
8648 * \param [in] fileName - the name of the MED file to read.
8649 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8650 * is to delete this field using decrRef() as it is no more needed.
8651 * \throw If reading the file fails.
8653 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8655 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8656 ret->contentNotNull();//to check that content type matches with \a this type.
8661 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8662 * that has been read from a specified MED file.
8663 * \param [in] fileName - the name of the MED file to read.
8664 * \param [in] fieldName - the name of the field to read.
8665 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8666 * is to delete this field using decrRef() as it is no more needed.
8667 * \throw If reading the file fails.
8668 * \throw If there is no field named \a fieldName in the file.
8670 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8672 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8673 ret->contentNotNull();//to check that content type matches with \a this type.
8678 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8679 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8681 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8682 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8683 * \warning this is a shallow copy constructor
8684 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8685 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8686 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8687 * is to delete this field using decrRef() as it is no more needed.
8689 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8691 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8694 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8696 return new MEDFileFieldMultiTS(*this);
8699 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8702 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8703 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8705 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8709 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8710 * following the given input policy.
8712 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8713 * By default (true) the globals are deeply copied.
8714 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8716 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8718 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8719 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8722 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8724 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8725 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8726 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8729 ret=MEDFileIntFieldMultiTS::New();
8731 ret->deepCpyGlobs(*this);
8733 ret->shallowCpyGlobs(*this);
8738 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8739 * \param [in] pos - a time step id.
8740 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8741 * delete this field using decrRef() as it is no more needed.
8742 * \throw If \a pos is not a valid time step id.
8744 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8746 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8749 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8750 throw INTERP_KERNEL::Exception(oss.str().c_str());
8752 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8755 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8756 ret->shallowCpyGlobs(*this);
8759 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8760 throw INTERP_KERNEL::Exception(oss.str().c_str());
8764 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8765 * mesh entities of a given dimension of the first mesh in MED file.
8766 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8767 * \param [in] type - a spatial discretization of interest.
8768 * \param [in] iteration - the iteration number of a required time step.
8769 * \param [in] order - the iteration order number of required time step.
8770 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8771 * \param [in] renumPol - specifies how to permute values of the result field according to
8772 * the optional numbers of cells and nodes, if any. The valid values are
8773 * - 0 - do not permute.
8774 * - 1 - permute cells.
8775 * - 2 - permute nodes.
8776 * - 3 - permute cells and nodes.
8778 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8779 * caller is to delete this field using decrRef() as it is no more needed.
8780 * \throw If the MED file is not readable.
8781 * \throw If there is no mesh in the MED file.
8782 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8783 * \throw If no field values of the required parameters are available.
8785 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8787 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8788 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8790 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8791 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8792 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8793 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8798 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8799 * the top level cells of the first mesh in MED file.
8800 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8801 * \param [in] type - a spatial discretization of interest.
8802 * \param [in] iteration - the iteration number of a required time step.
8803 * \param [in] order - the iteration order number of required time step.
8804 * \param [in] renumPol - specifies how to permute values of the result field according to
8805 * the optional numbers of cells and nodes, if any. The valid values are
8806 * - 0 - do not permute.
8807 * - 1 - permute cells.
8808 * - 2 - permute nodes.
8809 * - 3 - permute cells and nodes.
8811 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8812 * caller is to delete this field using decrRef() as it is no more needed.
8813 * \throw If the MED file is not readable.
8814 * \throw If there is no mesh in the MED file.
8815 * \throw If no field values of the required parameters are available.
8817 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8819 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8820 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8822 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8823 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8824 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8825 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8830 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8832 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8833 * \param [in] type - a spatial discretization of interest.
8834 * \param [in] iteration - the iteration number of a required time step.
8835 * \param [in] order - the iteration order number of required time step.
8836 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8837 * \param [in] mesh - the supporting mesh.
8838 * \param [in] renumPol - specifies how to permute values of the result field according to
8839 * the optional numbers of cells and nodes, if any. The valid values are
8840 * - 0 - do not permute.
8841 * - 1 - permute cells.
8842 * - 2 - permute nodes.
8843 * - 3 - permute cells and nodes.
8845 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8846 * caller is to delete this field using decrRef() as it is no more needed.
8847 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8848 * \throw If no field of \a this is lying on \a mesh.
8849 * \throw If no field values of the required parameters are available.
8851 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8853 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8854 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8856 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8857 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8858 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8859 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8864 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8866 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8867 * \param [in] type - a spatial discretization of the new field.
8868 * \param [in] iteration - the iteration number of a required time step.
8869 * \param [in] order - the iteration order number of required time step.
8870 * \param [in] mesh - the supporting mesh.
8871 * \param [in] renumPol - specifies how to permute values of the result field according to
8872 * the optional numbers of cells and nodes, if any. The valid values are
8873 * - 0 - do not permute.
8874 * - 1 - permute cells.
8875 * - 2 - permute nodes.
8876 * - 3 - permute cells and nodes.
8878 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8879 * caller is to delete this field using decrRef() as it is no more needed.
8880 * \throw If no field of \a this is lying on \a mesh.
8881 * \throw If no field values of the required parameters are available.
8883 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8885 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8886 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8888 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8889 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8890 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8891 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8896 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8897 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8898 * This method is useful for MED2 file format when field on different mesh was autorized.
8900 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8902 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8903 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8905 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8906 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8907 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8908 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8913 * Returns values and a profile of the field of a given type, of a given time step,
8914 * lying on a given support.
8915 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8916 * \param [in] type - a spatial discretization of the field.
8917 * \param [in] iteration - the iteration number of a required time step.
8918 * \param [in] order - the iteration order number of required time step.
8919 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8920 * \param [in] mesh - the supporting mesh.
8921 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8922 * field of interest lies on. If the field lies on all entities of the given
8923 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8924 * using decrRef() as it is no more needed.
8925 * \param [in] glob - the global data storing profiles and localization.
8926 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8927 * field. The caller is to delete this array using decrRef() as it is no more needed.
8928 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8929 * \throw If no field of \a this is lying on \a mesh.
8930 * \throw If no field values of the required parameters are available.
8932 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8934 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8935 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8937 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8938 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8939 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8942 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8944 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8946 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8947 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8949 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 !");
8953 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8955 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8957 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8958 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8960 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 !");
8965 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8966 * the given field is checked if its elements are sorted suitable for writing to MED file
8967 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8968 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8969 * \param [in] field - the field to add to \a this.
8970 * \throw If the name of \a field is empty.
8971 * \throw If the data array of \a field is not set.
8972 * \throw If existing time steps have different name or number of components than \a field.
8973 * \throw If the underlying mesh of \a field has no name.
8974 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8976 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8978 const DataArrayDouble *arr=0;
8980 arr=field->getArray();
8981 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8985 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8986 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8987 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8990 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8991 * A new profile is added only if no equal profile is missing.
8992 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8993 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8994 * \param [in] mesh - the supporting mesh of \a field.
8995 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8996 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8997 * \throw If either \a field or \a mesh or \a profile has an empty name.
8998 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8999 * \throw If the data array of \a field is not set.
9000 * \throw If the data array of \a this is already allocated but has different number of
9001 * components than \a field.
9002 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9003 * \sa setFieldNoProfileSBT()
9005 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9007 const DataArrayDouble *arr=0;
9009 arr=field->getArray();
9010 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9013 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9015 _content=new MEDFileFieldMultiTSWithoutSDA;
9018 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9019 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9022 catch(INTERP_KERNEL::Exception& e)
9025 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9026 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9029 catch(INTERP_KERNEL::Exception& e)
9032 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9036 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& 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
9038 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9041 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9043 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9046 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9048 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9051 //= MEDFileAnyTypeFieldMultiTSIterator
9053 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9058 _nb_iter=fmts->getNumberOfTS();
9062 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9066 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9068 if(_iter_id<_nb_iter)
9070 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9072 return fmts->getTimeStepAtPos(_iter_id++);
9080 //= MEDFileIntFieldMultiTS
9083 * Returns a new empty instance of MEDFileFieldMultiTS.
9084 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9085 * is to delete this field using decrRef() as it is no more needed.
9087 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9089 return new MEDFileIntFieldMultiTS;
9093 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9094 * that has been read from a specified MED file.
9095 * \param [in] fileName - the name of the MED file to read.
9096 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9097 * is to delete this field using decrRef() as it is no more needed.
9098 * \throw If reading the file fails.
9100 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9102 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9103 ret->contentNotNull();//to check that content type matches with \a this type.
9108 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9109 * that has been read from a specified MED file.
9110 * \param [in] fileName - the name of the MED file to read.
9111 * \param [in] fieldName - the name of the field to read.
9112 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9113 * is to delete this field using decrRef() as it is no more needed.
9114 * \throw If reading the file fails.
9115 * \throw If there is no field named \a fieldName in the file.
9117 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9119 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9120 ret->contentNotNull();//to check that content type matches with \a this type.
9125 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9126 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9128 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9129 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9130 * \warning this is a shallow copy constructor
9131 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9132 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9133 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9134 * is to delete this field using decrRef() as it is no more needed.
9136 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9138 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9142 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9143 * following the given input policy.
9145 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9146 * By default (true) the globals are deeply copied.
9147 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9149 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9151 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9152 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9155 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9157 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9158 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9159 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9162 ret=MEDFileFieldMultiTS::New();
9164 ret->deepCpyGlobs(*this);
9166 ret->shallowCpyGlobs(*this);
9170 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9172 return new MEDFileIntFieldMultiTS(*this);
9175 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9178 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9179 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9181 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9185 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9186 * mesh entities of a given dimension of the first mesh in MED file.
9187 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9188 * \param [in] type - a spatial discretization of interest.
9189 * \param [in] iteration - the iteration number of a required time step.
9190 * \param [in] order - the iteration order number of required time step.
9191 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9192 * \param [out] arrOut - the DataArrayInt containing values of field.
9193 * \param [in] renumPol - specifies how to permute values of the result field according to
9194 * the optional numbers of cells and nodes, if any. The valid values are
9195 * - 0 - do not permute.
9196 * - 1 - permute cells.
9197 * - 2 - permute nodes.
9198 * - 3 - permute cells and nodes.
9200 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9201 * caller is to delete this field using decrRef() as it is no more needed.
9202 * \throw If the MED file is not readable.
9203 * \throw If there is no mesh in the MED file.
9204 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9205 * \throw If no field values of the required parameters are available.
9207 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9209 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9210 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9212 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9213 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9214 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9215 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9220 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9221 * the top level cells of the first mesh in MED file.
9222 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9223 * \param [in] type - a spatial discretization of interest.
9224 * \param [in] iteration - the iteration number of a required time step.
9225 * \param [in] order - the iteration order number of required time step.
9226 * \param [out] arrOut - the DataArrayInt containing values of field.
9227 * \param [in] renumPol - specifies how to permute values of the result field according to
9228 * the optional numbers of cells and nodes, if any. The valid values are
9229 * - 0 - do not permute.
9230 * - 1 - permute cells.
9231 * - 2 - permute nodes.
9232 * - 3 - permute cells and nodes.
9234 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9235 * caller is to delete this field using decrRef() as it is no more needed.
9236 * \throw If the MED file is not readable.
9237 * \throw If there is no mesh in the MED file.
9238 * \throw If no field values of the required parameters are available.
9240 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9242 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9243 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9245 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9246 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9247 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9248 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9253 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9255 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9256 * \param [in] type - a spatial discretization of interest.
9257 * \param [in] iteration - the iteration number of a required time step.
9258 * \param [in] order - the iteration order number of required time step.
9259 * \param [out] arrOut - the DataArrayInt containing values of field.
9260 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9261 * \param [in] mesh - the supporting mesh.
9262 * \param [in] renumPol - specifies how to permute values of the result field according to
9263 * the optional numbers of cells and nodes, if any. The valid values are
9264 * - 0 - do not permute.
9265 * - 1 - permute cells.
9266 * - 2 - permute nodes.
9267 * - 3 - permute cells and nodes.
9269 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9270 * caller is to delete this field using decrRef() as it is no more needed.
9271 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9272 * \throw If no field of \a this is lying on \a mesh.
9273 * \throw If no field values of the required parameters are available.
9275 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9277 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9278 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9280 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9281 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9282 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9283 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9288 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9290 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9291 * \param [in] type - a spatial discretization of the new field.
9292 * \param [in] iteration - the iteration number of a required time step.
9293 * \param [in] order - the iteration order number of required time step.
9294 * \param [in] mesh - the supporting mesh.
9295 * \param [out] arrOut - the DataArrayInt containing values of field.
9296 * \param [in] renumPol - specifies how to permute values of the result field according to
9297 * the optional numbers of cells and nodes, if any. The valid values are
9298 * - 0 - do not permute.
9299 * - 1 - permute cells.
9300 * - 2 - permute nodes.
9301 * - 3 - permute cells and nodes.
9303 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9304 * caller is to delete this field using decrRef() as it is no more needed.
9305 * \throw If no field of \a this is lying on \a mesh.
9306 * \throw If no field values of the required parameters are available.
9308 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9310 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9311 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9313 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9314 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9315 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9316 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9321 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9322 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9323 * This method is useful for MED2 file format when field on different mesh was autorized.
9325 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9327 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9328 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9330 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9331 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9332 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9333 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9338 * Returns values and a profile of the field of a given type, of a given time step,
9339 * lying on a given support.
9340 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9341 * \param [in] type - a spatial discretization of the field.
9342 * \param [in] iteration - the iteration number of a required time step.
9343 * \param [in] order - the iteration order number of required time step.
9344 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9345 * \param [in] mesh - the supporting mesh.
9346 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9347 * field of interest lies on. If the field lies on all entities of the given
9348 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9349 * using decrRef() as it is no more needed.
9350 * \param [in] glob - the global data storing profiles and localization.
9351 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9352 * field. The caller is to delete this array using decrRef() as it is no more needed.
9353 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9354 * \throw If no field of \a this is lying on \a mesh.
9355 * \throw If no field values of the required parameters are available.
9357 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9359 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9360 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9362 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9363 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9364 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9368 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9369 * \param [in] pos - a time step id.
9370 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9371 * delete this field using decrRef() as it is no more needed.
9372 * \throw If \a pos is not a valid time step id.
9374 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9376 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9379 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9380 throw INTERP_KERNEL::Exception(oss.str().c_str());
9382 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9385 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9386 ret->shallowCpyGlobs(*this);
9389 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9390 throw INTERP_KERNEL::Exception(oss.str().c_str());
9394 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9395 * the given field is checked if its elements are sorted suitable for writing to MED file
9396 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9397 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9398 * \param [in] field - the field to add to \a this.
9399 * \throw If the name of \a field is empty.
9400 * \throw If the data array of \a field is not set.
9401 * \throw If existing time steps have different name or number of components than \a field.
9402 * \throw If the underlying mesh of \a field has no name.
9403 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9405 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9407 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9411 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9412 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9413 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9416 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9417 * A new profile is added only if no equal profile is missing.
9418 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9419 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9420 * \param [in] arrOfVals - the values of the field \a field used.
9421 * \param [in] mesh - the supporting mesh of \a field.
9422 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9423 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9424 * \throw If either \a field or \a mesh or \a profile has an empty name.
9425 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9426 * \throw If the data array of \a field is not set.
9427 * \throw If the data array of \a this is already allocated but has different number of
9428 * components than \a field.
9429 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9430 * \sa setFieldNoProfileSBT()
9432 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9434 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9437 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9439 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9441 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9442 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9444 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 !");
9448 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9450 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9452 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9453 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9455 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 !");
9459 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9461 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9464 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9468 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9469 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9472 catch(INTERP_KERNEL::Exception& e)
9475 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9476 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9479 catch(INTERP_KERNEL::Exception& e)
9482 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9484 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9489 MEDFileFields *MEDFileFields::New()
9491 return new MEDFileFields;
9494 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9496 return new MEDFileFields(fileName,loadAll,0);
9499 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9501 return new MEDFileFields(fileName,loadAll,ms);
9504 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9506 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9507 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9511 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9513 std::vector<const BigMemoryObject *> ret;
9514 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9515 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9519 MEDFileFields *MEDFileFields::deepCpy() const
9521 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9523 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9525 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9526 ret->_fields[i]=(*it)->deepCpy();
9528 ret->deepCpyGlobs(*this);
9532 MEDFileFields *MEDFileFields::shallowCpy() const
9534 return new MEDFileFields(*this);
9538 * 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
9539 * 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.
9540 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9542 * \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.
9543 * \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.
9545 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9547 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9549 std::set< std::pair<int,int> > s;
9550 bool firstShot=true;
9551 areThereSomeForgottenTS=false;
9552 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9554 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9556 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9557 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9559 { s=s1; firstShot=false; }
9562 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9564 areThereSomeForgottenTS=true;
9568 std::vector< std::pair<int,int> > ret;
9569 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9573 int MEDFileFields::getNumberOfFields() const
9575 return _fields.size();
9578 std::vector<std::string> MEDFileFields::getFieldsNames() const
9580 std::vector<std::string> ret(_fields.size());
9582 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9584 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9587 ret[i]=f->getName();
9591 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9592 throw INTERP_KERNEL::Exception(oss.str().c_str());
9598 std::vector<std::string> MEDFileFields::getMeshesNames() const
9600 std::vector<std::string> ret;
9601 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9603 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9605 ret.push_back(cur->getMeshName());
9610 std::string MEDFileFields::simpleRepr() const
9612 std::ostringstream oss;
9613 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9618 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9620 int nbOfFields=getNumberOfFields();
9621 std::string startLine(bkOffset,' ');
9622 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9624 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9626 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9629 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9633 oss << startLine << " - not defined !" << std::endl;
9637 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9639 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9640 std::string chapter(17,'0'+i);
9641 oss << startLine << chapter << std::endl;
9644 cur->simpleRepr(bkOffset+2,oss,i);
9648 oss << startLine << " - not defined !" << std::endl;
9650 oss << startLine << chapter << std::endl;
9652 simpleReprGlobs(oss);
9655 MEDFileFields::MEDFileFields()
9659 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9660 try:MEDFileFieldGlobsReal(fileName)
9662 MEDFileUtilities::CheckFileForRead(fileName);
9663 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9664 int nbFields(MEDnField(fid));
9665 _fields.resize(nbFields);
9666 med_field_type typcha;
9667 for(int i=0;i<nbFields;i++)
9669 std::vector<std::string> infos;
9670 std::string fieldName,dtunit;
9671 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9676 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9681 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9686 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] !";
9687 throw INTERP_KERNEL::Exception(oss.str().c_str());
9691 loadAllGlobals(fid);
9693 catch(INTERP_KERNEL::Exception& e)
9698 void MEDFileFields::writeLL(med_idt fid) const
9701 writeGlobals(fid,*this);
9702 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9704 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9707 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9708 throw INTERP_KERNEL::Exception(oss.str().c_str());
9710 elt->writeLL(fid,*this);
9714 void MEDFileFields::write(const std::string& fileName, int mode) const
9716 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9717 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9722 * This method alloc the arrays and load potentially huge arrays contained in this field.
9723 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9724 * This method can be also called to refresh or reinit values from a file.
9726 * \throw If the fileName is not set or points to a non readable MED file.
9728 void MEDFileFields::loadArrays()
9730 if(getFileName().empty())
9731 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9732 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9733 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9735 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9737 elt->loadBigArraysRecursively(fid,*elt);
9742 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9743 * But once data loaded once, this method does nothing.
9745 * \throw If the fileName is not set or points to a non readable MED file.
9746 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9748 void MEDFileFields::loadArraysIfNecessary()
9750 if(!getFileName().empty())
9752 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9753 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9755 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9757 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9763 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9764 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9765 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9767 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9769 void MEDFileFields::unloadArrays()
9771 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9773 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9775 elt->unloadArrays();
9780 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
9781 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9782 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9784 * \sa MEDFileFields::loadArraysIfNecessary
9786 void MEDFileFields::unloadArraysWithoutDataLoss()
9788 if(!getFileName().empty())
9792 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9794 std::vector<std::string> ret;
9795 std::set<std::string> ret2;
9796 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9798 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9799 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9800 if(ret2.find(*it2)==ret2.end())
9802 ret.push_back(*it2);
9809 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9811 std::vector<std::string> ret;
9812 std::set<std::string> ret2;
9813 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9815 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9816 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9817 if(ret2.find(*it2)==ret2.end())
9819 ret.push_back(*it2);
9826 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9828 std::vector<std::string> ret;
9829 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9831 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9832 ret.insert(ret.end(),tmp.begin(),tmp.end());
9837 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9839 std::vector<std::string> ret;
9840 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9842 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9843 ret.insert(ret.end(),tmp.begin(),tmp.end());
9848 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9850 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9851 (*it)->changePflsRefsNamesGen2(mapOfModif);
9854 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9856 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9857 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9860 void MEDFileFields::resize(int newSize)
9862 _fields.resize(newSize);
9865 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9867 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9871 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9874 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9875 _fields.push_back(field->getContent());
9876 appendGlobs(*field,1e-12);
9879 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9882 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9883 if(i>=(int)_fields.size())
9884 _fields.resize(i+1);
9885 _fields[i]=field->getContent();
9886 appendGlobs(*field,1e-12);
9889 void MEDFileFields::destroyFieldAtPos(int i)
9891 destroyFieldsAtPos(&i,&i+1);
9894 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9896 std::vector<bool> b(_fields.size(),true);
9897 for(const int *i=startIds;i!=endIds;i++)
9899 if(*i<0 || *i>=(int)_fields.size())
9901 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9902 throw INTERP_KERNEL::Exception(oss.str().c_str());
9906 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9908 for(std::size_t i=0;i<_fields.size();i++)
9910 fields[j++]=_fields[i];
9914 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9916 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9917 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9918 std::vector<bool> b(_fields.size(),true);
9920 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9922 if(k<0 || k>=(int)_fields.size())
9924 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9925 throw INTERP_KERNEL::Exception(oss.str().c_str());
9929 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9931 for(std::size_t i=0;i<_fields.size();i++)
9933 fields[j++]=_fields[i];
9937 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9940 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9942 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9944 ret=cur->changeMeshNames(modifTab) || ret;
9950 * \param [in] meshName the name of the mesh that will be renumbered.
9951 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9952 * This code corresponds to the distribution of types in the corresponding mesh.
9953 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9954 * \param [in] renumO2N the old to new renumber array.
9955 * \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
9958 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9961 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9963 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9966 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9972 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9974 if(i<0 || i>=(int)_fields.size())
9976 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9977 throw INTERP_KERNEL::Exception(oss.str().c_str());
9979 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9982 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9983 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9984 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9986 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9988 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9991 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9992 throw INTERP_KERNEL::Exception(oss.str().c_str());
9994 ret->shallowCpyGlobs(*this);
9999 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10000 * This method is accessible in python using __getitem__ with a list in input.
10001 * \return a new object that the caller should deal with.
10003 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10005 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10006 std::size_t sz=std::distance(startIds,endIds);
10007 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10009 for(const int *i=startIds;i!=endIds;i++,j++)
10011 if(*i<0 || *i>=(int)_fields.size())
10013 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10014 throw INTERP_KERNEL::Exception(oss.str().c_str());
10016 fields[j]=_fields[*i];
10018 ret->_fields=fields;
10022 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10024 return getFieldAtPos(getPosFromFieldName(fieldName));
10028 * This method removes, if any, fields in \a this having no time steps.
10029 * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
10031 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10033 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10035 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10036 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10038 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10041 if(elt->getNumberOfTS()>0)
10042 newFields.push_back(*it);
10045 if(_fields.size()==newFields.size())
10052 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10053 * This method can be seen as a filter applied on \a this, that returns an object containing
10054 * 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
10055 * shallow copied from \a this.
10057 * \param [in] meshName - the name of the mesh on w
10058 * \return a new object that the caller should deal with.
10060 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10062 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10063 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10065 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10068 if(cur->getMeshName()==meshName)
10071 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10072 ret->_fields.push_back(cur2);
10075 ret->shallowCpyOnlyUsedGlobs(*this);
10080 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10081 * Input time steps are specified using a pair of integer (iteration, order).
10082 * 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,
10083 * but for each multitimestep only the time steps in \a timeSteps are kept.
10084 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10086 * The returned object points to shallow copy of elements in \a this.
10088 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10089 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10090 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10092 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10094 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10095 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10097 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10100 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10101 ret->_fields.push_back(elt);
10103 ret->shallowCpyOnlyUsedGlobs(*this);
10108 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10110 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10112 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10113 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10115 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10118 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10119 if(elt->getNumberOfTS()!=0)
10120 ret->_fields.push_back(elt);
10122 ret->shallowCpyOnlyUsedGlobs(*this);
10126 MEDFileFieldsIterator *MEDFileFields::iterator()
10128 return new MEDFileFieldsIterator(this);
10131 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10133 std::string tmp(fieldName);
10134 std::vector<std::string> poss;
10135 for(std::size_t i=0;i<_fields.size();i++)
10137 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10140 std::string fname(f->getName());
10144 poss.push_back(fname);
10147 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10148 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10150 throw INTERP_KERNEL::Exception(oss.str().c_str());
10153 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10158 _nb_iter=fs->getNumberOfFields();
10162 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10166 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10168 if(_iter_id<_nb_iter)
10170 MEDFileFields *fs(_fs);
10172 return fs->getFieldAtPos(_iter_id++);