1 // Copyright (C) 2007-2015 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 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
480 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
481 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
485 spd->getSlice(start,stop,step);
486 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
487 med_filter filter=MED_FILTER_INIT;
488 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
489 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
490 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
491 /*lastblocksize=useless because count=1*/0,&filter);
492 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr);
493 MEDfilterClose(&filter);
496 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
499 dpd->checkCoherency();
500 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myIds(dpd->toDAI());
501 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
502 myIds->applyLin(1,-a);
503 int nbOfEltsToLoad(b-a+1);
504 med_filter filter=MED_FILTER_INIT;
505 {//TODO : manage int32 !
506 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(DataArrayDouble::New());
507 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
508 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
509 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
510 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
511 /*lastblocksize=useless because count=1*/0,&filter);
512 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer()));
513 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> feeder(DataArrayDouble::New());
514 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
515 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
517 MEDfilterClose(&filter);
520 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
524 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
529 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
531 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
532 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533 std::string fieldName(nasc.getName()),meshName(getMeshName());
534 int iteration(getIteration()),order(getOrder());
535 TypeOfField type(getType());
536 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
538 med_geometry_type mgeoti;
539 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
540 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
541 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
542 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
543 const PartDefinition *pd(_pd);
550 if(!_profile.empty())
551 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
552 _nval=pd->getNumberOfElems();
555 _end=start+_nval*nbi;
557 if(type==ON_CELLS && !_localization.empty())
559 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
560 setType(ON_GAUSS_PT);
563 setType(ON_GAUSS_NE);
564 _localization.clear();
569 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
571 std::string fieldName(nasc.getName()),meshName(getMeshName());
572 int iteration(getIteration()),order(getOrder());
573 TypeOfField type(getType());
574 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
575 med_geometry_type mgeoti;
576 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
578 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
581 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
582 if(_start<0 || _start>=arr->getNumberOfTuples())
584 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
585 throw INTERP_KERNEL::Exception(oss.str().c_str());
587 if(_end<0 || _end>arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
590 throw INTERP_KERNEL::Exception(oss.str().c_str());
592 int nbOfCompo(arr->getNumberOfComponents());
593 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
596 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
597 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
600 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
603 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
604 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
607 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
611 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
613 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
615 int delta=_end-_start;
616 _start=newValueOfStart;
620 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
622 return _father->getIteration();
625 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
627 return _father->getOrder();
630 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
632 return _father->getTime();
635 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
637 return _father->getMeshName();
640 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
642 const char startLine[]=" ## ";
643 std::string startLine2(bkOffset,' ');
644 startLine2+=startLine;
645 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
646 oss << startLine2 << "Localization #" << id << "." << std::endl;
647 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
649 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
650 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
651 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
654 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
659 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
664 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
669 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
671 return _father->getGeoType();
674 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
676 return _father->getNumberOfComponents();
679 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
684 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
686 return _father->getOrCreateAndGetArray();
689 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
691 const MEDFileFieldPerMeshPerType *fath=_father;
692 return fath->getOrCreateAndGetArray();
695 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
697 return _father->getInfo();
700 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
705 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
710 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
712 return _localization;
715 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
717 _localization=newLocName;
720 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
722 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
724 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
726 _profile=(*it2).second;
732 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
734 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
736 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
738 _localization=(*it2).second;
744 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
748 dads.push_back(std::pair<int,int>(_start,_end));
749 geoTypes.push_back(getGeoType());
754 pfls.push_back(glob->getProfile(_profile.c_str()));
756 if(_localization.empty())
760 locs.push_back(glob->getLocalizationId(_localization.c_str()));
764 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
766 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));
770 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
772 TypeOfField type=getType();
773 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
774 med_geometry_type mgeoti;
775 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
776 const DataArray *arr=getOrCreateAndGetArray();
778 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
779 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
780 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
781 const unsigned char *locToWrite=0;
783 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
785 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
787 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
788 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
789 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
793 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
798 dad.first=_start; dad.second=_end;
802 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
803 * This code corresponds to the distribution of types in the corresponding mesh.
804 * \param [out] ptToFill memory zone where the output will be stored.
805 * \return the size of data pushed into output param \a ptToFill
807 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
810 std::ostringstream oss;
811 std::size_t nbOfType=codeOfMesh.size()/3;
813 for(std::size_t i=0;i<nbOfType && found==-1;i++)
814 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
818 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
819 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
820 throw INTERP_KERNEL::Exception(oss.str().c_str());
825 if(_nval!=codeOfMesh[3*found+1])
827 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
828 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
829 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
830 throw INTERP_KERNEL::Exception(oss.str().c_str());
832 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
837 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
838 if(pfl->getNumberOfTuples()!=_nval)
840 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
841 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
843 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
844 throw INTERP_KERNEL::Exception(oss.str().c_str());
846 int offset2=codeOfMesh[3*found+2];
847 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
849 if(*pflId<codeOfMesh[3*found+1])
850 *work++=offset2+*pflId;
856 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
858 for(int i=_start;i<_end;i++)
863 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
874 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
878 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
881 std::map<std::pair<std::string,TypeOfField>,int> m;
882 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
883 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
884 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
885 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
887 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
888 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
893 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
895 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
896 * \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.
897 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
898 * \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)
899 * \param [in,out] glob if necessary by the method, new profiles can be added to it
900 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
901 * \param [out] result All new entries will be appended on it.
902 * \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 !)
904 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
905 const DataArrayInt *explicitIdsInMesh,
906 const std::vector<int>& newCode,
907 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
908 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
910 if(entriesOnSameDisc.empty())
912 TypeOfField type=entriesOnSameDisc[0]->getType();
913 int szEntities=0,szTuples=0;
914 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
915 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
916 int nbi=szTuples/szEntities;
917 if(szTuples%szEntities!=0)
918 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
919 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
921 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
922 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
923 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
924 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
925 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
927 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
929 int startOfEltIdOfChunk=(*it)->_start;
930 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
931 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
932 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
934 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
935 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
937 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
938 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
940 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
941 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
942 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
943 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
945 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
947 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
948 arrPart->renumberInPlace(renumTupleIds->begin());
949 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
951 const int *idIt=diffVals->begin();
952 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
954 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
956 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
957 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
958 int nbEntityElts=subIds->getNumberOfTuples();
960 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
961 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
965 result.push_back(eltToAdd);
966 offset2+=nbEntityElts*nbi;
968 ret=ret || li.empty();
973 * \param [in] typeF type of field of new chunk
974 * \param [in] geoType the geometric type of the chunk
975 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
976 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
977 * \param [in] nbi number of integration points
978 * \param [in] offset The offset in the **global array of data**.
979 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
980 * to the new chunk to create.
981 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
982 * \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
983 * and corresponding entry erased from \a entriesOnSameDisc.
984 * \return a newly allocated chunk
986 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
987 bool isPfl, int nbi, int offset,
988 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
989 MEDFileFieldGlobsReal& glob,
992 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
993 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
994 for(;it!=entriesOnSameDisc.end();it++)
996 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1000 if((*it)->_profile.empty())
1003 if(!(*it)->_profile.empty())
1005 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1006 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1012 if(it==entriesOnSameDisc.end())
1015 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1017 ret->_loc_id=(int)geoType;
1018 ret->_nval=nbMeshEntities;
1020 ret->_end=ret->_start+ret->_nval*nbi;
1023 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1024 glob.appendProfile(idsOfMeshElt);
1025 ret->_profile=idsOfMeshElt->getName();
1027 //tony treatment of localization
1032 notInExisting=false;
1033 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1034 ret->_loc_id=(int)geoType;
1035 ret->setNewStart(offset);
1036 entriesOnSameDisc.erase(it);
1042 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1044 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1049 return new MEDFileFieldPerMeshPerType(fath,geoType);
1052 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1054 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1057 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1059 std::vector<const BigMemoryObject *> ret;
1060 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1061 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1065 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1067 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1068 ret->_father=father;
1070 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1072 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1073 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1078 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1080 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1081 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1082 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1086 * This method is the most general one. No optimization is done here.
1087 * \param [in] multiTypePfl is the end user profile specified in high level API
1088 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1089 * \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.
1090 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1091 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1092 * \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.
1094 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)
1096 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1097 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1098 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1101 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1103 _field_pm_pt_pd.resize(1);
1104 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1105 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1108 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1110 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1111 if(!arr || !arr->isAllocated())
1112 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1113 _field_pm_pt_pd.resize(1);
1114 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1115 _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.
1118 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1120 TypeOfField type=field->getTypeOfField();
1121 if(type!=ON_GAUSS_PT)
1123 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1124 int sz=_field_pm_pt_pd.size();
1126 for(int j=0;j<sz && !found;j++)
1128 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1130 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136 _field_pm_pt_pd.resize(sz+1);
1137 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1139 std::vector<int> ret(1,(int)sz);
1144 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1145 int sz2=ret2.size();
1146 std::vector<int> ret3(sz2);
1148 for(int i=0;i<sz2;i++)
1150 int sz=_field_pm_pt_pd.size();
1151 int locIdToFind=ret2[i];
1153 for(int j=0;j<sz && !found;j++)
1155 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1157 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1164 _field_pm_pt_pd.resize(sz+1);
1165 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1173 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1175 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1176 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1178 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1179 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1181 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1182 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1183 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1184 if(retTmp->presenceOfValue(-1))
1185 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1186 std::vector<int> ret(retTmp->begin(),retTmp->end());
1190 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1192 TypeOfField type=field->getTypeOfField();
1193 if(type!=ON_GAUSS_PT)
1195 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1196 int sz=_field_pm_pt_pd.size();
1198 for(int j=0;j<sz && !found;j++)
1200 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1202 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208 _field_pm_pt_pd.resize(sz+1);
1209 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1211 std::vector<int> ret(1,0);
1216 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1217 int sz2=ret2.size();
1218 std::vector<int> ret3(sz2);
1220 for(int i=0;i<sz2;i++)
1222 int sz=_field_pm_pt_pd.size();
1223 int locIdToFind=ret2[i];
1225 for(int j=0;j<sz && !found;j++)
1227 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1229 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1236 _field_pm_pt_pd.resize(sz+1);
1237 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1245 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1247 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1248 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1250 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1251 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1253 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1254 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1255 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1256 if(retTmp->presenceOfValue(-1))
1257 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1258 std::vector<int> ret(retTmp->begin(),retTmp->end());
1262 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1267 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1269 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1270 int curDim=(int)cm.getDimension();
1271 dim=std::max(dim,curDim);
1274 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1276 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1278 (*it)->fillTypesOfFieldAvailable(types);
1282 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
1284 int sz=_field_pm_pt_pd.size();
1285 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1286 for(int i=0;i<sz;i++)
1288 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1292 int MEDFileFieldPerMeshPerType::getIteration() const
1294 return _father->getIteration();
1297 int MEDFileFieldPerMeshPerType::getOrder() const
1299 return _father->getOrder();
1302 double MEDFileFieldPerMeshPerType::getTime() const
1304 return _father->getTime();
1307 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1309 return _father->getMeshName();
1312 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1314 const char startLine[]=" ## ";
1315 std::string startLine2(bkOffset,' ');
1316 std::string startLine3(startLine2);
1317 startLine3+=startLine;
1318 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1320 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1321 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1324 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1325 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1329 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1331 cur->simpleRepr(bkOffset,oss,i);
1334 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1339 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1341 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 globalSz+=(*it)->getNumberOfTuples();
1345 nbOfEntries+=(int)_field_pm_pt_pd.size();
1348 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1354 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1356 return _father->getNumberOfComponents();
1359 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1362 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1364 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1371 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1373 return _father->getOrCreateAndGetArray();
1376 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1378 const MEDFileFieldPerMesh *fath=_father;
1379 return fath->getOrCreateAndGetArray();
1382 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1384 return _father->getInfo();
1387 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1389 std::vector<std::string> ret;
1390 std::set<std::string> ret2;
1391 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1393 std::string tmp=(*it1)->getProfile();
1395 if(ret2.find(tmp)==ret2.end())
1404 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1406 std::vector<std::string> ret;
1407 std::set<std::string> ret2;
1408 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1410 std::string tmp=(*it1)->getLocalization();
1411 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1412 if(ret2.find(tmp)==ret2.end())
1421 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1423 std::vector<std::string> ret;
1424 std::set<std::string> ret2;
1425 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1427 std::string tmp=(*it1)->getProfile();
1434 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1436 std::vector<std::string> ret;
1437 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1439 std::string tmp=(*it1)->getLocalization();
1440 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1446 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1448 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1449 (*it1)->changePflsRefsNamesGen(mapOfModif);
1452 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1454 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1455 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1458 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1460 if(_field_pm_pt_pd.empty())
1462 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1463 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1464 throw INTERP_KERNEL::Exception(oss.str().c_str());
1466 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1467 return _field_pm_pt_pd[locId];
1468 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1469 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1470 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1471 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1472 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1475 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1477 if(_field_pm_pt_pd.empty())
1479 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1480 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1481 throw INTERP_KERNEL::Exception(oss.str().c_str());
1483 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1484 return _field_pm_pt_pd[locId];
1485 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1486 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1487 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1488 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1489 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1492 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
1494 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1496 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1497 if(meshDim!=(int)cm.getDimension())
1500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1501 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1504 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1507 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1509 (*it)->fillValues(i,startEntryId,entries);
1513 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1515 _field_pm_pt_pd=leaves;
1516 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1517 (*it)->setFather(this);
1521 * \param [in,out] globalNum a global numbering counter for the renumbering.
1522 * \param [out] its - list of pair (start,stop) kept
1523 * \return bool - false if the type of field \a tof is not contained in \a this.
1525 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1528 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1529 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530 if((*it)->getType()==tof)
1532 newPmPtPd.push_back(*it);
1533 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1534 (*it)->setNewStart(globalNum);
1535 globalNum=(*it)->getEnd();
1536 its.push_back(bgEnd);
1540 _field_pm_pt_pd=newPmPtPd;
1545 * \param [in,out] globalNum a global numbering counter for the renumbering.
1546 * \param [out] its - list of pair (start,stop) kept
1547 * \return bool - false if the type of field \a tof is not contained in \a this.
1549 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1551 if(_field_pm_pt_pd.size()<=idOfDisc)
1553 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1554 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1555 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1556 elt->setNewStart(globalNum);
1557 globalNum=elt->getEnd();
1558 its.push_back(bgEnd);
1559 _field_pm_pt_pd=newPmPtPd;
1563 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1567 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1569 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1570 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571 med_geometry_type mgeoti;
1572 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1573 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1574 _field_pm_pt_pd.resize(nbProfiles);
1575 for(int i=0;i<nbProfiles;i++)
1577 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1581 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1582 for(int i=0;i<nbProfiles2;i++)
1583 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1587 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1589 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1590 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1593 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1595 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1596 (*it)->loadBigArray(fid,nasc);
1599 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1601 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1603 (*it)->copyOptionsFrom(*this);
1604 (*it)->writeLL(fid,nasc);
1608 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1613 medfGeoType=typmai3[(int)ikGeoType];
1616 medfGeoType=MED_NONE;
1619 medfGeoType=typmai3[(int)ikGeoType];
1620 return MED_NODE_ELEMENT;
1622 medfGeoType=typmai3[(int)ikGeoType];
1625 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1627 return MED_UNDEF_ENTITY_TYPE;
1630 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1632 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1635 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1637 return new MEDFileFieldPerMesh(fath,mesh);
1640 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1642 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1645 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1647 std::vector<const BigMemoryObject *> ret;
1648 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1649 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1653 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1655 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1656 ret->_father=father;
1658 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1660 if((const MEDFileFieldPerMeshPerType *)*it)
1661 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1666 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1668 std::string startLine(bkOffset,' ');
1669 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1670 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1672 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1674 const MEDFileFieldPerMeshPerType *cur=*it;
1676 cur->simpleRepr(bkOffset,oss,i);
1679 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1684 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1686 _mesh_name=mesh->getName();
1687 mesh->getTime(_mesh_iteration,_mesh_order);
1690 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1692 int nbOfTypes=code.size()/3;
1694 for(int i=0;i<nbOfTypes;i++)
1696 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1697 int nbOfCells=code[3*i+1];
1698 int pos=addNewEntryIfNecessary(type);
1699 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1705 * This method is the most general one. No optimization is done here.
1706 * \param [in] multiTypePfl is the end user profile specified in high level API
1707 * \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].
1708 * \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.
1709 * \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.
1710 * \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.
1711 * \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.
1713 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)
1715 int nbOfTypes(code.size()/3);
1716 for(int i=0;i<nbOfTypes;i++)
1718 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1719 int pos=addNewEntryIfNecessary(type);
1720 DataArrayInt *pfl=0;
1722 pfl=idsPerType[code[3*i+2]];
1723 int nbOfTupes2=code2.size()/3;
1725 for(;found<nbOfTupes2;found++)
1726 if(code[3*i]==code2[3*found])
1728 if(found==nbOfTupes2)
1729 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1730 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1734 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1736 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1737 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1740 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1742 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1743 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1746 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1748 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1749 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1752 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1754 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1755 (*it)->loadBigArraysRecursively(fid,nasc);
1758 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1760 int nbOfTypes=_field_pm_pt.size();
1761 for(int i=0;i<nbOfTypes;i++)
1763 _field_pm_pt[i]->copyOptionsFrom(*this);
1764 _field_pm_pt[i]->writeLL(fid,nasc);
1768 void MEDFileFieldPerMesh::getDimension(int& dim) const
1770 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1771 (*it)->getDimension(dim);
1774 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1776 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1777 (*it)->fillTypesOfFieldAvailable(types);
1780 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
1782 int sz=_field_pm_pt.size();
1783 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1784 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1785 for(int i=0;i<sz;i++)
1787 types[i]=_field_pm_pt[i]->getGeoType();
1788 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1793 double MEDFileFieldPerMesh::getTime() const
1796 return _father->getTime(tmp1,tmp2);
1799 int MEDFileFieldPerMesh::getIteration() const
1801 return _father->getIteration();
1804 int MEDFileFieldPerMesh::getOrder() const
1806 return _father->getOrder();
1809 int MEDFileFieldPerMesh::getNumberOfComponents() const
1811 return _father->getNumberOfComponents();
1814 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1816 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1818 const MEDFileFieldPerMeshPerType *fpmt(*it);
1821 if(fpmt->presenceOfMultiDiscPerGeoType())
1827 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1830 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1831 return _father->getOrCreateAndGetArray();
1834 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1837 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1838 return _father->getOrCreateAndGetArray();
1841 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1843 return _father->getInfo();
1847 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1848 * 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.
1849 * It returns 2 output vectors :
1850 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1851 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1852 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1854 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)
1856 int notNullPflsSz=0;
1857 int nbOfArrs=geoTypes.size();
1858 for(int i=0;i<nbOfArrs;i++)
1861 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1862 int nbOfDiffGeoTypes=geoTypes3.size();
1863 code.resize(3*nbOfDiffGeoTypes);
1864 notNullPfls.resize(notNullPflsSz);
1867 for(int i=0;i<nbOfDiffGeoTypes;i++)
1870 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1871 std::vector<const DataArrayInt *> notNullTmp;
1873 notNullTmp.push_back(pfls[j]);
1875 for(;j<nbOfArrs;j++)
1876 if(geoTypes[j]==refType)
1879 notNullTmp.push_back(pfls[j]);
1883 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1884 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1885 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1886 code[3*i]=(int)refType;
1887 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1888 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1889 if(notNullTmp.empty())
1893 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1894 code[3*i+2]=notNullPflsSz++;
1900 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1902 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)
1906 for(int i=0;i<sz;i++)
1910 if(type!=ON_GAUSS_NE)
1911 ret+=dads[i].second-dads[i].first;
1914 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1915 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1920 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1921 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1927 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1929 std::vector<std::string> ret;
1930 std::set<std::string> ret2;
1931 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1934 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1935 if(ret2.find(*it2)==ret2.end())
1937 ret.push_back(*it2);
1944 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1946 std::vector<std::string> ret;
1947 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1949 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1950 ret.insert(ret.end(),tmp.begin(),tmp.end());
1955 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1957 std::vector<std::string> ret;
1958 std::set<std::string> ret2;
1959 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1961 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1962 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1963 if(ret2.find(*it2)==ret2.end())
1965 ret.push_back(*it2);
1972 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1974 std::vector<std::string> ret;
1975 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1977 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1978 ret.insert(ret.end(),tmp.begin(),tmp.end());
1983 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1985 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1987 if((*it).first==_mesh_name)
1989 _mesh_name=(*it).second;
1996 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1997 MEDFileFieldGlobsReal& glob)
1999 if(_mesh_name!=meshName)
2001 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2002 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2003 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2004 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2005 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2006 getUndergroundDataArrayExt(entries);
2007 DataArray *arr0=getOrCreateAndGetArray();//tony
2009 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2010 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2012 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2015 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2016 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2018 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2020 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2021 sz+=(*it).second.second-(*it).second.first;
2024 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2026 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2027 ////////////////////
2028 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2029 int *workI2=explicitIdsOldInMesh->getPointer();
2030 int sz1=0,sz2=0,sid=1;
2031 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2032 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2033 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2035 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2036 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2037 int *workI=explicitIdsOldInArr->getPointer();
2038 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2040 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2041 (*itL2)->setLocId(sz2);
2042 (*itL2)->_tmp_work1=(*itL2)->getStart();
2043 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2045 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2047 explicitIdsOldInMesh->reAlloc(sz2);
2048 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2049 ////////////////////
2050 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2051 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2052 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2053 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2055 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2056 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2057 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2059 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2060 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2061 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2063 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2064 int newStart=elt->getLocId();
2065 elt->setLocId((*it)->getGeoType());
2066 elt->setNewStart(newStart);
2067 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2068 entriesKeptNew.push_back(elt);
2069 entriesKeptNew2.push_back(elt);
2071 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2072 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2073 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2074 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2076 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2079 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2081 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2082 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2084 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2085 glob,arr2,otherEntriesNew) || ret;
2089 // Assign new dispatching
2090 assignNewLeaves(otherEntriesNew);
2091 arr->cpyFrom(*arr2);
2096 * \param [in,out] globalNum a global numbering counter for the renumbering.
2097 * \param [out] its - list of pair (start,stop) kept
2099 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2101 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2102 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2104 std::vector< std::pair<int,int> > its2;
2105 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2108 its.insert(its.end(),its2.begin(),its2.end());
2115 * \param [in,out] globalNum a global numbering counter for the renumbering.
2116 * \param [out] its - list of pair (start,stop) kept
2118 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2120 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2121 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123 std::vector< std::pair<int,int> > its2;
2124 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2127 its.insert(its.end(),its2.begin(),its2.end());
2133 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2135 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2136 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2137 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2139 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2140 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2141 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2142 for(;it1!=types.end();it1++,it2++)
2144 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2145 elt->setLeaves((*it1).second);
2148 _field_pm_pt=fieldPmPt;
2151 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2153 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2154 (*it)->changePflsRefsNamesGen(mapOfModif);
2157 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2159 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2160 (*it)->changeLocsRefsNamesGen(mapOfModif);
2164 * \param [in] mesh is the whole mesh
2166 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2168 if(_field_pm_pt.empty())
2169 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2171 std::vector< std::pair<int,int> > dads;
2172 std::vector<const DataArrayInt *> pfls;
2173 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2174 std::vector<int> locs,code;
2175 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2176 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2177 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2179 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2182 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2183 throw INTERP_KERNEL::Exception(oss.str().c_str());
2186 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2187 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2190 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2192 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2195 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2196 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2202 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2206 if(nb!=mesh->getNumberOfNodes())
2208 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2209 oss << " nodes in mesh !";
2210 throw INTERP_KERNEL::Exception(oss.str().c_str());
2212 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2215 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2219 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2221 if(_field_pm_pt.empty())
2222 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2224 std::vector<std::pair<int,int> > dads;
2225 std::vector<const DataArrayInt *> pfls;
2226 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2227 std::vector<int> locs,code;
2228 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2229 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2230 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2232 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2235 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2236 throw INTERP_KERNEL::Exception(oss.str().c_str());
2238 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2239 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2243 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2248 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2252 if(nb!=mesh->getNumberOfNodes())
2254 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2255 oss << " nodes in mesh !";
2256 throw INTERP_KERNEL::Exception(oss.str().c_str());
2259 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2265 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2269 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2271 (*it)->getSizes(globalSz,nbOfEntries);
2273 entries.resize(nbOfEntries);
2275 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2277 (*it)->fillValues(nbOfEntries,entries);
2281 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2283 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2285 if((*it)->getGeoType()==typ)
2286 return (*it)->getLeafGivenLocId(locId);
2288 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2289 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2290 oss << "Possiblities are : ";
2291 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2293 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2294 oss << "\"" << cm2.getRepr() << "\", ";
2296 throw INTERP_KERNEL::Exception(oss.str().c_str());
2299 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2301 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303 if((*it)->getGeoType()==typ)
2304 return (*it)->getLeafGivenLocId(locId);
2306 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2307 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2308 oss << "Possiblities are : ";
2309 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2312 oss << "\"" << cm2.getRepr() << "\", ";
2314 throw INTERP_KERNEL::Exception(oss.str().c_str());
2317 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2320 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2321 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2322 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2324 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2329 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2334 int ret=std::distance(_field_pm_pt.begin(),it2);
2335 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2340 * 'dads' and 'locs' input parameters have the same number of elements
2341 * \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
2343 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2344 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2345 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2349 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2350 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2351 const std::vector<std::string>& infos=getInfo();
2352 da->setInfoOnComponents(infos);
2354 if(type==ON_GAUSS_PT)
2357 int nbOfArrs=dads.size();
2358 for(int i=0;i<nbOfArrs;i++)
2360 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2361 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2362 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2363 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2364 di->alloc(nbOfElems,1);
2366 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2367 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2376 * 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.
2377 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2378 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2379 * The order of cells in the returned field is those imposed by the profile.
2380 * \param [in] mesh is the global mesh.
2382 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2383 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2384 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2385 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2387 if(da->isIdentity())
2389 int nbOfTuples=da->getNumberOfTuples();
2390 if(nbOfTuples==mesh->getNumberOfCells())
2391 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2393 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2394 m2->setName(mesh->getName().c_str());
2395 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2401 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2403 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2404 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2405 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2407 if(da->isIdentity())
2409 int nbOfTuples=da->getNumberOfTuples();
2410 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2411 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2413 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2414 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2417 if(meshu->getNodalConnectivity()==0)
2419 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2420 int nb=da->getNbOfElems();
2421 const int *ptr=da->getConstPointer();
2422 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2423 meshuc->allocateCells(nb);
2424 for(int i=0;i<nb;i++)
2425 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2426 meshuc->finishInsertingCells();
2427 ret->setMesh(meshuc);
2428 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2429 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2430 disc->checkCoherencyBetween(meshuc,arrOut);
2435 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2437 DataArrayInt *arr2=0;
2438 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2439 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2440 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2441 int nnodes=mesh2->getNumberOfNodes();
2442 if(nnodes==(int)da->getNbOfElems())
2444 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2445 arrOut->renumberInPlace(da3->getConstPointer());
2446 mesh2->setName(mesh->getName().c_str());
2447 ret->setMesh(mesh2);
2452 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 !!!";
2453 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2454 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2455 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2456 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2457 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2458 throw INTERP_KERNEL::Exception(oss.str().c_str());
2464 * This method is the most light method of field retrieving.
2466 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2470 pflOut=DataArrayInt::New();
2471 pflOut->alloc(nbOfElems,1);
2476 pflOut=const_cast<DataArrayInt*>(pflIn);
2479 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2480 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2481 const std::vector<std::string>& infos=getInfo();
2482 int nbOfComp=infos.size();
2483 for(int i=0;i<nbOfComp;i++)
2484 da->setInfoOnComponent(i,infos[i].c_str());
2489 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),
2492 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2493 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2494 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2495 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2496 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2498 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2499 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2500 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2501 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2502 if(nbProfile>0 || nbProfile2>0)
2504 const PartDefinition *pd(0);
2506 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2507 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2514 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2517 const PartDefinition *pd(0);
2519 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2520 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2521 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2525 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2527 copyTinyInfoFrom(mesh);
2530 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2532 if(id>=(int)_pfls.size())
2534 _pfls[id]=DataArrayInt::New();
2535 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2536 _pfls[id]->setName(pflName);
2537 _pfls[id]->alloc(lgth,1);
2538 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2539 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2542 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2544 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2546 MEDprofileInfo(fid,i+1,pflName,&sz);
2547 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2548 if(i>=(int)_pfls.size())
2550 _pfls[i]=DataArrayInt::New();
2551 _pfls[i]->alloc(sz,1);
2552 _pfls[i]->setName(pflCpp.c_str());
2553 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2554 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2557 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2559 int nbOfPfls=_pfls.size();
2560 for(int i=0;i<nbOfPfls;i++)
2562 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2563 cpy->applyLin(1,1,0);
2564 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2565 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2566 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2569 int nbOfLocs=_locs.size();
2570 for(int i=0;i<nbOfLocs;i++)
2571 _locs[i]->writeLL(fid);
2574 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2576 std::vector<std::string> pfls=getPfls();
2577 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2579 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2582 _pfls.push_back(*it);
2586 int id=std::distance(pfls.begin(),it2);
2587 if(!(*it)->isEqual(*_pfls[id]))
2589 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2590 throw INTERP_KERNEL::Exception(oss.str().c_str());
2594 std::vector<std::string> locs=getLocs();
2595 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2597 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2600 _locs.push_back(*it);
2604 int id=std::distance(locs.begin(),it2);
2605 if(!(*it)->isEqual(*_locs[id],eps))
2607 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2608 throw INTERP_KERNEL::Exception(oss.str().c_str());
2614 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2616 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2617 getProfile((*it).c_str());
2620 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2622 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2623 getLocalization((*it).c_str());
2626 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2628 std::vector<std::string> profiles=real.getPflsReallyUsed();
2629 int sz=profiles.size();
2631 for(int i=0;i<sz;i++)
2632 loadProfileInFile(fid,i,profiles[i].c_str());
2634 std::vector<std::string> locs=real.getLocsReallyUsed();
2637 for(int i=0;i<sz;i++)
2638 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2641 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2643 int nProfil=MEDnProfile(fid);
2644 for(int i=0;i<nProfil;i++)
2645 loadProfileInFile(fid,i);
2646 int sz=MEDnLocalization(fid);
2648 for(int i=0;i<sz;i++)
2650 _locs[i]=MEDFileFieldLoc::New(fid,i);
2654 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2656 return new MEDFileFieldGlobs(fname);
2659 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2661 return new MEDFileFieldGlobs;
2664 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2666 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2669 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2671 std::vector<const BigMemoryObject *> ret;
2672 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2673 ret.push_back((const DataArrayInt *)*it);
2674 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2675 ret.push_back((const MEDFileFieldLoc *)*it);
2679 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2681 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2683 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2685 if((const DataArrayInt *)*it)
2686 ret->_pfls[i]=(*it)->deepCpy();
2689 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2691 if((const MEDFileFieldLoc*)*it)
2692 ret->_locs[i]=(*it)->deepCpy();
2698 * \throw if a profile in \a pfls in not in \a this.
2699 * \throw if a localization in \a locs in not in \a this.
2700 * \sa MEDFileFieldGlobs::deepCpyPart
2702 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2704 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2705 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2707 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2709 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2711 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2712 ret->_pfls.push_back(pfl2);
2714 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2716 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2718 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2720 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2721 ret->_locs.push_back(loc2);
2723 ret->setFileName(getFileName());
2728 * \throw if a profile in \a pfls in not in \a this.
2729 * \throw if a localization in \a locs in not in \a this.
2730 * \sa MEDFileFieldGlobs::shallowCpyPart
2732 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2734 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2735 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2737 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2739 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2740 ret->_pfls.push_back(pfl->deepCpy());
2742 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2744 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2746 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2747 ret->_locs.push_back(loc->deepCpy());
2749 ret->setFileName(getFileName());
2753 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2757 MEDFileFieldGlobs::MEDFileFieldGlobs()
2761 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2765 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2767 oss << "Profiles :\n";
2768 std::size_t n=_pfls.size();
2769 for(std::size_t i=0;i<n;i++)
2771 oss << " - #" << i << " ";
2772 const DataArrayInt *pfl=_pfls[i];
2774 oss << "\"" << pfl->getName() << "\"\n";
2779 oss << "Localizations :\n";
2780 for(std::size_t i=0;i<n;i++)
2782 oss << " - #" << i << " ";
2783 const MEDFileFieldLoc *loc=_locs[i];
2785 loc->simpleRepr(oss);
2791 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2793 _file_name=fileName;
2796 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2798 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2800 DataArrayInt *elt(*it);
2803 std::string name(elt->getName());
2804 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2806 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2808 elt->setName((*it2).second.c_str());
2816 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2818 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2820 MEDFileFieldLoc *elt(*it);
2823 std::string name(elt->getName());
2824 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2826 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2828 elt->setName((*it2).second.c_str());
2836 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2838 if(locId<0 || locId>=(int)_locs.size())
2839 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2840 return _locs[locId]->getNbOfGaussPtPerCell();
2843 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2845 return getLocalizationFromId(getLocalizationId(locName));
2848 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2850 if(locId<0 || locId>=(int)_locs.size())
2851 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2852 return *_locs[locId];
2855 namespace ParaMEDMEMImpl
2860 LocFinder(const std::string& loc):_loc(loc) { }
2861 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2863 const std::string &_loc;
2869 PflFinder(const std::string& pfl):_pfl(pfl) { }
2870 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2872 const std::string& _pfl;
2876 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2878 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2881 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2882 for(it=_locs.begin();it!=_locs.end();it++)
2883 oss << "\"" << (*it)->getName() << "\", ";
2884 throw INTERP_KERNEL::Exception(oss.str().c_str());
2886 return std::distance(_locs.begin(),it);
2890 * The returned value is never null.
2892 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2894 std::string pflNameCpp(pflName);
2895 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2898 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2899 for(it=_pfls.begin();it!=_pfls.end();it++)
2900 oss << "\"" << (*it)->getName() << "\", ";
2901 throw INTERP_KERNEL::Exception(oss.str().c_str());
2906 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2908 if(pflId<0 || pflId>=(int)_pfls.size())
2909 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2910 return _pfls[pflId];
2913 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2915 if(locId<0 || locId>=(int)_locs.size())
2916 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2917 return *_locs[locId];
2920 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2922 return getLocalizationFromId(getLocalizationId(locName));
2926 * The returned value is never null.
2928 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2930 std::string pflNameCpp(pflName);
2931 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2934 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2935 for(it=_pfls.begin();it!=_pfls.end();it++)
2936 oss << "\"" << (*it)->getName() << "\", ";
2937 throw INTERP_KERNEL::Exception(oss.str().c_str());
2942 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2944 if(pflId<0 || pflId>=(int)_pfls.size())
2945 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2946 return _pfls[pflId];
2949 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2951 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2953 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2955 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2956 newPfls.push_back(*it);
2961 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2963 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2965 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2967 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2968 newLocs.push_back(*it);
2973 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2975 int sz=_pfls.size();
2976 std::vector<std::string> ret(sz);
2977 for(int i=0;i<sz;i++)
2978 ret[i]=_pfls[i]->getName();
2982 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2984 int sz=_locs.size();
2985 std::vector<std::string> ret(sz);
2986 for(int i=0;i<sz;i++)
2987 ret[i]=_locs[i]->getName();
2991 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2993 std::vector<std::string> v=getPfls();
2994 std::string s(pflName);
2995 return std::find(v.begin(),v.end(),s)!=v.end();
2998 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3000 std::vector<std::string> v=getLocs();
3001 std::string s(locName);
3002 return std::find(v.begin(),v.end(),s)!=v.end();
3005 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3007 std::map<int,std::vector<int> > m;
3009 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3011 const DataArrayInt *tmp=(*it);
3014 m[tmp->getHashCode()].push_back(i);
3017 std::vector< std::vector<int> > ret;
3018 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3020 if((*it2).second.size()>1)
3022 std::vector<int> ret0;
3023 bool equalityOrNot=false;
3024 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3026 std::vector<int>::const_iterator it4=it3; it4++;
3027 for(;it4!=(*it2).second.end();it4++)
3029 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3032 ret0.push_back(*it3);
3033 ret0.push_back(*it4);
3039 ret.push_back(ret0);
3045 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3047 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3050 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3052 std::string name(pfl->getName());
3054 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3055 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3056 if(name==(*it)->getName())
3058 if(!pfl->isEqual(*(*it)))
3060 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3061 throw INTERP_KERNEL::Exception(oss.str().c_str());
3065 _pfls.push_back(pfl);
3068 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)
3070 std::string name(locName);
3072 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3073 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3074 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3075 if((*it)->isName(locName))
3077 if(!(*it)->isEqual(*obj,1e-12))
3079 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3080 throw INTERP_KERNEL::Exception(oss.str().c_str());
3083 _locs.push_back(obj);
3086 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3088 std::vector<std::string> names=getPfls();
3089 return CreateNewNameNotIn("NewPfl_",names);
3092 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3094 std::vector<std::string> names=getLocs();
3095 return CreateNewNameNotIn("NewLoc_",names);
3098 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3100 for(std::size_t sz=0;sz<100000;sz++)
3102 std::ostringstream tryName;
3103 tryName << prefix << sz;
3104 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3105 return tryName.str();
3107 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3111 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3112 * \param [in] fname - the file name.
3114 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3119 * Creates an empty MEDFileFieldGlobsReal.
3121 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3125 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3130 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3132 std::vector<const BigMemoryObject *> ret;
3133 ret.push_back((const MEDFileFieldGlobs *)_globals);
3138 * Returns a string describing profiles and Gauss points held in \a this.
3139 * \return std::string - the description string.
3141 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3143 const MEDFileFieldGlobs *glob=_globals;
3144 std::ostringstream oss2; oss2 << glob;
3145 std::string stars(oss2.str().length(),'*');
3146 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3148 glob->simpleRepr(oss);
3150 oss << "NO GLOBAL INFORMATION !\n";
3153 void MEDFileFieldGlobsReal::resetContent()
3155 _globals=MEDFileFieldGlobs::New();
3158 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3163 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3164 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3166 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3168 _globals=other._globals;
3172 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3173 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3175 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3177 const MEDFileFieldGlobs *otherg(other._globals);
3180 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3184 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3185 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3187 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3189 const MEDFileFieldGlobs *otherg(other._globals);
3192 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3195 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3197 _globals=other._globals;
3198 if((const MEDFileFieldGlobs *)_globals)
3199 _globals=other._globals->deepCpy();
3203 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3204 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3205 * \param [in] eps - a precision used to compare Gauss points with same name held by
3206 * \a this and \a other MEDFileFieldGlobsReal.
3207 * \throw If \a this and \a other hold profiles with equal names but different ids.
3208 * \throw If \a this and \a other hold different Gauss points with equal names.
3210 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3212 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3213 if(thisGlobals==otherGlobals)
3217 _globals=other._globals;
3220 _globals->appendGlobs(*other._globals,eps);
3223 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3225 checkGlobsPflsPartCoherency();
3226 checkGlobsLocsPartCoherency();
3229 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3231 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3234 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3236 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3239 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3241 contentNotNull()->loadProfileInFile(fid,id,pflName);
3244 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3246 contentNotNull()->loadProfileInFile(fid,id);
3249 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3251 contentNotNull()->loadGlobals(fid,*this);
3254 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3256 contentNotNull()->loadAllGlobals(fid);
3259 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3261 contentNotNull()->writeGlobals(fid,opt);
3265 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3266 * or getPflsReallyUsedMulti().
3267 * \return std::vector<std::string> - a sequence of names of all profiles.
3269 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3271 return contentNotNull()->getPfls();
3275 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3276 * or getLocsReallyUsedMulti().
3277 * \return std::vector<std::string> - a sequence of names of all localizations.
3279 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3281 return contentNotNull()->getLocs();
3285 * Checks if the profile with a given name exists.
3286 * \param [in] pflName - the profile name of interest.
3287 * \return bool - \c true if the profile named \a pflName exists.
3289 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3291 return contentNotNull()->existsPfl(pflName);
3295 * Checks if the localization with a given name exists.
3296 * \param [in] locName - the localization name of interest.
3297 * \return bool - \c true if the localization named \a locName exists.
3299 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3301 return contentNotNull()->existsLoc(locName);
3304 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3306 return contentNotNull()->createNewNameOfPfl();
3309 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3311 return contentNotNull()->createNewNameOfLoc();
3315 * Sets the name of a MED file.
3316 * \param [inout] fileName - the file name.
3318 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3320 contentNotNull()->setFileName(fileName);
3324 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3325 * in the same order.
3326 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3327 * Each item of this sequence is a vector containing ids of equal profiles.
3329 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3331 return contentNotNull()->whichAreEqualProfiles();
3335 * Finds equal localizations.
3336 * \param [in] eps - a precision used to compare real values of the localizations.
3337 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3338 * Each item of this sequence is a vector containing ids of equal localizations.
3340 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3342 return contentNotNull()->whichAreEqualLocs(eps);
3346 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3347 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3348 * this sequence is a pair whose
3349 * - the first item is a vector of profile names to replace by the second item,
3350 * - the second item is a profile name to replace every profile name of the first item.
3352 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3354 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3358 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3359 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3360 * this sequence is a pair whose
3361 * - the first item is a vector of localization names to replace by the second item,
3362 * - the second item is a localization name to replace every localization name of the first item.
3364 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3366 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3370 * Replaces references to some profiles (a reference is a profile name) by references
3371 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3372 * them-selves accordingly. <br>
3373 * This method is a generalization of changePflName().
3374 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3375 * this sequence is a pair whose
3376 * - the first item is a vector of profile names to replace by the second item,
3377 * - the second item is a profile name to replace every profile of the first item.
3378 * \sa changePflsRefsNamesGen()
3379 * \sa changePflName()
3381 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3383 changePflsRefsNamesGen(mapOfModif);
3384 changePflsNamesInStruct(mapOfModif);
3388 * Replaces references to some localizations (a reference is a localization name) by references
3389 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3390 * them-selves accordingly. <br>
3391 * This method is a generalization of changeLocName().
3392 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3393 * this sequence is a pair whose
3394 * - the first item is a vector of localization names to replace by the second item,
3395 * - the second item is a localization name to replace every localization of the first item.
3396 * \sa changeLocsRefsNamesGen()
3397 * \sa changeLocName()
3399 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3401 changeLocsRefsNamesGen(mapOfModif);
3402 changeLocsNamesInStruct(mapOfModif);
3406 * Renames the profile having a given name and updates references to this profile.
3407 * \param [in] oldName - the name of the profile to rename.
3408 * \param [in] newName - a new name of the profile.
3409 * \sa changePflsNames().
3411 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3413 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3414 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3416 changePflsNames(mapOfModif);
3420 * Renames the localization having a given name and updates references to this localization.
3421 * \param [in] oldName - the name of the localization to rename.
3422 * \param [in] newName - a new name of the localization.
3423 * \sa changeLocsNames().
3425 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3427 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3428 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3430 changeLocsNames(mapOfModif);
3434 * Removes duplicated profiles. Returns a map used to update references to removed
3435 * profiles via changePflsRefsNamesGen().
3436 * Equal profiles are found using whichAreEqualProfiles().
3437 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3438 * a sequence describing the performed replacements of profiles. Each element of
3439 * this sequence is a pair whose
3440 * - the first item is a vector of profile names replaced by the second item,
3441 * - the second item is a profile name replacing every profile of the first item.
3443 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3445 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3446 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3448 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3450 std::vector< std::string > tmp((*it).size());
3452 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3453 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3454 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3456 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3457 killProfileIds(tmp2);
3459 changePflsRefsNamesGen(ret);
3464 * Removes duplicated localizations. Returns a map used to update references to removed
3465 * localizations via changeLocsRefsNamesGen().
3466 * Equal localizations are found using whichAreEqualLocs().
3467 * \param [in] eps - a precision used to compare real values of the localizations.
3468 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3469 * a sequence describing the performed replacements of localizations. Each element of
3470 * this sequence is a pair whose
3471 * - the first item is a vector of localization names replaced by the second item,
3472 * - the second item is a localization name replacing every localization of the first item.
3474 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3476 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3477 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3479 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3481 std::vector< std::string > tmp((*it).size());
3483 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3484 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3485 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3487 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3488 killLocalizationIds(tmp2);
3490 changeLocsRefsNamesGen(ret);
3495 * Returns number of Gauss points per cell in a given localization.
3496 * \param [in] locId - an id of the localization of interest.
3497 * \return int - the number of the Gauss points per cell.
3499 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3501 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3505 * Returns an id of a localization by its name.
3506 * \param [in] loc - the localization name of interest.
3507 * \return int - the id of the localization.
3508 * \throw If there is no a localization named \a loc.
3510 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3512 return contentNotNull()->getLocalizationId(loc);
3516 * Returns the name of the MED file.
3517 * \return const std::string& - the MED file name.
3519 std::string MEDFileFieldGlobsReal::getFileName() const
3521 return contentNotNull()->getFileName();
3525 * Returns a localization object by its name.
3526 * \param [in] locName - the name of the localization of interest.
3527 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3528 * \throw If there is no a localization named \a locName.
3530 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3532 return contentNotNull()->getLocalization(locName);
3536 * Returns a localization object by its id.
3537 * \param [in] locId - the id of the localization of interest.
3538 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3539 * \throw If there is no a localization with id \a locId.
3541 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3543 return contentNotNull()->getLocalizationFromId(locId);
3547 * Returns a profile array by its name.
3548 * \param [in] pflName - the name of the profile of interest.
3549 * \return const DataArrayInt * - the profile array having the name \a pflName.
3550 * \throw If there is no a profile named \a pflName.
3552 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3554 return contentNotNull()->getProfile(pflName);
3558 * Returns a profile array by its id.
3559 * \param [in] pflId - the id of the profile of interest.
3560 * \return const DataArrayInt * - the profile array having the id \a pflId.
3561 * \throw If there is no a profile with id \a pflId.
3563 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3565 return contentNotNull()->getProfileFromId(pflId);
3569 * Returns a localization object, apt for modification, by its id.
3570 * \param [in] locId - the id of the localization of interest.
3571 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3572 * having the id \a locId.
3573 * \throw If there is no a localization with id \a locId.
3575 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3577 return contentNotNull()->getLocalizationFromId(locId);
3581 * Returns a localization object, apt for modification, by its name.
3582 * \param [in] locName - the name of the localization of interest.
3583 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3584 * having the name \a locName.
3585 * \throw If there is no a localization named \a locName.
3587 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3589 return contentNotNull()->getLocalization(locName);
3593 * Returns a profile array, apt for modification, by its name.
3594 * \param [in] pflName - the name of the profile of interest.
3595 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3596 * \throw If there is no a profile named \a pflName.
3598 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3600 return contentNotNull()->getProfile(pflName);
3604 * Returns a profile array, apt for modification, by its id.
3605 * \param [in] pflId - the id of the profile of interest.
3606 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3607 * \throw If there is no a profile with id \a pflId.
3609 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3611 return contentNotNull()->getProfileFromId(pflId);
3615 * Removes profiles given by their ids. No data is updated to track this removal.
3616 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3618 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3620 contentNotNull()->killProfileIds(pflIds);
3624 * Removes localizations given by their ids. No data is updated to track this removal.
3625 * \param [in] locIds - a sequence of ids of the localizations to remove.
3627 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3629 contentNotNull()->killLocalizationIds(locIds);
3633 * Stores a profile array.
3634 * \param [in] pfl - the profile array to store.
3635 * \throw If the name of \a pfl is empty.
3636 * \throw If a profile with the same name as that of \a pfl already exists but contains
3639 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3641 contentNotNull()->appendProfile(pfl);
3645 * Adds a new localization of Gauss points.
3646 * \param [in] locName - the name of the new localization.
3647 * \param [in] geoType - a geometrical type of the reference cell.
3648 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3649 * must be \c nbOfNodesPerCell * \c dimOfType.
3650 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3651 * must be _wg_.size() * \c dimOfType.
3652 * \param [in] w - the weights of Gauss points.
3653 * \throw If \a locName is empty.
3654 * \throw If a localization with the name \a locName already exists but is
3655 * different form the new one.
3657 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)
3659 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3662 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3664 MEDFileFieldGlobs *g(_globals);
3666 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3670 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3672 const MEDFileFieldGlobs *g(_globals);
3674 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3678 //= MEDFileFieldNameScope
3680 MEDFileFieldNameScope::MEDFileFieldNameScope()
3684 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3689 * Returns the name of \a this field.
3690 * \return std::string - a string containing the field name.
3692 std::string MEDFileFieldNameScope::getName() const
3698 * Sets name of \a this field
3699 * \param [in] name - the new field name.
3701 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3706 std::string MEDFileFieldNameScope::getDtUnit() const
3711 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3716 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3719 _dt_unit=other._dt_unit;
3722 //= MEDFileAnyTypeField1TSWithoutSDA
3724 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3726 _field_per_mesh.resize(other._field_per_mesh.size());
3728 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3730 if((const MEDFileFieldPerMesh *)*it)
3731 _field_per_mesh[i]=(*it)->deepCpy(this);
3736 * Prints a string describing \a this field into a stream. This string is outputted
3737 * by \c print Python command.
3738 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3739 * \param [in,out] oss - the out stream.
3740 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3741 * info id printed, else, not.
3743 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3745 std::string startOfLine(bkOffset,' ');
3746 oss << startOfLine << "Field ";
3748 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3749 oss << "on one time Step ";
3751 oss << "(" << f1tsId << ") ";
3752 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3753 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3754 const DataArray *arr=getUndergroundDataArray();
3757 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3760 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3761 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3762 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3764 if(arr->isAllocated())
3766 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3769 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3773 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3775 oss << startOfLine << "----------------------" << std::endl;
3776 if(!_field_per_mesh.empty())
3779 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3781 const MEDFileFieldPerMesh *cur=(*it2);
3783 cur->simpleRepr(bkOffset,oss,i);
3785 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3790 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3792 oss << startOfLine << "----------------------" << std::endl;
3795 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3797 const DataArray *arr(getUndergroundDataArray());
3799 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3800 int nbOfCompo=arr->getNumberOfComponents();
3801 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3802 for(int i=0;i<nbOfCompo;i++)
3805 std::vector<int> v(1,i);
3806 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3807 ret[i]->setArray(arr2);
3812 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)
3816 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3821 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3822 * empty. Returns -1 if this in on nodes.
3823 * \return int - the dimension of \a this.
3825 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3828 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3829 (*it)->getDimension(ret);
3834 * Returns the mesh name.
3835 * \return std::string - a string holding the mesh name.
3836 * \throw If \c _field_per_mesh.empty()
3838 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3840 if(_field_per_mesh.empty())
3841 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3842 return _field_per_mesh[0]->getMeshName();
3845 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3847 std::string oldName(getMeshName());
3848 std::vector< std::pair<std::string,std::string> > v(1);
3849 v[0].first=oldName; v[0].second=newMeshName;
3853 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3856 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3858 MEDFileFieldPerMesh *cur(*it);
3860 ret=cur->changeMeshNames(modifTab) || ret;
3866 * Returns the number of iteration of the state of underlying mesh.
3867 * \return int - the iteration number.
3868 * \throw If \c _field_per_mesh.empty()
3870 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3872 if(_field_per_mesh.empty())
3873 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3874 return _field_per_mesh[0]->getMeshIteration();
3878 * Returns the order number of iteration of the state of underlying mesh.
3879 * \return int - the order number.
3880 * \throw If \c _field_per_mesh.empty()
3882 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3884 if(_field_per_mesh.empty())
3885 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3886 return _field_per_mesh[0]->getMeshOrder();
3890 * Checks if \a this field is tagged by a given iteration number and a given
3891 * iteration order number.
3892 * \param [in] iteration - the iteration number of interest.
3893 * \param [in] order - the iteration order number of interest.
3894 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3895 * \a this->getOrder() == \a order.
3897 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3899 return iteration==_iteration && order==_order;
3903 * Returns number of iteration and order number of iteration when
3904 * \a this field has been calculated.
3905 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3908 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3910 std::pair<int,int> p;
3916 * Returns number of iteration and order number of iteration when
3917 * \a this field has been calculated.
3918 * \param [in,out] p - a pair returning the iteration number and the iteration
3921 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3928 * Returns all types of spatial discretization of \a this field.
3929 * \param [in,out] types - a sequence of types of \a this field.
3931 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3933 std::set<TypeOfField> types2;
3934 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3936 (*it)->fillTypesOfFieldAvailable(types2);
3938 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3939 std::copy(types2.begin(),types2.end(),bi);
3943 * Returns all types of spatial discretization of \a this field.
3944 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3947 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3949 std::vector<TypeOfField> ret;
3950 fillTypesOfFieldAvailable(ret);
3954 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3956 std::vector<std::string> ret;
3957 std::set<std::string> ret2;
3958 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3960 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3961 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3962 if(ret2.find(*it2)==ret2.end())
3964 ret.push_back(*it2);
3971 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3973 std::vector<std::string> ret;
3974 std::set<std::string> ret2;
3975 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3977 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3978 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3979 if(ret2.find(*it2)==ret2.end())
3981 ret.push_back(*it2);
3988 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3990 std::vector<std::string> ret;
3991 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3993 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3994 ret.insert(ret.end(),tmp.begin(),tmp.end());
3999 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4001 std::vector<std::string> ret;
4002 std::set<std::string> ret2;
4003 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4005 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4006 ret.insert(ret.end(),tmp.begin(),tmp.end());
4011 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4013 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4014 (*it)->changePflsRefsNamesGen(mapOfModif);
4017 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4019 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4020 (*it)->changeLocsRefsNamesGen(mapOfModif);
4024 * Returns all attributes of parts of \a this field lying on a given mesh.
4025 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4026 * item of every of returned sequences refers to the _i_-th part of \a this field.
4027 * Thus all sequences returned by this method are of the same length equal to number
4028 * of different types of supporting entities.<br>
4029 * A field part can include sub-parts with several different spatial discretizations,
4030 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4031 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4032 * of a nested sequence corresponds to a type of spatial discretization.<br>
4033 * This method allows for iteration over MEDFile DataStructure without any overhead.
4034 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4035 * for the case with only one underlying mesh. (Actually, the number of meshes is
4036 * not checked if \a mname == \c NULL).
4037 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4038 * a field part is returned.
4039 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4040 * This sequence is of the same length as \a types.
4041 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4042 * discretization. A profile name can be empty.
4043 * Length of this and of nested sequences is the same as that of \a typesF.
4044 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4045 * discretization. A localization name can be empty.
4046 * Length of this and of nested sequences is the same as that of \a typesF.
4047 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4048 * of ids of tuples within the data array, per each type of spatial
4049 * discretization within one mesh entity type.
4050 * Length of this and of nested sequences is the same as that of \a typesF.
4051 * \throw If no field is lying on \a mname.
4053 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
4057 meshId=getMeshIdFromMeshName(mname);
4059 if(_field_per_mesh.empty())
4060 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4061 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4065 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4066 * maximal absolute dimension and values returned via the out parameter \a levs are
4067 * dimensions relative to the maximal absolute dimension. <br>
4068 * This method is designed for MEDFileField1TS instances that have a discretization
4069 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4070 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4071 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4072 * Only these 3 discretizations will be taken into account here. If \a this is
4073 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4074 * This method is useful to make the link between the dimension of the underlying mesh
4075 * and the levels of \a this, because it is possible that the highest dimension of \a this
4076 * field is not equal to the dimension of the underlying mesh.
4078 * Let's consider the following case:
4079 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4080 * TETRA4, HEXA8, TRI3 and SEG2.
4081 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4082 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4084 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4085 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4086 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4087 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4088 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4089 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4091 * to retrieve the highest level of
4092 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4093 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4094 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4095 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4096 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4097 * for the case with only one underlying mesh. (Actually, the number of meshes is
4098 * not checked if \a mname == \c NULL).
4099 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4100 * absolute one. They are in decreasing order. This sequence is cleared before
4102 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4103 * \throw If no field is lying on \a mname.
4105 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4108 int meshId=getMeshIdFromMeshName(mname);
4109 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4110 std::vector< std::vector<TypeOfField> > typesF;
4111 std::vector< std::vector<std::string> > pfls, locs;
4112 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4114 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4115 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4116 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4118 st.erase(INTERP_KERNEL::NORM_ERROR);
4120 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4122 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4123 ret1.insert((int)cm.getDimension());
4125 int ret=*std::max_element(ret1.begin(),ret1.end());
4126 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4127 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4132 * \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.
4133 * \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.
4134 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4135 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4137 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4139 int mid=getMeshIdFromMeshName(mName);
4140 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4144 * \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.
4145 * \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.
4146 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4147 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4149 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4151 int mid=getMeshIdFromMeshName(mName);
4152 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4156 * \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.
4158 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4160 if(_field_per_mesh.empty())
4161 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4164 std::string mName2(mName);
4166 std::vector<std::string> msg;
4167 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4168 if(mName2==(*it)->getMeshName())
4171 msg.push_back((*it)->getMeshName());
4172 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4173 oss << "Possible meshes are : ";
4174 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4175 oss << "\"" << (*it2) << "\" ";
4176 throw INTERP_KERNEL::Exception(oss.str().c_str());
4179 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4183 std::string tmp(mesh->getName());
4185 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4186 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4188 for(;it!=_field_per_mesh.end();it++,i++)
4190 if((*it)->getMeshName()==tmp)
4193 int sz=_field_per_mesh.size();
4194 _field_per_mesh.resize(sz+1);
4195 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4199 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4200 MEDFileFieldGlobsReal& glob)
4203 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4205 MEDFileFieldPerMesh *fpm(*it);
4207 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4213 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4214 * splitting that leads to single spatial discretization of this.
4216 * \sa splitMultiDiscrPerGeoTypes
4218 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4220 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4221 std::vector< std::vector<TypeOfField> > typesF;
4222 std::vector< std::vector<std::string> > pfls,locs;
4223 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4224 std::set<TypeOfField> allEnt;
4225 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4226 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4227 allEnt.insert(*it2);
4228 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4229 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4230 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4232 std::vector< std::pair<int,int> > its;
4233 ret[i]=shallowCpy();
4234 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4235 ret[i]->updateData(newLgth,its);
4241 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4242 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4244 * \sa splitDiscretizations
4246 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4248 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4249 std::vector< std::vector<TypeOfField> > typesF;
4250 std::vector< std::vector<std::string> > pfls,locs;
4251 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4252 std::set<TypeOfField> allEnt;
4253 std::size_t nbOfMDPGT(0),ii(0);
4254 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4256 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4257 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4258 allEnt.insert(*it2);
4260 if(allEnt.size()!=1)
4261 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4263 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4266 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4267 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4270 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4271 for(std::size_t i=0;i<nbOfMDPGT;i++)
4273 std::vector< std::pair<int,int> > its;
4274 ret[i]=shallowCpy();
4275 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4276 ret[i]->updateData(newLgth,its);
4281 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4283 int globalCounter(0);
4284 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4285 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4286 return globalCounter;
4289 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4291 int globalCounter(0);
4292 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4293 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4294 return globalCounter;
4297 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4299 if(_nb_of_tuples_to_be_allocated>=0)
4301 _nb_of_tuples_to_be_allocated=newLgth;
4302 const DataArray *oldArr(getUndergroundDataArray());
4305 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4306 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4308 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4312 if(_nb_of_tuples_to_be_allocated==-1)
4314 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4316 const DataArray *oldArr(getUndergroundDataArray());
4317 if(!oldArr || !oldArr->isAllocated())
4318 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4319 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4320 newArr->alloc(newLgth,getNumberOfComponents());
4322 newArr->copyStringInfoFrom(*oldArr);
4324 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4326 if((*it).second<(*it).first)
4327 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4328 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4329 pos+=(*it).second-(*it).first;
4334 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4337 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4339 if(_field_per_mesh.empty())
4340 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4341 if(_field_per_mesh.size()>1)
4342 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4343 _field_per_mesh[0]->copyOptionsFrom(opts);
4344 _field_per_mesh[0]->writeLL(fid,nasc);
4348 * 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.
4349 * If false is returned the memory allocation is not required.
4351 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4353 if(_nb_of_tuples_to_be_allocated>=0)
4355 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4356 _nb_of_tuples_to_be_allocated=-2;
4359 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4361 if(_nb_of_tuples_to_be_allocated==-1)
4362 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4363 if(_nb_of_tuples_to_be_allocated<-3)
4364 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4365 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4368 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4370 med_int numdt,numit;
4374 med_int meshnumdt,meshnumit;
4375 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4376 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4377 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4378 if(_iteration!=numdt || _order!=numit)
4379 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4380 _field_per_mesh.resize(nmesh);
4385 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4386 mm=ms->getMeshWithName(meshNameCpp);
4389 for(int i=0;i<nmesh;i++)
4390 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4391 _nb_of_tuples_to_be_allocated=0;
4392 for(int i=0;i<nmesh;i++)
4393 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4396 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4398 allocIfNecessaryTheArrayToReceiveDataFromFile();
4399 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4400 (*it)->loadBigArraysRecursively(fid,nasc);
4403 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4405 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4406 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4407 (*it)->loadBigArraysRecursively(fid,nasc);
4410 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4412 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4413 loadBigArraysRecursively(fid,nasc);
4416 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4418 DataArray *thisArr(getUndergroundDataArray());
4419 if(thisArr && thisArr->isAllocated())
4421 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4422 thisArr->desallocate();
4426 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4428 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4431 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4433 std::vector<const BigMemoryObject *> ret;
4434 if(getUndergroundDataArray())
4435 ret.push_back(getUndergroundDataArray());
4436 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4437 ret.push_back((const MEDFileFieldPerMesh *)*it);
4442 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4443 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4444 * "Sort By Type"), if not, an exception is thrown.
4445 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4446 * \param [in] arr - the array of values.
4447 * \param [in,out] glob - the global data where profiles and localization present in
4448 * \a field, if any, are added.
4449 * \throw If the name of \a field is empty.
4450 * \throw If the data array of \a field is not set.
4451 * \throw If \a this->_arr is already allocated but has different number of components
4453 * \throw If the underlying mesh of \a field has no name.
4454 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4456 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4458 const MEDCouplingMesh *mesh=field->getMesh();
4460 TypeOfField type=field->getTypeOfField();
4461 std::vector<DataArrayInt *> dummy;
4462 int start=copyTinyInfoFrom(field,arr);
4463 int pos=addNewEntryIfNecessary(mesh);
4466 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4467 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4470 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4474 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4475 * of a given mesh are used as the support of the given field (a real support is not used).
4476 * Elements of the given mesh must be sorted suitable for writing to MED file.
4477 * Order of underlying mesh entities of the given field specified by \a profile parameter
4478 * is not prescribed; this method permutes field values to have them sorted by element
4479 * type as required for writing to MED file. A new profile is added only if no equal
4480 * profile is missing.
4481 * \param [in] field - the field to add to \a this. The field double values are ignored.
4482 * \param [in] arrOfVals - the values of the field \a field used.
4483 * \param [in] mesh - the supporting mesh of \a field.
4484 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4485 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4486 * \param [in,out] glob - the global data where profiles and localization present in
4487 * \a field, if any, are added.
4488 * \throw If either \a field or \a mesh or \a profile has an empty name.
4489 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4490 * \throw If the data array of \a field is not set.
4491 * \throw If \a this->_arr is already allocated but has different number of components
4493 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4494 * \sa setFieldNoProfileSBT()
4496 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4499 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4500 if(!arrOfVals || !arrOfVals->isAllocated())
4501 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4502 TypeOfField type=field->getTypeOfField();
4503 std::vector<DataArrayInt *> idsInPflPerType;
4504 std::vector<DataArrayInt *> idsPerType;
4505 std::vector<int> code,code2;
4506 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4509 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4510 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4511 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4512 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4514 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4515 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4516 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4518 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4519 throw INTERP_KERNEL::Exception(oss.str().c_str());
4522 int start=copyTinyInfoFrom(field,arrOfVals);
4523 code2=m->getDistributionOfTypes();
4525 int pos=addNewEntryIfNecessary(m);
4526 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4530 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4531 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4532 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4533 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4534 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4535 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4537 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4538 throw INTERP_KERNEL::Exception(oss.str().c_str());
4540 int start=copyTinyInfoFrom(field,arrOfVals);
4541 int pos=addNewEntryIfNecessary(m);
4542 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4547 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4549 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4551 if(_nb_of_tuples_to_be_allocated>=0)
4552 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 !");
4553 DataArray *arr(getOrCreateAndGetArray());
4554 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4555 _nb_of_tuples_to_be_allocated=-3;
4559 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4560 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4561 * larger by the size of \a field. Returns an id of the first not filled
4562 * tuple of \a this->_arr.
4563 * \param [in] field - the field to copy the info on components and the name from.
4564 * \return int - the id of first not initialized tuple of \a this->_arr.
4565 * \throw If the name of \a field is empty.
4566 * \throw If the data array of \a field is not set.
4567 * \throw If \a this->_arr is already allocated but has different number of components
4570 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4573 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4574 std::string name(field->getName());
4575 setName(name.c_str());
4576 setDtUnit(field->getTimeUnit());
4578 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4580 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4581 if(!arr->isAllocated())
4582 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4583 _dt=field->getTime(_iteration,_order);
4584 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4585 if(!getOrCreateAndGetArray()->isAllocated())
4587 allocNotFromFile(arr->getNumberOfTuples());
4592 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4593 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4594 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4595 _nb_of_tuples_to_be_allocated=-3;
4596 return oldNbOfTuples;
4601 * Returns number of components in \a this field
4602 * \return int - the number of components.
4604 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4606 return getOrCreateAndGetArray()->getNumberOfComponents();
4610 * Change info on components in \a this.
4611 * \throw If size of \a infos is not equal to the number of components already in \a this.
4613 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4615 DataArray *arr=getOrCreateAndGetArray();
4616 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4620 * Returns info on components of \a this field.
4621 * \return const std::vector<std::string>& - a sequence of strings each being an
4622 * information on _i_-th component.
4624 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4626 const DataArray *arr=getOrCreateAndGetArray();
4627 return arr->getInfoOnComponents();
4631 * Returns a mutable info on components of \a this field.
4632 * \return std::vector<std::string>& - a sequence of strings each being an
4633 * information on _i_-th component.
4635 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4637 DataArray *arr=getOrCreateAndGetArray();
4638 return arr->getInfoOnComponents();
4641 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4643 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4645 const MEDFileFieldPerMesh *fpm(*it);
4648 if(fpm->presenceOfMultiDiscPerGeoType())
4655 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4656 * \param [in] type - a spatial discretization of the new field.
4657 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4658 * \param [in] mName - a name of the supporting mesh.
4659 * \param [in] renumPol - specifies how to permute values of the result field according to
4660 * the optional numbers of cells and nodes, if any. The valid values are
4661 * - 0 - do not permute.
4662 * - 1 - permute cells.
4663 * - 2 - permute nodes.
4664 * - 3 - permute cells and nodes.
4666 * \param [in] glob - the global data storing profiles and localization.
4667 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4668 * caller is to delete this field using decrRef() as it is no more needed.
4669 * \throw If the MED file is not readable.
4670 * \throw If there is no mesh named \a mName in the MED file.
4671 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4672 * \throw If no field of \a this is lying on the mesh \a mName.
4673 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4675 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4677 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4679 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4681 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4682 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4686 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4687 * \param [in] type - a spatial discretization of the new field.
4688 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4689 * \param [in] renumPol - specifies how to permute values of the result field according to
4690 * the optional numbers of cells and nodes, if any. The valid values are
4691 * - 0 - do not permute.
4692 * - 1 - permute cells.
4693 * - 2 - permute nodes.
4694 * - 3 - permute cells and nodes.
4696 * \param [in] glob - the global data storing profiles and localization.
4697 * \param [in] mesh - the supporting mesh.
4698 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4699 * caller is to delete this field using decrRef() as it is no more needed.
4700 * \throw If the MED file is not readable.
4701 * \throw If no field of \a this is lying on \a mesh.
4702 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4703 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4705 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4707 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4708 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4709 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4710 if(meshDimRelToMax==1)
4711 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4712 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4716 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4718 * \param [in] type - a spatial discretization of the new field.
4719 * \param [in] mName - a name of the supporting mesh.
4720 * \param [in] renumPol - specifies how to permute values of the result field according to
4721 * the optional numbers of cells and nodes, if any. The valid values are
4722 * - 0 - do not permute.
4723 * - 1 - permute cells.
4724 * - 2 - permute nodes.
4725 * - 3 - permute cells and nodes.
4727 * \param [in] glob - the global data storing profiles and localization.
4728 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4729 * caller is to delete this field using decrRef() as it is no more needed.
4730 * \throw If the MED file is not readable.
4731 * \throw If there is no mesh named \a mName in the MED file.
4732 * \throw If there are no mesh entities in the mesh.
4733 * \throw If no field values of the given \a type are available.
4735 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4737 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4739 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4741 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4742 int absDim=getDimension();
4743 int meshDimRelToMax=absDim-mm->getMeshDimension();
4744 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4748 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4749 * \param [in] type - a spatial discretization of the new field.
4750 * \param [in] renumPol - specifies how to permute values of the result field according to
4751 * the optional numbers of cells and nodes, if any. The valid values are
4752 * - 0 - do not permute.
4753 * - 1 - permute cells.
4754 * - 2 - permute nodes.
4755 * - 3 - permute cells and nodes.
4757 * \param [in] glob - the global data storing profiles and localization.
4758 * \param [in] mesh - the supporting mesh.
4759 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4760 * field according to \a renumPol.
4761 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4762 * field according to \a renumPol.
4763 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4764 * caller is to delete this field using decrRef() as it is no more needed.
4765 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4766 * \throw If no field of \a this is lying on \a mesh.
4767 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4769 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
4771 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4772 int meshId=getMeshIdFromMeshName(mesh->getName());
4774 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4779 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4786 throw INTERP_KERNEL::Exception(msg1);
4787 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4790 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4792 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4793 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4794 throw INTERP_KERNEL::Exception(oss.str().c_str());
4796 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4797 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4798 std::vector<DataArray *> arrOut2(1,arrOut);
4799 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4800 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4801 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4808 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4810 throw INTERP_KERNEL::Exception(msg1);
4813 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4815 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4816 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4817 throw INTERP_KERNEL::Exception(oss.str().c_str());
4819 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4820 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4821 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4822 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4827 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4832 * Returns values and a profile of the field of a given type lying on a given support.
4833 * \param [in] type - a spatial discretization of the field.
4834 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4835 * \param [in] mesh - the supporting mesh.
4836 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4837 * field of interest lies on. If the field lies on all entities of the given
4838 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4839 * using decrRef() as it is no more needed.
4840 * \param [in] glob - the global data storing profiles and localization.
4841 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4842 * field. The caller is to delete this array using decrRef() as it is no more needed.
4843 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4844 * \throw If no field of \a this is lying on \a mesh.
4845 * \throw If no field values of the given \a type are available.
4847 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4849 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4850 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4851 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4852 ret->setName(nasc.getName().c_str());
4856 //= MEDFileField1TSWithoutSDA
4859 * Throws if a given value is not a valid (non-extended) relative dimension.
4860 * \param [in] meshDimRelToMax - the relative dimension value.
4861 * \throw If \a meshDimRelToMax > 0.
4863 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4865 if(meshDimRelToMax>0)
4866 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4870 * Checks if elements of a given mesh are in the order suitable for writing
4871 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4872 * vector describing types of elements and their number.
4873 * \param [in] mesh - the mesh to check.
4874 * \return std::vector<int> - a vector holding for each element type (1) item of
4875 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4876 * These values are in full-interlace mode.
4877 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4879 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4882 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4883 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4884 int nbOfTypes=geoTypes.size();
4885 std::vector<int> code(3*nbOfTypes);
4886 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4887 arr1->alloc(nbOfTypes,1);
4888 int *arrPtr=arr1->getPointer();
4889 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4890 for(int i=0;i<nbOfTypes;i++,it++)
4891 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4892 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4893 const int *arrPtr2=arr2->getConstPointer();
4895 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4898 int nbCells=mesh->getNumberOfCellsWithType(*it);
4899 code[3*pos]=(int)(*it);
4900 code[3*pos+1]=nbCells;
4901 code[3*pos+2]=-1;//no profiles
4903 std::vector<const DataArrayInt *> idsPerType;//no profiles
4904 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4908 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4913 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4915 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4919 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4920 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4921 * item of every of returned sequences refers to the _i_-th part of \a this field.
4922 * Thus all sequences returned by this method are of the same length equal to number
4923 * of different types of supporting entities.<br>
4924 * A field part can include sub-parts with several different spatial discretizations,
4925 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4926 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4927 * of a nested sequence corresponds to a type of spatial discretization.<br>
4928 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4929 * The overhead is due to selecting values into new instances of DataArrayDouble.
4930 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4931 * for the case with only one underlying mesh. (Actually, the number of meshes is
4932 * not checked if \a mname == \c NULL).
4933 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4934 * a field part is returned.
4935 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4936 * A field part can include sub-parts with several different spatial discretizations,
4937 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4938 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4939 * This sequence is of the same length as \a types.
4940 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4941 * discretization. A profile name can be empty.
4942 * Length of this and of nested sequences is the same as that of \a typesF.
4943 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4944 * discretization. A localization name can be empty.
4945 * Length of this and of nested sequences is the same as that of \a typesF.
4946 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4947 * per each type of spatial discretization within one mesh entity type.
4948 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4949 * Length of this and of nested sequences is the same as that of \a typesF.
4950 * \throw If no field is lying on \a mname.
4952 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
4956 meshId=getMeshIdFromMeshName(mname);
4958 if(_field_per_mesh.empty())
4959 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4960 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4961 int nbOfRet=ret0.size();
4962 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4963 for(int i=0;i<nbOfRet;i++)
4965 const std::vector< std::pair<int,int> >& p=ret0[i];
4966 int nbOfRet1=p.size();
4967 ret[i].resize(nbOfRet1);
4968 for(int j=0;j<nbOfRet1;j++)
4970 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4978 * Returns a pointer to the underground DataArrayDouble instance. So the
4979 * caller should not decrRef() it. This method allows for a direct access to the field
4980 * values. This method is quite unusable if there is more than a nodal field or a cell
4981 * field on single geometric cell type.
4982 * \return DataArrayDouble * - the pointer to the field values array.
4984 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4986 const DataArrayDouble *ret=_arr;
4988 return const_cast<DataArrayDouble *>(ret);
4993 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4998 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5000 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5001 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5002 ret->deepCpyLeavesFrom(*this);
5003 const DataArrayDouble *arr(_arr);
5006 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
5007 ret->setArray(arr2);
5013 * Returns a pointer to the underground DataArrayDouble instance. So the
5014 * caller should not decrRef() it. This method allows for a direct access to the field
5015 * values. This method is quite unusable if there is more than a nodal field or a cell
5016 * field on single geometric cell type.
5017 * \return DataArrayDouble * - the pointer to the field values array.
5019 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5021 return getUndergroundDataArrayDouble();
5025 * Returns a pointer to the underground DataArrayDouble instance and a
5026 * sequence describing parameters of a support of each part of \a this field. The
5027 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5028 * direct access to the field values. This method is intended for the field lying on one
5030 * \param [in,out] entries - the sequence describing parameters of a support of each
5031 * part of \a this field. Each item of this sequence consists of two parts. The
5032 * first part describes a type of mesh entity and an id of discretization of a
5033 * current field part. The second part describes a range of values [begin,end)
5034 * within the returned array relating to the current field part.
5035 * \return DataArrayDouble * - the pointer to the field values array.
5036 * \throw If the number of underlying meshes is not equal to 1.
5037 * \throw If no field values are available.
5038 * \sa getUndergroundDataArray()
5040 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5042 if(_field_per_mesh.size()!=1)
5043 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5044 if(_field_per_mesh[0]==0)
5045 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5046 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5047 return getUndergroundDataArrayDouble();
5051 * Returns a pointer to the underground DataArrayDouble instance and a
5052 * sequence describing parameters of a support of each part of \a this field. The
5053 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5054 * direct access to the field values. This method is intended for the field lying on one
5056 * \param [in,out] entries - the sequence describing parameters of a support of each
5057 * part of \a this field. Each item of this sequence consists of two parts. The
5058 * first part describes a type of mesh entity and an id of discretization of a
5059 * current field part. The second part describes a range of values [begin,end)
5060 * within the returned array relating to the current field part.
5061 * \return DataArrayDouble * - the pointer to the field values array.
5062 * \throw If the number of underlying meshes is not equal to 1.
5063 * \throw If no field values are available.
5064 * \sa getUndergroundDataArray()
5066 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5068 return getUndergroundDataArrayDoubleExt(entries);
5071 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5073 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5074 arr->setInfoAndChangeNbOfCompo(infos);
5077 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5081 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5083 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5084 ret->deepCpyLeavesFrom(*this);
5088 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5090 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5091 if((const DataArrayDouble *)_arr)
5092 ret->_arr=_arr->deepCpy();
5096 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5100 _nb_of_tuples_to_be_allocated=-1;
5104 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5106 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5108 _nb_of_tuples_to_be_allocated=-3;
5113 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5115 return DataArrayDouble::New();
5118 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5120 DataArrayDouble *ret=_arr;
5123 _arr=DataArrayDouble::New();
5127 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5129 return getOrCreateAndGetArrayDouble();
5132 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5134 const DataArrayDouble *ret=_arr;
5137 DataArrayDouble *ret2=DataArrayDouble::New();
5138 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5142 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5144 return getOrCreateAndGetArrayDouble();
5147 //= MEDFileIntField1TSWithoutSDA
5149 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5151 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5154 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5158 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5159 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5161 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5162 arr->setInfoAndChangeNbOfCompo(infos);
5165 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5170 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5172 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5173 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5174 ret->deepCpyLeavesFrom(*this);
5175 const DataArrayInt *arr(_arr);
5178 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5179 ret->setArray(arr2);
5185 * Returns a pointer to the underground DataArrayInt instance. So the
5186 * caller should not decrRef() it. This method allows for a direct access to the field
5187 * values. This method is quite unusable if there is more than a nodal field or a cell
5188 * field on single geometric cell type.
5189 * \return DataArrayInt * - the pointer to the field values array.
5191 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5193 return getUndergroundDataArrayInt();
5197 * Returns a pointer to the underground DataArrayInt instance. So the
5198 * caller should not decrRef() it. This method allows for a direct access to the field
5199 * values. This method is quite unusable if there is more than a nodal field or a cell
5200 * field on single geometric cell type.
5201 * \return DataArrayInt * - the pointer to the field values array.
5203 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5205 const DataArrayInt *ret=_arr;
5207 return const_cast<DataArrayInt *>(ret);
5213 * Returns a pointer to the underground DataArrayInt instance and a
5214 * sequence describing parameters of a support of each part of \a this field. The
5215 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5216 * direct access to the field values. This method is intended for the field lying on one
5218 * \param [in,out] entries - the sequence describing parameters of a support of each
5219 * part of \a this field. Each item of this sequence consists of two parts. The
5220 * first part describes a type of mesh entity and an id of discretization of a
5221 * current field part. The second part describes a range of values [begin,end)
5222 * within the returned array relating to the current field part.
5223 * \return DataArrayInt * - the pointer to the field values array.
5224 * \throw If the number of underlying meshes is not equal to 1.
5225 * \throw If no field values are available.
5226 * \sa getUndergroundDataArray()
5228 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5230 return getUndergroundDataArrayIntExt(entries);
5234 * Returns a pointer to the underground DataArrayInt instance and a
5235 * sequence describing parameters of a support of each part of \a this field. The
5236 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5237 * direct access to the field values. This method is intended for the field lying on one
5239 * \param [in,out] entries - the sequence describing parameters of a support of each
5240 * part of \a this field. Each item of this sequence consists of two parts. The
5241 * first part describes a type of mesh entity and an id of discretization of a
5242 * current field part. The second part describes a range of values [begin,end)
5243 * within the returned array relating to the current field part.
5244 * \return DataArrayInt * - the pointer to the field values array.
5245 * \throw If the number of underlying meshes is not equal to 1.
5246 * \throw If no field values are available.
5247 * \sa getUndergroundDataArray()
5249 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5251 if(_field_per_mesh.size()!=1)
5252 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5253 if(_field_per_mesh[0]==0)
5254 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5255 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5256 return getUndergroundDataArrayInt();
5259 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5261 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5262 ret->deepCpyLeavesFrom(*this);
5266 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5268 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5269 if((const DataArrayInt *)_arr)
5270 ret->_arr=_arr->deepCpy();
5274 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5278 _nb_of_tuples_to_be_allocated=-1;
5282 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5284 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5286 _nb_of_tuples_to_be_allocated=-3;
5291 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5293 return DataArrayInt::New();
5296 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5298 DataArrayInt *ret=_arr;
5301 _arr=DataArrayInt::New();
5305 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5307 return getOrCreateAndGetArrayInt();
5310 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5312 const DataArrayInt *ret=_arr;
5315 DataArrayInt *ret2=DataArrayInt::New();
5316 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5320 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5322 return getOrCreateAndGetArrayInt();
5325 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5329 //= MEDFileAnyTypeField1TS
5331 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5333 med_field_type typcha;
5335 std::vector<std::string> infos;
5336 std::string dtunit,fieldName;
5337 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5338 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5343 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5348 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5353 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] !";
5354 throw INTERP_KERNEL::Exception(oss.str().c_str());
5357 ret->setDtUnit(dtunit.c_str());
5358 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5360 med_int numdt,numit;
5362 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5363 ret->setTime(numdt,numit,dt);
5366 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5368 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5372 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5373 try:MEDFileFieldGlobsReal(fileName)
5375 MEDFileUtilities::CheckFileForRead(fileName);
5376 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5377 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5380 catch(INTERP_KERNEL::Exception& e)
5385 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5387 med_field_type typcha;
5388 std::vector<std::string> infos;
5391 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5392 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5397 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5402 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5407 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] !";
5408 throw INTERP_KERNEL::Exception(oss.str().c_str());
5411 ret->setDtUnit(dtunit.c_str());
5412 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5416 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5417 throw INTERP_KERNEL::Exception(oss.str().c_str());
5420 med_int numdt,numit;
5422 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5423 ret->setTime(numdt,numit,dt);
5426 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5428 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5432 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5433 try:MEDFileFieldGlobsReal(fileName)
5435 MEDFileUtilities::CheckFileForRead(fileName);
5436 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5437 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5440 catch(INTERP_KERNEL::Exception& e)
5445 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5448 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5449 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5451 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5452 ret->setFileName(fileName);
5453 ret->_content=c; c->incrRef();
5456 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5458 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5459 ret->setFileName(fileName);
5460 ret->_content=c; c->incrRef();
5463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5466 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5468 MEDFileUtilities::CheckFileForRead(fileName);
5469 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5470 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5471 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5472 ret->loadGlobals(fid);
5476 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5478 MEDFileUtilities::CheckFileForRead(fileName);
5479 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5480 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5481 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5482 ret->loadGlobals(fid);
5486 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5488 MEDFileUtilities::CheckFileForRead(fileName);
5489 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5490 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5491 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5492 ret->loadGlobals(fid);
5496 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5498 med_field_type typcha;
5499 std::vector<std::string> infos;
5502 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5503 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5508 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5513 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5518 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] !";
5519 throw INTERP_KERNEL::Exception(oss.str().c_str());
5522 ret->setDtUnit(dtunit.c_str());
5523 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5526 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5527 for(int i=0;i<nbOfStep2 && !found;i++)
5529 med_int numdt,numit;
5531 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5532 if(numdt==iteration && numit==order)
5538 dtits[i]=std::pair<int,int>(numdt,numit);
5542 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5543 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5544 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5545 throw INTERP_KERNEL::Exception(oss.str().c_str());
5548 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5550 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5554 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5555 try:MEDFileFieldGlobsReal(fileName)
5557 MEDFileUtilities::CheckFileForRead(fileName);
5558 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5559 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5562 catch(INTERP_KERNEL::Exception& e)
5568 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5569 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5571 * \warning this is a shallow copy constructor
5573 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5575 if(!shallowCopyOfContent)
5577 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5578 otherPtr->incrRef();
5579 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5583 _content=other.shallowCpy();
5587 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)
5591 int nbFields=MEDnField(fid);
5592 if(fieldIdCFormat>=nbFields)
5594 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5595 throw INTERP_KERNEL::Exception(oss.str().c_str());
5598 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5599 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5600 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5601 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5602 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5603 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5606 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5607 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5608 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5609 infos.clear(); infos.resize(ncomp);
5610 for(int j=0;j<ncomp;j++)
5611 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5616 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5619 * \return in case of success the number of time steps available for the field with name \a fieldName.
5621 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)
5623 int nbFields=MEDnField(fid);
5625 std::vector<std::string> fns(nbFields);
5627 for(int i=0;i<nbFields && !found;i++)
5630 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5632 found=(tmp==fieldName);
5638 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5639 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5640 oss << "\"" << *it << "\" ";
5641 throw INTERP_KERNEL::Exception(oss.str().c_str());
5647 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5648 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5649 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5650 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5651 * to keep a valid instance.
5652 * 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.
5653 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5654 * 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.
5656 * \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.
5657 * \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.
5658 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5659 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5660 * \param [in] newLocName is the new localization name.
5661 * \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.
5662 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5664 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5666 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5667 std::string oldPflName=disc->getProfile();
5668 std::vector<std::string> vv=getPflsReallyUsedMulti();
5669 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5670 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5672 disc->setProfile(newPflName);
5673 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5674 pfl->setName(newPflName);
5678 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5679 throw INTERP_KERNEL::Exception(oss.str().c_str());
5684 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5685 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5686 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5687 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5688 * to keep a valid instance.
5689 * 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.
5690 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5691 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5692 * 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.
5694 * \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.
5695 * \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.
5696 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5697 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5698 * \param [in] newLocName is the new localization name.
5699 * \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.
5700 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5702 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5704 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5705 std::string oldLocName=disc->getLocalization();
5706 std::vector<std::string> vv=getLocsReallyUsedMulti();
5707 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5708 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5710 disc->setLocalization(newLocName);
5711 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5712 loc.setName(newLocName);
5716 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5717 throw INTERP_KERNEL::Exception(oss.str().c_str());
5721 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5723 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5725 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5729 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5731 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5733 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5738 * Writes \a this field into a MED file specified by its name.
5739 * \param [in] fileName - the MED file name.
5740 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5741 * - 2 - erase; an existing file is removed.
5742 * - 1 - append; same data should not be present in an existing file.
5743 * - 0 - overwrite; same data present in an existing file is overwritten.
5744 * \throw If the field name is not set.
5745 * \throw If no field data is set.
5746 * \throw If \a mode == 1 and the same data is present in an existing file.
5748 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5750 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5751 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5756 * This method alloc the arrays and load potentially huge arrays contained in this field.
5757 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5758 * This method can be also called to refresh or reinit values from a file.
5760 * \throw If the fileName is not set or points to a non readable MED file.
5761 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5763 void MEDFileAnyTypeField1TS::loadArrays()
5765 if(getFileName().empty())
5766 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5767 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5768 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5772 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5773 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5774 * this method does not throw if \a this does not come from file read.
5776 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5778 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5780 if(!getFileName().empty())
5782 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5783 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5788 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5789 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5790 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5792 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5794 void MEDFileAnyTypeField1TS::unloadArrays()
5796 contentNotNullBase()->unloadArrays();
5800 * 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.
5801 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5802 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5804 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5806 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5808 if(!getFileName().empty())
5809 contentNotNullBase()->unloadArrays();
5812 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5814 int nbComp=getNumberOfComponents();
5815 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5816 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5817 for(int i=0;i<nbComp;i++)
5819 std::string info=getInfo()[i];
5821 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5822 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5823 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5825 if(getName().empty())
5826 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5827 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5828 writeGlobals(fid,*this);
5829 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5832 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5834 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5837 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5839 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5840 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5845 * Returns a string describing \a this field. This string is outputted
5846 * by \c print Python command.
5848 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5850 std::ostringstream oss;
5851 contentNotNullBase()->simpleRepr(0,oss,-1);
5852 simpleReprGlobs(oss);
5857 * This method returns all profiles whose name is non empty used.
5858 * \b WARNING If profile is used several times it will be reported \b only \b once.
5859 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5861 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5863 return contentNotNullBase()->getPflsReallyUsed2();
5867 * This method returns all localizations whose name is non empty used.
5868 * \b WARNING If localization is used several times it will be reported \b only \b once.
5870 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5872 return contentNotNullBase()->getLocsReallyUsed2();
5876 * This method returns all profiles whose name is non empty used.
5877 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5879 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5881 return contentNotNullBase()->getPflsReallyUsedMulti2();
5885 * This method returns all localizations whose name is non empty used.
5886 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5888 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5890 return contentNotNullBase()->getLocsReallyUsedMulti2();
5893 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5895 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5898 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5900 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5903 int MEDFileAnyTypeField1TS::getDimension() const
5905 return contentNotNullBase()->getDimension();
5908 int MEDFileAnyTypeField1TS::getIteration() const
5910 return contentNotNullBase()->getIteration();
5913 int MEDFileAnyTypeField1TS::getOrder() const
5915 return contentNotNullBase()->getOrder();
5918 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5920 return contentNotNullBase()->getTime(iteration,order);
5923 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5925 contentNotNullBase()->setTime(iteration,order,val);
5928 std::string MEDFileAnyTypeField1TS::getName() const
5930 return contentNotNullBase()->getName();
5933 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5935 contentNotNullBase()->setName(name);
5938 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5940 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5943 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5945 return contentNotNullBase()->getDtUnit();
5948 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5950 contentNotNullBase()->setDtUnit(dtUnit);
5953 std::string MEDFileAnyTypeField1TS::getMeshName() const
5955 return contentNotNullBase()->getMeshName();
5958 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5960 contentNotNullBase()->setMeshName(newMeshName);
5963 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5965 return contentNotNullBase()->changeMeshNames(modifTab);
5968 int MEDFileAnyTypeField1TS::getMeshIteration() const
5970 return contentNotNullBase()->getMeshIteration();
5973 int MEDFileAnyTypeField1TS::getMeshOrder() const
5975 return contentNotNullBase()->getMeshOrder();
5978 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5980 return contentNotNullBase()->getNumberOfComponents();
5983 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5985 return contentNotNullBase()->isDealingTS(iteration,order);
5988 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5990 return contentNotNullBase()->getDtIt();
5993 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5995 contentNotNullBase()->fillIteration(p);
5998 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6000 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6003 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6005 contentNotNullBase()->setInfo(infos);
6008 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6010 return contentNotNullBase()->getInfo();
6012 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6014 return contentNotNullBase()->getInfo();
6017 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6019 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6022 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6024 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6027 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6029 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6032 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6034 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6037 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6039 return contentNotNullBase()->getTypesOfFieldAvailable();
6042 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,
6043 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6045 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6049 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6050 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6051 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6053 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6055 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6057 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6058 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6059 std::size_t sz(contentsSplit.size());
6060 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6061 for(std::size_t i=0;i<sz;i++)
6063 ret[i]=shallowCpy();
6064 ret[i]->_content=contentsSplit[i];
6070 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6071 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6073 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6075 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6077 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6078 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6079 std::size_t sz(contentsSplit.size());
6080 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6081 for(std::size_t i=0;i<sz;i++)
6083 ret[i]=shallowCpy();
6084 ret[i]->_content=contentsSplit[i];
6090 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6091 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6093 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6095 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6097 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6098 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6099 std::size_t sz(contentsSplit.size());
6100 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6101 for(std::size_t i=0;i<sz;i++)
6103 ret[i]=shallowCpy();
6104 ret[i]->_content=contentsSplit[i];
6109 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6111 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6112 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6113 ret->_content=_content->deepCpy();
6114 ret->deepCpyGlobs(*this);
6118 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6120 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6126 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6127 * the first field that has been read from a specified MED file.
6128 * \param [in] fileName - the name of the MED file to read.
6129 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6130 * is to delete this field using decrRef() as it is no more needed.
6131 * \throw If reading the file fails.
6133 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6135 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6136 ret->contentNotNull();
6141 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6142 * a given field that has been read from a specified MED file.
6143 * \param [in] fileName - the name of the MED file to read.
6144 * \param [in] fieldName - the name of the field to read.
6145 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6146 * is to delete this field using decrRef() as it is no more needed.
6147 * \throw If reading the file fails.
6148 * \throw If there is no field named \a fieldName in the file.
6150 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6152 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6153 ret->contentNotNull();
6158 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6159 * a given field that has been read from a specified MED file.
6160 * \param [in] fileName - the name of the MED file to read.
6161 * \param [in] fieldName - the name of the field to read.
6162 * \param [in] iteration - the iteration number of a required time step.
6163 * \param [in] order - the iteration order number of required time step.
6164 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6165 * is to delete this field using decrRef() as it is no more needed.
6166 * \throw If reading the file fails.
6167 * \throw If there is no field named \a fieldName in the file.
6168 * \throw If the required time step is missing from the file.
6170 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6172 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6173 ret->contentNotNull();
6178 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6179 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6181 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6182 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6183 * \warning this is a shallow copy constructor
6184 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6185 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6186 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6187 * is to delete this field using decrRef() as it is no more needed.
6189 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6191 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6192 ret->contentNotNull();
6197 * Returns a new empty instance of MEDFileField1TS.
6198 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6199 * is to delete this field using decrRef() as it is no more needed.
6201 MEDFileField1TS *MEDFileField1TS::New()
6203 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6204 ret->contentNotNull();
6209 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6210 * following the given input policy.
6212 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6213 * By default (true) the globals are deeply copied.
6214 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6216 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6218 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6219 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6222 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6224 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6225 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6226 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6229 ret=MEDFileIntField1TS::New();
6231 ret->deepCpyGlobs(*this);
6233 ret->shallowCpyGlobs(*this);
6237 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6239 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6241 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6242 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6244 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 !");
6248 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6250 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6252 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6253 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6255 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 !");
6259 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6262 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6263 if(!((DataArray*)arr))
6264 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6265 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6267 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6268 f->setArray(arrOutC);
6271 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6273 if(!((DataArray*)arr))
6274 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6275 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6277 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6282 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6283 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6286 catch(INTERP_KERNEL::Exception& e)
6289 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6290 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6293 catch(INTERP_KERNEL::Exception& e)
6296 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6297 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6300 catch(INTERP_KERNEL::Exception& e)
6304 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6305 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6307 * \warning this is a shallow copy constructor
6309 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6310 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6313 catch(INTERP_KERNEL::Exception& e)
6316 MEDFileField1TS::MEDFileField1TS()
6318 _content=new MEDFileField1TSWithoutSDA;
6322 * Returns a new MEDCouplingFieldDouble of a given type lying on
6323 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6324 * has not been constructed via file reading, an exception is thrown.
6325 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6326 * \param [in] type - a spatial discretization of interest.
6327 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6328 * \param [in] renumPol - specifies how to permute values of the result field according to
6329 * the optional numbers of cells and nodes, if any. The valid values are
6330 * - 0 - do not permute.
6331 * - 1 - permute cells.
6332 * - 2 - permute nodes.
6333 * - 3 - permute cells and nodes.
6335 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6336 * caller is to delete this field using decrRef() as it is no more needed.
6337 * \throw If \a this field has not been constructed via file reading.
6338 * \throw If the MED file is not readable.
6339 * \throw If there is no mesh in the MED file.
6340 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6341 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6342 * \sa getFieldOnMeshAtLevel()
6344 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6346 if(getFileName().empty())
6347 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6348 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6349 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6350 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6355 * Returns a new MEDCouplingFieldDouble of a given type lying on
6356 * the top level cells of the first mesh in MED file. If \a this field
6357 * has not been constructed via file reading, an exception is thrown.
6358 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6359 * \param [in] type - a spatial discretization of interest.
6360 * \param [in] renumPol - specifies how to permute values of the result field according to
6361 * the optional numbers of cells and nodes, if any. The valid values are
6362 * - 0 - do not permute.
6363 * - 1 - permute cells.
6364 * - 2 - permute nodes.
6365 * - 3 - permute cells and nodes.
6367 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6368 * caller is to delete this field using decrRef() as it is no more needed.
6369 * \throw If \a this field has not been constructed via file reading.
6370 * \throw If the MED file is not readable.
6371 * \throw If there is no mesh in the MED file.
6372 * \throw If no field values of the given \a type.
6373 * \throw If no field values lying on the top level support.
6374 * \sa getFieldAtLevel()
6376 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6378 if(getFileName().empty())
6379 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6380 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6381 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6382 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6387 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6388 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6389 * \param [in] type - a spatial discretization of the new field.
6390 * \param [in] mesh - the supporting mesh.
6391 * \param [in] renumPol - specifies how to permute values of the result field according to
6392 * the optional numbers of cells and nodes, if any. The valid values are
6393 * - 0 - do not permute.
6394 * - 1 - permute cells.
6395 * - 2 - permute nodes.
6396 * - 3 - permute cells and nodes.
6398 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6399 * caller is to delete this field using decrRef() as it is no more needed.
6400 * \throw If no field of \a this is lying on \a mesh.
6401 * \throw If the mesh is empty.
6402 * \throw If no field values of the given \a type are available.
6403 * \sa getFieldAtLevel()
6404 * \sa getFieldOnMeshAtLevel()
6406 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6408 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6409 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6410 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6415 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6416 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6417 * \param [in] type - a spatial discretization of interest.
6418 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6419 * \param [in] mesh - the supporting mesh.
6420 * \param [in] renumPol - specifies how to permute values of the result field according to
6421 * the optional numbers of cells and nodes, if any. The valid values are
6422 * - 0 - do not permute.
6423 * - 1 - permute cells.
6424 * - 2 - permute nodes.
6425 * - 3 - permute cells and nodes.
6427 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6428 * caller is to delete this field using decrRef() as it is no more needed.
6429 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6430 * \throw If no field of \a this is lying on \a mesh.
6431 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6432 * \sa getFieldAtLevel()
6433 * \sa getFieldOnMeshAtLevel()
6435 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6437 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6438 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6439 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6444 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6445 * This method is called "Old" because in MED3 norm a field has only one meshName
6446 * attached, so this method is for readers of MED2 files. If \a this field
6447 * has not been constructed via file reading, an exception is thrown.
6448 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6449 * \param [in] type - a spatial discretization of interest.
6450 * \param [in] mName - a name of the supporting mesh.
6451 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6452 * \param [in] renumPol - specifies how to permute values of the result field according to
6453 * the optional numbers of cells and nodes, if any. The valid values are
6454 * - 0 - do not permute.
6455 * - 1 - permute cells.
6456 * - 2 - permute nodes.
6457 * - 3 - permute cells and nodes.
6459 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6460 * caller is to delete this field using decrRef() as it is no more needed.
6461 * \throw If the MED file is not readable.
6462 * \throw If there is no mesh named \a mName in the MED file.
6463 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6464 * \throw If \a this field has not been constructed via file reading.
6465 * \throw If no field of \a this is lying on the mesh named \a mName.
6466 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6467 * \sa getFieldAtLevel()
6469 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6471 if(getFileName().empty())
6472 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6473 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6474 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6475 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6480 * Returns values and a profile of the field of a given type lying on a given support.
6481 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6482 * \param [in] type - a spatial discretization of the field.
6483 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6484 * \param [in] mesh - the supporting mesh.
6485 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6486 * field of interest lies on. If the field lies on all entities of the given
6487 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6488 * using decrRef() as it is no more needed.
6489 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6490 * field. The caller is to delete this array using decrRef() as it is no more needed.
6491 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6492 * \throw If no field of \a this is lying on \a mesh.
6493 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6495 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6497 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6498 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6502 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6503 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6504 * "Sort By Type"), if not, an exception is thrown.
6505 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6506 * \param [in] field - the field to add to \a this.
6507 * \throw If the name of \a field is empty.
6508 * \throw If the data array of \a field is not set.
6509 * \throw If the data array is already allocated but has different number of components
6511 * \throw If the underlying mesh of \a field has no name.
6512 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6514 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6517 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6521 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6522 * can be an aggregation of several MEDCouplingFieldDouble instances.
6523 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6524 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6527 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6528 * A new profile is added only if no equal profile is missing.
6529 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6531 * \param [in] mesh - the supporting mesh of \a field.
6532 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6533 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6534 * \throw If either \a field or \a mesh or \a profile has an empty name.
6535 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6536 * \throw If the data array of \a field is not set.
6537 * \throw If the data array of \a this is already allocated but has different number of
6538 * components than \a field.
6539 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6540 * \sa setFieldNoProfileSBT()
6542 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6545 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6548 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6550 return new MEDFileField1TS(*this);
6553 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6555 return contentNotNull()->getUndergroundDataArrayDouble();
6558 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6560 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6563 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6564 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6566 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6569 //= MEDFileIntField1TS
6571 MEDFileIntField1TS *MEDFileIntField1TS::New()
6573 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6574 ret->contentNotNull();
6578 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6580 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6581 ret->contentNotNull();
6585 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6587 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6588 ret->contentNotNull();
6592 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6594 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6595 ret->contentNotNull();
6599 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6601 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6602 ret->contentNotNull();
6606 MEDFileIntField1TS::MEDFileIntField1TS()
6608 _content=new MEDFileIntField1TSWithoutSDA;
6611 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6612 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6615 catch(INTERP_KERNEL::Exception& e)
6618 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6619 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6622 catch(INTERP_KERNEL::Exception& e)
6625 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6626 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6629 catch(INTERP_KERNEL::Exception& e)
6633 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6634 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6636 * \warning this is a shallow copy constructor
6638 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6642 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6644 return new MEDFileIntField1TS(*this);
6648 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6649 * following the given input policy.
6651 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6652 * By default (true) the globals are deeply copied.
6653 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6655 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6657 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6658 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6661 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6663 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6664 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6665 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6668 ret=MEDFileField1TS::New();
6670 ret->deepCpyGlobs(*this);
6672 ret->shallowCpyGlobs(*this);
6677 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6678 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6679 * "Sort By Type"), if not, an exception is thrown.
6680 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6681 * \param [in] field - the field to add to \a this. The field double values are ignored.
6682 * \param [in] arrOfVals - the values of the field \a field used.
6683 * \throw If the name of \a field is empty.
6684 * \throw If the data array of \a field is not set.
6685 * \throw If the data array is already allocated but has different number of components
6687 * \throw If the underlying mesh of \a field has no name.
6688 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6690 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6693 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6697 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6698 * can be an aggregation of several MEDCouplingFieldDouble instances.
6699 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6700 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6703 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6704 * A new profile is added only if no equal profile is missing.
6705 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6706 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6707 * \param [in] arrOfVals - the values of the field \a field used.
6708 * \param [in] mesh - the supporting mesh of \a field.
6709 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6710 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6711 * \throw If either \a field or \a mesh or \a profile has an empty name.
6712 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6713 * \throw If the data array of \a field is not set.
6714 * \throw If the data array of \a this is already allocated but has different number of
6715 * components than \a field.
6716 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6717 * \sa setFieldNoProfileSBT()
6719 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6722 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6725 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6727 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6729 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6730 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6732 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 !");
6736 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6738 if(getFileName().empty())
6739 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6740 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6741 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6742 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6744 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6746 arrOut->incrRef(); // arrOut2 dies at the end of the func
6750 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6752 if(!((DataArray *)arr))
6753 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6754 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6756 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6762 * Returns a new MEDCouplingFieldDouble of a given type lying on
6763 * the top level cells of the first mesh in MED file. If \a this field
6764 * has not been constructed via file reading, an exception is thrown.
6765 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6766 * \param [in] type - a spatial discretization of interest.
6767 * \param [out] arrOut - the DataArrayInt containing values of field.
6768 * \param [in] renumPol - specifies how to permute values of the result field according to
6769 * the optional numbers of cells and nodes, if any. The valid values are
6770 * - 0 - do not permute.
6771 * - 1 - permute cells.
6772 * - 2 - permute nodes.
6773 * - 3 - permute cells and nodes.
6775 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6776 * caller is to delete this field using decrRef() as it is no more needed.
6777 * \throw If \a this field has not been constructed via file reading.
6778 * \throw If the MED file is not readable.
6779 * \throw If there is no mesh in the MED file.
6780 * \throw If no field values of the given \a type.
6781 * \throw If no field values lying on the top level support.
6782 * \sa getFieldAtLevel()
6784 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6786 if(getFileName().empty())
6787 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6788 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6789 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6790 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6795 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6796 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6797 * \param [in] type - a spatial discretization of the new field.
6798 * \param [in] mesh - the supporting mesh.
6799 * \param [out] arrOut - the DataArrayInt containing values of field.
6800 * \param [in] renumPol - specifies how to permute values of the result field according to
6801 * the optional numbers of cells and nodes, if any. The valid values are
6802 * - 0 - do not permute.
6803 * - 1 - permute cells.
6804 * - 2 - permute nodes.
6805 * - 3 - permute cells and nodes.
6807 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6808 * caller is to delete this field using decrRef() as it is no more needed.
6809 * \throw If no field of \a this is lying on \a mesh.
6810 * \throw If the mesh is empty.
6811 * \throw If no field values of the given \a type are available.
6812 * \sa getFieldAtLevel()
6813 * \sa getFieldOnMeshAtLevel()
6815 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6817 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6818 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6819 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6824 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6825 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6826 * \param [in] type - a spatial discretization of interest.
6827 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6828 * \param [out] arrOut - the DataArrayInt containing values of field.
6829 * \param [in] mesh - the supporting mesh.
6830 * \param [in] renumPol - specifies how to permute values of the result field according to
6831 * the optional numbers of cells and nodes, if any. The valid values are
6832 * - 0 - do not permute.
6833 * - 1 - permute cells.
6834 * - 2 - permute nodes.
6835 * - 3 - permute cells and nodes.
6837 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6838 * caller is to delete this field using decrRef() as it is no more needed.
6839 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6840 * \throw If no field of \a this is lying on \a mesh.
6841 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6842 * \sa getFieldAtLevel()
6843 * \sa getFieldOnMeshAtLevel()
6845 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6847 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6848 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6849 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6854 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6855 * This method is called "Old" because in MED3 norm a field has only one meshName
6856 * attached, so this method is for readers of MED2 files. If \a this field
6857 * has not been constructed via file reading, an exception is thrown.
6858 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6859 * \param [in] type - a spatial discretization of interest.
6860 * \param [in] mName - a name of the supporting mesh.
6861 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6862 * \param [out] arrOut - the DataArrayInt containing values of field.
6863 * \param [in] renumPol - specifies how to permute values of the result field according to
6864 * the optional numbers of cells and nodes, if any. The valid values are
6865 * - 0 - do not permute.
6866 * - 1 - permute cells.
6867 * - 2 - permute nodes.
6868 * - 3 - permute cells and nodes.
6870 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6871 * caller is to delete this field using decrRef() as it is no more needed.
6872 * \throw If the MED file is not readable.
6873 * \throw If there is no mesh named \a mName in the MED file.
6874 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6875 * \throw If \a this field has not been constructed via file reading.
6876 * \throw If no field of \a this is lying on the mesh named \a mName.
6877 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6878 * \sa getFieldAtLevel()
6880 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6882 if(getFileName().empty())
6883 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6884 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6885 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6886 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6891 * Returns values and a profile of the field of a given type lying on a given support.
6892 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6893 * \param [in] type - a spatial discretization of the field.
6894 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6895 * \param [in] mesh - the supporting mesh.
6896 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6897 * field of interest lies on. If the field lies on all entities of the given
6898 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6899 * using decrRef() as it is no more needed.
6900 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6901 * field. The caller is to delete this array using decrRef() as it is no more needed.
6902 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6903 * \throw If no field of \a this is lying on \a mesh.
6904 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6906 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6908 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6909 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6912 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6914 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6916 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6917 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6919 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 !");
6923 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6925 return contentNotNull()->getUndergroundDataArrayInt();
6928 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6930 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6934 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6939 * \param [in] fieldId field id in C mode
6941 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6943 med_field_type typcha;
6944 std::string dtunitOut;
6945 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6946 setDtUnit(dtunitOut.c_str());
6947 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6950 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)
6951 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6953 setDtUnit(dtunit.c_str());
6954 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6956 catch(INTERP_KERNEL::Exception& e)
6961 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6963 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6964 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6965 ret+=(*it).capacity();
6969 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6971 std::vector<const BigMemoryObject *> ret;
6972 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6973 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6978 * 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
6981 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6983 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6984 ret->setInfo(_infos);
6985 int sz=(int)_time_steps.size();
6986 for(const int *id=startIds;id!=endIds;id++)
6988 if(*id>=0 && *id<sz)
6990 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6991 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6995 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6997 ret->pushBackTimeStep(tse2);
7001 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7002 oss << " ! Should be in [0," << sz << ") !";
7003 throw INTERP_KERNEL::Exception(oss.str().c_str());
7006 if(ret->getNumberOfTS()>0)
7007 ret->synchronizeNameScope();
7008 ret->copyNameScope(*this);
7013 * 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
7016 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7018 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7019 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7020 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7021 ret->setInfo(_infos);
7022 int sz=(int)_time_steps.size();
7024 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7028 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7029 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7033 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7035 ret->pushBackTimeStep(tse2);
7039 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7040 oss << " ! Should be in [0," << sz << ") !";
7041 throw INTERP_KERNEL::Exception(oss.str().c_str());
7044 if(ret->getNumberOfTS()>0)
7045 ret->synchronizeNameScope();
7046 ret->copyNameScope(*this);
7050 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7053 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7054 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7056 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7059 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7060 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7061 ids->pushBackSilent(id);
7063 return buildFromTimeStepIds(ids->begin(),ids->end());
7066 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7069 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7070 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7072 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7075 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7076 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7077 ids->pushBackSilent(id);
7079 return buildFromTimeStepIds(ids->begin(),ids->end());
7082 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7084 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7086 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7089 if(cur->presenceOfMultiDiscPerGeoType())
7095 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7100 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7105 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7108 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7110 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7111 if(pt->isDealingTS(iteration,order))
7114 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7115 std::vector< std::pair<int,int> > vp=getIterations();
7116 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7117 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7118 throw INTERP_KERNEL::Exception(oss.str().c_str());
7121 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7123 return *_time_steps[getTimeStepPos(iteration,order)];
7126 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7128 return *_time_steps[getTimeStepPos(iteration,order)];
7131 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7133 if(_time_steps.empty())
7134 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7135 return _time_steps[0]->getMeshName();
7138 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7140 std::string oldName(getMeshName());
7141 std::vector< std::pair<std::string,std::string> > v(1);
7142 v[0].first=oldName; v[0].second=newMeshName;
7146 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7149 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7151 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7153 ret=cur->changeMeshNames(modifTab) || ret;
7159 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7161 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7163 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7167 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7169 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7171 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7174 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7175 MEDFileFieldGlobsReal& glob)
7178 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7180 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7182 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7187 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7189 std::string startLine(bkOffset,' ');
7190 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7192 oss << " (" << fmtsId << ")";
7193 oss << " has the following name: \"" << _name << "\"." << std::endl;
7194 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7195 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7197 oss << startLine << " - \"" << *it << "\"" << std::endl;
7200 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7202 std::string chapter(17,'0'+i);
7203 oss << startLine << chapter << std::endl;
7204 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7206 cur->simpleRepr(bkOffset+2,oss,i);
7208 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7209 oss << startLine << chapter << std::endl;
7213 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7215 std::size_t sz=_time_steps.size();
7216 std::vector< std::pair<int,int> > ret(sz);
7218 for(std::size_t i=0;i<sz;i++)
7220 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7223 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7227 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7228 throw INTERP_KERNEL::Exception(oss.str().c_str());
7234 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7236 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7238 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7239 checkCoherencyOfType(tse2);
7240 if(_time_steps.empty())
7242 setName(tse2->getName().c_str());
7243 setInfo(tse2->getInfo());
7245 checkThatComponentsMatch(tse2->getInfo());
7246 _time_steps.push_back(tse);
7249 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7251 std::size_t nbOfCompo=_infos.size();
7252 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7254 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7257 if((cur->getInfo()).size()!=nbOfCompo)
7259 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7260 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7261 throw INTERP_KERNEL::Exception(oss.str().c_str());
7263 cur->copyNameScope(*this);
7268 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7270 _time_steps.resize(nbPdt);
7271 for(int i=0;i<nbPdt;i++)
7273 std::vector< std::pair<int,int> > ts;
7274 med_int numdt=0,numo=0;
7275 med_int meshIt=0,meshOrder=0;
7277 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7282 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7287 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7291 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7294 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7296 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7300 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7302 if(_time_steps.empty())
7303 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7304 checkThatNbOfCompoOfTSMatchThis();
7305 std::vector<std::string> infos(getInfo());
7306 int nbComp=infos.size();
7307 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7308 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7309 for(int i=0;i<nbComp;i++)
7311 std::string info=infos[i];
7313 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7314 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7315 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7318 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7319 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7320 int nbOfTS=_time_steps.size();
7321 for(int i=0;i<nbOfTS;i++)
7322 _time_steps[i]->writeLL(fid,opts,*this);
7325 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7329 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7331 elt->loadBigArraysRecursively(fid,nasc);
7335 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7337 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7339 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7341 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7345 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7347 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7349 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7351 elt->unloadArrays();
7355 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7357 return _time_steps.size();
7360 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7362 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7363 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7365 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7367 newTS.push_back(*it);
7372 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7374 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7375 int maxId=(int)_time_steps.size();
7377 std::set<int> idsToDel;
7378 for(const int *id=startIds;id!=endIds;id++,ii++)
7380 if(*id>=0 && *id<maxId)
7382 idsToDel.insert(*id);
7386 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7387 throw INTERP_KERNEL::Exception(oss.str().c_str());
7390 for(int iii=0;iii<maxId;iii++)
7391 if(idsToDel.find(iii)==idsToDel.end())
7392 newTS.push_back(_time_steps[iii]);
7396 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7398 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7399 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7400 if(nbOfEntriesToKill==0)
7402 std::size_t sz=_time_steps.size();
7403 std::vector<bool> b(sz,true);
7405 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7407 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7408 for(std::size_t i=0;i<sz;i++)
7410 newTS.push_back(_time_steps[i]);
7414 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7417 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7420 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7424 tmp->getTime(it2,ord);
7425 if(it2==iteration && order==ord)
7428 oss << "(" << it2 << "," << ord << "), ";
7431 throw INTERP_KERNEL::Exception(oss.str().c_str());
7434 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7437 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7439 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7441 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7445 double ti=tmp->getTime(it2,ord);
7446 if(fabs(time-ti)<eps)
7452 throw INTERP_KERNEL::Exception(oss.str().c_str());
7455 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7457 int lgth=_time_steps.size();
7458 std::vector< std::pair<int,int> > ret(lgth);
7459 for(int i=0;i<lgth;i++)
7460 _time_steps[i]->fillIteration(ret[i]);
7465 * 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'
7466 * This method returns two things.
7467 * - The absolute dimension of 'this' in first parameter.
7468 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7469 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7471 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7472 * Only these 3 discretizations will be taken into account here.
7474 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7475 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7476 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7478 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7479 * 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'.
7481 * Let's consider the typical following case :
7482 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7483 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7484 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7486 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7488 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7490 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7491 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7492 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7493 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7495 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7497 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7500 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7502 if(pos<0 || pos>=(int)_time_steps.size())
7504 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7505 throw INTERP_KERNEL::Exception(oss.str().c_str());
7507 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7510 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7511 oss << "\nTry to use following method eraseEmptyTS !";
7512 throw INTERP_KERNEL::Exception(oss.str().c_str());
7517 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7519 if(pos<0 || pos>=(int)_time_steps.size())
7521 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7522 throw INTERP_KERNEL::Exception(oss.str().c_str());
7524 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7527 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7528 oss << "\nTry to use following method eraseEmptyTS !";
7529 throw INTERP_KERNEL::Exception(oss.str().c_str());
7534 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7536 std::vector<std::string> ret;
7537 std::set<std::string> ret2;
7538 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7540 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7541 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7542 if(ret2.find(*it2)==ret2.end())
7544 ret.push_back(*it2);
7551 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7553 std::vector<std::string> ret;
7554 std::set<std::string> ret2;
7555 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7557 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7558 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7559 if(ret2.find(*it2)==ret2.end())
7561 ret.push_back(*it2);
7568 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7570 std::vector<std::string> ret;
7571 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7573 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7574 ret.insert(ret.end(),tmp.begin(),tmp.end());
7579 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7581 std::vector<std::string> ret;
7582 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7584 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7585 ret.insert(ret.end(),tmp.begin(),tmp.end());
7590 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7592 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7593 (*it)->changePflsRefsNamesGen2(mapOfModif);
7596 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7598 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7599 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7602 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7604 int lgth=_time_steps.size();
7605 std::vector< std::vector<TypeOfField> > ret(lgth);
7606 for(int i=0;i<lgth;i++)
7607 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7612 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7614 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
7616 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7619 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7621 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7623 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7625 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7626 ret->_time_steps[i]=(*it)->deepCpy();
7631 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7633 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7634 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7635 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7636 for(std::size_t i=0;i<sz;i++)
7638 ret[i]=shallowCpy();
7639 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7641 for(std::size_t i=0;i<sz2;i++)
7643 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7646 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7647 throw INTERP_KERNEL::Exception(oss.str().c_str());
7651 for(std::size_t i=0;i<sz;i++)
7652 for(std::size_t j=0;j<sz2;j++)
7653 ret[i]->_time_steps[j]=ts[j][i];
7658 * This method splits into discretization each time steps in \a this.
7659 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7661 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7663 std::size_t sz(_time_steps.size());
7664 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7665 for(std::size_t i=0;i<sz;i++)
7667 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7670 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7671 throw INTERP_KERNEL::Exception(oss.str().c_str());
7673 items[i]=timeStep->splitDiscretizations();
7676 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7677 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7678 std::vector< TypeOfField > types;
7679 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7680 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7682 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7684 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7685 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7686 if(it2==types.end())
7687 types.push_back(ts[0]);
7689 ret.resize(types.size()); ret2.resize(types.size());
7690 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7691 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7693 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7694 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7695 ret2[pos].push_back(*it1);
7697 for(std::size_t i=0;i<types.size();i++)
7699 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7700 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7701 elt->pushBackTimeStep(*it1);//also updates infos in elt
7703 elt->MEDFileFieldNameScope::operator=(*this);
7709 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7711 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7713 std::size_t sz(_time_steps.size());
7714 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7715 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7716 for(std::size_t i=0;i<sz;i++)
7718 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7721 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7722 throw INTERP_KERNEL::Exception(oss.str().c_str());
7724 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7725 if(szOut==std::numeric_limits<std::size_t>::max())
7726 szOut=items[i].size();
7728 if(items[i].size()!=szOut)
7729 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7731 if(szOut==std::numeric_limits<std::size_t>::max())
7732 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7733 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7734 for(std::size_t i=0;i<szOut;i++)
7736 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7737 for(std::size_t j=0;j<sz;j++)
7738 elt->pushBackTimeStep(items[j][i]);
7740 elt->MEDFileFieldNameScope::operator=(*this);
7745 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7747 _name=field->getName();
7749 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7751 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7752 _infos=arr->getInfoOnComponents();
7755 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7757 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7758 if(_name!=field->getName())
7760 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7761 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7762 throw INTERP_KERNEL::Exception(oss.str().c_str());
7765 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7766 checkThatComponentsMatch(arr->getInfoOnComponents());
7769 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7771 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7772 if(getInfo().size()!=compos.size())
7774 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7775 oss << " number of components of element to append (" << compos.size() << ") !";
7776 throw INTERP_KERNEL::Exception(oss.str().c_str());
7780 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7781 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7782 oss << " But compo in input fields are : ";
7783 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7785 throw INTERP_KERNEL::Exception(oss.str().c_str());
7789 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7791 std::size_t sz=_infos.size();
7793 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7795 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7797 if(elt->getInfo().size()!=sz)
7799 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7800 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7801 throw INTERP_KERNEL::Exception(oss.str().c_str());
7806 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7809 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7810 if(!_time_steps.empty())
7811 checkCoherencyOfTinyInfo(field,arr);
7812 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7813 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7814 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7815 copyTinyInfoFrom(field,arr);
7816 _time_steps.push_back(obj);
7819 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7822 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7823 if(!_time_steps.empty())
7824 checkCoherencyOfTinyInfo(field,arr);
7825 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7826 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7827 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7828 copyTinyInfoFrom(field,arr);
7829 _time_steps.push_back(obj);
7832 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7834 int sz=(int)_time_steps.size();
7837 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7838 throw INTERP_KERNEL::Exception(oss.str().c_str());
7840 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7843 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7845 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7846 throw INTERP_KERNEL::Exception(oss.str().c_str());
7852 //= MEDFileFieldMultiTSWithoutSDA
7854 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)
7856 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7859 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7863 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7868 * \param [in] fieldId field id in C mode
7870 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7871 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7874 catch(INTERP_KERNEL::Exception& e)
7877 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)
7878 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7881 catch(INTERP_KERNEL::Exception& e)
7884 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7886 return new MEDFileField1TSWithoutSDA;
7889 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7892 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7893 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7895 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7898 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7900 return MEDFileField1TSWithoutSDA::TYPE_STR;
7903 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7905 return new MEDFileFieldMultiTSWithoutSDA(*this);
7908 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7910 return new MEDFileFieldMultiTSWithoutSDA;
7914 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7915 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7917 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
7919 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7920 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7922 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7923 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7926 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7928 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7929 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7931 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7933 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7936 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7938 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7939 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7940 ret->setIteration(i,elt);
7946 //= MEDFileAnyTypeFieldMultiTS
7948 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7952 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7953 try:MEDFileFieldGlobsReal(fileName)
7955 MEDFileUtilities::CheckFileForRead(fileName);
7956 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7957 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7960 catch(INTERP_KERNEL::Exception& e)
7965 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7967 med_field_type typcha;
7968 std::vector<std::string> infos;
7971 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7972 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7977 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7982 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7987 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] !";
7988 throw INTERP_KERNEL::Exception(oss.str().c_str());
7991 ret->setDtUnit(dtunit.c_str());
7995 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7997 med_field_type typcha;
7999 std::vector<std::string> infos;
8000 std::string dtunit,fieldName;
8001 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8002 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8007 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
8012 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
8017 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] !";
8018 throw INTERP_KERNEL::Exception(oss.str().c_str());
8021 ret->setDtUnit(dtunit.c_str());
8025 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8028 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8029 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8031 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8032 ret->setFileName(fileName);
8033 ret->_content=c; c->incrRef();
8036 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8038 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8039 ret->setFileName(fileName);
8040 ret->_content=c; c->incrRef();
8043 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8046 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
8047 try:MEDFileFieldGlobsReal(fileName)
8049 MEDFileUtilities::CheckFileForRead(fileName);
8050 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8051 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
8054 catch(INTERP_KERNEL::Exception& e)
8059 //= MEDFileIntFieldMultiTSWithoutSDA
8061 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)
8063 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
8066 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8070 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8074 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)
8075 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
8078 catch(INTERP_KERNEL::Exception& e)
8082 * \param [in] fieldId field id in C mode
8084 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
8085 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
8088 catch(INTERP_KERNEL::Exception& e)
8091 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8093 return new MEDFileIntField1TSWithoutSDA;
8096 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8099 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8100 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8102 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8105 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8107 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8110 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8112 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8115 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8117 return new MEDFileIntFieldMultiTSWithoutSDA;
8120 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8122 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8123 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8125 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8127 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8130 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8132 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8133 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8134 ret->setIteration(i,elt);
8140 //= MEDFileAnyTypeFieldMultiTS
8143 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8144 * that has been read from a specified MED file.
8145 * \param [in] fileName - the name of the MED file to read.
8146 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8147 * is to delete this field using decrRef() as it is no more needed.
8148 * \throw If reading the file fails.
8150 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8152 MEDFileUtilities::CheckFileForRead(fileName);
8153 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8154 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8155 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8156 ret->loadGlobals(fid);
8161 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8162 * that has been read from a specified MED file.
8163 * \param [in] fileName - the name of the MED file to read.
8164 * \param [in] fieldName - the name of the field to read.
8165 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8166 * is to delete this field using decrRef() as it is no more needed.
8167 * \throw If reading the file fails.
8168 * \throw If there is no field named \a fieldName in the file.
8170 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8172 MEDFileUtilities::CheckFileForRead(fileName);
8173 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8174 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
8175 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8176 ret->loadGlobals(fid);
8181 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8182 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8184 * \warning this is a shallow copy constructor
8186 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8188 if(!shallowCopyOfContent)
8190 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8191 otherPtr->incrRef();
8192 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8196 _content=other.shallowCpy();
8200 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8202 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8204 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8208 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8210 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8212 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8216 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8218 return contentNotNullBase()->getPflsReallyUsed2();
8221 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8223 return contentNotNullBase()->getLocsReallyUsed2();
8226 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8228 return contentNotNullBase()->getPflsReallyUsedMulti2();
8231 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8233 return contentNotNullBase()->getLocsReallyUsedMulti2();
8236 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8238 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8241 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8243 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8246 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8248 return contentNotNullBase()->getNumberOfTS();
8251 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8253 contentNotNullBase()->eraseEmptyTS();
8256 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8258 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8261 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8263 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8266 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8268 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8269 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8274 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8276 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8277 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8282 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8284 return contentNotNullBase()->getIterations();
8287 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8289 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8290 pushBackTimeStep(*it);
8293 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8296 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8297 checkCoherencyOfType(f1ts);
8299 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8300 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8302 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8303 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8304 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8305 _content->pushBackTimeStep(cSafe);
8306 appendGlobs(*f1ts,1e-12);
8309 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8311 contentNotNullBase()->synchronizeNameScope();
8314 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8316 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8319 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8321 return contentNotNullBase()->getPosGivenTime(time,eps);
8324 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8326 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8329 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8331 return contentNotNullBase()->getTypesOfFieldAvailable();
8334 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
8336 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8339 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8341 return contentNotNullBase()->getName();
8344 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8346 contentNotNullBase()->setName(name);
8349 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8351 return contentNotNullBase()->getDtUnit();
8354 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8356 contentNotNullBase()->setDtUnit(dtUnit);
8359 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8361 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8364 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8366 return contentNotNullBase()->getTimeSteps(ret1);
8369 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8371 return contentNotNullBase()->getMeshName();
8374 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8376 contentNotNullBase()->setMeshName(newMeshName);
8379 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8381 return contentNotNullBase()->changeMeshNames(modifTab);
8384 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8386 return contentNotNullBase()->getInfo();
8389 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8391 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8394 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8396 return contentNotNullBase()->setInfo(info);
8399 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8401 const std::vector<std::string> ret=getInfo();
8402 return (int)ret.size();
8405 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8407 writeGlobals(fid,*this);
8408 contentNotNullBase()->writeLL(fid,*this);
8412 * Writes \a this field into a MED file specified by its name.
8413 * \param [in] fileName - the MED file name.
8414 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8415 * - 2 - erase; an existing file is removed.
8416 * - 1 - append; same data should not be present in an existing file.
8417 * - 0 - overwrite; same data present in an existing file is overwritten.
8418 * \throw If the field name is not set.
8419 * \throw If no field data is set.
8420 * \throw If \a mode == 1 and the same data is present in an existing file.
8422 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8424 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8425 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8430 * This method alloc the arrays and load potentially huge arrays contained in this field.
8431 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8432 * This method can be also called to refresh or reinit values from a file.
8434 * \throw If the fileName is not set or points to a non readable MED file.
8436 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8438 if(getFileName().empty())
8439 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8440 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8441 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8445 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8446 * But once data loaded once, this method does nothing.
8448 * \throw If the fileName is not set or points to a non readable MED file.
8449 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8451 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8453 if(!getFileName().empty())
8455 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8456 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8461 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8462 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8463 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8465 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8467 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8469 contentNotNullBase()->unloadArrays();
8473 * 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.
8474 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8475 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8477 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8479 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8481 if(!getFileName().empty())
8482 contentNotNullBase()->unloadArrays();
8485 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8487 std::ostringstream oss;
8488 contentNotNullBase()->simpleRepr(0,oss,-1);
8489 simpleReprGlobs(oss);
8493 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8495 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8498 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8500 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8501 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8506 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8507 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8508 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8510 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8512 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8514 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8515 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8516 std::size_t sz(contentsSplit.size());
8517 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8518 for(std::size_t i=0;i<sz;i++)
8520 ret[i]=shallowCpy();
8521 ret[i]->_content=contentsSplit[i];
8527 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8528 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8530 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8532 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8534 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8535 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8536 std::size_t sz(contentsSplit.size());
8537 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8538 for(std::size_t i=0;i<sz;i++)
8540 ret[i]=shallowCpy();
8541 ret[i]->_content=contentsSplit[i];
8547 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8548 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8550 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8552 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8554 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8555 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8556 std::size_t sz(contentsSplit.size());
8557 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8558 for(std::size_t i=0;i<sz;i++)
8560 ret[i]=shallowCpy();
8561 ret[i]->_content=contentsSplit[i];
8566 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8568 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8569 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8570 ret->_content=_content->deepCpy();
8571 ret->deepCpyGlobs(*this);
8575 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8581 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8582 * \param [in] iteration - the iteration number of a required time step.
8583 * \param [in] order - the iteration order number of required time step.
8584 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8585 * delete this field using decrRef() as it is no more needed.
8586 * \throw If there is no required time step in \a this field.
8588 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8590 int pos=getPosOfTimeStep(iteration,order);
8591 return getTimeStepAtPos(pos);
8595 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8596 * \param [in] time - the time of the time step of interest.
8597 * \param [in] eps - a precision used to compare time values.
8598 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8599 * delete this field using decrRef() as it is no more needed.
8600 * \throw If there is no required time step in \a this field.
8602 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8604 int pos=getPosGivenTime(time,eps);
8605 return getTimeStepAtPos(pos);
8609 * 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.
8610 * The float64 value of time attached to the pair of integers are not considered here.
8611 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8613 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8614 * \throw If there is a null pointer in \a vectFMTS.
8616 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8618 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8619 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8620 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8621 while(!lstFMTS.empty())
8623 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8624 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8626 throw INTERP_KERNEL::Exception(msg);
8627 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8628 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8629 elt.push_back(curIt); it=lstFMTS.erase(it);
8630 while(it!=lstFMTS.end())
8634 throw INTERP_KERNEL::Exception(msg);
8635 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8637 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8647 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8648 * All returned instances in a subvector can be safely loaded, rendered along time
8649 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8650 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8651 * 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).
8652 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8653 * 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.
8655 * \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().
8656 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8657 * \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.
8658 * \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.
8660 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8661 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8662 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8663 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8664 * \throw If mesh is null.
8665 * \throw If an element in \a vectFMTS is null.
8666 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8668 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8670 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8672 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8673 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8674 if(vectFMTS.empty())
8676 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8677 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8679 throw INTERP_KERNEL::Exception(msg);
8681 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8682 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8683 for(;it!=vectFMTS.end();it++,i++)
8686 throw INTERP_KERNEL::Exception(msg);
8687 TypeOfField tof0,tof1;
8688 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8691 vectFMTSNotNodes.push_back(*it);
8693 vectFMTSNodes.push_back(*it);
8696 vectFMTSNotNodes.push_back(*it);
8698 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8699 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8701 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8704 bool isFetched(false);
8705 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8708 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8709 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8710 { ret[i].push_back(*it2); isFetched=true; }
8714 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8715 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8716 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8724 * 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.
8725 * \param [out] cmps - same size than the returned vector.
8727 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8729 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8730 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8731 while(!lstFMTS.empty())
8733 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8734 MEDFileAnyTypeFieldMultiTS *ref(*it);
8735 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8736 elt.push_back(ref); it=lstFMTS.erase(it);
8737 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8738 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8739 while(it!=lstFMTS.end())
8741 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8742 if(cmp->isEqual(curIt))
8743 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8747 ret.push_back(elt); cmps.push_back(cmp);
8753 * 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.
8754 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8756 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8757 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8758 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8759 * \thorw If \a f0 and \a f1 do not have the same times steps.
8760 * \throw If mesh is null.
8761 * \throw If \a f0 or \a f1 is null.
8762 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8764 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8767 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8769 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8770 if(f0->getMeshName()!=mesh->getName())
8772 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8773 throw INTERP_KERNEL::Exception(oss.str().c_str());
8775 if(f1->getMeshName()!=mesh->getName())
8777 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8778 throw INTERP_KERNEL::Exception(oss.str().c_str());
8780 int nts=f0->getNumberOfTS();
8781 if(nts!=f1->getNumberOfTS())
8782 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8785 for(int i=0;i<nts;i++)
8787 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8788 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8789 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8790 if(tofs0.size()!=1 || tofs1.size()!=1)
8791 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8794 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8795 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8798 { tof0=tofs0[0]; tof1=tofs1[0]; }
8799 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8801 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() << ") !";
8802 throw INTERP_KERNEL::Exception(oss.str().c_str());
8804 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8806 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() << ") !";
8807 throw INTERP_KERNEL::Exception(oss.str().c_str());
8809 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8811 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() << ") !";
8812 throw INTERP_KERNEL::Exception(oss.str().c_str());
8818 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8820 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8823 //= MEDFileFieldMultiTS
8826 * Returns a new empty instance of MEDFileFieldMultiTS.
8827 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8828 * is to delete this field using decrRef() as it is no more needed.
8830 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8832 return new MEDFileFieldMultiTS;
8836 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8837 * that has been read from a specified MED file.
8838 * \param [in] fileName - the name of the MED file to read.
8839 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8840 * is to delete this field using decrRef() as it is no more needed.
8841 * \throw If reading the file fails.
8843 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8845 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8846 ret->contentNotNull();//to check that content type matches with \a this type.
8851 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8852 * that has been read from a specified MED file.
8853 * \param [in] fileName - the name of the MED file to read.
8854 * \param [in] fieldName - the name of the field to read.
8855 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8856 * is to delete this field using decrRef() as it is no more needed.
8857 * \throw If reading the file fails.
8858 * \throw If there is no field named \a fieldName in the file.
8860 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8862 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8863 ret->contentNotNull();//to check that content type matches with \a this type.
8868 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8869 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8871 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8872 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8873 * \warning this is a shallow copy constructor
8874 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8875 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8876 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8877 * is to delete this field using decrRef() as it is no more needed.
8879 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8881 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8884 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8886 return new MEDFileFieldMultiTS(*this);
8889 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8892 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8893 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8895 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8899 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8900 * following the given input policy.
8902 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8903 * By default (true) the globals are deeply copied.
8904 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8906 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8908 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8909 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8912 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8914 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8915 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8916 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8919 ret=MEDFileIntFieldMultiTS::New();
8921 ret->deepCpyGlobs(*this);
8923 ret->shallowCpyGlobs(*this);
8928 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8929 * \param [in] pos - a time step id.
8930 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8931 * delete this field using decrRef() as it is no more needed.
8932 * \throw If \a pos is not a valid time step id.
8934 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8936 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8939 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8940 throw INTERP_KERNEL::Exception(oss.str().c_str());
8942 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8945 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8946 ret->shallowCpyGlobs(*this);
8949 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8950 throw INTERP_KERNEL::Exception(oss.str().c_str());
8954 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8955 * mesh entities of a given dimension of the first mesh in MED file.
8956 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8957 * \param [in] type - a spatial discretization of interest.
8958 * \param [in] iteration - the iteration number of a required time step.
8959 * \param [in] order - the iteration order number of required time step.
8960 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8961 * \param [in] renumPol - specifies how to permute values of the result field according to
8962 * the optional numbers of cells and nodes, if any. The valid values are
8963 * - 0 - do not permute.
8964 * - 1 - permute cells.
8965 * - 2 - permute nodes.
8966 * - 3 - permute cells and nodes.
8968 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8969 * caller is to delete this field using decrRef() as it is no more needed.
8970 * \throw If the MED file is not readable.
8971 * \throw If there is no mesh in the MED file.
8972 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8973 * \throw If no field values of the required parameters are available.
8975 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8977 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8978 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8980 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8981 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8982 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8983 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8988 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8989 * the top level cells of the first mesh in MED file.
8990 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8991 * \param [in] type - a spatial discretization of interest.
8992 * \param [in] iteration - the iteration number of a required time step.
8993 * \param [in] order - the iteration order number of required time step.
8994 * \param [in] renumPol - specifies how to permute values of the result field according to
8995 * the optional numbers of cells and nodes, if any. The valid values are
8996 * - 0 - do not permute.
8997 * - 1 - permute cells.
8998 * - 2 - permute nodes.
8999 * - 3 - permute cells and nodes.
9001 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9002 * caller is to delete this field using decrRef() as it is no more needed.
9003 * \throw If the MED file is not readable.
9004 * \throw If there is no mesh in the MED file.
9005 * \throw If no field values of the required parameters are available.
9007 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9009 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9010 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9012 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9013 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9014 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9015 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9020 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9022 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9023 * \param [in] type - a spatial discretization of interest.
9024 * \param [in] iteration - the iteration number of a required time step.
9025 * \param [in] order - the iteration order number of required time step.
9026 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9027 * \param [in] mesh - the supporting mesh.
9028 * \param [in] renumPol - specifies how to permute values of the result field according to
9029 * the optional numbers of cells and nodes, if any. The valid values are
9030 * - 0 - do not permute.
9031 * - 1 - permute cells.
9032 * - 2 - permute nodes.
9033 * - 3 - permute cells and nodes.
9035 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9036 * caller is to delete this field using decrRef() as it is no more needed.
9037 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9038 * \throw If no field of \a this is lying on \a mesh.
9039 * \throw If no field values of the required parameters are available.
9041 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9043 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9044 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9046 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9047 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9048 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9049 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9054 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9056 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9057 * \param [in] type - a spatial discretization of the new field.
9058 * \param [in] iteration - the iteration number of a required time step.
9059 * \param [in] order - the iteration order number of required time step.
9060 * \param [in] mesh - the supporting mesh.
9061 * \param [in] renumPol - specifies how to permute values of the result field according to
9062 * the optional numbers of cells and nodes, if any. The valid values are
9063 * - 0 - do not permute.
9064 * - 1 - permute cells.
9065 * - 2 - permute nodes.
9066 * - 3 - permute cells and nodes.
9068 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9069 * caller is to delete this field using decrRef() as it is no more needed.
9070 * \throw If no field of \a this is lying on \a mesh.
9071 * \throw If no field values of the required parameters are available.
9073 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9075 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9076 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9078 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9079 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9080 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9081 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9086 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9087 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9088 * This method is useful for MED2 file format when field on different mesh was autorized.
9090 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9092 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9093 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9095 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9096 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9097 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9098 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9103 * Returns values and a profile of the field of a given type, of a given time step,
9104 * lying on a given support.
9105 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9106 * \param [in] type - a spatial discretization of the field.
9107 * \param [in] iteration - the iteration number of a required time step.
9108 * \param [in] order - the iteration order number of required time step.
9109 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9110 * \param [in] mesh - the supporting mesh.
9111 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9112 * field of interest lies on. If the field lies on all entities of the given
9113 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9114 * using decrRef() as it is no more needed.
9115 * \param [in] glob - the global data storing profiles and localization.
9116 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9117 * field. The caller is to delete this array using decrRef() as it is no more needed.
9118 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9119 * \throw If no field of \a this is lying on \a mesh.
9120 * \throw If no field values of the required parameters are available.
9122 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9124 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9125 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9127 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9128 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9129 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9132 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9134 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9136 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9137 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9139 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 !");
9143 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9145 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9147 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9148 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9150 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 !");
9155 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9156 * the given field is checked if its elements are sorted suitable for writing to MED file
9157 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9158 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9159 * \param [in] field - the field to add to \a this.
9160 * \throw If the name of \a field is empty.
9161 * \throw If the data array of \a field is not set.
9162 * \throw If existing time steps have different name or number of components than \a field.
9163 * \throw If the underlying mesh of \a field has no name.
9164 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9166 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9168 const DataArrayDouble *arr=0;
9170 arr=field->getArray();
9171 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9175 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9176 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9177 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9180 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9181 * A new profile is added only if no equal profile is missing.
9182 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9183 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9184 * \param [in] mesh - the supporting mesh of \a field.
9185 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9186 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9187 * \throw If either \a field or \a mesh or \a profile has an empty name.
9188 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9189 * \throw If the data array of \a field is not set.
9190 * \throw If the data array of \a this is already allocated but has different number of
9191 * components than \a field.
9192 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9193 * \sa setFieldNoProfileSBT()
9195 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9197 const DataArrayDouble *arr=0;
9199 arr=field->getArray();
9200 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9203 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9205 _content=new MEDFileFieldMultiTSWithoutSDA;
9208 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9209 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9212 catch(INTERP_KERNEL::Exception& e)
9215 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9216 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9219 catch(INTERP_KERNEL::Exception& e)
9222 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9226 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
9228 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9231 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9233 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9236 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9238 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9241 //= MEDFileAnyTypeFieldMultiTSIterator
9243 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9248 _nb_iter=fmts->getNumberOfTS();
9252 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9256 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9258 if(_iter_id<_nb_iter)
9260 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9262 return fmts->getTimeStepAtPos(_iter_id++);
9270 //= MEDFileIntFieldMultiTS
9273 * Returns a new empty instance of MEDFileFieldMultiTS.
9274 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9275 * is to delete this field using decrRef() as it is no more needed.
9277 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9279 return new MEDFileIntFieldMultiTS;
9283 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9284 * that has been read from a specified MED file.
9285 * \param [in] fileName - the name of the MED file to read.
9286 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9287 * is to delete this field using decrRef() as it is no more needed.
9288 * \throw If reading the file fails.
9290 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9292 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9293 ret->contentNotNull();//to check that content type matches with \a this type.
9298 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9299 * that has been read from a specified MED file.
9300 * \param [in] fileName - the name of the MED file to read.
9301 * \param [in] fieldName - the name of the field to read.
9302 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9303 * is to delete this field using decrRef() as it is no more needed.
9304 * \throw If reading the file fails.
9305 * \throw If there is no field named \a fieldName in the file.
9307 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9309 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9310 ret->contentNotNull();//to check that content type matches with \a this type.
9315 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9316 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9318 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9319 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9320 * \warning this is a shallow copy constructor
9321 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9322 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9323 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9324 * is to delete this field using decrRef() as it is no more needed.
9326 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9328 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9332 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9333 * following the given input policy.
9335 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9336 * By default (true) the globals are deeply copied.
9337 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9339 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9341 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9342 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9345 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9347 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9348 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9349 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9352 ret=MEDFileFieldMultiTS::New();
9354 ret->deepCpyGlobs(*this);
9356 ret->shallowCpyGlobs(*this);
9360 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9362 return new MEDFileIntFieldMultiTS(*this);
9365 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9368 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9369 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9371 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9375 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9376 * mesh entities of a given dimension of the first mesh in MED file.
9377 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9378 * \param [in] type - a spatial discretization of interest.
9379 * \param [in] iteration - the iteration number of a required time step.
9380 * \param [in] order - the iteration order number of required time step.
9381 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9382 * \param [out] arrOut - the DataArrayInt containing values of field.
9383 * \param [in] renumPol - specifies how to permute values of the result field according to
9384 * the optional numbers of cells and nodes, if any. The valid values are
9385 * - 0 - do not permute.
9386 * - 1 - permute cells.
9387 * - 2 - permute nodes.
9388 * - 3 - permute cells and nodes.
9390 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9391 * caller is to delete this field using decrRef() as it is no more needed.
9392 * \throw If the MED file is not readable.
9393 * \throw If there is no mesh in the MED file.
9394 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9395 * \throw If no field values of the required parameters are available.
9397 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9399 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9400 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9402 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9403 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9404 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9405 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9410 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9411 * the top level cells of the first mesh in MED file.
9412 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9413 * \param [in] type - a spatial discretization of interest.
9414 * \param [in] iteration - the iteration number of a required time step.
9415 * \param [in] order - the iteration order number of required time step.
9416 * \param [out] arrOut - the DataArrayInt containing values of field.
9417 * \param [in] renumPol - specifies how to permute values of the result field according to
9418 * the optional numbers of cells and nodes, if any. The valid values are
9419 * - 0 - do not permute.
9420 * - 1 - permute cells.
9421 * - 2 - permute nodes.
9422 * - 3 - permute cells and nodes.
9424 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9425 * caller is to delete this field using decrRef() as it is no more needed.
9426 * \throw If the MED file is not readable.
9427 * \throw If there is no mesh in the MED file.
9428 * \throw If no field values of the required parameters are available.
9430 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9432 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9433 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9435 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9436 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9437 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9438 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9443 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9445 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9446 * \param [in] type - a spatial discretization of interest.
9447 * \param [in] iteration - the iteration number of a required time step.
9448 * \param [in] order - the iteration order number of required time step.
9449 * \param [out] arrOut - the DataArrayInt containing values of field.
9450 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9451 * \param [in] mesh - the supporting mesh.
9452 * \param [in] renumPol - specifies how to permute values of the result field according to
9453 * the optional numbers of cells and nodes, if any. The valid values are
9454 * - 0 - do not permute.
9455 * - 1 - permute cells.
9456 * - 2 - permute nodes.
9457 * - 3 - permute cells and nodes.
9459 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9460 * caller is to delete this field using decrRef() as it is no more needed.
9461 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9462 * \throw If no field of \a this is lying on \a mesh.
9463 * \throw If no field values of the required parameters are available.
9465 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9467 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9468 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9470 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9471 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9472 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9473 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9478 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9480 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9481 * \param [in] type - a spatial discretization of the new field.
9482 * \param [in] iteration - the iteration number of a required time step.
9483 * \param [in] order - the iteration order number of required time step.
9484 * \param [in] mesh - the supporting mesh.
9485 * \param [out] arrOut - the DataArrayInt containing values of field.
9486 * \param [in] renumPol - specifies how to permute values of the result field according to
9487 * the optional numbers of cells and nodes, if any. The valid values are
9488 * - 0 - do not permute.
9489 * - 1 - permute cells.
9490 * - 2 - permute nodes.
9491 * - 3 - permute cells and nodes.
9493 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9494 * caller is to delete this field using decrRef() as it is no more needed.
9495 * \throw If no field of \a this is lying on \a mesh.
9496 * \throw If no field values of the required parameters are available.
9498 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9500 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9501 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9503 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9504 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9505 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9506 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9511 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9512 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9513 * This method is useful for MED2 file format when field on different mesh was autorized.
9515 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9517 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9518 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9520 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9521 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9522 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9523 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9528 * Returns values and a profile of the field of a given type, of a given time step,
9529 * lying on a given support.
9530 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9531 * \param [in] type - a spatial discretization of the field.
9532 * \param [in] iteration - the iteration number of a required time step.
9533 * \param [in] order - the iteration order number of required time step.
9534 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9535 * \param [in] mesh - the supporting mesh.
9536 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9537 * field of interest lies on. If the field lies on all entities of the given
9538 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9539 * using decrRef() as it is no more needed.
9540 * \param [in] glob - the global data storing profiles and localization.
9541 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9542 * field. The caller is to delete this array using decrRef() as it is no more needed.
9543 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9544 * \throw If no field of \a this is lying on \a mesh.
9545 * \throw If no field values of the required parameters are available.
9547 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9549 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9550 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9552 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9553 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9554 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9558 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9559 * \param [in] pos - a time step id.
9560 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9561 * delete this field using decrRef() as it is no more needed.
9562 * \throw If \a pos is not a valid time step id.
9564 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9566 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9569 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9570 throw INTERP_KERNEL::Exception(oss.str().c_str());
9572 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9575 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9576 ret->shallowCpyGlobs(*this);
9579 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9580 throw INTERP_KERNEL::Exception(oss.str().c_str());
9584 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9585 * the given field is checked if its elements are sorted suitable for writing to MED file
9586 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9587 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9588 * \param [in] field - the field to add to \a this.
9589 * \throw If the name of \a field is empty.
9590 * \throw If the data array of \a field is not set.
9591 * \throw If existing time steps have different name or number of components than \a field.
9592 * \throw If the underlying mesh of \a field has no name.
9593 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9595 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9597 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9601 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9602 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9603 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9606 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9607 * A new profile is added only if no equal profile is missing.
9608 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9609 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9610 * \param [in] arrOfVals - the values of the field \a field used.
9611 * \param [in] mesh - the supporting mesh of \a field.
9612 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9613 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9614 * \throw If either \a field or \a mesh or \a profile has an empty name.
9615 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9616 * \throw If the data array of \a field is not set.
9617 * \throw If the data array of \a this is already allocated but has different number of
9618 * components than \a field.
9619 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9620 * \sa setFieldNoProfileSBT()
9622 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9624 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9627 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9629 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9631 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9632 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9634 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 !");
9638 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9640 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9642 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9643 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9645 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 !");
9649 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9651 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9654 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9658 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9659 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9662 catch(INTERP_KERNEL::Exception& e)
9665 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9666 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9669 catch(INTERP_KERNEL::Exception& e)
9672 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9674 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9679 MEDFileFields *MEDFileFields::New()
9681 return new MEDFileFields;
9684 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9686 return new MEDFileFields(fileName,loadAll,0);
9689 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9691 return new MEDFileFields(fileName,loadAll,ms);
9694 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9696 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9697 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9701 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9703 std::vector<const BigMemoryObject *> ret;
9704 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9705 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9709 MEDFileFields *MEDFileFields::deepCpy() const
9711 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9713 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9715 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9716 ret->_fields[i]=(*it)->deepCpy();
9718 ret->deepCpyGlobs(*this);
9722 MEDFileFields *MEDFileFields::shallowCpy() const
9724 return new MEDFileFields(*this);
9728 * 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
9729 * 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.
9730 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9732 * \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.
9733 * \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.
9735 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9737 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9739 std::set< std::pair<int,int> > s;
9740 bool firstShot=true;
9741 areThereSomeForgottenTS=false;
9742 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9744 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9746 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9747 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9749 { s=s1; firstShot=false; }
9752 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9754 areThereSomeForgottenTS=true;
9758 std::vector< std::pair<int,int> > ret;
9759 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9763 int MEDFileFields::getNumberOfFields() const
9765 return _fields.size();
9768 std::vector<std::string> MEDFileFields::getFieldsNames() const
9770 std::vector<std::string> ret(_fields.size());
9772 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9774 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9777 ret[i]=f->getName();
9781 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9782 throw INTERP_KERNEL::Exception(oss.str().c_str());
9788 std::vector<std::string> MEDFileFields::getMeshesNames() const
9790 std::vector<std::string> ret;
9791 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9793 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9795 ret.push_back(cur->getMeshName());
9800 std::string MEDFileFields::simpleRepr() const
9802 std::ostringstream oss;
9803 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9808 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9810 int nbOfFields=getNumberOfFields();
9811 std::string startLine(bkOffset,' ');
9812 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9814 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9816 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9819 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9823 oss << startLine << " - not defined !" << std::endl;
9827 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9829 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9830 std::string chapter(17,'0'+i);
9831 oss << startLine << chapter << std::endl;
9834 cur->simpleRepr(bkOffset+2,oss,i);
9838 oss << startLine << " - not defined !" << std::endl;
9840 oss << startLine << chapter << std::endl;
9842 simpleReprGlobs(oss);
9845 MEDFileFields::MEDFileFields()
9849 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9850 try:MEDFileFieldGlobsReal(fileName)
9852 MEDFileUtilities::CheckFileForRead(fileName);
9853 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9854 int nbFields(MEDnField(fid));
9855 _fields.resize(nbFields);
9856 med_field_type typcha;
9857 for(int i=0;i<nbFields;i++)
9859 std::vector<std::string> infos;
9860 std::string fieldName,dtunit;
9861 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9866 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9871 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9876 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] !";
9877 throw INTERP_KERNEL::Exception(oss.str().c_str());
9881 loadAllGlobals(fid);
9883 catch(INTERP_KERNEL::Exception& e)
9888 void MEDFileFields::writeLL(med_idt fid) const
9891 writeGlobals(fid,*this);
9892 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9894 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9897 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9898 throw INTERP_KERNEL::Exception(oss.str().c_str());
9900 elt->writeLL(fid,*this);
9904 void MEDFileFields::write(const std::string& fileName, int mode) const
9906 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9907 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9912 * This method alloc the arrays and load potentially huge arrays contained in this field.
9913 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9914 * This method can be also called to refresh or reinit values from a file.
9916 * \throw If the fileName is not set or points to a non readable MED file.
9918 void MEDFileFields::loadArrays()
9920 if(getFileName().empty())
9921 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9922 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9923 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9925 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9927 elt->loadBigArraysRecursively(fid,*elt);
9932 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9933 * But once data loaded once, this method does nothing.
9935 * \throw If the fileName is not set or points to a non readable MED file.
9936 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9938 void MEDFileFields::loadArraysIfNecessary()
9940 if(!getFileName().empty())
9942 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9943 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9945 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9947 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9953 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9954 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9955 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9957 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9959 void MEDFileFields::unloadArrays()
9961 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9963 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9965 elt->unloadArrays();
9970 * 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.
9971 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9972 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9974 * \sa MEDFileFields::loadArraysIfNecessary
9976 void MEDFileFields::unloadArraysWithoutDataLoss()
9978 if(!getFileName().empty())
9982 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9984 std::vector<std::string> ret;
9985 std::set<std::string> ret2;
9986 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9988 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9989 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9990 if(ret2.find(*it2)==ret2.end())
9992 ret.push_back(*it2);
9999 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10001 std::vector<std::string> ret;
10002 std::set<std::string> ret2;
10003 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10005 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10006 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10007 if(ret2.find(*it2)==ret2.end())
10009 ret.push_back(*it2);
10016 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10018 std::vector<std::string> ret;
10019 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10021 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10022 ret.insert(ret.end(),tmp.begin(),tmp.end());
10027 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10029 std::vector<std::string> ret;
10030 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10032 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10033 ret.insert(ret.end(),tmp.begin(),tmp.end());
10038 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10040 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10041 (*it)->changePflsRefsNamesGen2(mapOfModif);
10044 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10046 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10047 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10050 void MEDFileFields::resize(int newSize)
10052 _fields.resize(newSize);
10055 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10057 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10061 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10064 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10065 _fields.push_back(field->getContent());
10066 appendGlobs(*field,1e-12);
10069 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10072 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10073 if(i>=(int)_fields.size())
10074 _fields.resize(i+1);
10075 _fields[i]=field->getContent();
10076 appendGlobs(*field,1e-12);
10079 void MEDFileFields::destroyFieldAtPos(int i)
10081 destroyFieldsAtPos(&i,&i+1);
10084 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10086 std::vector<bool> b(_fields.size(),true);
10087 for(const int *i=startIds;i!=endIds;i++)
10089 if(*i<0 || *i>=(int)_fields.size())
10091 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10092 throw INTERP_KERNEL::Exception(oss.str().c_str());
10096 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10098 for(std::size_t i=0;i<_fields.size();i++)
10100 fields[j++]=_fields[i];
10104 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10106 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10107 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10108 std::vector<bool> b(_fields.size(),true);
10110 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10112 if(k<0 || k>=(int)_fields.size())
10114 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10115 throw INTERP_KERNEL::Exception(oss.str().c_str());
10119 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10121 for(std::size_t i=0;i<_fields.size();i++)
10123 fields[j++]=_fields[i];
10127 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10130 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10132 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10134 ret=cur->changeMeshNames(modifTab) || ret;
10140 * \param [in] meshName the name of the mesh that will be renumbered.
10141 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10142 * This code corresponds to the distribution of types in the corresponding mesh.
10143 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10144 * \param [in] renumO2N the old to new renumber array.
10145 * \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
10146 * field in \a this.
10148 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10151 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10153 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10156 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10162 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10164 if(i<0 || i>=(int)_fields.size())
10166 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10167 throw INTERP_KERNEL::Exception(oss.str().c_str());
10169 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10172 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10173 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10174 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10176 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10178 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10181 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10182 throw INTERP_KERNEL::Exception(oss.str().c_str());
10184 ret->shallowCpyGlobs(*this);
10189 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10190 * This method is accessible in python using __getitem__ with a list in input.
10191 * \return a new object that the caller should deal with.
10193 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10195 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10196 std::size_t sz=std::distance(startIds,endIds);
10197 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10199 for(const int *i=startIds;i!=endIds;i++,j++)
10201 if(*i<0 || *i>=(int)_fields.size())
10203 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10204 throw INTERP_KERNEL::Exception(oss.str().c_str());
10206 fields[j]=_fields[*i];
10208 ret->_fields=fields;
10212 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10214 return getFieldAtPos(getPosFromFieldName(fieldName));
10218 * This method removes, if any, fields in \a this having no time steps.
10219 * 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.
10221 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10223 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10225 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10226 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10228 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10231 if(elt->getNumberOfTS()>0)
10232 newFields.push_back(*it);
10235 if(_fields.size()==newFields.size())
10242 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10243 * This method can be seen as a filter applied on \a this, that returns an object containing
10244 * 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
10245 * shallow copied from \a this.
10247 * \param [in] meshName - the name of the mesh on w
10248 * \return a new object that the caller should deal with.
10250 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10252 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10253 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10255 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10258 if(cur->getMeshName()==meshName)
10261 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10262 ret->_fields.push_back(cur2);
10265 ret->shallowCpyOnlyUsedGlobs(*this);
10270 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10271 * Input time steps are specified using a pair of integer (iteration, order).
10272 * 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,
10273 * but for each multitimestep only the time steps in \a timeSteps are kept.
10274 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10276 * The returned object points to shallow copy of elements in \a this.
10278 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10279 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10280 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10282 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10284 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10285 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10287 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10290 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10291 ret->_fields.push_back(elt);
10293 ret->shallowCpyOnlyUsedGlobs(*this);
10298 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10300 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10302 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10303 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10305 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10308 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10309 if(elt->getNumberOfTS()!=0)
10310 ret->_fields.push_back(elt);
10312 ret->shallowCpyOnlyUsedGlobs(*this);
10316 MEDFileFieldsIterator *MEDFileFields::iterator()
10318 return new MEDFileFieldsIterator(this);
10321 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10323 std::string tmp(fieldName);
10324 std::vector<std::string> poss;
10325 for(std::size_t i=0;i<_fields.size();i++)
10327 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10330 std::string fname(f->getName());
10334 poss.push_back(fname);
10337 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10338 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10340 throw INTERP_KERNEL::Exception(oss.str().c_str());
10343 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10348 _nb_iter=fs->getNumberOfFields();
10352 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10356 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10358 if(_iter_id<_nb_iter)
10360 MEDFileFields *fs(_fs);
10362 return fs->getFieldAtPos(_iter_id++);