1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileFieldOverView.hxx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[34];
41 using namespace ParaMEDMEM;
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
48 return new MEDFileFieldLoc(fid,locName);
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 return new MEDFileFieldLoc(fid,id);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
58 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
63 med_geometry_type geotype;
64 med_geometry_type sectiongeotype;
66 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
70 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71 _nb_node_per_cell=cm.getNumberOfNodes();
72 _ref_coo.resize(_dim*_nb_node_per_cell);
73 _gs_coo.resize(_dim*_nb_gauss_pt);
74 _w.resize(_nb_gauss_pt);
75 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 med_geometry_type geotype;
81 med_geometry_type sectiongeotype;
83 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
88 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
89 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90 _nb_node_per_cell=cm.getNumberOfNodes();
91 _ref_coo.resize(_dim*_nb_node_per_cell);
92 _gs_coo.resize(_dim*_nb_gauss_pt);
93 _w.resize(_nb_gauss_pt);
94 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
98 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
119 return std::vector<const BigMemoryObject *>();
122 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 static const char OFF7[]="\n ";
125 oss << "\"" << _name << "\"" << OFF7;
126 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
127 oss << "Dimension=" << _dim << OFF7;
128 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
129 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
130 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
131 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 void MEDFileFieldLoc::setName(const std::string& name)
140 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
142 if(_name!=other._name)
146 if(_nb_gauss_pt!=other._nb_gauss_pt)
148 if(_nb_node_per_cell!=other._nb_node_per_cell)
150 if(_geo_type!=other._geo_type)
152 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
154 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
156 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162 void MEDFileFieldLoc::writeLL(med_idt fid) const
164 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
167 std::string MEDFileFieldLoc::repr() const
169 std::ostringstream oss; oss.precision(15);
170 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
171 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
172 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
173 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
174 oss << "\n - Ref coords are : ";
175 int sz=_ref_coo.size();
178 int nbOfTuples=sz/_dim;
179 for(int i=0;i<nbOfTuples;i++)
182 for(int j=0;j<_dim;j++)
183 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
188 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
189 oss << "\n - Gauss coords in reference element : ";
193 int nbOfTuples=sz/_dim;
194 for(int i=0;i<nbOfTuples;i++)
197 for(int j=0;j<_dim;j++)
198 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
203 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
204 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
208 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
210 _type=field->getTypeOfField();
216 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
217 _end=_start+nbOfCells;
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
224 const int *arrPtr=arr->getConstPointer();
225 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
226 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
233 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
234 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
236 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
237 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
238 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
239 const int *dai2Ptr=dai2->getConstPointer();
240 int nbi=gsLoc.getWeights().size();
241 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
243 const int *da3Ptr=da3->getConstPointer();
244 if(da3->getNumberOfTuples()!=nbOfCells)
245 {//profile : for gauss even in NoProfile !!!
246 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
248 da3->setName(_profile.c_str());
249 glob.appendProfile(da3);
251 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
252 _nval=da3->getNbOfElems();
253 da4->alloc(_nval*nbi,1);
254 int *da4Ptr=da4->getPointer();
255 for(int i=0;i<_nval;i++)
257 int ref=dai2Ptr[offset+da3Ptr[i]];
258 for(int j=0;j<nbi;j++)
261 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
262 _localization=oss2.str();
263 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
264 _end=_start+_nval*nbi;
265 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
269 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
276 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
277 * \param [in] multiTypePfl is the end user profile specified in high level API
278 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
279 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
280 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
281 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
283 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
286 _type=field->getTypeOfField();
287 std::string pflName(multiTypePfl->getName());
288 std::ostringstream oss; oss << pflName;
292 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
299 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
300 if(_type!=ON_GAUSS_PT)
302 locIds->setName(oss.str().c_str());
303 glob.appendProfile(locIds);
312 _nval=idsInPfl->getNumberOfTuples();
313 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
319 _nval=idsInPfl->getNumberOfTuples();
320 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
329 arr3->computeOffsets2();
330 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
331 int trueNval=tmp->getNumberOfTuples();
332 _nval=idsInPfl->getNumberOfTuples();
333 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
334 _end=_start+trueNval;
339 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
341 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
342 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
343 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
349 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
351 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
353 for(const int *pt=da4->begin();pt!=da4->end();pt++)
354 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
355 tmp->alloc(trueNval,1);
356 int *tmpPtr=tmp->getPointer();
357 for(const int *pt=da4->begin();pt!=da4->end();pt++)
358 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361 _nval=da4->getNumberOfTuples();
362 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
363 _end=_start+trueNval;
364 oss << "_loc_" << _loc_id;
367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
368 da5->setName(oss.str().c_str());
369 glob.appendProfile(da5);
374 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
376 da3->setName(oss.str().c_str());
377 glob.appendProfile(da3);
381 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
382 _localization=oss2.str();
383 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
387 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
392 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 _nval=arrr->getNumberOfTuples();
396 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
401 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
403 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
413 return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
418 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
421 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
423 std::vector<const BigMemoryObject *> ret(1);
424 ret[0]=(const PartDefinition*)_pd;
428 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
430 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
435 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
436 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
441 catch(INTERP_KERNEL::Exception& e)
446 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
450 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
454 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
455 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
459 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
461 const PartDefinition *pd(_pd);
464 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
466 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
467 if(_end-_start!=nbValsInFile*nbi)
469 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
470 throw INTERP_KERNEL::Exception(oss.str().c_str());
472 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr);
476 if(!_profile.empty())
477 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
478 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
481 int profilesize,nbi,start,stop,step;
482 spd->getSlice(start,stop,step);
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
484 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
485 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
486 med_filter filter=MED_FILTER_INIT;
487 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
488 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
489 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
490 /*lastblocksize=useless because count=1*/0,&filter);
491 MEDfieldValueAdvancedRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr);
492 MEDfilterClose(&filter);
496 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
500 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
505 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
507 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
508 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
509 std::string fieldName(nasc.getName()),meshName(getMeshName());
510 int iteration(getIteration()),order(getOrder());
511 TypeOfField type(getType());
512 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
514 med_geometry_type mgeoti;
515 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
516 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
517 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
518 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
519 const PartDefinition *pd(_pd);
526 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
528 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : Part def only implemented for split one !");
529 if(!_profile.empty())
530 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
531 int start1,stop1,step1;
532 spd->getSlice(start1,stop1,step1);
533 _nval=DataArray::GetNumberOfItemGivenBES(start1,stop1,step1,"MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively");
536 _end=start+_nval*nbi;
538 if(type==ON_CELLS && !_localization.empty())
540 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
541 setType(ON_GAUSS_PT);
544 setType(ON_GAUSS_NE);
545 _localization.clear();
550 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
552 std::string fieldName(nasc.getName()),meshName(getMeshName());
553 int iteration(getIteration()),order(getOrder());
554 TypeOfField type(getType());
555 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
556 med_geometry_type mgeoti;
557 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
559 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
562 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
563 if(_start<0 || _start>=arr->getNumberOfTuples())
565 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
566 throw INTERP_KERNEL::Exception(oss.str().c_str());
568 if(_end<0 || _end>arr->getNumberOfTuples())
570 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
571 throw INTERP_KERNEL::Exception(oss.str().c_str());
573 int nbOfCompo(arr->getNumberOfComponents());
574 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
577 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
578 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
581 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
584 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
585 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
588 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
592 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
594 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
596 int delta=_end-_start;
597 _start=newValueOfStart;
601 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
603 return _father->getIteration();
606 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
608 return _father->getOrder();
611 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
613 return _father->getTime();
616 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
618 return _father->getMeshName();
621 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
623 const char startLine[]=" ## ";
624 std::string startLine2(bkOffset,' ');
625 startLine2+=startLine;
626 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
627 oss << startLine2 << "Localization #" << id << "." << std::endl;
628 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
630 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
631 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
632 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
635 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
640 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
645 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
650 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
652 return _father->getGeoType();
655 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
657 return _father->getNumberOfComponents();
660 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
665 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
667 return _father->getOrCreateAndGetArray();
670 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
672 const MEDFileFieldPerMeshPerType *fath=_father;
673 return fath->getOrCreateAndGetArray();
676 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
678 return _father->getInfo();
681 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
686 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
691 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
693 return _localization;
696 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
698 _localization=newLocName;
701 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
703 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
705 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
707 _profile=(*it2).second;
713 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
715 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
717 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
719 _localization=(*it2).second;
725 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
729 dads.push_back(std::pair<int,int>(_start,_end));
730 geoTypes.push_back(getGeoType());
735 pfls.push_back(glob->getProfile(_profile.c_str()));
737 if(_localization.empty())
741 locs.push_back(glob->getLocalizationId(_localization.c_str()));
745 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
747 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
751 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
753 TypeOfField type=getType();
754 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
755 med_geometry_type mgeoti;
756 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
757 const DataArray *arr=getOrCreateAndGetArray();
759 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
760 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
761 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
762 const unsigned char *locToWrite=0;
764 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
766 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
768 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
769 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
770 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
774 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
779 dad.first=_start; dad.second=_end;
783 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
784 * This code corresponds to the distribution of types in the corresponding mesh.
785 * \param [out] ptToFill memory zone where the output will be stored.
786 * \return the size of data pushed into output param \a ptToFill
788 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
791 std::ostringstream oss;
792 std::size_t nbOfType=codeOfMesh.size()/3;
794 for(std::size_t i=0;i<nbOfType && found==-1;i++)
795 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
799 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
800 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
801 throw INTERP_KERNEL::Exception(oss.str().c_str());
806 if(_nval!=codeOfMesh[3*found+1])
808 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
809 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
810 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
811 throw INTERP_KERNEL::Exception(oss.str().c_str());
813 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
818 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
819 if(pfl->getNumberOfTuples()!=_nval)
821 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
822 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
824 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
825 throw INTERP_KERNEL::Exception(oss.str().c_str());
827 int offset2=codeOfMesh[3*found+2];
828 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
830 if(*pflId<codeOfMesh[3*found+1])
831 *work++=offset2+*pflId;
837 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
839 for(int i=_start;i<_end;i++)
844 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
855 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
859 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
862 std::map<std::pair<std::string,TypeOfField>,int> m;
863 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
864 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
865 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
866 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
868 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
869 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
874 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
876 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
877 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
878 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
879 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
880 * \param [in,out] glob if necessary by the method, new profiles can be added to it
881 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
882 * \param [out] result All new entries will be appended on it.
883 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
885 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
886 const DataArrayInt *explicitIdsInMesh,
887 const std::vector<int>& newCode,
888 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
889 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
891 if(entriesOnSameDisc.empty())
893 TypeOfField type=entriesOnSameDisc[0]->getType();
894 int szEntities=0,szTuples=0;
895 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
896 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
897 int nbi=szTuples/szEntities;
898 if(szTuples%szEntities!=0)
899 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
900 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
901 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
902 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
903 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
904 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
905 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
906 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
908 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
910 int startOfEltIdOfChunk=(*it)->_start;
911 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
912 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
913 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
915 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
916 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
918 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
919 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
921 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
922 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
923 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
924 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
926 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
928 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
929 arrPart->renumberInPlace(renumTupleIds->begin());
930 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
932 const int *idIt=diffVals->begin();
933 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
935 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
937 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
938 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
939 int nbEntityElts=subIds->getNumberOfTuples();
941 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
942 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
946 result.push_back(eltToAdd);
947 offset2+=nbEntityElts*nbi;
949 ret=ret || li.empty();
954 * \param [in] typeF type of field of new chunk
955 * \param [in] geoType the geometric type of the chunk
956 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
957 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
958 * \param [in] nbi number of integration points
959 * \param [in] offset The offset in the **global array of data**.
960 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
961 * to the new chunk to create.
962 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
963 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
964 * and corresponding entry erased from \a entriesOnSameDisc.
965 * \return a newly allocated chunk
967 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
968 bool isPfl, int nbi, int offset,
969 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
970 MEDFileFieldGlobsReal& glob,
973 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
974 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
975 for(;it!=entriesOnSameDisc.end();it++)
977 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
981 if((*it)->_profile.empty())
984 if(!(*it)->_profile.empty())
986 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
987 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
993 if(it==entriesOnSameDisc.end())
996 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
998 ret->_loc_id=(int)geoType;
999 ret->_nval=nbMeshEntities;
1001 ret->_end=ret->_start+ret->_nval*nbi;
1004 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1005 glob.appendProfile(idsOfMeshElt);
1006 ret->_profile=idsOfMeshElt->getName();
1008 //tony treatment of localization
1013 notInExisting=false;
1014 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1015 ret->_loc_id=(int)geoType;
1016 ret->setNewStart(offset);
1017 entriesOnSameDisc.erase(it);
1023 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1025 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1028 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1030 return new MEDFileFieldPerMeshPerType(fath,geoType);
1033 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1035 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1038 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1040 std::vector<const BigMemoryObject *> ret;
1041 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1042 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1046 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1048 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1049 ret->_father=father;
1051 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1053 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1054 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1059 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1061 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1062 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1063 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1067 * This method is the most general one. No optimization is done here.
1068 * \param [in] multiTypePfl is the end user profile specified in high level API
1069 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1070 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1071 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1072 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1073 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1075 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1077 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1078 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1079 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1082 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1084 _field_pm_pt_pd.resize(1);
1085 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1086 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1089 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1091 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1092 if(!arr || !arr->isAllocated())
1093 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1094 _field_pm_pt_pd.resize(1);
1095 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1096 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1099 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1101 TypeOfField type=field->getTypeOfField();
1102 if(type!=ON_GAUSS_PT)
1104 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1105 int sz=_field_pm_pt_pd.size();
1107 for(int j=0;j<sz && !found;j++)
1109 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1111 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1117 _field_pm_pt_pd.resize(sz+1);
1118 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1120 std::vector<int> ret(1,(int)sz);
1125 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1126 int sz2=ret2.size();
1127 std::vector<int> ret3(sz2);
1129 for(int i=0;i<sz2;i++)
1131 int sz=_field_pm_pt_pd.size();
1132 int locIdToFind=ret2[i];
1134 for(int j=0;j<sz && !found;j++)
1136 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1138 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1145 _field_pm_pt_pd.resize(sz+1);
1146 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1154 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1156 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1157 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1159 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1160 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1162 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1163 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1164 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1165 if(retTmp->presenceOfValue(-1))
1166 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1167 std::vector<int> ret(retTmp->begin(),retTmp->end());
1171 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1173 TypeOfField type=field->getTypeOfField();
1174 if(type!=ON_GAUSS_PT)
1176 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1177 int sz=_field_pm_pt_pd.size();
1179 for(int j=0;j<sz && !found;j++)
1181 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1183 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1189 _field_pm_pt_pd.resize(sz+1);
1190 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1192 std::vector<int> ret(1,0);
1197 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1198 int sz2=ret2.size();
1199 std::vector<int> ret3(sz2);
1201 for(int i=0;i<sz2;i++)
1203 int sz=_field_pm_pt_pd.size();
1204 int locIdToFind=ret2[i];
1206 for(int j=0;j<sz && !found;j++)
1208 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1210 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1217 _field_pm_pt_pd.resize(sz+1);
1218 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1226 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1228 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1229 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1231 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1232 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1234 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1235 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1237 if(retTmp->presenceOfValue(-1))
1238 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1239 std::vector<int> ret(retTmp->begin(),retTmp->end());
1243 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1248 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1250 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1251 int curDim=(int)cm.getDimension();
1252 dim=std::max(dim,curDim);
1255 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1257 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1259 (*it)->fillTypesOfFieldAvailable(types);
1263 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1265 int sz=_field_pm_pt_pd.size();
1266 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1267 for(int i=0;i<sz;i++)
1269 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1273 int MEDFileFieldPerMeshPerType::getIteration() const
1275 return _father->getIteration();
1278 int MEDFileFieldPerMeshPerType::getOrder() const
1280 return _father->getOrder();
1283 double MEDFileFieldPerMeshPerType::getTime() const
1285 return _father->getTime();
1288 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1290 return _father->getMeshName();
1293 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1295 const char startLine[]=" ## ";
1296 std::string startLine2(bkOffset,' ');
1297 std::string startLine3(startLine2);
1298 startLine3+=startLine;
1299 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1301 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1302 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1305 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1306 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1308 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1310 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1312 cur->simpleRepr(bkOffset,oss,i);
1315 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1320 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1322 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1324 globalSz+=(*it)->getNumberOfTuples();
1326 nbOfEntries+=(int)_field_pm_pt_pd.size();
1329 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1335 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1337 return _father->getNumberOfComponents();
1340 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1343 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1345 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1352 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1354 return _father->getOrCreateAndGetArray();
1357 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1359 const MEDFileFieldPerMesh *fath=_father;
1360 return fath->getOrCreateAndGetArray();
1363 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1365 return _father->getInfo();
1368 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1370 std::vector<std::string> ret;
1371 std::set<std::string> ret2;
1372 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1374 std::string tmp=(*it1)->getProfile();
1376 if(ret2.find(tmp)==ret2.end())
1385 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1387 std::vector<std::string> ret;
1388 std::set<std::string> ret2;
1389 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1391 std::string tmp=(*it1)->getLocalization();
1392 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1393 if(ret2.find(tmp)==ret2.end())
1402 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1404 std::vector<std::string> ret;
1405 std::set<std::string> ret2;
1406 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1408 std::string tmp=(*it1)->getProfile();
1415 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1417 std::vector<std::string> ret;
1418 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1420 std::string tmp=(*it1)->getLocalization();
1421 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1427 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1430 (*it1)->changePflsRefsNamesGen(mapOfModif);
1433 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1435 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1436 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1439 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1441 if(_field_pm_pt_pd.empty())
1443 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1444 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1445 throw INTERP_KERNEL::Exception(oss.str().c_str());
1447 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1448 return _field_pm_pt_pd[locId];
1449 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1450 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1451 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1452 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1453 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1456 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1458 if(_field_pm_pt_pd.empty())
1460 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1461 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1462 throw INTERP_KERNEL::Exception(oss.str().c_str());
1464 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1465 return _field_pm_pt_pd[locId];
1466 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1467 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1468 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1469 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1470 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1473 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1475 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1477 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1478 if(meshDim!=(int)cm.getDimension())
1481 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1482 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1485 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1488 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1490 (*it)->fillValues(i,startEntryId,entries);
1494 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1496 _field_pm_pt_pd=leaves;
1497 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1498 (*it)->setFather(this);
1502 * \param [in,out] globalNum a global numbering counter for the renumbering.
1503 * \param [out] its - list of pair (start,stop) kept
1504 * \return bool - false if the type of field \a tof is not contained in \a this.
1506 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1509 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1511 if((*it)->getType()==tof)
1513 newPmPtPd.push_back(*it);
1514 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1515 (*it)->setNewStart(globalNum);
1516 globalNum=(*it)->getEnd();
1517 its.push_back(bgEnd);
1521 _field_pm_pt_pd=newPmPtPd;
1526 * \param [in,out] globalNum a global numbering counter for the renumbering.
1527 * \param [out] its - list of pair (start,stop) kept
1528 * \return bool - false if the type of field \a tof is not contained in \a this.
1530 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1532 if(_field_pm_pt_pd.size()<=idOfDisc)
1534 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1535 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1536 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1537 elt->setNewStart(globalNum);
1538 globalNum=elt->getEnd();
1539 its.push_back(bgEnd);
1540 _field_pm_pt_pd=newPmPtPd;
1544 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1548 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1550 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1551 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1552 med_geometry_type mgeoti;
1553 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1554 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1555 _field_pm_pt_pd.resize(nbProfiles);
1556 for(int i=0;i<nbProfiles;i++)
1558 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1562 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1563 for(int i=0;i<nbProfiles2;i++)
1564 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1568 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1570 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1571 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1574 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1576 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1577 (*it)->loadBigArray(fid,nasc);
1580 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1582 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1584 (*it)->copyOptionsFrom(*this);
1585 (*it)->writeLL(fid,nasc);
1589 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1594 medfGeoType=typmai3[(int)ikGeoType];
1597 medfGeoType=MED_NONE;
1600 medfGeoType=typmai3[(int)ikGeoType];
1601 return MED_NODE_ELEMENT;
1603 medfGeoType=typmai3[(int)ikGeoType];
1606 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1608 return MED_UNDEF_ENTITY_TYPE;
1611 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm)
1613 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm);
1616 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1618 return new MEDFileFieldPerMesh(fath,mesh);
1621 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1623 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1626 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1628 std::vector<const BigMemoryObject *> ret;
1629 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1630 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1634 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1636 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1637 ret->_father=father;
1639 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1641 if((const MEDFileFieldPerMeshPerType *)*it)
1642 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1647 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1649 std::string startLine(bkOffset,' ');
1650 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1651 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1653 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1655 const MEDFileFieldPerMeshPerType *cur=*it;
1657 cur->simpleRepr(bkOffset,oss,i);
1660 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1665 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1667 _mesh_name=mesh->getName();
1668 mesh->getTime(_mesh_iteration,_mesh_order);
1671 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1673 int nbOfTypes=code.size()/3;
1675 for(int i=0;i<nbOfTypes;i++)
1677 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1678 int nbOfCells=code[3*i+1];
1679 int pos=addNewEntryIfNecessary(type);
1680 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1686 * This method is the most general one. No optimization is done here.
1687 * \param [in] multiTypePfl is the end user profile specified in high level API
1688 * \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].
1689 * \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.
1690 * \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.
1691 * \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.
1692 * \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.
1694 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)
1696 int nbOfTypes(code.size()/3);
1697 for(int i=0;i<nbOfTypes;i++)
1699 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1700 int pos=addNewEntryIfNecessary(type);
1701 DataArrayInt *pfl=0;
1703 pfl=idsPerType[code[3*i+2]];
1704 int nbOfTupes2=code2.size()/3;
1706 for(;found<nbOfTupes2;found++)
1707 if(code[3*i]==code2[3*found])
1709 if(found==nbOfTupes2)
1710 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1711 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1715 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1717 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1718 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1721 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1723 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1724 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1727 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1729 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1730 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1733 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1735 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1736 (*it)->loadBigArraysRecursively(fid,nasc);
1739 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1741 int nbOfTypes=_field_pm_pt.size();
1742 for(int i=0;i<nbOfTypes;i++)
1744 _field_pm_pt[i]->copyOptionsFrom(*this);
1745 _field_pm_pt[i]->writeLL(fid,nasc);
1749 void MEDFileFieldPerMesh::getDimension(int& dim) const
1751 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1752 (*it)->getDimension(dim);
1755 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1757 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1758 (*it)->fillTypesOfFieldAvailable(types);
1761 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
1763 int sz=_field_pm_pt.size();
1764 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1765 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1766 for(int i=0;i<sz;i++)
1768 types[i]=_field_pm_pt[i]->getGeoType();
1769 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1774 double MEDFileFieldPerMesh::getTime() const
1777 return _father->getTime(tmp1,tmp2);
1780 int MEDFileFieldPerMesh::getIteration() const
1782 return _father->getIteration();
1785 int MEDFileFieldPerMesh::getOrder() const
1787 return _father->getOrder();
1790 int MEDFileFieldPerMesh::getNumberOfComponents() const
1792 return _father->getNumberOfComponents();
1795 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1797 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1799 const MEDFileFieldPerMeshPerType *fpmt(*it);
1802 if(fpmt->presenceOfMultiDiscPerGeoType())
1808 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1811 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1812 return _father->getOrCreateAndGetArray();
1815 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1818 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1819 return _father->getOrCreateAndGetArray();
1822 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1824 return _father->getInfo();
1828 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1829 * 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.
1830 * It returns 2 output vectors :
1831 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1832 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1833 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1835 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)
1837 int notNullPflsSz=0;
1838 int nbOfArrs=geoTypes.size();
1839 for(int i=0;i<nbOfArrs;i++)
1842 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1843 int nbOfDiffGeoTypes=geoTypes3.size();
1844 code.resize(3*nbOfDiffGeoTypes);
1845 notNullPfls.resize(notNullPflsSz);
1848 for(int i=0;i<nbOfDiffGeoTypes;i++)
1851 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1852 std::vector<const DataArrayInt *> notNullTmp;
1854 notNullTmp.push_back(pfls[j]);
1856 for(;j<nbOfArrs;j++)
1857 if(geoTypes[j]==refType)
1860 notNullTmp.push_back(pfls[j]);
1864 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1865 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1866 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1867 code[3*i]=(int)refType;
1868 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1869 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1870 if(notNullTmp.empty())
1874 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1875 code[3*i+2]=notNullPflsSz++;
1881 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1883 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)
1887 for(int i=0;i<sz;i++)
1891 if(type!=ON_GAUSS_NE)
1892 ret+=dads[i].second-dads[i].first;
1895 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1896 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1901 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1902 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1908 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1910 std::vector<std::string> ret;
1911 std::set<std::string> ret2;
1912 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1914 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1915 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1916 if(ret2.find(*it2)==ret2.end())
1918 ret.push_back(*it2);
1925 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1927 std::vector<std::string> ret;
1928 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1930 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1931 ret.insert(ret.end(),tmp.begin(),tmp.end());
1936 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1938 std::vector<std::string> ret;
1939 std::set<std::string> ret2;
1940 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1942 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1943 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1944 if(ret2.find(*it2)==ret2.end())
1946 ret.push_back(*it2);
1953 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1955 std::vector<std::string> ret;
1956 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1958 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1959 ret.insert(ret.end(),tmp.begin(),tmp.end());
1964 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1966 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1968 if((*it).first==_mesh_name)
1970 _mesh_name=(*it).second;
1977 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1978 MEDFileFieldGlobsReal& glob)
1980 if(_mesh_name!=meshName)
1982 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1983 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1984 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1985 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1986 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1987 getUndergroundDataArrayExt(entries);
1988 DataArray *arr0=getOrCreateAndGetArray();//tony
1990 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1991 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1993 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1996 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1997 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1999 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2001 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2002 sz+=(*it).second.second-(*it).second.first;
2005 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2007 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2008 ////////////////////
2009 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2010 int *workI2=explicitIdsOldInMesh->getPointer();
2011 int sz1=0,sz2=0,sid=1;
2012 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2013 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2014 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2016 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2017 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2018 int *workI=explicitIdsOldInArr->getPointer();
2019 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2021 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2022 (*itL2)->setLocId(sz2);
2023 (*itL2)->_tmp_work1=(*itL2)->getStart();
2024 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2026 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2028 explicitIdsOldInMesh->reAlloc(sz2);
2029 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2030 ////////////////////
2031 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2032 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2033 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2034 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2036 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2037 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2038 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2040 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2041 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2042 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2044 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2045 int newStart=elt->getLocId();
2046 elt->setLocId((*it)->getGeoType());
2047 elt->setNewStart(newStart);
2048 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2049 entriesKeptNew.push_back(elt);
2050 entriesKeptNew2.push_back(elt);
2052 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2053 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2054 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2055 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2057 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2060 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2062 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2063 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2065 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2066 glob,arr2,otherEntriesNew) || ret;
2070 // Assign new dispatching
2071 assignNewLeaves(otherEntriesNew);
2072 arr->cpyFrom(*arr2);
2077 * \param [in,out] globalNum a global numbering counter for the renumbering.
2078 * \param [out] its - list of pair (start,stop) kept
2080 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2082 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2083 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2085 std::vector< std::pair<int,int> > its2;
2086 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2089 its.insert(its.end(),its2.begin(),its2.end());
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::keepOnlyGaussDiscretization(std::size_t idOfDisc, 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)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2108 its.insert(its.end(),its2.begin(),its2.end());
2114 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2116 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2117 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2118 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2120 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2121 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2122 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2123 for(;it1!=types.end();it1++,it2++)
2125 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2126 elt->setLeaves((*it1).second);
2129 _field_pm_pt=fieldPmPt;
2132 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2134 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2135 (*it)->changePflsRefsNamesGen(mapOfModif);
2138 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2140 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2141 (*it)->changeLocsRefsNamesGen(mapOfModif);
2145 * \param [in] mesh is the whole mesh
2147 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2149 if(_field_pm_pt.empty())
2150 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2152 std::vector< std::pair<int,int> > dads;
2153 std::vector<const DataArrayInt *> pfls;
2154 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2155 std::vector<int> locs,code;
2156 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2157 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2160 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2163 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2164 throw INTERP_KERNEL::Exception(oss.str().c_str());
2167 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2168 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2171 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2173 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2176 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2177 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2183 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2187 if(nb!=mesh->getNumberOfNodes())
2189 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2190 oss << " nodes in mesh !";
2191 throw INTERP_KERNEL::Exception(oss.str().c_str());
2193 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2196 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2200 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2202 if(_field_pm_pt.empty())
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2205 std::vector<std::pair<int,int> > dads;
2206 std::vector<const DataArrayInt *> pfls;
2207 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2208 std::vector<int> locs,code;
2209 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2210 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2211 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2213 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2216 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2217 throw INTERP_KERNEL::Exception(oss.str().c_str());
2219 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2220 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2224 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2229 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2233 if(nb!=mesh->getNumberOfNodes())
2235 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2236 oss << " nodes in mesh !";
2237 throw INTERP_KERNEL::Exception(oss.str().c_str());
2240 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2246 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2250 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2252 (*it)->getSizes(globalSz,nbOfEntries);
2254 entries.resize(nbOfEntries);
2256 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2258 (*it)->fillValues(nbOfEntries,entries);
2262 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2264 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2266 if((*it)->getGeoType()==typ)
2267 return (*it)->getLeafGivenLocId(locId);
2269 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2270 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2271 oss << "Possiblities are : ";
2272 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2274 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2275 oss << "\"" << cm2.getRepr() << "\", ";
2277 throw INTERP_KERNEL::Exception(oss.str().c_str());
2280 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2282 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2284 if((*it)->getGeoType()==typ)
2285 return (*it)->getLeafGivenLocId(locId);
2287 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2288 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2289 oss << "Possiblities are : ";
2290 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2292 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2293 oss << "\"" << cm2.getRepr() << "\", ";
2295 throw INTERP_KERNEL::Exception(oss.str().c_str());
2298 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2301 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2302 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2303 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2305 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2310 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2315 int ret=std::distance(_field_pm_pt.begin(),it2);
2316 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2321 * 'dads' and 'locs' input parameters have the same number of elements
2322 * \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
2324 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2325 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2326 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2329 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2330 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2331 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2332 const std::vector<std::string>& infos=getInfo();
2333 da->setInfoOnComponents(infos);
2335 if(type==ON_GAUSS_PT)
2338 int nbOfArrs=dads.size();
2339 for(int i=0;i<nbOfArrs;i++)
2341 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2342 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2343 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2345 di->alloc(nbOfElems,1);
2347 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2348 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2357 * 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.
2358 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2359 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2360 * The order of cells in the returned field is those imposed by the profile.
2361 * \param [in] mesh is the global mesh.
2363 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2364 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2365 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2366 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2368 if(da->isIdentity())
2370 int nbOfTuples=da->getNumberOfTuples();
2371 if(nbOfTuples==mesh->getNumberOfCells())
2372 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2374 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2375 m2->setName(mesh->getName().c_str());
2376 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2382 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2384 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2385 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2386 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2388 if(da->isIdentity())
2390 int nbOfTuples=da->getNumberOfTuples();
2391 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2392 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2394 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2395 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2398 if(meshu->getNodalConnectivity()==0)
2400 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2401 int nb=da->getNbOfElems();
2402 const int *ptr=da->getConstPointer();
2403 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2404 meshuc->allocateCells(nb);
2405 for(int i=0;i<nb;i++)
2406 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2407 meshuc->finishInsertingCells();
2408 ret->setMesh(meshuc);
2409 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2410 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2411 disc->checkCoherencyBetween(meshuc,arrOut);
2416 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2418 DataArrayInt *arr2=0;
2419 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2420 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2421 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2422 int nnodes=mesh2->getNumberOfNodes();
2423 if(nnodes==(int)da->getNbOfElems())
2425 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2426 arrOut->renumberInPlace(da3->getConstPointer());
2427 mesh2->setName(mesh->getName().c_str());
2428 ret->setMesh(mesh2);
2433 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 !!!";
2434 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2435 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2436 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2437 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2438 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2439 throw INTERP_KERNEL::Exception(oss.str().c_str());
2445 * This method is the most light method of field retrieving.
2447 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2451 pflOut=DataArrayInt::New();
2452 pflOut->alloc(nbOfElems,1);
2457 pflOut=const_cast<DataArrayInt*>(pflIn);
2460 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2461 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2462 const std::vector<std::string>& infos=getInfo();
2463 int nbOfComp=infos.size();
2464 for(int i=0;i<nbOfComp;i++)
2465 da->setInfoOnComponent(i,infos[i].c_str());
2470 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),
2473 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2474 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2475 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2476 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2477 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2479 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],meshCsit+1,meshName,pflName,locName));
2480 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2481 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],meshCsit+1,meshName,pflName,locName));
2482 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2483 if(nbProfile>0 || nbProfile2>0)
2485 const PartDefinition *pd(0);
2487 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[i]),typmai2[i]);
2488 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc,pd));
2495 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName);
2498 const PartDefinition *pd(0);
2500 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2501 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2502 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2506 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2508 copyTinyInfoFrom(mesh);
2511 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2513 if(id>=(int)_pfls.size())
2515 _pfls[id]=DataArrayInt::New();
2516 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2517 _pfls[id]->setName(pflName);
2518 _pfls[id]->alloc(lgth,1);
2519 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2520 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2523 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2525 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2527 MEDprofileInfo(fid,i+1,pflName,&sz);
2528 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2529 if(i>=(int)_pfls.size())
2531 _pfls[i]=DataArrayInt::New();
2532 _pfls[i]->alloc(sz,1);
2533 _pfls[i]->setName(pflCpp.c_str());
2534 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2535 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2538 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2540 int nbOfPfls=_pfls.size();
2541 for(int i=0;i<nbOfPfls;i++)
2543 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2544 cpy->applyLin(1,1,0);
2545 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2546 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2547 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2550 int nbOfLocs=_locs.size();
2551 for(int i=0;i<nbOfLocs;i++)
2552 _locs[i]->writeLL(fid);
2555 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2557 std::vector<std::string> pfls=getPfls();
2558 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2560 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2563 _pfls.push_back(*it);
2567 int id=std::distance(pfls.begin(),it2);
2568 if(!(*it)->isEqual(*_pfls[id]))
2570 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2571 throw INTERP_KERNEL::Exception(oss.str().c_str());
2575 std::vector<std::string> locs=getLocs();
2576 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2578 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2581 _locs.push_back(*it);
2585 int id=std::distance(locs.begin(),it2);
2586 if(!(*it)->isEqual(*_locs[id],eps))
2588 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2589 throw INTERP_KERNEL::Exception(oss.str().c_str());
2595 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2597 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2598 getProfile((*it).c_str());
2601 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2603 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2604 getLocalization((*it).c_str());
2607 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2609 std::vector<std::string> profiles=real.getPflsReallyUsed();
2610 int sz=profiles.size();
2612 for(int i=0;i<sz;i++)
2613 loadProfileInFile(fid,i,profiles[i].c_str());
2615 std::vector<std::string> locs=real.getLocsReallyUsed();
2618 for(int i=0;i<sz;i++)
2619 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2622 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2624 int nProfil=MEDnProfile(fid);
2625 for(int i=0;i<nProfil;i++)
2626 loadProfileInFile(fid,i);
2627 int sz=MEDnLocalization(fid);
2629 for(int i=0;i<sz;i++)
2631 _locs[i]=MEDFileFieldLoc::New(fid,i);
2635 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2637 return new MEDFileFieldGlobs(fname);
2640 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2642 return new MEDFileFieldGlobs;
2645 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2647 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2650 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2652 std::vector<const BigMemoryObject *> ret;
2653 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2654 ret.push_back((const DataArrayInt *)*it);
2655 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2656 ret.push_back((const MEDFileFieldLoc *)*it);
2660 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2662 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2664 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2666 if((const DataArrayInt *)*it)
2667 ret->_pfls[i]=(*it)->deepCpy();
2670 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2672 if((const MEDFileFieldLoc*)*it)
2673 ret->_locs[i]=(*it)->deepCpy();
2679 * \throw if a profile in \a pfls in not in \a this.
2680 * \throw if a localization in \a locs in not in \a this.
2681 * \sa MEDFileFieldGlobs::deepCpyPart
2683 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2685 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2686 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2688 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2690 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2692 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2693 ret->_pfls.push_back(pfl2);
2695 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2697 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2699 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2701 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2702 ret->_locs.push_back(loc2);
2704 ret->setFileName(getFileName());
2709 * \throw if a profile in \a pfls in not in \a this.
2710 * \throw if a localization in \a locs in not in \a this.
2711 * \sa MEDFileFieldGlobs::shallowCpyPart
2713 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2715 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2716 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2718 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2720 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2721 ret->_pfls.push_back(pfl->deepCpy());
2723 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2725 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2727 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2728 ret->_locs.push_back(loc->deepCpy());
2730 ret->setFileName(getFileName());
2734 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2738 MEDFileFieldGlobs::MEDFileFieldGlobs()
2742 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2746 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2748 oss << "Profiles :\n";
2749 std::size_t n=_pfls.size();
2750 for(std::size_t i=0;i<n;i++)
2752 oss << " - #" << i << " ";
2753 const DataArrayInt *pfl=_pfls[i];
2755 oss << "\"" << pfl->getName() << "\"\n";
2760 oss << "Localizations :\n";
2761 for(std::size_t i=0;i<n;i++)
2763 oss << " - #" << i << " ";
2764 const MEDFileFieldLoc *loc=_locs[i];
2766 loc->simpleRepr(oss);
2772 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2774 _file_name=fileName;
2777 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2779 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2781 DataArrayInt *elt(*it);
2784 std::string name(elt->getName());
2785 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2787 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2789 elt->setName((*it2).second.c_str());
2797 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2799 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2801 MEDFileFieldLoc *elt(*it);
2804 std::string name(elt->getName());
2805 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2807 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2809 elt->setName((*it2).second.c_str());
2817 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2819 if(locId<0 || locId>=(int)_locs.size())
2820 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2821 return _locs[locId]->getNbOfGaussPtPerCell();
2824 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2826 return getLocalizationFromId(getLocalizationId(locName));
2829 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2831 if(locId<0 || locId>=(int)_locs.size())
2832 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2833 return *_locs[locId];
2836 namespace ParaMEDMEMImpl
2841 LocFinder(const std::string& loc):_loc(loc) { }
2842 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2844 const std::string &_loc;
2850 PflFinder(const std::string& pfl):_pfl(pfl) { }
2851 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2853 const std::string& _pfl;
2857 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2859 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2862 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2863 for(it=_locs.begin();it!=_locs.end();it++)
2864 oss << "\"" << (*it)->getName() << "\", ";
2865 throw INTERP_KERNEL::Exception(oss.str().c_str());
2867 return std::distance(_locs.begin(),it);
2871 * The returned value is never null.
2873 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2875 std::string pflNameCpp(pflName);
2876 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2879 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2880 for(it=_pfls.begin();it!=_pfls.end();it++)
2881 oss << "\"" << (*it)->getName() << "\", ";
2882 throw INTERP_KERNEL::Exception(oss.str().c_str());
2887 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2889 if(pflId<0 || pflId>=(int)_pfls.size())
2890 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2891 return _pfls[pflId];
2894 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2896 if(locId<0 || locId>=(int)_locs.size())
2897 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2898 return *_locs[locId];
2901 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2903 return getLocalizationFromId(getLocalizationId(locName));
2907 * The returned value is never null.
2909 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2911 std::string pflNameCpp(pflName);
2912 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2915 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2916 for(it=_pfls.begin();it!=_pfls.end();it++)
2917 oss << "\"" << (*it)->getName() << "\", ";
2918 throw INTERP_KERNEL::Exception(oss.str().c_str());
2923 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2925 if(pflId<0 || pflId>=(int)_pfls.size())
2926 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2927 return _pfls[pflId];
2930 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2932 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2934 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2936 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2937 newPfls.push_back(*it);
2942 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2944 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2946 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2948 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2949 newLocs.push_back(*it);
2954 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2956 int sz=_pfls.size();
2957 std::vector<std::string> ret(sz);
2958 for(int i=0;i<sz;i++)
2959 ret[i]=_pfls[i]->getName();
2963 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2965 int sz=_locs.size();
2966 std::vector<std::string> ret(sz);
2967 for(int i=0;i<sz;i++)
2968 ret[i]=_locs[i]->getName();
2972 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2974 std::vector<std::string> v=getPfls();
2975 std::string s(pflName);
2976 return std::find(v.begin(),v.end(),s)!=v.end();
2979 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2981 std::vector<std::string> v=getLocs();
2982 std::string s(locName);
2983 return std::find(v.begin(),v.end(),s)!=v.end();
2986 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2988 std::map<int,std::vector<int> > m;
2990 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2992 const DataArrayInt *tmp=(*it);
2995 m[tmp->getHashCode()].push_back(i);
2998 std::vector< std::vector<int> > ret;
2999 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3001 if((*it2).second.size()>1)
3003 std::vector<int> ret0;
3004 bool equalityOrNot=false;
3005 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3007 std::vector<int>::const_iterator it4=it3; it4++;
3008 for(;it4!=(*it2).second.end();it4++)
3010 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3013 ret0.push_back(*it3);
3014 ret0.push_back(*it4);
3020 ret.push_back(ret0);
3026 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3028 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3031 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3033 std::string name(pfl->getName());
3035 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3036 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3037 if(name==(*it)->getName())
3039 if(!pfl->isEqual(*(*it)))
3041 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3042 throw INTERP_KERNEL::Exception(oss.str().c_str());
3046 _pfls.push_back(pfl);
3049 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)
3051 std::string name(locName);
3053 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3054 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3055 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3056 if((*it)->isName(locName))
3058 if(!(*it)->isEqual(*obj,1e-12))
3060 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3061 throw INTERP_KERNEL::Exception(oss.str().c_str());
3064 _locs.push_back(obj);
3067 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3069 std::vector<std::string> names=getPfls();
3070 return CreateNewNameNotIn("NewPfl_",names);
3073 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3075 std::vector<std::string> names=getLocs();
3076 return CreateNewNameNotIn("NewLoc_",names);
3079 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3081 for(std::size_t sz=0;sz<100000;sz++)
3083 std::ostringstream tryName;
3084 tryName << prefix << sz;
3085 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3086 return tryName.str();
3088 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3092 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3093 * \param [in] fname - the file name.
3095 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3100 * Creates an empty MEDFileFieldGlobsReal.
3102 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3106 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3111 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3113 std::vector<const BigMemoryObject *> ret;
3114 ret.push_back((const MEDFileFieldGlobs *)_globals);
3119 * Returns a string describing profiles and Gauss points held in \a this.
3120 * \return std::string - the description string.
3122 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3124 const MEDFileFieldGlobs *glob=_globals;
3125 std::ostringstream oss2; oss2 << glob;
3126 std::string stars(oss2.str().length(),'*');
3127 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3129 glob->simpleRepr(oss);
3131 oss << "NO GLOBAL INFORMATION !\n";
3134 void MEDFileFieldGlobsReal::resetContent()
3136 _globals=MEDFileFieldGlobs::New();
3139 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3144 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3145 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3147 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3149 _globals=other._globals;
3153 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3154 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3156 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3158 const MEDFileFieldGlobs *otherg(other._globals);
3161 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3165 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3166 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3168 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3170 const MEDFileFieldGlobs *otherg(other._globals);
3173 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3176 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3178 _globals=other._globals;
3179 if((const MEDFileFieldGlobs *)_globals)
3180 _globals=other._globals->deepCpy();
3184 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3185 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3186 * \param [in] eps - a precision used to compare Gauss points with same name held by
3187 * \a this and \a other MEDFileFieldGlobsReal.
3188 * \throw If \a this and \a other hold profiles with equal names but different ids.
3189 * \throw If \a this and \a other hold different Gauss points with equal names.
3191 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3193 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3194 if(thisGlobals==otherGlobals)
3198 _globals=other._globals;
3201 _globals->appendGlobs(*other._globals,eps);
3204 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3206 checkGlobsPflsPartCoherency();
3207 checkGlobsLocsPartCoherency();
3210 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3212 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3215 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3217 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3220 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3222 contentNotNull()->loadProfileInFile(fid,id,pflName);
3225 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3227 contentNotNull()->loadProfileInFile(fid,id);
3230 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3232 contentNotNull()->loadGlobals(fid,*this);
3235 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3237 contentNotNull()->loadAllGlobals(fid);
3240 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3242 contentNotNull()->writeGlobals(fid,opt);
3246 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3247 * or getPflsReallyUsedMulti().
3248 * \return std::vector<std::string> - a sequence of names of all profiles.
3250 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3252 return contentNotNull()->getPfls();
3256 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3257 * or getLocsReallyUsedMulti().
3258 * \return std::vector<std::string> - a sequence of names of all localizations.
3260 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3262 return contentNotNull()->getLocs();
3266 * Checks if the profile with a given name exists.
3267 * \param [in] pflName - the profile name of interest.
3268 * \return bool - \c true if the profile named \a pflName exists.
3270 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3272 return contentNotNull()->existsPfl(pflName);
3276 * Checks if the localization with a given name exists.
3277 * \param [in] locName - the localization name of interest.
3278 * \return bool - \c true if the localization named \a locName exists.
3280 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3282 return contentNotNull()->existsLoc(locName);
3285 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3287 return contentNotNull()->createNewNameOfPfl();
3290 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3292 return contentNotNull()->createNewNameOfLoc();
3296 * Sets the name of a MED file.
3297 * \param [inout] fileName - the file name.
3299 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3301 contentNotNull()->setFileName(fileName);
3305 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3306 * in the same order.
3307 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3308 * Each item of this sequence is a vector containing ids of equal profiles.
3310 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3312 return contentNotNull()->whichAreEqualProfiles();
3316 * Finds equal localizations.
3317 * \param [in] eps - a precision used to compare real values of the localizations.
3318 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3319 * Each item of this sequence is a vector containing ids of equal localizations.
3321 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3323 return contentNotNull()->whichAreEqualLocs(eps);
3327 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3328 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3329 * this sequence is a pair whose
3330 * - the first item is a vector of profile names to replace by the second item,
3331 * - the second item is a profile name to replace every profile name of the first item.
3333 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3335 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3339 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3340 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3341 * this sequence is a pair whose
3342 * - the first item is a vector of localization names to replace by the second item,
3343 * - the second item is a localization name to replace every localization name of the first item.
3345 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3347 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3351 * Replaces references to some profiles (a reference is a profile name) by references
3352 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3353 * them-selves accordingly. <br>
3354 * This method is a generalization of changePflName().
3355 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3356 * this sequence is a pair whose
3357 * - the first item is a vector of profile names to replace by the second item,
3358 * - the second item is a profile name to replace every profile of the first item.
3359 * \sa changePflsRefsNamesGen()
3360 * \sa changePflName()
3362 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3364 changePflsRefsNamesGen(mapOfModif);
3365 changePflsNamesInStruct(mapOfModif);
3369 * Replaces references to some localizations (a reference is a localization name) by references
3370 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3371 * them-selves accordingly. <br>
3372 * This method is a generalization of changeLocName().
3373 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3374 * this sequence is a pair whose
3375 * - the first item is a vector of localization names to replace by the second item,
3376 * - the second item is a localization name to replace every localization of the first item.
3377 * \sa changeLocsRefsNamesGen()
3378 * \sa changeLocName()
3380 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3382 changeLocsRefsNamesGen(mapOfModif);
3383 changeLocsNamesInStruct(mapOfModif);
3387 * Renames the profile having a given name and updates references to this profile.
3388 * \param [in] oldName - the name of the profile to rename.
3389 * \param [in] newName - a new name of the profile.
3390 * \sa changePflsNames().
3392 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3394 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3395 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3397 changePflsNames(mapOfModif);
3401 * Renames the localization having a given name and updates references to this localization.
3402 * \param [in] oldName - the name of the localization to rename.
3403 * \param [in] newName - a new name of the localization.
3404 * \sa changeLocsNames().
3406 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3408 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3409 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3411 changeLocsNames(mapOfModif);
3415 * Removes duplicated profiles. Returns a map used to update references to removed
3416 * profiles via changePflsRefsNamesGen().
3417 * Equal profiles are found using whichAreEqualProfiles().
3418 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3419 * a sequence describing the performed replacements of profiles. Each element of
3420 * this sequence is a pair whose
3421 * - the first item is a vector of profile names replaced by the second item,
3422 * - the second item is a profile name replacing every profile of the first item.
3424 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3426 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3427 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3429 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3431 std::vector< std::string > tmp((*it).size());
3433 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3434 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3435 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3437 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3438 killProfileIds(tmp2);
3440 changePflsRefsNamesGen(ret);
3445 * Removes duplicated localizations. Returns a map used to update references to removed
3446 * localizations via changeLocsRefsNamesGen().
3447 * Equal localizations are found using whichAreEqualLocs().
3448 * \param [in] eps - a precision used to compare real values of the localizations.
3449 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3450 * a sequence describing the performed replacements of localizations. Each element of
3451 * this sequence is a pair whose
3452 * - the first item is a vector of localization names replaced by the second item,
3453 * - the second item is a localization name replacing every localization of the first item.
3455 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3457 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3458 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3460 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3462 std::vector< std::string > tmp((*it).size());
3464 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3465 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3466 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3468 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3469 killLocalizationIds(tmp2);
3471 changeLocsRefsNamesGen(ret);
3476 * Returns number of Gauss points per cell in a given localization.
3477 * \param [in] locId - an id of the localization of interest.
3478 * \return int - the number of the Gauss points per cell.
3480 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3482 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3486 * Returns an id of a localization by its name.
3487 * \param [in] loc - the localization name of interest.
3488 * \return int - the id of the localization.
3489 * \throw If there is no a localization named \a loc.
3491 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3493 return contentNotNull()->getLocalizationId(loc);
3497 * Returns the name of the MED file.
3498 * \return const std::string& - the MED file name.
3500 std::string MEDFileFieldGlobsReal::getFileName() const
3502 return contentNotNull()->getFileName();
3506 * Returns a localization object by its name.
3507 * \param [in] locName - the name of the localization of interest.
3508 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3509 * \throw If there is no a localization named \a locName.
3511 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3513 return contentNotNull()->getLocalization(locName);
3517 * Returns a localization object by its id.
3518 * \param [in] locId - the id of the localization of interest.
3519 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3520 * \throw If there is no a localization with id \a locId.
3522 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3524 return contentNotNull()->getLocalizationFromId(locId);
3528 * Returns a profile array by its name.
3529 * \param [in] pflName - the name of the profile of interest.
3530 * \return const DataArrayInt * - the profile array having the name \a pflName.
3531 * \throw If there is no a profile named \a pflName.
3533 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3535 return contentNotNull()->getProfile(pflName);
3539 * Returns a profile array by its id.
3540 * \param [in] pflId - the id of the profile of interest.
3541 * \return const DataArrayInt * - the profile array having the id \a pflId.
3542 * \throw If there is no a profile with id \a pflId.
3544 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3546 return contentNotNull()->getProfileFromId(pflId);
3550 * Returns a localization object, apt for modification, by its id.
3551 * \param [in] locId - the id of the localization of interest.
3552 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3553 * having the id \a locId.
3554 * \throw If there is no a localization with id \a locId.
3556 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3558 return contentNotNull()->getLocalizationFromId(locId);
3562 * Returns a localization object, apt for modification, by its name.
3563 * \param [in] locName - the name of the localization of interest.
3564 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3565 * having the name \a locName.
3566 * \throw If there is no a localization named \a locName.
3568 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3570 return contentNotNull()->getLocalization(locName);
3574 * Returns a profile array, apt for modification, by its name.
3575 * \param [in] pflName - the name of the profile of interest.
3576 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3577 * \throw If there is no a profile named \a pflName.
3579 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3581 return contentNotNull()->getProfile(pflName);
3585 * Returns a profile array, apt for modification, by its id.
3586 * \param [in] pflId - the id of the profile of interest.
3587 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3588 * \throw If there is no a profile with id \a pflId.
3590 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3592 return contentNotNull()->getProfileFromId(pflId);
3596 * Removes profiles given by their ids. No data is updated to track this removal.
3597 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3599 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3601 contentNotNull()->killProfileIds(pflIds);
3605 * Removes localizations given by their ids. No data is updated to track this removal.
3606 * \param [in] locIds - a sequence of ids of the localizations to remove.
3608 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3610 contentNotNull()->killLocalizationIds(locIds);
3614 * Stores a profile array.
3615 * \param [in] pfl - the profile array to store.
3616 * \throw If the name of \a pfl is empty.
3617 * \throw If a profile with the same name as that of \a pfl already exists but contains
3620 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3622 contentNotNull()->appendProfile(pfl);
3626 * Adds a new localization of Gauss points.
3627 * \param [in] locName - the name of the new localization.
3628 * \param [in] geoType - a geometrical type of the reference cell.
3629 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3630 * must be \c nbOfNodesPerCell * \c dimOfType.
3631 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3632 * must be _wg_.size() * \c dimOfType.
3633 * \param [in] w - the weights of Gauss points.
3634 * \throw If \a locName is empty.
3635 * \throw If a localization with the name \a locName already exists but is
3636 * different form the new one.
3638 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)
3640 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3643 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3645 MEDFileFieldGlobs *g(_globals);
3647 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3651 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3653 const MEDFileFieldGlobs *g(_globals);
3655 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3659 //= MEDFileFieldNameScope
3661 MEDFileFieldNameScope::MEDFileFieldNameScope()
3665 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3670 * Returns the name of \a this field.
3671 * \return std::string - a string containing the field name.
3673 std::string MEDFileFieldNameScope::getName() const
3679 * Sets name of \a this field
3680 * \param [in] name - the new field name.
3682 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3687 std::string MEDFileFieldNameScope::getDtUnit() const
3692 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3697 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3700 _dt_unit=other._dt_unit;
3703 //= MEDFileAnyTypeField1TSWithoutSDA
3705 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3707 _field_per_mesh.resize(other._field_per_mesh.size());
3709 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3711 if((const MEDFileFieldPerMesh *)*it)
3712 _field_per_mesh[i]=(*it)->deepCpy(this);
3717 * Prints a string describing \a this field into a stream. This string is outputted
3718 * by \c print Python command.
3719 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3720 * \param [in,out] oss - the out stream.
3721 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3722 * info id printed, else, not.
3724 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3726 std::string startOfLine(bkOffset,' ');
3727 oss << startOfLine << "Field ";
3729 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3730 oss << "on one time Step ";
3732 oss << "(" << f1tsId << ") ";
3733 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3734 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3735 const DataArray *arr=getUndergroundDataArray();
3738 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3741 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3742 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3743 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3745 if(arr->isAllocated())
3747 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3750 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3754 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3756 oss << startOfLine << "----------------------" << std::endl;
3757 if(!_field_per_mesh.empty())
3760 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3762 const MEDFileFieldPerMesh *cur=(*it2);
3764 cur->simpleRepr(bkOffset,oss,i);
3766 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3771 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3773 oss << startOfLine << "----------------------" << std::endl;
3776 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3778 const DataArray *arr(getUndergroundDataArray());
3780 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3781 int nbOfCompo=arr->getNumberOfComponents();
3782 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3783 for(int i=0;i<nbOfCompo;i++)
3786 std::vector<int> v(1,i);
3787 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3788 ret[i]->setArray(arr2);
3793 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)
3797 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3802 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3803 * empty. Returns -1 if this in on nodes.
3804 * \return int - the dimension of \a this.
3806 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3809 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3810 (*it)->getDimension(ret);
3815 * Returns the mesh name.
3816 * \return std::string - a string holding the mesh name.
3817 * \throw If \c _field_per_mesh.empty()
3819 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3821 if(_field_per_mesh.empty())
3822 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3823 return _field_per_mesh[0]->getMeshName();
3826 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3828 std::string oldName(getMeshName());
3829 std::vector< std::pair<std::string,std::string> > v(1);
3830 v[0].first=oldName; v[0].second=newMeshName;
3834 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3837 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3839 MEDFileFieldPerMesh *cur(*it);
3841 ret=cur->changeMeshNames(modifTab) || ret;
3847 * Returns the number of iteration of the state of underlying mesh.
3848 * \return int - the iteration number.
3849 * \throw If \c _field_per_mesh.empty()
3851 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3853 if(_field_per_mesh.empty())
3854 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3855 return _field_per_mesh[0]->getMeshIteration();
3859 * Returns the order number of iteration of the state of underlying mesh.
3860 * \return int - the order number.
3861 * \throw If \c _field_per_mesh.empty()
3863 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3865 if(_field_per_mesh.empty())
3866 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3867 return _field_per_mesh[0]->getMeshOrder();
3871 * Checks if \a this field is tagged by a given iteration number and a given
3872 * iteration order number.
3873 * \param [in] iteration - the iteration number of interest.
3874 * \param [in] order - the iteration order number of interest.
3875 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3876 * \a this->getOrder() == \a order.
3878 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3880 return iteration==_iteration && order==_order;
3884 * Returns number of iteration and order number of iteration when
3885 * \a this field has been calculated.
3886 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3889 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3891 std::pair<int,int> p;
3897 * Returns number of iteration and order number of iteration when
3898 * \a this field has been calculated.
3899 * \param [in,out] p - a pair returning the iteration number and the iteration
3902 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3909 * Returns all types of spatial discretization of \a this field.
3910 * \param [in,out] types - a sequence of types of \a this field.
3912 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3914 std::set<TypeOfField> types2;
3915 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3917 (*it)->fillTypesOfFieldAvailable(types2);
3919 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3920 std::copy(types2.begin(),types2.end(),bi);
3924 * Returns all types of spatial discretization of \a this field.
3925 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3928 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3930 std::vector<TypeOfField> ret;
3931 fillTypesOfFieldAvailable(ret);
3935 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3937 std::vector<std::string> ret;
3938 std::set<std::string> ret2;
3939 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3941 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3942 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3943 if(ret2.find(*it2)==ret2.end())
3945 ret.push_back(*it2);
3952 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3954 std::vector<std::string> ret;
3955 std::set<std::string> ret2;
3956 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3958 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3959 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3960 if(ret2.find(*it2)==ret2.end())
3962 ret.push_back(*it2);
3969 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3971 std::vector<std::string> ret;
3972 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3974 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3975 ret.insert(ret.end(),tmp.begin(),tmp.end());
3980 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3982 std::vector<std::string> ret;
3983 std::set<std::string> ret2;
3984 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3986 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3987 ret.insert(ret.end(),tmp.begin(),tmp.end());
3992 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3994 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3995 (*it)->changePflsRefsNamesGen(mapOfModif);
3998 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4000 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4001 (*it)->changeLocsRefsNamesGen(mapOfModif);
4005 * Returns all attributes of parts of \a this field lying on a given mesh.
4006 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4007 * item of every of returned sequences refers to the _i_-th part of \a this field.
4008 * Thus all sequences returned by this method are of the same length equal to number
4009 * of different types of supporting entities.<br>
4010 * A field part can include sub-parts with several different spatial discretizations,
4011 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4012 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4013 * of a nested sequence corresponds to a type of spatial discretization.<br>
4014 * This method allows for iteration over MEDFile DataStructure without any overhead.
4015 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4016 * for the case with only one underlying mesh. (Actually, the number of meshes is
4017 * not checked if \a mname == \c NULL).
4018 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4019 * a field part is returned.
4020 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4021 * This sequence is of the same length as \a types.
4022 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4023 * discretization. A profile name can be empty.
4024 * Length of this and of nested sequences is the same as that of \a typesF.
4025 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4026 * discretization. A localization name can be empty.
4027 * Length of this and of nested sequences is the same as that of \a typesF.
4028 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4029 * of ids of tuples within the data array, per each type of spatial
4030 * discretization within one mesh entity type.
4031 * Length of this and of nested sequences is the same as that of \a typesF.
4032 * \throw If no field is lying on \a mname.
4034 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
4038 meshId=getMeshIdFromMeshName(mname);
4040 if(_field_per_mesh.empty())
4041 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4042 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4046 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4047 * maximal absolute dimension and values returned via the out parameter \a levs are
4048 * dimensions relative to the maximal absolute dimension. <br>
4049 * This method is designed for MEDFileField1TS instances that have a discretization
4050 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4051 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4052 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4053 * Only these 3 discretizations will be taken into account here. If \a this is
4054 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4055 * This method is useful to make the link between the dimension of the underlying mesh
4056 * and the levels of \a this, because it is possible that the highest dimension of \a this
4057 * field is not equal to the dimension of the underlying mesh.
4059 * Let's consider the following case:
4060 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4061 * TETRA4, HEXA8, TRI3 and SEG2.
4062 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4063 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4065 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4066 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4067 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4068 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4069 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4070 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4072 * to retrieve the highest level of
4073 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4074 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4075 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4076 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4077 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4078 * for the case with only one underlying mesh. (Actually, the number of meshes is
4079 * not checked if \a mname == \c NULL).
4080 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4081 * absolute one. They are in decreasing order. This sequence is cleared before
4083 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4084 * \throw If no field is lying on \a mname.
4086 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4089 int meshId=getMeshIdFromMeshName(mname);
4090 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4091 std::vector< std::vector<TypeOfField> > typesF;
4092 std::vector< std::vector<std::string> > pfls, locs;
4093 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4095 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4096 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4097 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4099 st.erase(INTERP_KERNEL::NORM_ERROR);
4101 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4103 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4104 ret1.insert((int)cm.getDimension());
4106 int ret=*std::max_element(ret1.begin(),ret1.end());
4107 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4108 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4113 * \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.
4114 * \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.
4115 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4116 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4118 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4120 int mid=getMeshIdFromMeshName(mName);
4121 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4125 * \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.
4126 * \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.
4127 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4128 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4130 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4132 int mid=getMeshIdFromMeshName(mName);
4133 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4137 * \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.
4139 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4141 if(_field_per_mesh.empty())
4142 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4145 std::string mName2(mName);
4147 std::vector<std::string> msg;
4148 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4149 if(mName2==(*it)->getMeshName())
4152 msg.push_back((*it)->getMeshName());
4153 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4154 oss << "Possible meshes are : ";
4155 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4156 oss << "\"" << (*it2) << "\" ";
4157 throw INTERP_KERNEL::Exception(oss.str().c_str());
4160 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4163 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4164 std::string tmp(mesh->getName());
4166 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4167 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4169 for(;it!=_field_per_mesh.end();it++,i++)
4171 if((*it)->getMeshName()==tmp)
4174 int sz=_field_per_mesh.size();
4175 _field_per_mesh.resize(sz+1);
4176 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4180 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4181 MEDFileFieldGlobsReal& glob)
4184 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4186 MEDFileFieldPerMesh *fpm(*it);
4188 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4194 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4195 * splitting that leads to single spatial discretization of this.
4197 * \sa splitMultiDiscrPerGeoTypes
4199 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4201 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4202 std::vector< std::vector<TypeOfField> > typesF;
4203 std::vector< std::vector<std::string> > pfls,locs;
4204 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4205 std::set<TypeOfField> allEnt;
4206 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4207 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4208 allEnt.insert(*it2);
4209 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4210 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4211 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4213 std::vector< std::pair<int,int> > its;
4214 ret[i]=shallowCpy();
4215 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4216 ret[i]->updateData(newLgth,its);
4222 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4223 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4225 * \sa splitDiscretizations
4227 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4229 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4230 std::vector< std::vector<TypeOfField> > typesF;
4231 std::vector< std::vector<std::string> > pfls,locs;
4232 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4233 std::set<TypeOfField> allEnt;
4234 std::size_t nbOfMDPGT(0),ii(0);
4235 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4237 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4238 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4239 allEnt.insert(*it2);
4241 if(allEnt.size()!=1)
4242 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4244 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4247 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4248 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4251 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4252 for(std::size_t i=0;i<nbOfMDPGT;i++)
4254 std::vector< std::pair<int,int> > its;
4255 ret[i]=shallowCpy();
4256 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4257 ret[i]->updateData(newLgth,its);
4262 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4264 int globalCounter(0);
4265 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4266 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4267 return globalCounter;
4270 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4272 int globalCounter(0);
4273 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4274 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4275 return globalCounter;
4278 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4280 if(_nb_of_tuples_to_be_allocated>=0)
4282 _nb_of_tuples_to_be_allocated=newLgth;
4283 const DataArray *oldArr(getUndergroundDataArray());
4286 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4287 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4289 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4293 if(_nb_of_tuples_to_be_allocated==-1)
4295 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4297 const DataArray *oldArr(getUndergroundDataArray());
4298 if(!oldArr || !oldArr->isAllocated())
4299 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4300 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4301 newArr->alloc(newLgth,getNumberOfComponents());
4303 newArr->copyStringInfoFrom(*oldArr);
4305 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4307 if((*it).second<(*it).first)
4308 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4309 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4310 pos+=(*it).second-(*it).first;
4315 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4318 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4320 if(_field_per_mesh.empty())
4321 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4322 if(_field_per_mesh.size()>1)
4323 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4324 _field_per_mesh[0]->copyOptionsFrom(opts);
4325 _field_per_mesh[0]->writeLL(fid,nasc);
4329 * 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.
4330 * If false is returned the memory allocation is not required.
4332 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4334 if(_nb_of_tuples_to_be_allocated>=0)
4336 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4337 _nb_of_tuples_to_be_allocated=-2;
4340 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4342 if(_nb_of_tuples_to_be_allocated==-1)
4343 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4344 if(_nb_of_tuples_to_be_allocated<-3)
4345 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4346 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4349 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4351 med_int numdt,numit;
4355 med_int meshnumdt,meshnumit;
4356 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4357 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4358 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4359 if(_iteration!=numdt || _order!=numit)
4360 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4361 _field_per_mesh.resize(nmesh);
4366 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4367 mm=ms->getMeshWithName(meshNameCpp);
4370 for(int i=0;i<nmesh;i++)
4371 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm);
4372 _nb_of_tuples_to_be_allocated=0;
4373 for(int i=0;i<nmesh;i++)
4374 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4377 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4379 allocIfNecessaryTheArrayToReceiveDataFromFile();
4380 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4381 (*it)->loadBigArraysRecursively(fid,nasc);
4384 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4386 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4387 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4388 (*it)->loadBigArraysRecursively(fid,nasc);
4391 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms)
4393 loadOnlyStructureOfDataRecursively(fid,nasc,ms);
4394 loadBigArraysRecursively(fid,nasc);
4397 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4399 DataArray *thisArr(getUndergroundDataArray());
4400 if(thisArr && thisArr->isAllocated())
4402 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4403 thisArr->desallocate();
4407 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4409 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4412 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4414 std::vector<const BigMemoryObject *> ret;
4415 if(getUndergroundDataArray())
4416 ret.push_back(getUndergroundDataArray());
4417 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4418 ret.push_back((const MEDFileFieldPerMesh *)*it);
4423 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4424 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4425 * "Sort By Type"), if not, an exception is thrown.
4426 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4427 * \param [in] arr - the array of values.
4428 * \param [in,out] glob - the global data where profiles and localization present in
4429 * \a field, if any, are added.
4430 * \throw If the name of \a field is empty.
4431 * \throw If the data array of \a field is not set.
4432 * \throw If \a this->_arr is already allocated but has different number of components
4434 * \throw If the underlying mesh of \a field has no name.
4435 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4437 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4439 const MEDCouplingMesh *mesh=field->getMesh();
4441 TypeOfField type=field->getTypeOfField();
4442 std::vector<DataArrayInt *> dummy;
4443 int start=copyTinyInfoFrom(field,arr);
4444 int pos=addNewEntryIfNecessary(mesh);
4447 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4448 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4451 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4455 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4456 * of a given mesh are used as the support of the given field (a real support is not used).
4457 * Elements of the given mesh must be sorted suitable for writing to MED file.
4458 * Order of underlying mesh entities of the given field specified by \a profile parameter
4459 * is not prescribed; this method permutes field values to have them sorted by element
4460 * type as required for writing to MED file. A new profile is added only if no equal
4461 * profile is missing.
4462 * \param [in] field - the field to add to \a this. The field double values are ignored.
4463 * \param [in] arrOfVals - the values of the field \a field used.
4464 * \param [in] mesh - the supporting mesh of \a field.
4465 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4466 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4467 * \param [in,out] glob - the global data where profiles and localization present in
4468 * \a field, if any, are added.
4469 * \throw If either \a field or \a mesh or \a profile has an empty name.
4470 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4471 * \throw If the data array of \a field is not set.
4472 * \throw If \a this->_arr is already allocated but has different number of components
4474 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4475 * \sa setFieldNoProfileSBT()
4477 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4480 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4481 if(!arrOfVals || !arrOfVals->isAllocated())
4482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4483 TypeOfField type=field->getTypeOfField();
4484 std::vector<DataArrayInt *> idsInPflPerType;
4485 std::vector<DataArrayInt *> idsPerType;
4486 std::vector<int> code,code2;
4487 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4490 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4491 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4492 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4493 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4495 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4496 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4497 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4499 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4500 throw INTERP_KERNEL::Exception(oss.str().c_str());
4503 int start=copyTinyInfoFrom(field,arrOfVals);
4504 code2=m->getDistributionOfTypes();
4506 int pos=addNewEntryIfNecessary(m);
4507 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4511 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4512 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4513 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4514 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4515 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4516 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4518 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4519 throw INTERP_KERNEL::Exception(oss.str().c_str());
4521 int start=copyTinyInfoFrom(field,arrOfVals);
4522 int pos=addNewEntryIfNecessary(m);
4523 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4528 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4530 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4532 if(_nb_of_tuples_to_be_allocated>=0)
4533 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 !");
4534 DataArray *arr(getOrCreateAndGetArray());
4535 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4536 _nb_of_tuples_to_be_allocated=-3;
4540 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4541 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4542 * larger by the size of \a field. Returns an id of the first not filled
4543 * tuple of \a this->_arr.
4544 * \param [in] field - the field to copy the info on components and the name from.
4545 * \return int - the id of first not initialized tuple of \a this->_arr.
4546 * \throw If the name of \a field is empty.
4547 * \throw If the data array of \a field is not set.
4548 * \throw If \a this->_arr is already allocated but has different number of components
4551 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4554 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4555 std::string name(field->getName());
4556 setName(name.c_str());
4557 setDtUnit(field->getTimeUnit());
4559 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4561 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4562 if(!arr->isAllocated())
4563 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4564 _dt=field->getTime(_iteration,_order);
4565 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4566 if(!getOrCreateAndGetArray()->isAllocated())
4568 allocNotFromFile(arr->getNumberOfTuples());
4573 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4574 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4575 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4576 _nb_of_tuples_to_be_allocated=-3;
4577 return oldNbOfTuples;
4582 * Returns number of components in \a this field
4583 * \return int - the number of components.
4585 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4587 return getOrCreateAndGetArray()->getNumberOfComponents();
4591 * Change info on components in \a this.
4592 * \throw If size of \a infos is not equal to the number of components already in \a this.
4594 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4596 DataArray *arr=getOrCreateAndGetArray();
4597 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4601 * Returns info on components of \a this field.
4602 * \return const std::vector<std::string>& - a sequence of strings each being an
4603 * information on _i_-th component.
4605 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4607 const DataArray *arr=getOrCreateAndGetArray();
4608 return arr->getInfoOnComponents();
4612 * Returns a mutable info on components of \a this field.
4613 * \return std::vector<std::string>& - a sequence of strings each being an
4614 * information on _i_-th component.
4616 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4618 DataArray *arr=getOrCreateAndGetArray();
4619 return arr->getInfoOnComponents();
4622 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4624 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4626 const MEDFileFieldPerMesh *fpm(*it);
4629 if(fpm->presenceOfMultiDiscPerGeoType())
4636 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4637 * \param [in] type - a spatial discretization of the new field.
4638 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4639 * \param [in] mName - a name of the supporting mesh.
4640 * \param [in] renumPol - specifies how to permute values of the result field according to
4641 * the optional numbers of cells and nodes, if any. The valid values are
4642 * - 0 - do not permute.
4643 * - 1 - permute cells.
4644 * - 2 - permute nodes.
4645 * - 3 - permute cells and nodes.
4647 * \param [in] glob - the global data storing profiles and localization.
4648 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4649 * caller is to delete this field using decrRef() as it is no more needed.
4650 * \throw If the MED file is not readable.
4651 * \throw If there is no mesh named \a mName in the MED file.
4652 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4653 * \throw If no field of \a this is lying on the mesh \a mName.
4654 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4656 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4658 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4660 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4662 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4663 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4667 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4668 * \param [in] type - a spatial discretization of the new field.
4669 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4670 * \param [in] renumPol - specifies how to permute values of the result field according to
4671 * the optional numbers of cells and nodes, if any. The valid values are
4672 * - 0 - do not permute.
4673 * - 1 - permute cells.
4674 * - 2 - permute nodes.
4675 * - 3 - permute cells and nodes.
4677 * \param [in] glob - the global data storing profiles and localization.
4678 * \param [in] mesh - the supporting mesh.
4679 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4680 * caller is to delete this field using decrRef() as it is no more needed.
4681 * \throw If the MED file is not readable.
4682 * \throw If no field of \a this is lying on \a mesh.
4683 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4684 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4686 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4688 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4689 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4690 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4691 if(meshDimRelToMax==1)
4692 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4693 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4697 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4699 * \param [in] type - a spatial discretization of the new field.
4700 * \param [in] mName - a name of the supporting mesh.
4701 * \param [in] renumPol - specifies how to permute values of the result field according to
4702 * the optional numbers of cells and nodes, if any. The valid values are
4703 * - 0 - do not permute.
4704 * - 1 - permute cells.
4705 * - 2 - permute nodes.
4706 * - 3 - permute cells and nodes.
4708 * \param [in] glob - the global data storing profiles and localization.
4709 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4710 * caller is to delete this field using decrRef() as it is no more needed.
4711 * \throw If the MED file is not readable.
4712 * \throw If there is no mesh named \a mName in the MED file.
4713 * \throw If there are no mesh entities in the mesh.
4714 * \throw If no field values of the given \a type are available.
4716 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4718 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4720 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4722 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4723 int absDim=getDimension();
4724 int meshDimRelToMax=absDim-mm->getMeshDimension();
4725 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4729 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4730 * \param [in] type - a spatial discretization of the new field.
4731 * \param [in] renumPol - specifies how to permute values of the result field according to
4732 * the optional numbers of cells and nodes, if any. The valid values are
4733 * - 0 - do not permute.
4734 * - 1 - permute cells.
4735 * - 2 - permute nodes.
4736 * - 3 - permute cells and nodes.
4738 * \param [in] glob - the global data storing profiles and localization.
4739 * \param [in] mesh - the supporting mesh.
4740 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4741 * field according to \a renumPol.
4742 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4743 * field according to \a renumPol.
4744 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4745 * caller is to delete this field using decrRef() as it is no more needed.
4746 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4747 * \throw If no field of \a this is lying on \a mesh.
4748 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4750 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
4752 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4753 int meshId=getMeshIdFromMeshName(mesh->getName());
4755 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4760 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4767 throw INTERP_KERNEL::Exception(msg1);
4768 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4771 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4773 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4774 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4775 throw INTERP_KERNEL::Exception(oss.str().c_str());
4777 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4778 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4779 std::vector<DataArray *> arrOut2(1,arrOut);
4780 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4781 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4782 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4789 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4791 throw INTERP_KERNEL::Exception(msg1);
4794 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4796 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4797 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4798 throw INTERP_KERNEL::Exception(oss.str().c_str());
4800 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4801 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4802 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4803 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4808 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4813 * Returns values and a profile of the field of a given type lying on a given support.
4814 * \param [in] type - a spatial discretization of the field.
4815 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4816 * \param [in] mesh - the supporting mesh.
4817 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4818 * field of interest lies on. If the field lies on all entities of the given
4819 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4820 * using decrRef() as it is no more needed.
4821 * \param [in] glob - the global data storing profiles and localization.
4822 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4823 * field. The caller is to delete this array using decrRef() as it is no more needed.
4824 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4825 * \throw If no field of \a this is lying on \a mesh.
4826 * \throw If no field values of the given \a type are available.
4828 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4830 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4831 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4832 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4833 ret->setName(nasc.getName().c_str());
4837 //= MEDFileField1TSWithoutSDA
4840 * Throws if a given value is not a valid (non-extended) relative dimension.
4841 * \param [in] meshDimRelToMax - the relative dimension value.
4842 * \throw If \a meshDimRelToMax > 0.
4844 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4846 if(meshDimRelToMax>0)
4847 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4851 * Checks if elements of a given mesh are in the order suitable for writing
4852 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4853 * vector describing types of elements and their number.
4854 * \param [in] mesh - the mesh to check.
4855 * \return std::vector<int> - a vector holding for each element type (1) item of
4856 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4857 * These values are in full-interlace mode.
4858 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4860 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4863 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4864 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4865 int nbOfTypes=geoTypes.size();
4866 std::vector<int> code(3*nbOfTypes);
4867 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4868 arr1->alloc(nbOfTypes,1);
4869 int *arrPtr=arr1->getPointer();
4870 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4871 for(int i=0;i<nbOfTypes;i++,it++)
4872 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4873 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4874 const int *arrPtr2=arr2->getConstPointer();
4876 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4879 int nbCells=mesh->getNumberOfCellsWithType(*it);
4880 code[3*pos]=(int)(*it);
4881 code[3*pos+1]=nbCells;
4882 code[3*pos+2]=-1;//no profiles
4884 std::vector<const DataArrayInt *> idsPerType;//no profiles
4885 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4889 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4894 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4896 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4900 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4901 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4902 * item of every of returned sequences refers to the _i_-th part of \a this field.
4903 * Thus all sequences returned by this method are of the same length equal to number
4904 * of different types of supporting entities.<br>
4905 * A field part can include sub-parts with several different spatial discretizations,
4906 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4907 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4908 * of a nested sequence corresponds to a type of spatial discretization.<br>
4909 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4910 * The overhead is due to selecting values into new instances of DataArrayDouble.
4911 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4912 * for the case with only one underlying mesh. (Actually, the number of meshes is
4913 * not checked if \a mname == \c NULL).
4914 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4915 * a field part is returned.
4916 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4917 * A field part can include sub-parts with several different spatial discretizations,
4918 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4919 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4920 * This sequence is of the same length as \a types.
4921 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4922 * discretization. A profile name can be empty.
4923 * Length of this and of nested sequences is the same as that of \a typesF.
4924 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4925 * discretization. A localization name can be empty.
4926 * Length of this and of nested sequences is the same as that of \a typesF.
4927 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4928 * per each type of spatial discretization within one mesh entity type.
4929 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4930 * Length of this and of nested sequences is the same as that of \a typesF.
4931 * \throw If no field is lying on \a mname.
4933 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
4937 meshId=getMeshIdFromMeshName(mname);
4939 if(_field_per_mesh.empty())
4940 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4941 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4942 int nbOfRet=ret0.size();
4943 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4944 for(int i=0;i<nbOfRet;i++)
4946 const std::vector< std::pair<int,int> >& p=ret0[i];
4947 int nbOfRet1=p.size();
4948 ret[i].resize(nbOfRet1);
4949 for(int j=0;j<nbOfRet1;j++)
4951 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4959 * Returns a pointer to the underground DataArrayDouble instance. So the
4960 * caller should not decrRef() it. This method allows for a direct access to the field
4961 * values. This method is quite unusable if there is more than a nodal field or a cell
4962 * field on single geometric cell type.
4963 * \return DataArrayDouble * - the pointer to the field values array.
4965 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4967 const DataArrayDouble *ret=_arr;
4969 return const_cast<DataArrayDouble *>(ret);
4974 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4979 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4981 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4982 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4983 ret->deepCpyLeavesFrom(*this);
4984 const DataArrayDouble *arr(_arr);
4987 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4988 ret->setArray(arr2);
4994 * Returns a pointer to the underground DataArrayDouble instance. So the
4995 * caller should not decrRef() it. This method allows for a direct access to the field
4996 * values. This method is quite unusable if there is more than a nodal field or a cell
4997 * field on single geometric cell type.
4998 * \return DataArrayDouble * - the pointer to the field values array.
5000 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5002 return getUndergroundDataArrayDouble();
5006 * Returns a pointer to the underground DataArrayDouble instance and a
5007 * sequence describing parameters of a support of each part of \a this field. The
5008 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5009 * direct access to the field values. This method is intended for the field lying on one
5011 * \param [in,out] entries - the sequence describing parameters of a support of each
5012 * part of \a this field. Each item of this sequence consists of two parts. The
5013 * first part describes a type of mesh entity and an id of discretization of a
5014 * current field part. The second part describes a range of values [begin,end)
5015 * within the returned array relating to the current field part.
5016 * \return DataArrayDouble * - the pointer to the field values array.
5017 * \throw If the number of underlying meshes is not equal to 1.
5018 * \throw If no field values are available.
5019 * \sa getUndergroundDataArray()
5021 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5023 if(_field_per_mesh.size()!=1)
5024 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5025 if(_field_per_mesh[0]==0)
5026 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5027 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5028 return getUndergroundDataArrayDouble();
5032 * Returns a pointer to the underground DataArrayDouble instance and a
5033 * sequence describing parameters of a support of each part of \a this field. The
5034 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5035 * direct access to the field values. This method is intended for the field lying on one
5037 * \param [in,out] entries - the sequence describing parameters of a support of each
5038 * part of \a this field. Each item of this sequence consists of two parts. The
5039 * first part describes a type of mesh entity and an id of discretization of a
5040 * current field part. The second part describes a range of values [begin,end)
5041 * within the returned array relating to the current field part.
5042 * \return DataArrayDouble * - the pointer to the field values array.
5043 * \throw If the number of underlying meshes is not equal to 1.
5044 * \throw If no field values are available.
5045 * \sa getUndergroundDataArray()
5047 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5049 return getUndergroundDataArrayDoubleExt(entries);
5052 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5054 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5055 arr->setInfoAndChangeNbOfCompo(infos);
5058 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5062 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5064 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5065 ret->deepCpyLeavesFrom(*this);
5069 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5071 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5072 if((const DataArrayDouble *)_arr)
5073 ret->_arr=_arr->deepCpy();
5077 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5081 _nb_of_tuples_to_be_allocated=-1;
5085 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5087 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5089 _nb_of_tuples_to_be_allocated=-3;
5094 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5096 return DataArrayDouble::New();
5099 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5101 DataArrayDouble *ret=_arr;
5104 _arr=DataArrayDouble::New();
5108 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5110 return getOrCreateAndGetArrayDouble();
5113 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5115 const DataArrayDouble *ret=_arr;
5118 DataArrayDouble *ret2=DataArrayDouble::New();
5119 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5123 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5125 return getOrCreateAndGetArrayDouble();
5128 //= MEDFileIntField1TSWithoutSDA
5130 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5132 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5135 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5139 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5140 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5142 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5143 arr->setInfoAndChangeNbOfCompo(infos);
5146 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5151 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5153 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5154 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5155 ret->deepCpyLeavesFrom(*this);
5156 const DataArrayInt *arr(_arr);
5159 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5160 ret->setArray(arr2);
5166 * Returns a pointer to the underground DataArrayInt instance. So the
5167 * caller should not decrRef() it. This method allows for a direct access to the field
5168 * values. This method is quite unusable if there is more than a nodal field or a cell
5169 * field on single geometric cell type.
5170 * \return DataArrayInt * - the pointer to the field values array.
5172 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5174 return getUndergroundDataArrayInt();
5178 * Returns a pointer to the underground DataArrayInt instance. So the
5179 * caller should not decrRef() it. This method allows for a direct access to the field
5180 * values. This method is quite unusable if there is more than a nodal field or a cell
5181 * field on single geometric cell type.
5182 * \return DataArrayInt * - the pointer to the field values array.
5184 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5186 const DataArrayInt *ret=_arr;
5188 return const_cast<DataArrayInt *>(ret);
5194 * Returns a pointer to the underground DataArrayInt instance and a
5195 * sequence describing parameters of a support of each part of \a this field. The
5196 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5197 * direct access to the field values. This method is intended for the field lying on one
5199 * \param [in,out] entries - the sequence describing parameters of a support of each
5200 * part of \a this field. Each item of this sequence consists of two parts. The
5201 * first part describes a type of mesh entity and an id of discretization of a
5202 * current field part. The second part describes a range of values [begin,end)
5203 * within the returned array relating to the current field part.
5204 * \return DataArrayInt * - the pointer to the field values array.
5205 * \throw If the number of underlying meshes is not equal to 1.
5206 * \throw If no field values are available.
5207 * \sa getUndergroundDataArray()
5209 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5211 return getUndergroundDataArrayIntExt(entries);
5215 * Returns a pointer to the underground DataArrayInt instance and a
5216 * sequence describing parameters of a support of each part of \a this field. The
5217 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5218 * direct access to the field values. This method is intended for the field lying on one
5220 * \param [in,out] entries - the sequence describing parameters of a support of each
5221 * part of \a this field. Each item of this sequence consists of two parts. The
5222 * first part describes a type of mesh entity and an id of discretization of a
5223 * current field part. The second part describes a range of values [begin,end)
5224 * within the returned array relating to the current field part.
5225 * \return DataArrayInt * - the pointer to the field values array.
5226 * \throw If the number of underlying meshes is not equal to 1.
5227 * \throw If no field values are available.
5228 * \sa getUndergroundDataArray()
5230 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5232 if(_field_per_mesh.size()!=1)
5233 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5234 if(_field_per_mesh[0]==0)
5235 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5236 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5237 return getUndergroundDataArrayInt();
5240 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5242 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5243 ret->deepCpyLeavesFrom(*this);
5247 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5249 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5250 if((const DataArrayInt *)_arr)
5251 ret->_arr=_arr->deepCpy();
5255 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5259 _nb_of_tuples_to_be_allocated=-1;
5263 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5265 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5267 _nb_of_tuples_to_be_allocated=-3;
5272 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5274 return DataArrayInt::New();
5277 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5279 DataArrayInt *ret=_arr;
5282 _arr=DataArrayInt::New();
5286 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5288 return getOrCreateAndGetArrayInt();
5291 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5293 const DataArrayInt *ret=_arr;
5296 DataArrayInt *ret2=DataArrayInt::New();
5297 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5301 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5303 return getOrCreateAndGetArrayInt();
5306 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5310 //= MEDFileAnyTypeField1TS
5312 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5314 med_field_type typcha;
5316 std::vector<std::string> infos;
5317 std::string dtunit,fieldName;
5318 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5319 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5324 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5329 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5334 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] !";
5335 throw INTERP_KERNEL::Exception(oss.str().c_str());
5338 ret->setDtUnit(dtunit.c_str());
5339 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5341 med_int numdt,numit;
5343 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5344 ret->setTime(numdt,numit,dt);
5347 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5349 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5353 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5354 try:MEDFileFieldGlobsReal(fileName)
5356 MEDFileUtilities::CheckFileForRead(fileName);
5357 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5358 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5361 catch(INTERP_KERNEL::Exception& e)
5366 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5368 med_field_type typcha;
5369 std::vector<std::string> infos;
5372 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5373 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5378 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5383 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5388 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] !";
5389 throw INTERP_KERNEL::Exception(oss.str().c_str());
5392 ret->setDtUnit(dtunit.c_str());
5393 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5397 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5398 throw INTERP_KERNEL::Exception(oss.str().c_str());
5401 med_int numdt,numit;
5403 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5404 ret->setTime(numdt,numit,dt);
5407 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5409 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5413 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5414 try:MEDFileFieldGlobsReal(fileName)
5416 MEDFileUtilities::CheckFileForRead(fileName);
5417 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5418 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5421 catch(INTERP_KERNEL::Exception& e)
5426 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5429 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5430 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5432 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5433 ret->setFileName(fileName);
5434 ret->_content=c; c->incrRef();
5437 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5439 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5440 ret->setFileName(fileName);
5441 ret->_content=c; c->incrRef();
5444 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5447 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5449 MEDFileUtilities::CheckFileForRead(fileName);
5450 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5451 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5452 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5453 ret->loadGlobals(fid);
5457 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5459 MEDFileUtilities::CheckFileForRead(fileName);
5460 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5461 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5462 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5463 ret->loadGlobals(fid);
5467 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5469 MEDFileUtilities::CheckFileForRead(fileName);
5470 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5471 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5472 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5473 ret->loadGlobals(fid);
5477 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5479 med_field_type typcha;
5480 std::vector<std::string> infos;
5483 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5484 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5489 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5494 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5499 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] !";
5500 throw INTERP_KERNEL::Exception(oss.str().c_str());
5503 ret->setDtUnit(dtunit.c_str());
5504 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5507 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5508 for(int i=0;i<nbOfStep2 && !found;i++)
5510 med_int numdt,numit;
5512 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5513 if(numdt==iteration && numit==order)
5519 dtits[i]=std::pair<int,int>(numdt,numit);
5523 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5524 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5525 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5526 throw INTERP_KERNEL::Exception(oss.str().c_str());
5529 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5531 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms);
5535 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5536 try:MEDFileFieldGlobsReal(fileName)
5538 MEDFileUtilities::CheckFileForRead(fileName);
5539 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5540 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5543 catch(INTERP_KERNEL::Exception& e)
5549 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5550 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5552 * \warning this is a shallow copy constructor
5554 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5556 if(!shallowCopyOfContent)
5558 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5559 otherPtr->incrRef();
5560 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5564 _content=other.shallowCpy();
5568 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)
5572 int nbFields=MEDnField(fid);
5573 if(fieldIdCFormat>=nbFields)
5575 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5576 throw INTERP_KERNEL::Exception(oss.str().c_str());
5579 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5580 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5581 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5582 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5583 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5584 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5587 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5588 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5589 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5590 infos.clear(); infos.resize(ncomp);
5591 for(int j=0;j<ncomp;j++)
5592 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5597 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5600 * \return in case of success the number of time steps available for the field with name \a fieldName.
5602 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)
5604 int nbFields=MEDnField(fid);
5606 std::vector<std::string> fns(nbFields);
5608 for(int i=0;i<nbFields && !found;i++)
5611 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5613 found=(tmp==fieldName);
5619 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5620 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5621 oss << "\"" << *it << "\" ";
5622 throw INTERP_KERNEL::Exception(oss.str().c_str());
5628 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5629 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5630 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5631 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5632 * to keep a valid instance.
5633 * 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.
5634 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5635 * 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.
5637 * \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.
5638 * \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.
5639 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5640 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5641 * \param [in] newLocName is the new localization name.
5642 * \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.
5643 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5645 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5647 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5648 std::string oldPflName=disc->getProfile();
5649 std::vector<std::string> vv=getPflsReallyUsedMulti();
5650 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5651 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5653 disc->setProfile(newPflName);
5654 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5655 pfl->setName(newPflName);
5659 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5660 throw INTERP_KERNEL::Exception(oss.str().c_str());
5665 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5666 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5667 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5668 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5669 * to keep a valid instance.
5670 * 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.
5671 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5672 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5673 * 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.
5675 * \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.
5676 * \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.
5677 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5678 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5679 * \param [in] newLocName is the new localization name.
5680 * \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.
5681 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5683 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5685 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5686 std::string oldLocName=disc->getLocalization();
5687 std::vector<std::string> vv=getLocsReallyUsedMulti();
5688 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5689 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5691 disc->setLocalization(newLocName);
5692 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5693 loc.setName(newLocName);
5697 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5698 throw INTERP_KERNEL::Exception(oss.str().c_str());
5702 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5704 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5706 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5710 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5712 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5714 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5719 * Writes \a this field into a MED file specified by its name.
5720 * \param [in] fileName - the MED file name.
5721 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5722 * - 2 - erase; an existing file is removed.
5723 * - 1 - append; same data should not be present in an existing file.
5724 * - 0 - overwrite; same data present in an existing file is overwritten.
5725 * \throw If the field name is not set.
5726 * \throw If no field data is set.
5727 * \throw If \a mode == 1 and the same data is present in an existing file.
5729 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5731 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5732 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5737 * This method alloc the arrays and load potentially huge arrays contained in this field.
5738 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5739 * This method can be also called to refresh or reinit values from a file.
5741 * \throw If the fileName is not set or points to a non readable MED file.
5742 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5744 void MEDFileAnyTypeField1TS::loadArrays()
5746 if(getFileName().empty())
5747 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5748 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5749 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5753 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5754 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5755 * this method does not throw if \a this does not come from file read.
5757 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5759 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5761 if(!getFileName().empty())
5763 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5764 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5769 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5770 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5771 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5773 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5775 void MEDFileAnyTypeField1TS::unloadArrays()
5777 contentNotNullBase()->unloadArrays();
5781 * 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.
5782 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5783 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5785 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5787 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5789 if(!getFileName().empty())
5790 contentNotNullBase()->unloadArrays();
5793 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5795 int nbComp=getNumberOfComponents();
5796 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5797 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5798 for(int i=0;i<nbComp;i++)
5800 std::string info=getInfo()[i];
5802 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5803 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5804 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5806 if(getName().empty())
5807 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5808 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5809 writeGlobals(fid,*this);
5810 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5813 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5815 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5818 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5820 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5821 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5826 * Returns a string describing \a this field. This string is outputted
5827 * by \c print Python command.
5829 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5831 std::ostringstream oss;
5832 contentNotNullBase()->simpleRepr(0,oss,-1);
5833 simpleReprGlobs(oss);
5838 * This method returns all profiles whose name is non empty used.
5839 * \b WARNING If profile is used several times it will be reported \b only \b once.
5840 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5842 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5844 return contentNotNullBase()->getPflsReallyUsed2();
5848 * This method returns all localizations whose name is non empty used.
5849 * \b WARNING If localization is used several times it will be reported \b only \b once.
5851 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5853 return contentNotNullBase()->getLocsReallyUsed2();
5857 * This method returns all profiles whose name is non empty used.
5858 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5860 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5862 return contentNotNullBase()->getPflsReallyUsedMulti2();
5866 * This method returns all localizations whose name is non empty used.
5867 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5869 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5871 return contentNotNullBase()->getLocsReallyUsedMulti2();
5874 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5876 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5879 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5881 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5884 int MEDFileAnyTypeField1TS::getDimension() const
5886 return contentNotNullBase()->getDimension();
5889 int MEDFileAnyTypeField1TS::getIteration() const
5891 return contentNotNullBase()->getIteration();
5894 int MEDFileAnyTypeField1TS::getOrder() const
5896 return contentNotNullBase()->getOrder();
5899 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5901 return contentNotNullBase()->getTime(iteration,order);
5904 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5906 contentNotNullBase()->setTime(iteration,order,val);
5909 std::string MEDFileAnyTypeField1TS::getName() const
5911 return contentNotNullBase()->getName();
5914 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5916 contentNotNullBase()->setName(name);
5919 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5921 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5924 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5926 return contentNotNullBase()->getDtUnit();
5929 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5931 contentNotNullBase()->setDtUnit(dtUnit);
5934 std::string MEDFileAnyTypeField1TS::getMeshName() const
5936 return contentNotNullBase()->getMeshName();
5939 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5941 contentNotNullBase()->setMeshName(newMeshName);
5944 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5946 return contentNotNullBase()->changeMeshNames(modifTab);
5949 int MEDFileAnyTypeField1TS::getMeshIteration() const
5951 return contentNotNullBase()->getMeshIteration();
5954 int MEDFileAnyTypeField1TS::getMeshOrder() const
5956 return contentNotNullBase()->getMeshOrder();
5959 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5961 return contentNotNullBase()->getNumberOfComponents();
5964 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5966 return contentNotNullBase()->isDealingTS(iteration,order);
5969 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5971 return contentNotNullBase()->getDtIt();
5974 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5976 contentNotNullBase()->fillIteration(p);
5979 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5981 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5984 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5986 contentNotNullBase()->setInfo(infos);
5989 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5991 return contentNotNullBase()->getInfo();
5993 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5995 return contentNotNullBase()->getInfo();
5998 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6000 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6003 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6005 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6008 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6010 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6013 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6015 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6018 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6020 return contentNotNullBase()->getTypesOfFieldAvailable();
6023 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,
6024 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6026 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6030 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6031 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6032 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6034 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6036 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6038 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6039 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6040 std::size_t sz(contentsSplit.size());
6041 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6042 for(std::size_t i=0;i<sz;i++)
6044 ret[i]=shallowCpy();
6045 ret[i]->_content=contentsSplit[i];
6051 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6052 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6054 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6056 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6058 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6059 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6060 std::size_t sz(contentsSplit.size());
6061 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6062 for(std::size_t i=0;i<sz;i++)
6064 ret[i]=shallowCpy();
6065 ret[i]->_content=contentsSplit[i];
6071 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6072 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6074 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6076 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6078 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6079 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6080 std::size_t sz(contentsSplit.size());
6081 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6082 for(std::size_t i=0;i<sz;i++)
6084 ret[i]=shallowCpy();
6085 ret[i]->_content=contentsSplit[i];
6090 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6092 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6093 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6094 ret->_content=_content->deepCpy();
6095 ret->deepCpyGlobs(*this);
6099 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6101 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6107 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6108 * the first field that has been read from a specified MED file.
6109 * \param [in] fileName - the name of the MED file to read.
6110 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6111 * is to delete this field using decrRef() as it is no more needed.
6112 * \throw If reading the file fails.
6114 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6116 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6117 ret->contentNotNull();
6122 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6123 * a given field that has been read from a specified MED file.
6124 * \param [in] fileName - the name of the MED file to read.
6125 * \param [in] fieldName - the name of the field to read.
6126 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6127 * is to delete this field using decrRef() as it is no more needed.
6128 * \throw If reading the file fails.
6129 * \throw If there is no field named \a fieldName in the file.
6131 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6133 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6134 ret->contentNotNull();
6139 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6140 * a given field that has been read from a specified MED file.
6141 * \param [in] fileName - the name of the MED file to read.
6142 * \param [in] fieldName - the name of the field to read.
6143 * \param [in] iteration - the iteration number of a required time step.
6144 * \param [in] order - the iteration order number of required time step.
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.
6149 * \throw If the required time step is missing from the file.
6151 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6153 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6154 ret->contentNotNull();
6159 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6160 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6162 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6163 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6164 * \warning this is a shallow copy constructor
6165 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6166 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6167 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6168 * is to delete this field using decrRef() as it is no more needed.
6170 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6172 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6173 ret->contentNotNull();
6178 * Returns a new empty instance of MEDFileField1TS.
6179 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6180 * is to delete this field using decrRef() as it is no more needed.
6182 MEDFileField1TS *MEDFileField1TS::New()
6184 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6185 ret->contentNotNull();
6190 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6191 * following the given input policy.
6193 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6194 * By default (true) the globals are deeply copied.
6195 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6197 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6199 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6200 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6203 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6205 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6206 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6207 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6210 ret=MEDFileIntField1TS::New();
6212 ret->deepCpyGlobs(*this);
6214 ret->shallowCpyGlobs(*this);
6218 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6220 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6222 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6223 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6225 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 !");
6229 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6231 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6233 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6234 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6236 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 !");
6240 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6243 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6244 if(!((DataArray*)arr))
6245 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6246 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6248 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6249 f->setArray(arrOutC);
6252 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6254 if(!((DataArray*)arr))
6255 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6256 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6258 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6263 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6264 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6267 catch(INTERP_KERNEL::Exception& e)
6270 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6271 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6274 catch(INTERP_KERNEL::Exception& e)
6277 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6278 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6281 catch(INTERP_KERNEL::Exception& e)
6285 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6286 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6288 * \warning this is a shallow copy constructor
6290 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6291 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6294 catch(INTERP_KERNEL::Exception& e)
6297 MEDFileField1TS::MEDFileField1TS()
6299 _content=new MEDFileField1TSWithoutSDA;
6303 * Returns a new MEDCouplingFieldDouble of a given type lying on
6304 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6305 * has not been constructed via file reading, an exception is thrown.
6306 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6307 * \param [in] type - a spatial discretization of interest.
6308 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6309 * \param [in] renumPol - specifies how to permute values of the result field according to
6310 * the optional numbers of cells and nodes, if any. The valid values are
6311 * - 0 - do not permute.
6312 * - 1 - permute cells.
6313 * - 2 - permute nodes.
6314 * - 3 - permute cells and nodes.
6316 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6317 * caller is to delete this field using decrRef() as it is no more needed.
6318 * \throw If \a this field has not been constructed via file reading.
6319 * \throw If the MED file is not readable.
6320 * \throw If there is no mesh in the MED file.
6321 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6322 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6323 * \sa getFieldOnMeshAtLevel()
6325 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6327 if(getFileName().empty())
6328 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6329 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6330 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6331 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6336 * Returns a new MEDCouplingFieldDouble of a given type lying on
6337 * the top level cells of the first mesh in MED file. If \a this field
6338 * has not been constructed via file reading, an exception is thrown.
6339 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6340 * \param [in] type - a spatial discretization of interest.
6341 * \param [in] renumPol - specifies how to permute values of the result field according to
6342 * the optional numbers of cells and nodes, if any. The valid values are
6343 * - 0 - do not permute.
6344 * - 1 - permute cells.
6345 * - 2 - permute nodes.
6346 * - 3 - permute cells and nodes.
6348 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6349 * caller is to delete this field using decrRef() as it is no more needed.
6350 * \throw If \a this field has not been constructed via file reading.
6351 * \throw If the MED file is not readable.
6352 * \throw If there is no mesh in the MED file.
6353 * \throw If no field values of the given \a type.
6354 * \throw If no field values lying on the top level support.
6355 * \sa getFieldAtLevel()
6357 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6359 if(getFileName().empty())
6360 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6361 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6362 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6363 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6368 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6369 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6370 * \param [in] type - a spatial discretization of the new field.
6371 * \param [in] mesh - the supporting mesh.
6372 * \param [in] renumPol - specifies how to permute values of the result field according to
6373 * the optional numbers of cells and nodes, if any. The valid values are
6374 * - 0 - do not permute.
6375 * - 1 - permute cells.
6376 * - 2 - permute nodes.
6377 * - 3 - permute cells and nodes.
6379 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6380 * caller is to delete this field using decrRef() as it is no more needed.
6381 * \throw If no field of \a this is lying on \a mesh.
6382 * \throw If the mesh is empty.
6383 * \throw If no field values of the given \a type are available.
6384 * \sa getFieldAtLevel()
6385 * \sa getFieldOnMeshAtLevel()
6387 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6389 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6390 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6391 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6396 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6397 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6398 * \param [in] type - a spatial discretization of interest.
6399 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6400 * \param [in] mesh - the supporting mesh.
6401 * \param [in] renumPol - specifies how to permute values of the result field according to
6402 * the optional numbers of cells and nodes, if any. The valid values are
6403 * - 0 - do not permute.
6404 * - 1 - permute cells.
6405 * - 2 - permute nodes.
6406 * - 3 - permute cells and nodes.
6408 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6409 * caller is to delete this field using decrRef() as it is no more needed.
6410 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6411 * \throw If no field of \a this is lying on \a mesh.
6412 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6413 * \sa getFieldAtLevel()
6414 * \sa getFieldOnMeshAtLevel()
6416 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6418 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6419 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6420 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6425 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6426 * This method is called "Old" because in MED3 norm a field has only one meshName
6427 * attached, so this method is for readers of MED2 files. If \a this field
6428 * has not been constructed via file reading, an exception is thrown.
6429 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6430 * \param [in] type - a spatial discretization of interest.
6431 * \param [in] mName - a name of the supporting mesh.
6432 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6433 * \param [in] renumPol - specifies how to permute values of the result field according to
6434 * the optional numbers of cells and nodes, if any. The valid values are
6435 * - 0 - do not permute.
6436 * - 1 - permute cells.
6437 * - 2 - permute nodes.
6438 * - 3 - permute cells and nodes.
6440 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6441 * caller is to delete this field using decrRef() as it is no more needed.
6442 * \throw If the MED file is not readable.
6443 * \throw If there is no mesh named \a mName in the MED file.
6444 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6445 * \throw If \a this field has not been constructed via file reading.
6446 * \throw If no field of \a this is lying on the mesh named \a mName.
6447 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6448 * \sa getFieldAtLevel()
6450 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6452 if(getFileName().empty())
6453 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6454 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6455 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6456 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6461 * Returns values and a profile of the field of a given type lying on a given support.
6462 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6463 * \param [in] type - a spatial discretization of the field.
6464 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6465 * \param [in] mesh - the supporting mesh.
6466 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6467 * field of interest lies on. If the field lies on all entities of the given
6468 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6469 * using decrRef() as it is no more needed.
6470 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6471 * field. The caller is to delete this array using decrRef() as it is no more needed.
6472 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6473 * \throw If no field of \a this is lying on \a mesh.
6474 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6476 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6478 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6479 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6483 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6484 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6485 * "Sort By Type"), if not, an exception is thrown.
6486 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6487 * \param [in] field - the field to add to \a this.
6488 * \throw If the name of \a field is empty.
6489 * \throw If the data array of \a field is not set.
6490 * \throw If the data array is already allocated but has different number of components
6492 * \throw If the underlying mesh of \a field has no name.
6493 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6495 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6498 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6502 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6503 * can be an aggregation of several MEDCouplingFieldDouble instances.
6504 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6505 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6508 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6509 * A new profile is added only if no equal profile is missing.
6510 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6511 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6512 * \param [in] mesh - the supporting mesh of \a field.
6513 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6514 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6515 * \throw If either \a field or \a mesh or \a profile has an empty name.
6516 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6517 * \throw If the data array of \a field is not set.
6518 * \throw If the data array of \a this is already allocated but has different number of
6519 * components than \a field.
6520 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6521 * \sa setFieldNoProfileSBT()
6523 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6526 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6529 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6531 return new MEDFileField1TS(*this);
6534 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6536 return contentNotNull()->getUndergroundDataArrayDouble();
6539 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6541 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6544 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6545 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6547 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6550 //= MEDFileIntField1TS
6552 MEDFileIntField1TS *MEDFileIntField1TS::New()
6554 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6555 ret->contentNotNull();
6559 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6561 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6562 ret->contentNotNull();
6566 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6568 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6569 ret->contentNotNull();
6573 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6575 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6576 ret->contentNotNull();
6580 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6582 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6583 ret->contentNotNull();
6587 MEDFileIntField1TS::MEDFileIntField1TS()
6589 _content=new MEDFileIntField1TSWithoutSDA;
6592 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6593 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6596 catch(INTERP_KERNEL::Exception& e)
6599 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6600 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6603 catch(INTERP_KERNEL::Exception& e)
6606 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6607 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6610 catch(INTERP_KERNEL::Exception& e)
6614 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6615 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6617 * \warning this is a shallow copy constructor
6619 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6623 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6625 return new MEDFileIntField1TS(*this);
6629 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6630 * following the given input policy.
6632 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6633 * By default (true) the globals are deeply copied.
6634 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6636 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6638 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6639 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6642 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6644 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6645 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6646 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6649 ret=MEDFileField1TS::New();
6651 ret->deepCpyGlobs(*this);
6653 ret->shallowCpyGlobs(*this);
6658 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6659 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6660 * "Sort By Type"), if not, an exception is thrown.
6661 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6662 * \param [in] field - the field to add to \a this. The field double values are ignored.
6663 * \param [in] arrOfVals - the values of the field \a field used.
6664 * \throw If the name of \a field is empty.
6665 * \throw If the data array of \a field is not set.
6666 * \throw If the data array is already allocated but has different number of components
6668 * \throw If the underlying mesh of \a field has no name.
6669 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6671 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6674 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6678 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6679 * can be an aggregation of several MEDCouplingFieldDouble instances.
6680 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6681 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6684 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6685 * A new profile is added only if no equal profile is missing.
6686 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6687 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6688 * \param [in] arrOfVals - the values of the field \a field used.
6689 * \param [in] mesh - the supporting mesh of \a field.
6690 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6691 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6692 * \throw If either \a field or \a mesh or \a profile has an empty name.
6693 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6694 * \throw If the data array of \a field is not set.
6695 * \throw If the data array of \a this is already allocated but has different number of
6696 * components than \a field.
6697 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6698 * \sa setFieldNoProfileSBT()
6700 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6703 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6706 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6708 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6710 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6711 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6713 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 !");
6717 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6719 if(getFileName().empty())
6720 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6721 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6722 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6723 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6725 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6730 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6732 if(!((DataArray *)arr))
6733 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6734 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6736 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6742 * Returns a new MEDCouplingFieldDouble of a given type lying on
6743 * the top level cells of the first mesh in MED file. If \a this field
6744 * has not been constructed via file reading, an exception is thrown.
6745 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6746 * \param [in] type - a spatial discretization of interest.
6747 * \param [out] arrOut - the DataArrayInt containing values of field.
6748 * \param [in] renumPol - specifies how to permute values of the result field according to
6749 * the optional numbers of cells and nodes, if any. The valid values are
6750 * - 0 - do not permute.
6751 * - 1 - permute cells.
6752 * - 2 - permute nodes.
6753 * - 3 - permute cells and nodes.
6755 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6756 * caller is to delete this field using decrRef() as it is no more needed.
6757 * \throw If \a this field has not been constructed via file reading.
6758 * \throw If the MED file is not readable.
6759 * \throw If there is no mesh in the MED file.
6760 * \throw If no field values of the given \a type.
6761 * \throw If no field values lying on the top level support.
6762 * \sa getFieldAtLevel()
6764 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6766 if(getFileName().empty())
6767 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6768 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6769 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6770 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6775 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6776 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6777 * \param [in] type - a spatial discretization of the new field.
6778 * \param [in] mesh - the supporting mesh.
6779 * \param [out] arrOut - the DataArrayInt containing values of field.
6780 * \param [in] renumPol - specifies how to permute values of the result field according to
6781 * the optional numbers of cells and nodes, if any. The valid values are
6782 * - 0 - do not permute.
6783 * - 1 - permute cells.
6784 * - 2 - permute nodes.
6785 * - 3 - permute cells and nodes.
6787 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6788 * caller is to delete this field using decrRef() as it is no more needed.
6789 * \throw If no field of \a this is lying on \a mesh.
6790 * \throw If the mesh is empty.
6791 * \throw If no field values of the given \a type are available.
6792 * \sa getFieldAtLevel()
6793 * \sa getFieldOnMeshAtLevel()
6795 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6797 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6798 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6799 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6804 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6805 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6806 * \param [in] type - a spatial discretization of interest.
6807 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6808 * \param [out] arrOut - the DataArrayInt containing values of field.
6809 * \param [in] mesh - the supporting mesh.
6810 * \param [in] renumPol - specifies how to permute values of the result field according to
6811 * the optional numbers of cells and nodes, if any. The valid values are
6812 * - 0 - do not permute.
6813 * - 1 - permute cells.
6814 * - 2 - permute nodes.
6815 * - 3 - permute cells and nodes.
6817 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6818 * caller is to delete this field using decrRef() as it is no more needed.
6819 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6820 * \throw If no field of \a this is lying on \a mesh.
6821 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6822 * \sa getFieldAtLevel()
6823 * \sa getFieldOnMeshAtLevel()
6825 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6827 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6828 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6829 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6834 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6835 * This method is called "Old" because in MED3 norm a field has only one meshName
6836 * attached, so this method is for readers of MED2 files. If \a this field
6837 * has not been constructed via file reading, an exception is thrown.
6838 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6839 * \param [in] type - a spatial discretization of interest.
6840 * \param [in] mName - a name of the supporting mesh.
6841 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6842 * \param [out] arrOut - the DataArrayInt containing values of field.
6843 * \param [in] renumPol - specifies how to permute values of the result field according to
6844 * the optional numbers of cells and nodes, if any. The valid values are
6845 * - 0 - do not permute.
6846 * - 1 - permute cells.
6847 * - 2 - permute nodes.
6848 * - 3 - permute cells and nodes.
6850 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6851 * caller is to delete this field using decrRef() as it is no more needed.
6852 * \throw If the MED file is not readable.
6853 * \throw If there is no mesh named \a mName in the MED file.
6854 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6855 * \throw If \a this field has not been constructed via file reading.
6856 * \throw If no field of \a this is lying on the mesh named \a mName.
6857 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6858 * \sa getFieldAtLevel()
6860 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6862 if(getFileName().empty())
6863 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6864 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6865 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6866 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6871 * Returns values and a profile of the field of a given type lying on a given support.
6872 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6873 * \param [in] type - a spatial discretization of the field.
6874 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6875 * \param [in] mesh - the supporting mesh.
6876 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6877 * field of interest lies on. If the field lies on all entities of the given
6878 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6879 * using decrRef() as it is no more needed.
6880 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6881 * field. The caller is to delete this array using decrRef() as it is no more needed.
6882 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6883 * \throw If no field of \a this is lying on \a mesh.
6884 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6886 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6888 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6889 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6892 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6894 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6896 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6897 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6899 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 !");
6903 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6905 return contentNotNull()->getUndergroundDataArrayInt();
6908 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6910 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6914 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6919 * \param [in] fieldId field id in C mode
6921 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
6923 med_field_type typcha;
6924 std::string dtunitOut;
6925 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6926 setDtUnit(dtunitOut.c_str());
6927 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms);
6930 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)
6931 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6933 setDtUnit(dtunit.c_str());
6934 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms);
6936 catch(INTERP_KERNEL::Exception& e)
6941 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6943 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6944 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6945 ret+=(*it).capacity();
6949 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6951 std::vector<const BigMemoryObject *> ret;
6952 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6953 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6958 * 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
6961 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6963 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6964 ret->setInfo(_infos);
6965 int sz=(int)_time_steps.size();
6966 for(const int *id=startIds;id!=endIds;id++)
6968 if(*id>=0 && *id<sz)
6970 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6971 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6975 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6977 ret->pushBackTimeStep(tse2);
6981 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6982 oss << " ! Should be in [0," << sz << ") !";
6983 throw INTERP_KERNEL::Exception(oss.str().c_str());
6986 if(ret->getNumberOfTS()>0)
6987 ret->synchronizeNameScope();
6988 ret->copyNameScope(*this);
6993 * 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
6996 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6998 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6999 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7000 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7001 ret->setInfo(_infos);
7002 int sz=(int)_time_steps.size();
7004 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7008 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7009 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7013 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7015 ret->pushBackTimeStep(tse2);
7019 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7020 oss << " ! Should be in [0," << sz << ") !";
7021 throw INTERP_KERNEL::Exception(oss.str().c_str());
7024 if(ret->getNumberOfTS()>0)
7025 ret->synchronizeNameScope();
7026 ret->copyNameScope(*this);
7030 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7033 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7034 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7036 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7039 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7040 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7041 ids->pushBackSilent(id);
7043 return buildFromTimeStepIds(ids->begin(),ids->end());
7046 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7049 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7050 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7052 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7055 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7056 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7057 ids->pushBackSilent(id);
7059 return buildFromTimeStepIds(ids->begin(),ids->end());
7062 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7064 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7066 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7069 if(cur->presenceOfMultiDiscPerGeoType())
7075 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7085 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7088 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7090 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7091 if(pt->isDealingTS(iteration,order))
7094 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7095 std::vector< std::pair<int,int> > vp=getIterations();
7096 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7097 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7098 throw INTERP_KERNEL::Exception(oss.str().c_str());
7101 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7103 return *_time_steps[getTimeStepPos(iteration,order)];
7106 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7108 return *_time_steps[getTimeStepPos(iteration,order)];
7111 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7113 if(_time_steps.empty())
7114 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7115 return _time_steps[0]->getMeshName();
7118 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7120 std::string oldName(getMeshName());
7121 std::vector< std::pair<std::string,std::string> > v(1);
7122 v[0].first=oldName; v[0].second=newMeshName;
7126 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7129 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7131 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7133 ret=cur->changeMeshNames(modifTab) || ret;
7139 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7141 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7143 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7147 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7149 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7151 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7154 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7155 MEDFileFieldGlobsReal& glob)
7158 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7160 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7162 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7167 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7169 std::string startLine(bkOffset,' ');
7170 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7172 oss << " (" << fmtsId << ")";
7173 oss << " has the following name: \"" << _name << "\"." << std::endl;
7174 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7175 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7177 oss << startLine << " - \"" << *it << "\"" << std::endl;
7180 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7182 std::string chapter(17,'0'+i);
7183 oss << startLine << chapter << std::endl;
7184 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7186 cur->simpleRepr(bkOffset+2,oss,i);
7188 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7189 oss << startLine << chapter << std::endl;
7193 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7195 std::size_t sz=_time_steps.size();
7196 std::vector< std::pair<int,int> > ret(sz);
7198 for(std::size_t i=0;i<sz;i++)
7200 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7203 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7207 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7208 throw INTERP_KERNEL::Exception(oss.str().c_str());
7214 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7216 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7218 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7219 checkCoherencyOfType(tse2);
7220 if(_time_steps.empty())
7222 setName(tse2->getName().c_str());
7223 setInfo(tse2->getInfo());
7225 checkThatComponentsMatch(tse2->getInfo());
7226 _time_steps.push_back(tse);
7229 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7231 std::size_t nbOfCompo=_infos.size();
7232 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7234 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7237 if((cur->getInfo()).size()!=nbOfCompo)
7239 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7240 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7241 throw INTERP_KERNEL::Exception(oss.str().c_str());
7243 cur->copyNameScope(*this);
7248 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms)
7250 _time_steps.resize(nbPdt);
7251 for(int i=0;i<nbPdt;i++)
7253 std::vector< std::pair<int,int> > ts;
7254 med_int numdt=0,numo=0;
7255 med_int meshIt=0,meshOrder=0;
7257 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7262 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7267 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7271 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7274 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms);
7276 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms);
7280 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7282 if(_time_steps.empty())
7283 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7284 checkThatNbOfCompoOfTSMatchThis();
7285 std::vector<std::string> infos(getInfo());
7286 int nbComp=infos.size();
7287 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7288 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7289 for(int i=0;i<nbComp;i++)
7291 std::string info=infos[i];
7293 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7294 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7295 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7298 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7299 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7300 int nbOfTS=_time_steps.size();
7301 for(int i=0;i<nbOfTS;i++)
7302 _time_steps[i]->writeLL(fid,opts,*this);
7305 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7307 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7309 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7311 elt->loadBigArraysRecursively(fid,nasc);
7315 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7317 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7319 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7321 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7325 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7327 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7329 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7331 elt->unloadArrays();
7335 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7337 return _time_steps.size();
7340 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7342 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7343 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7345 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7347 newTS.push_back(*it);
7352 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7354 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7355 int maxId=(int)_time_steps.size();
7357 std::set<int> idsToDel;
7358 for(const int *id=startIds;id!=endIds;id++,ii++)
7360 if(*id>=0 && *id<maxId)
7362 idsToDel.insert(*id);
7366 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7367 throw INTERP_KERNEL::Exception(oss.str().c_str());
7370 for(int iii=0;iii<maxId;iii++)
7371 if(idsToDel.find(iii)==idsToDel.end())
7372 newTS.push_back(_time_steps[iii]);
7376 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7378 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7379 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7380 if(nbOfEntriesToKill==0)
7382 std::size_t sz=_time_steps.size();
7383 std::vector<bool> b(sz,true);
7385 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7387 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7388 for(std::size_t i=0;i<sz;i++)
7390 newTS.push_back(_time_steps[i]);
7394 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7397 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7398 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7400 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7404 tmp->getTime(it2,ord);
7405 if(it2==iteration && order==ord)
7408 oss << "(" << it2 << "," << ord << "), ";
7411 throw INTERP_KERNEL::Exception(oss.str().c_str());
7414 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7417 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7419 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7421 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7425 double ti=tmp->getTime(it2,ord);
7426 if(fabs(time-ti)<eps)
7432 throw INTERP_KERNEL::Exception(oss.str().c_str());
7435 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7437 int lgth=_time_steps.size();
7438 std::vector< std::pair<int,int> > ret(lgth);
7439 for(int i=0;i<lgth;i++)
7440 _time_steps[i]->fillIteration(ret[i]);
7445 * 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'
7446 * This method returns two things.
7447 * - The absolute dimension of 'this' in first parameter.
7448 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7449 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7451 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7452 * Only these 3 discretizations will be taken into account here.
7454 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7455 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7456 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7458 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7459 * 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'.
7461 * Let's consider the typical following case :
7462 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7463 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7464 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7466 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7468 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7470 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7471 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7472 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7473 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7475 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7477 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7480 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7482 if(pos<0 || pos>=(int)_time_steps.size())
7484 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7485 throw INTERP_KERNEL::Exception(oss.str().c_str());
7487 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7490 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7491 oss << "\nTry to use following method eraseEmptyTS !";
7492 throw INTERP_KERNEL::Exception(oss.str().c_str());
7497 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7499 if(pos<0 || pos>=(int)_time_steps.size())
7501 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7502 throw INTERP_KERNEL::Exception(oss.str().c_str());
7504 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7507 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7508 oss << "\nTry to use following method eraseEmptyTS !";
7509 throw INTERP_KERNEL::Exception(oss.str().c_str());
7514 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7516 std::vector<std::string> ret;
7517 std::set<std::string> ret2;
7518 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7520 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7521 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7522 if(ret2.find(*it2)==ret2.end())
7524 ret.push_back(*it2);
7531 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7533 std::vector<std::string> ret;
7534 std::set<std::string> ret2;
7535 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7537 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7538 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7539 if(ret2.find(*it2)==ret2.end())
7541 ret.push_back(*it2);
7548 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7550 std::vector<std::string> ret;
7551 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7553 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7554 ret.insert(ret.end(),tmp.begin(),tmp.end());
7559 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7561 std::vector<std::string> ret;
7562 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7564 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7565 ret.insert(ret.end(),tmp.begin(),tmp.end());
7570 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7572 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7573 (*it)->changePflsRefsNamesGen2(mapOfModif);
7576 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7578 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7579 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7582 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7584 int lgth=_time_steps.size();
7585 std::vector< std::vector<TypeOfField> > ret(lgth);
7586 for(int i=0;i<lgth;i++)
7587 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7592 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7594 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
7596 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7599 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7601 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7603 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7605 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7606 ret->_time_steps[i]=(*it)->deepCpy();
7611 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7613 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7614 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7615 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7616 for(std::size_t i=0;i<sz;i++)
7618 ret[i]=shallowCpy();
7619 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7621 for(std::size_t i=0;i<sz2;i++)
7623 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7626 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7627 throw INTERP_KERNEL::Exception(oss.str().c_str());
7631 for(std::size_t i=0;i<sz;i++)
7632 for(std::size_t j=0;j<sz2;j++)
7633 ret[i]->_time_steps[j]=ts[j][i];
7638 * This method splits into discretization each time steps in \a this.
7639 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7641 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7643 std::size_t sz(_time_steps.size());
7644 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7645 for(std::size_t i=0;i<sz;i++)
7647 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7650 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7651 throw INTERP_KERNEL::Exception(oss.str().c_str());
7653 items[i]=timeStep->splitDiscretizations();
7656 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7657 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7658 std::vector< TypeOfField > types;
7659 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7660 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7662 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7664 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7665 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7666 if(it2==types.end())
7667 types.push_back(ts[0]);
7669 ret.resize(types.size()); ret2.resize(types.size());
7670 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7671 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7673 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7674 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7675 ret2[pos].push_back(*it1);
7677 for(std::size_t i=0;i<types.size();i++)
7679 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7680 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7681 elt->pushBackTimeStep(*it1);//also updates infos in elt
7683 elt->MEDFileFieldNameScope::operator=(*this);
7689 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7691 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7693 std::size_t sz(_time_steps.size());
7694 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7695 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7696 for(std::size_t i=0;i<sz;i++)
7698 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7701 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7702 throw INTERP_KERNEL::Exception(oss.str().c_str());
7704 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7705 if(szOut==std::numeric_limits<std::size_t>::max())
7706 szOut=items[i].size();
7708 if(items[i].size()!=szOut)
7709 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7711 if(szOut==std::numeric_limits<std::size_t>::max())
7712 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7713 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7714 for(std::size_t i=0;i<szOut;i++)
7716 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7717 for(std::size_t j=0;j<sz;j++)
7718 elt->pushBackTimeStep(items[j][i]);
7720 elt->MEDFileFieldNameScope::operator=(*this);
7725 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7727 _name=field->getName();
7729 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7731 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7732 _infos=arr->getInfoOnComponents();
7735 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7737 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7738 if(_name!=field->getName())
7740 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7741 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7742 throw INTERP_KERNEL::Exception(oss.str().c_str());
7745 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7746 checkThatComponentsMatch(arr->getInfoOnComponents());
7749 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7751 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7752 if(getInfo().size()!=compos.size())
7754 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7755 oss << " number of components of element to append (" << compos.size() << ") !";
7756 throw INTERP_KERNEL::Exception(oss.str().c_str());
7760 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7761 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7762 oss << " But compo in input fields are : ";
7763 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7765 throw INTERP_KERNEL::Exception(oss.str().c_str());
7769 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7771 std::size_t sz=_infos.size();
7773 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7775 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7777 if(elt->getInfo().size()!=sz)
7779 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7780 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7781 throw INTERP_KERNEL::Exception(oss.str().c_str());
7786 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7789 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7790 if(!_time_steps.empty())
7791 checkCoherencyOfTinyInfo(field,arr);
7792 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7793 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7794 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7795 copyTinyInfoFrom(field,arr);
7796 _time_steps.push_back(obj);
7799 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7802 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7803 if(!_time_steps.empty())
7804 checkCoherencyOfTinyInfo(field,arr);
7805 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7806 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7807 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7808 copyTinyInfoFrom(field,arr);
7809 _time_steps.push_back(obj);
7812 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7814 int sz=(int)_time_steps.size();
7817 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7818 throw INTERP_KERNEL::Exception(oss.str().c_str());
7820 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7823 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7825 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7826 throw INTERP_KERNEL::Exception(oss.str().c_str());
7832 //= MEDFileFieldMultiTSWithoutSDA
7834 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)
7836 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
7839 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7843 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7848 * \param [in] fieldId field id in C mode
7850 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
7851 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
7854 catch(INTERP_KERNEL::Exception& e)
7857 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)
7858 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
7861 catch(INTERP_KERNEL::Exception& e)
7864 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7866 return new MEDFileField1TSWithoutSDA;
7869 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7872 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7873 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7875 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7878 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7880 return MEDFileField1TSWithoutSDA::TYPE_STR;
7883 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7885 return new MEDFileFieldMultiTSWithoutSDA(*this);
7888 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7890 return new MEDFileFieldMultiTSWithoutSDA;
7894 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7895 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7897 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
7899 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7900 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7902 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7903 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7906 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7908 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7909 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7911 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7913 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7916 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7918 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7919 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7920 ret->setIteration(i,elt);
7926 //= MEDFileAnyTypeFieldMultiTS
7928 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7932 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7933 try:MEDFileFieldGlobsReal(fileName)
7935 MEDFileUtilities::CheckFileForRead(fileName);
7936 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7937 _content=BuildContentFrom(fid,fileName,loadAll,ms);
7940 catch(INTERP_KERNEL::Exception& e)
7945 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7947 med_field_type typcha;
7948 std::vector<std::string> infos;
7951 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7952 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7957 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7962 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms);
7967 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] !";
7968 throw INTERP_KERNEL::Exception(oss.str().c_str());
7971 ret->setDtUnit(dtunit.c_str());
7975 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
7977 med_field_type typcha;
7979 std::vector<std::string> infos;
7980 std::string dtunit,fieldName;
7981 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7982 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7987 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7992 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms);
7997 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] !";
7998 throw INTERP_KERNEL::Exception(oss.str().c_str());
8001 ret->setDtUnit(dtunit.c_str());
8005 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8008 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8009 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8011 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8012 ret->setFileName(fileName);
8013 ret->_content=c; c->incrRef();
8016 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8018 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8019 ret->setFileName(fileName);
8020 ret->_content=c; c->incrRef();
8023 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8026 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
8027 try:MEDFileFieldGlobsReal(fileName)
8029 MEDFileUtilities::CheckFileForRead(fileName);
8030 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8031 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
8034 catch(INTERP_KERNEL::Exception& e)
8039 //= MEDFileIntFieldMultiTSWithoutSDA
8041 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)
8043 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms);
8046 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8050 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8054 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)
8055 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms)
8058 catch(INTERP_KERNEL::Exception& e)
8062 * \param [in] fieldId field id in C mode
8064 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms)
8065 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms)
8068 catch(INTERP_KERNEL::Exception& e)
8071 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8073 return new MEDFileIntField1TSWithoutSDA;
8076 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8079 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8080 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8082 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8085 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8087 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8090 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8092 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8095 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8097 return new MEDFileIntFieldMultiTSWithoutSDA;
8100 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8102 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8103 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8105 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8107 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8110 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8112 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8113 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8114 ret->setIteration(i,elt);
8120 //= MEDFileAnyTypeFieldMultiTS
8123 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8124 * that has been read from a specified MED file.
8125 * \param [in] fileName - the name of the MED file to read.
8126 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8127 * is to delete this field using decrRef() as it is no more needed.
8128 * \throw If reading the file fails.
8130 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8132 MEDFileUtilities::CheckFileForRead(fileName);
8133 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8134 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8135 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8136 ret->loadGlobals(fid);
8141 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8142 * that has been read from a specified MED file.
8143 * \param [in] fileName - the name of the MED file to read.
8144 * \param [in] fieldName - the name of the field to read.
8145 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8146 * is to delete this field using decrRef() as it is no more needed.
8147 * \throw If reading the file fails.
8148 * \throw If there is no field named \a fieldName in the file.
8150 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8152 MEDFileUtilities::CheckFileForRead(fileName);
8153 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8154 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
8155 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8156 ret->loadGlobals(fid);
8161 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8162 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8164 * \warning this is a shallow copy constructor
8166 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8168 if(!shallowCopyOfContent)
8170 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8171 otherPtr->incrRef();
8172 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8176 _content=other.shallowCpy();
8180 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8182 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8184 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8188 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8190 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8192 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8196 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8198 return contentNotNullBase()->getPflsReallyUsed2();
8201 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8203 return contentNotNullBase()->getLocsReallyUsed2();
8206 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8208 return contentNotNullBase()->getPflsReallyUsedMulti2();
8211 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8213 return contentNotNullBase()->getLocsReallyUsedMulti2();
8216 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8218 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8221 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8223 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8226 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8228 return contentNotNullBase()->getNumberOfTS();
8231 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8233 contentNotNullBase()->eraseEmptyTS();
8236 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8238 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8241 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8243 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8246 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8248 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8249 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8254 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8256 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8257 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8262 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8264 return contentNotNullBase()->getIterations();
8267 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8269 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8270 pushBackTimeStep(*it);
8273 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8276 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8277 checkCoherencyOfType(f1ts);
8279 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8280 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8282 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8283 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8284 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8285 _content->pushBackTimeStep(cSafe);
8286 appendGlobs(*f1ts,1e-12);
8289 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8291 contentNotNullBase()->synchronizeNameScope();
8294 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8296 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8299 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8301 return contentNotNullBase()->getPosGivenTime(time,eps);
8304 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8306 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8309 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8311 return contentNotNullBase()->getTypesOfFieldAvailable();
8314 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
8316 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8319 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8321 return contentNotNullBase()->getName();
8324 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8326 contentNotNullBase()->setName(name);
8329 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8331 return contentNotNullBase()->getDtUnit();
8334 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8336 contentNotNullBase()->setDtUnit(dtUnit);
8339 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8341 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8344 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8346 return contentNotNullBase()->getTimeSteps(ret1);
8349 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8351 return contentNotNullBase()->getMeshName();
8354 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8356 contentNotNullBase()->setMeshName(newMeshName);
8359 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8361 return contentNotNullBase()->changeMeshNames(modifTab);
8364 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8366 return contentNotNullBase()->getInfo();
8369 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8371 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8374 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8376 return contentNotNullBase()->setInfo(info);
8379 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8381 const std::vector<std::string> ret=getInfo();
8382 return (int)ret.size();
8385 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8387 writeGlobals(fid,*this);
8388 contentNotNullBase()->writeLL(fid,*this);
8392 * Writes \a this field into a MED file specified by its name.
8393 * \param [in] fileName - the MED file name.
8394 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8395 * - 2 - erase; an existing file is removed.
8396 * - 1 - append; same data should not be present in an existing file.
8397 * - 0 - overwrite; same data present in an existing file is overwritten.
8398 * \throw If the field name is not set.
8399 * \throw If no field data is set.
8400 * \throw If \a mode == 1 and the same data is present in an existing file.
8402 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8404 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8405 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8410 * This method alloc the arrays and load potentially huge arrays contained in this field.
8411 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8412 * This method can be also called to refresh or reinit values from a file.
8414 * \throw If the fileName is not set or points to a non readable MED file.
8416 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8418 if(getFileName().empty())
8419 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8420 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8421 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8425 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8426 * But once data loaded once, this method does nothing.
8428 * \throw If the fileName is not set or points to a non readable MED file.
8429 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8431 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8433 if(!getFileName().empty())
8435 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8436 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8441 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8442 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8443 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8445 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8447 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8449 contentNotNullBase()->unloadArrays();
8453 * 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.
8454 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8455 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8457 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8459 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8461 if(!getFileName().empty())
8462 contentNotNullBase()->unloadArrays();
8465 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8467 std::ostringstream oss;
8468 contentNotNullBase()->simpleRepr(0,oss,-1);
8469 simpleReprGlobs(oss);
8473 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8475 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8478 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8480 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8481 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8486 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8487 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8488 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8490 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8492 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8494 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8495 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8496 std::size_t sz(contentsSplit.size());
8497 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8498 for(std::size_t i=0;i<sz;i++)
8500 ret[i]=shallowCpy();
8501 ret[i]->_content=contentsSplit[i];
8507 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8508 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8510 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8512 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8514 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8515 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
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 sub-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::splitMultiDiscrPerGeoTypes() const
8532 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8534 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8535 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
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];
8546 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8548 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8549 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8550 ret->_content=_content->deepCpy();
8551 ret->deepCpyGlobs(*this);
8555 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8561 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8562 * \param [in] iteration - the iteration number of a required time step.
8563 * \param [in] order - the iteration order number of required time step.
8564 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8565 * delete this field using decrRef() as it is no more needed.
8566 * \throw If there is no required time step in \a this field.
8568 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8570 int pos=getPosOfTimeStep(iteration,order);
8571 return getTimeStepAtPos(pos);
8575 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8576 * \param [in] time - the time of the time step of interest.
8577 * \param [in] eps - a precision used to compare time values.
8578 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8579 * delete this field using decrRef() as it is no more needed.
8580 * \throw If there is no required time step in \a this field.
8582 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8584 int pos=getPosGivenTime(time,eps);
8585 return getTimeStepAtPos(pos);
8589 * 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.
8590 * The float64 value of time attached to the pair of integers are not considered here.
8591 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8593 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8594 * \throw If there is a null pointer in \a vectFMTS.
8596 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8598 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8599 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8600 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8601 while(!lstFMTS.empty())
8603 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8604 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8606 throw INTERP_KERNEL::Exception(msg);
8607 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8608 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8609 elt.push_back(curIt); it=lstFMTS.erase(it);
8610 while(it!=lstFMTS.end())
8614 throw INTERP_KERNEL::Exception(msg);
8615 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8617 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8627 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8628 * All returned instances in a subvector can be safely loaded, rendered along time
8629 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8630 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8631 * 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).
8632 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8633 * 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.
8635 * \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().
8636 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8637 * \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.
8638 * \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.
8640 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8641 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8642 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8643 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8644 * \throw If mesh is null.
8645 * \throw If an element in \a vectFMTS is null.
8646 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8648 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8650 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8652 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8653 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8654 if(vectFMTS.empty())
8656 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8657 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8659 throw INTERP_KERNEL::Exception(msg);
8661 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8662 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8663 for(;it!=vectFMTS.end();it++,i++)
8666 throw INTERP_KERNEL::Exception(msg);
8667 TypeOfField tof0,tof1;
8668 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8671 vectFMTSNotNodes.push_back(*it);
8673 vectFMTSNodes.push_back(*it);
8676 vectFMTSNotNodes.push_back(*it);
8678 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8679 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8681 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8684 bool isFetched(false);
8685 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8688 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8689 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8690 { ret[i].push_back(*it2); isFetched=true; }
8694 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8695 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8696 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8704 * 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.
8705 * \param [out] cmps - same size than the returned vector.
8707 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8709 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8710 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8711 while(!lstFMTS.empty())
8713 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8714 MEDFileAnyTypeFieldMultiTS *ref(*it);
8715 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8716 elt.push_back(ref); it=lstFMTS.erase(it);
8717 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8718 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8719 while(it!=lstFMTS.end())
8721 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8722 if(cmp->isEqual(curIt))
8723 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8727 ret.push_back(elt); cmps.push_back(cmp);
8733 * 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.
8734 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8736 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8737 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8738 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8739 * \thorw If \a f0 and \a f1 do not have the same times steps.
8740 * \throw If mesh is null.
8741 * \throw If \a f0 or \a f1 is null.
8742 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8744 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8747 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8749 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8750 if(f0->getMeshName()!=mesh->getName())
8752 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8753 throw INTERP_KERNEL::Exception(oss.str().c_str());
8755 if(f1->getMeshName()!=mesh->getName())
8757 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8758 throw INTERP_KERNEL::Exception(oss.str().c_str());
8760 int nts=f0->getNumberOfTS();
8761 if(nts!=f1->getNumberOfTS())
8762 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8765 for(int i=0;i<nts;i++)
8767 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8768 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8769 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8770 if(tofs0.size()!=1 || tofs1.size()!=1)
8771 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8774 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8775 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8778 { tof0=tofs0[0]; tof1=tofs1[0]; }
8779 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8781 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() << ") !";
8782 throw INTERP_KERNEL::Exception(oss.str().c_str());
8784 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8786 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() << ") !";
8787 throw INTERP_KERNEL::Exception(oss.str().c_str());
8789 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8791 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() << ") !";
8792 throw INTERP_KERNEL::Exception(oss.str().c_str());
8798 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8800 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8803 //= MEDFileFieldMultiTS
8806 * Returns a new empty instance of MEDFileFieldMultiTS.
8807 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8808 * is to delete this field using decrRef() as it is no more needed.
8810 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8812 return new MEDFileFieldMultiTS;
8816 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8817 * that has been read from a specified MED file.
8818 * \param [in] fileName - the name of the MED file to read.
8819 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8820 * is to delete this field using decrRef() as it is no more needed.
8821 * \throw If reading the file fails.
8823 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8825 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8826 ret->contentNotNull();//to check that content type matches with \a this type.
8831 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8832 * that has been read from a specified MED file.
8833 * \param [in] fileName - the name of the MED file to read.
8834 * \param [in] fieldName - the name of the field to read.
8835 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8836 * is to delete this field using decrRef() as it is no more needed.
8837 * \throw If reading the file fails.
8838 * \throw If there is no field named \a fieldName in the file.
8840 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8842 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8843 ret->contentNotNull();//to check that content type matches with \a this type.
8848 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8849 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8851 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8852 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8853 * \warning this is a shallow copy constructor
8854 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8855 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8856 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8857 * is to delete this field using decrRef() as it is no more needed.
8859 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8861 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8864 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8866 return new MEDFileFieldMultiTS(*this);
8869 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8872 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8873 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8875 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8879 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8880 * following the given input policy.
8882 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8883 * By default (true) the globals are deeply copied.
8884 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8886 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8888 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8889 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8892 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8894 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8895 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8896 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8899 ret=MEDFileIntFieldMultiTS::New();
8901 ret->deepCpyGlobs(*this);
8903 ret->shallowCpyGlobs(*this);
8908 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8909 * \param [in] pos - a time step id.
8910 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8911 * delete this field using decrRef() as it is no more needed.
8912 * \throw If \a pos is not a valid time step id.
8914 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8916 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8919 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8920 throw INTERP_KERNEL::Exception(oss.str().c_str());
8922 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8925 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8926 ret->shallowCpyGlobs(*this);
8929 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8930 throw INTERP_KERNEL::Exception(oss.str().c_str());
8934 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8935 * mesh entities of a given dimension of the first mesh in MED file.
8936 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8937 * \param [in] type - a spatial discretization of interest.
8938 * \param [in] iteration - the iteration number of a required time step.
8939 * \param [in] order - the iteration order number of required time step.
8940 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8941 * \param [in] renumPol - specifies how to permute values of the result field according to
8942 * the optional numbers of cells and nodes, if any. The valid values are
8943 * - 0 - do not permute.
8944 * - 1 - permute cells.
8945 * - 2 - permute nodes.
8946 * - 3 - permute cells and nodes.
8948 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8949 * caller is to delete this field using decrRef() as it is no more needed.
8950 * \throw If the MED file is not readable.
8951 * \throw If there is no mesh in the MED file.
8952 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8953 * \throw If no field values of the required parameters are available.
8955 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8957 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8958 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8960 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8961 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8962 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8963 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8968 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8969 * the top level cells of the first mesh in MED file.
8970 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8971 * \param [in] type - a spatial discretization of interest.
8972 * \param [in] iteration - the iteration number of a required time step.
8973 * \param [in] order - the iteration order number of required time step.
8974 * \param [in] renumPol - specifies how to permute values of the result field according to
8975 * the optional numbers of cells and nodes, if any. The valid values are
8976 * - 0 - do not permute.
8977 * - 1 - permute cells.
8978 * - 2 - permute nodes.
8979 * - 3 - permute cells and nodes.
8981 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8982 * caller is to delete this field using decrRef() as it is no more needed.
8983 * \throw If the MED file is not readable.
8984 * \throw If there is no mesh in the MED file.
8985 * \throw If no field values of the required parameters are available.
8987 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8989 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8990 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8992 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8993 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8994 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8995 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9000 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9002 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9003 * \param [in] type - a spatial discretization of interest.
9004 * \param [in] iteration - the iteration number of a required time step.
9005 * \param [in] order - the iteration order number of required time step.
9006 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9007 * \param [in] mesh - the supporting mesh.
9008 * \param [in] renumPol - specifies how to permute values of the result field according to
9009 * the optional numbers of cells and nodes, if any. The valid values are
9010 * - 0 - do not permute.
9011 * - 1 - permute cells.
9012 * - 2 - permute nodes.
9013 * - 3 - permute cells and nodes.
9015 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9016 * caller is to delete this field using decrRef() as it is no more needed.
9017 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9018 * \throw If no field of \a this is lying on \a mesh.
9019 * \throw If no field values of the required parameters are available.
9021 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9023 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9024 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9026 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9027 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9028 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9029 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9034 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9036 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9037 * \param [in] type - a spatial discretization of the new field.
9038 * \param [in] iteration - the iteration number of a required time step.
9039 * \param [in] order - the iteration order number of required time step.
9040 * \param [in] mesh - the supporting mesh.
9041 * \param [in] renumPol - specifies how to permute values of the result field according to
9042 * the optional numbers of cells and nodes, if any. The valid values are
9043 * - 0 - do not permute.
9044 * - 1 - permute cells.
9045 * - 2 - permute nodes.
9046 * - 3 - permute cells and nodes.
9048 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9049 * caller is to delete this field using decrRef() as it is no more needed.
9050 * \throw If no field of \a this is lying on \a mesh.
9051 * \throw If no field values of the required parameters are available.
9053 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9055 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9056 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9059 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9060 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9061 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9066 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9067 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9068 * This method is useful for MED2 file format when field on different mesh was autorized.
9070 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9072 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9073 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9075 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9076 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9077 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9078 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9083 * Returns values and a profile of the field of a given type, of a given time step,
9084 * lying on a given support.
9085 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9086 * \param [in] type - a spatial discretization of the field.
9087 * \param [in] iteration - the iteration number of a required time step.
9088 * \param [in] order - the iteration order number of required time step.
9089 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9090 * \param [in] mesh - the supporting mesh.
9091 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9092 * field of interest lies on. If the field lies on all entities of the given
9093 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9094 * using decrRef() as it is no more needed.
9095 * \param [in] glob - the global data storing profiles and localization.
9096 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9097 * field. The caller is to delete this array using decrRef() as it is no more needed.
9098 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9099 * \throw If no field of \a this is lying on \a mesh.
9100 * \throw If no field values of the required parameters are available.
9102 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9104 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9105 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9107 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9108 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9109 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9112 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9114 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9116 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9117 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9119 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 !");
9123 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9125 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9127 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9128 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9130 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 !");
9135 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9136 * the given field is checked if its elements are sorted suitable for writing to MED file
9137 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9138 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9139 * \param [in] field - the field to add to \a this.
9140 * \throw If the name of \a field is empty.
9141 * \throw If the data array of \a field is not set.
9142 * \throw If existing time steps have different name or number of components than \a field.
9143 * \throw If the underlying mesh of \a field has no name.
9144 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9146 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9148 const DataArrayDouble *arr=0;
9150 arr=field->getArray();
9151 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9155 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9156 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9157 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9160 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9161 * A new profile is added only if no equal profile is missing.
9162 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9163 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9164 * \param [in] mesh - the supporting mesh of \a field.
9165 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9166 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9167 * \throw If either \a field or \a mesh or \a profile has an empty name.
9168 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9169 * \throw If the data array of \a field is not set.
9170 * \throw If the data array of \a this is already allocated but has different number of
9171 * components than \a field.
9172 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9173 * \sa setFieldNoProfileSBT()
9175 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9177 const DataArrayDouble *arr=0;
9179 arr=field->getArray();
9180 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9183 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9185 _content=new MEDFileFieldMultiTSWithoutSDA;
9188 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9189 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9192 catch(INTERP_KERNEL::Exception& e)
9195 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9196 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9199 catch(INTERP_KERNEL::Exception& e)
9202 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9206 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
9208 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9211 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9213 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9216 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9218 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9221 //= MEDFileAnyTypeFieldMultiTSIterator
9223 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9228 _nb_iter=fmts->getNumberOfTS();
9232 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9236 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9238 if(_iter_id<_nb_iter)
9240 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9242 return fmts->getTimeStepAtPos(_iter_id++);
9250 //= MEDFileIntFieldMultiTS
9253 * Returns a new empty instance of MEDFileFieldMultiTS.
9254 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9255 * is to delete this field using decrRef() as it is no more needed.
9257 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9259 return new MEDFileIntFieldMultiTS;
9263 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9264 * that has been read from a specified MED file.
9265 * \param [in] fileName - the name of the MED file to read.
9266 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9267 * is to delete this field using decrRef() as it is no more needed.
9268 * \throw If reading the file fails.
9270 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9272 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9273 ret->contentNotNull();//to check that content type matches with \a this type.
9278 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9279 * that has been read from a specified MED file.
9280 * \param [in] fileName - the name of the MED file to read.
9281 * \param [in] fieldName - the name of the field to read.
9282 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9283 * is to delete this field using decrRef() as it is no more needed.
9284 * \throw If reading the file fails.
9285 * \throw If there is no field named \a fieldName in the file.
9287 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9289 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9290 ret->contentNotNull();//to check that content type matches with \a this type.
9295 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9296 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9298 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9299 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9300 * \warning this is a shallow copy constructor
9301 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9302 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9303 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9304 * is to delete this field using decrRef() as it is no more needed.
9306 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9308 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9312 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9313 * following the given input policy.
9315 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9316 * By default (true) the globals are deeply copied.
9317 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9319 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9321 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9322 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9325 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9327 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9328 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9329 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9332 ret=MEDFileFieldMultiTS::New();
9334 ret->deepCpyGlobs(*this);
9336 ret->shallowCpyGlobs(*this);
9340 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9342 return new MEDFileIntFieldMultiTS(*this);
9345 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9348 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9349 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9351 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9355 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9356 * mesh entities of a given dimension of the first mesh in MED file.
9357 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9358 * \param [in] type - a spatial discretization of interest.
9359 * \param [in] iteration - the iteration number of a required time step.
9360 * \param [in] order - the iteration order number of required time step.
9361 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9362 * \param [out] arrOut - the DataArrayInt containing values of field.
9363 * \param [in] renumPol - specifies how to permute values of the result field according to
9364 * the optional numbers of cells and nodes, if any. The valid values are
9365 * - 0 - do not permute.
9366 * - 1 - permute cells.
9367 * - 2 - permute nodes.
9368 * - 3 - permute cells and nodes.
9370 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9371 * caller is to delete this field using decrRef() as it is no more needed.
9372 * \throw If the MED file is not readable.
9373 * \throw If there is no mesh in the MED file.
9374 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9375 * \throw If no field values of the required parameters are available.
9377 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9379 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9380 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9382 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9383 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9384 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9385 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9390 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9391 * the top level cells of the first mesh in MED file.
9392 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9393 * \param [in] type - a spatial discretization of interest.
9394 * \param [in] iteration - the iteration number of a required time step.
9395 * \param [in] order - the iteration order number of required time step.
9396 * \param [out] arrOut - the DataArrayInt containing values of field.
9397 * \param [in] renumPol - specifies how to permute values of the result field according to
9398 * the optional numbers of cells and nodes, if any. The valid values are
9399 * - 0 - do not permute.
9400 * - 1 - permute cells.
9401 * - 2 - permute nodes.
9402 * - 3 - permute cells and nodes.
9404 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9405 * caller is to delete this field using decrRef() as it is no more needed.
9406 * \throw If the MED file is not readable.
9407 * \throw If there is no mesh in the MED file.
9408 * \throw If no field values of the required parameters are available.
9410 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9412 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9413 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9415 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9416 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9417 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9418 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9423 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9425 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9426 * \param [in] type - a spatial discretization of interest.
9427 * \param [in] iteration - the iteration number of a required time step.
9428 * \param [in] order - the iteration order number of required time step.
9429 * \param [out] arrOut - the DataArrayInt containing values of field.
9430 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9431 * \param [in] mesh - the supporting mesh.
9432 * \param [in] renumPol - specifies how to permute values of the result field according to
9433 * the optional numbers of cells and nodes, if any. The valid values are
9434 * - 0 - do not permute.
9435 * - 1 - permute cells.
9436 * - 2 - permute nodes.
9437 * - 3 - permute cells and nodes.
9439 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9440 * caller is to delete this field using decrRef() as it is no more needed.
9441 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9442 * \throw If no field of \a this is lying on \a mesh.
9443 * \throw If no field values of the required parameters are available.
9445 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9447 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9448 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9450 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9451 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9452 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9453 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9458 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9460 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9461 * \param [in] type - a spatial discretization of the new field.
9462 * \param [in] iteration - the iteration number of a required time step.
9463 * \param [in] order - the iteration order number of required time step.
9464 * \param [in] mesh - the supporting mesh.
9465 * \param [out] arrOut - the DataArrayInt containing values of field.
9466 * \param [in] renumPol - specifies how to permute values of the result field according to
9467 * the optional numbers of cells and nodes, if any. The valid values are
9468 * - 0 - do not permute.
9469 * - 1 - permute cells.
9470 * - 2 - permute nodes.
9471 * - 3 - permute cells and nodes.
9473 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9474 * caller is to delete this field using decrRef() as it is no more needed.
9475 * \throw If no field of \a this is lying on \a mesh.
9476 * \throw If no field values of the required parameters are available.
9478 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9480 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9481 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9483 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9484 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9485 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9486 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9491 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9492 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9493 * This method is useful for MED2 file format when field on different mesh was autorized.
9495 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9497 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9498 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9500 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9501 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9502 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9503 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9508 * Returns values and a profile of the field of a given type, of a given time step,
9509 * lying on a given support.
9510 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9511 * \param [in] type - a spatial discretization of the field.
9512 * \param [in] iteration - the iteration number of a required time step.
9513 * \param [in] order - the iteration order number of required time step.
9514 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9515 * \param [in] mesh - the supporting mesh.
9516 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9517 * field of interest lies on. If the field lies on all entities of the given
9518 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9519 * using decrRef() as it is no more needed.
9520 * \param [in] glob - the global data storing profiles and localization.
9521 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9522 * field. The caller is to delete this array using decrRef() as it is no more needed.
9523 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9524 * \throw If no field of \a this is lying on \a mesh.
9525 * \throw If no field values of the required parameters are available.
9527 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9529 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9530 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9532 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9533 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9534 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9538 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9539 * \param [in] pos - a time step id.
9540 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9541 * delete this field using decrRef() as it is no more needed.
9542 * \throw If \a pos is not a valid time step id.
9544 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9546 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9549 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9550 throw INTERP_KERNEL::Exception(oss.str().c_str());
9552 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9555 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9556 ret->shallowCpyGlobs(*this);
9559 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9560 throw INTERP_KERNEL::Exception(oss.str().c_str());
9564 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9565 * the given field is checked if its elements are sorted suitable for writing to MED file
9566 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9567 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9568 * \param [in] field - the field to add to \a this.
9569 * \throw If the name of \a field is empty.
9570 * \throw If the data array of \a field is not set.
9571 * \throw If existing time steps have different name or number of components than \a field.
9572 * \throw If the underlying mesh of \a field has no name.
9573 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9575 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9577 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9581 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9582 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9583 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9586 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9587 * A new profile is added only if no equal profile is missing.
9588 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9589 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9590 * \param [in] arrOfVals - the values of the field \a field used.
9591 * \param [in] mesh - the supporting mesh of \a field.
9592 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9593 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9594 * \throw If either \a field or \a mesh or \a profile has an empty name.
9595 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9596 * \throw If the data array of \a field is not set.
9597 * \throw If the data array of \a this is already allocated but has different number of
9598 * components than \a field.
9599 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9600 * \sa setFieldNoProfileSBT()
9602 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9604 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9607 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9609 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9611 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9612 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9614 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 !");
9618 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9620 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9622 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9623 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9625 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 !");
9629 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9631 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9634 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9638 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9639 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9642 catch(INTERP_KERNEL::Exception& e)
9645 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
9646 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms)
9649 catch(INTERP_KERNEL::Exception& e)
9652 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9654 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9659 MEDFileFields *MEDFileFields::New()
9661 return new MEDFileFields;
9664 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9666 return new MEDFileFields(fileName,loadAll,0);
9669 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9671 return new MEDFileFields(fileName,loadAll,ms);
9674 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9676 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9677 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9681 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9683 std::vector<const BigMemoryObject *> ret;
9684 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9685 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9689 MEDFileFields *MEDFileFields::deepCpy() const
9691 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9693 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9695 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9696 ret->_fields[i]=(*it)->deepCpy();
9698 ret->deepCpyGlobs(*this);
9702 MEDFileFields *MEDFileFields::shallowCpy() const
9704 return new MEDFileFields(*this);
9708 * 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
9709 * 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.
9710 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9712 * \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.
9713 * \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.
9715 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9717 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9719 std::set< std::pair<int,int> > s;
9720 bool firstShot=true;
9721 areThereSomeForgottenTS=false;
9722 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9724 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9726 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9727 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9729 { s=s1; firstShot=false; }
9732 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9734 areThereSomeForgottenTS=true;
9738 std::vector< std::pair<int,int> > ret;
9739 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9743 int MEDFileFields::getNumberOfFields() const
9745 return _fields.size();
9748 std::vector<std::string> MEDFileFields::getFieldsNames() const
9750 std::vector<std::string> ret(_fields.size());
9752 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9754 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9757 ret[i]=f->getName();
9761 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9762 throw INTERP_KERNEL::Exception(oss.str().c_str());
9768 std::vector<std::string> MEDFileFields::getMeshesNames() const
9770 std::vector<std::string> ret;
9771 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9773 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9775 ret.push_back(cur->getMeshName());
9780 std::string MEDFileFields::simpleRepr() const
9782 std::ostringstream oss;
9783 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9788 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9790 int nbOfFields=getNumberOfFields();
9791 std::string startLine(bkOffset,' ');
9792 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9794 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9796 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9799 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9803 oss << startLine << " - not defined !" << std::endl;
9807 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9809 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9810 std::string chapter(17,'0'+i);
9811 oss << startLine << chapter << std::endl;
9814 cur->simpleRepr(bkOffset+2,oss,i);
9818 oss << startLine << " - not defined !" << std::endl;
9820 oss << startLine << chapter << std::endl;
9822 simpleReprGlobs(oss);
9825 MEDFileFields::MEDFileFields()
9829 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9830 try:MEDFileFieldGlobsReal(fileName)
9832 MEDFileUtilities::CheckFileForRead(fileName);
9833 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9834 int nbFields(MEDnField(fid));
9835 _fields.resize(nbFields);
9836 med_field_type typcha;
9837 for(int i=0;i<nbFields;i++)
9839 std::vector<std::string> infos;
9840 std::string fieldName,dtunit;
9841 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9846 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9851 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms);
9856 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] !";
9857 throw INTERP_KERNEL::Exception(oss.str().c_str());
9861 loadAllGlobals(fid);
9863 catch(INTERP_KERNEL::Exception& e)
9868 void MEDFileFields::writeLL(med_idt fid) const
9871 writeGlobals(fid,*this);
9872 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9874 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9877 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9878 throw INTERP_KERNEL::Exception(oss.str().c_str());
9880 elt->writeLL(fid,*this);
9884 void MEDFileFields::write(const std::string& fileName, int mode) const
9886 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9887 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9892 * This method alloc the arrays and load potentially huge arrays contained in this field.
9893 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9894 * This method can be also called to refresh or reinit values from a file.
9896 * \throw If the fileName is not set or points to a non readable MED file.
9898 void MEDFileFields::loadArrays()
9900 if(getFileName().empty())
9901 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9902 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9903 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9905 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9907 elt->loadBigArraysRecursively(fid,*elt);
9912 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9913 * But once data loaded once, this method does nothing.
9915 * \throw If the fileName is not set or points to a non readable MED file.
9916 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9918 void MEDFileFields::loadArraysIfNecessary()
9920 if(!getFileName().empty())
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->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9933 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9934 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9935 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9937 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9939 void MEDFileFields::unloadArrays()
9941 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9943 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9945 elt->unloadArrays();
9950 * 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.
9951 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9952 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9954 * \sa MEDFileFields::loadArraysIfNecessary
9956 void MEDFileFields::unloadArraysWithoutDataLoss()
9958 if(!getFileName().empty())
9962 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9964 std::vector<std::string> ret;
9965 std::set<std::string> ret2;
9966 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9968 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9969 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9970 if(ret2.find(*it2)==ret2.end())
9972 ret.push_back(*it2);
9979 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9981 std::vector<std::string> ret;
9982 std::set<std::string> ret2;
9983 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9985 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9986 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9987 if(ret2.find(*it2)==ret2.end())
9989 ret.push_back(*it2);
9996 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9998 std::vector<std::string> ret;
9999 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10001 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10002 ret.insert(ret.end(),tmp.begin(),tmp.end());
10007 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10009 std::vector<std::string> ret;
10010 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10012 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10013 ret.insert(ret.end(),tmp.begin(),tmp.end());
10018 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10020 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10021 (*it)->changePflsRefsNamesGen2(mapOfModif);
10024 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10026 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10027 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10030 void MEDFileFields::resize(int newSize)
10032 _fields.resize(newSize);
10035 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10037 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10041 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10044 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10045 _fields.push_back(field->getContent());
10046 appendGlobs(*field,1e-12);
10049 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10052 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10053 if(i>=(int)_fields.size())
10054 _fields.resize(i+1);
10055 _fields[i]=field->getContent();
10056 appendGlobs(*field,1e-12);
10059 void MEDFileFields::destroyFieldAtPos(int i)
10061 destroyFieldsAtPos(&i,&i+1);
10064 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10066 std::vector<bool> b(_fields.size(),true);
10067 for(const int *i=startIds;i!=endIds;i++)
10069 if(*i<0 || *i>=(int)_fields.size())
10071 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10072 throw INTERP_KERNEL::Exception(oss.str().c_str());
10076 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10078 for(std::size_t i=0;i<_fields.size();i++)
10080 fields[j++]=_fields[i];
10084 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10086 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10087 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10088 std::vector<bool> b(_fields.size(),true);
10090 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10092 if(k<0 || k>=(int)_fields.size())
10094 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10095 throw INTERP_KERNEL::Exception(oss.str().c_str());
10099 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10101 for(std::size_t i=0;i<_fields.size();i++)
10103 fields[j++]=_fields[i];
10107 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10110 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10112 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10114 ret=cur->changeMeshNames(modifTab) || ret;
10120 * \param [in] meshName the name of the mesh that will be renumbered.
10121 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10122 * This code corresponds to the distribution of types in the corresponding mesh.
10123 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10124 * \param [in] renumO2N the old to new renumber array.
10125 * \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
10126 * field in \a this.
10128 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10131 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10133 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10136 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10142 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10144 if(i<0 || i>=(int)_fields.size())
10146 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10147 throw INTERP_KERNEL::Exception(oss.str().c_str());
10149 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10152 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10153 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10154 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10156 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10158 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10161 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10162 throw INTERP_KERNEL::Exception(oss.str().c_str());
10164 ret->shallowCpyGlobs(*this);
10169 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10170 * This method is accessible in python using __getitem__ with a list in input.
10171 * \return a new object that the caller should deal with.
10173 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10175 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10176 std::size_t sz=std::distance(startIds,endIds);
10177 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10179 for(const int *i=startIds;i!=endIds;i++,j++)
10181 if(*i<0 || *i>=(int)_fields.size())
10183 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10184 throw INTERP_KERNEL::Exception(oss.str().c_str());
10186 fields[j]=_fields[*i];
10188 ret->_fields=fields;
10192 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10194 return getFieldAtPos(getPosFromFieldName(fieldName));
10198 * This method removes, if any, fields in \a this having no time steps.
10199 * 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.
10201 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10203 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10205 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10206 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10208 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10211 if(elt->getNumberOfTS()>0)
10212 newFields.push_back(*it);
10215 if(_fields.size()==newFields.size())
10222 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10223 * This method can be seen as a filter applied on \a this, that returns an object containing
10224 * 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
10225 * shallow copied from \a this.
10227 * \param [in] meshName - the name of the mesh on w
10228 * \return a new object that the caller should deal with.
10230 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10232 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10233 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10235 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10238 if(cur->getMeshName()==meshName)
10241 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10242 ret->_fields.push_back(cur2);
10245 ret->shallowCpyOnlyUsedGlobs(*this);
10250 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10251 * Input time steps are specified using a pair of integer (iteration, order).
10252 * 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,
10253 * but for each multitimestep only the time steps in \a timeSteps are kept.
10254 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10256 * The returned object points to shallow copy of elements in \a this.
10258 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10259 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10260 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10262 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10264 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10265 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10267 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10270 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10271 ret->_fields.push_back(elt);
10273 ret->shallowCpyOnlyUsedGlobs(*this);
10278 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10280 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10282 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10283 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10285 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10288 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10289 if(elt->getNumberOfTS()!=0)
10290 ret->_fields.push_back(elt);
10292 ret->shallowCpyOnlyUsedGlobs(*this);
10296 MEDFileFieldsIterator *MEDFileFields::iterator()
10298 return new MEDFileFieldsIterator(this);
10301 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10303 std::string tmp(fieldName);
10304 std::vector<std::string> poss;
10305 for(std::size_t i=0;i<_fields.size();i++)
10307 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10310 std::string fname(f->getName());
10314 poss.push_back(fname);
10317 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10318 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10320 throw INTERP_KERNEL::Exception(oss.str().c_str());
10323 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10328 _nb_iter=fs->getNumberOfFields();
10332 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10336 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10338 if(_iter_id<_nb_iter)
10340 MEDFileFields *fs(_fs);
10342 return fs->getFieldAtPos(_iter_id++);